当前位置: 首页 > news >正文

有了主机如何做网站十堰优化seo

有了主机如何做网站,十堰优化seo,wordpress实现登录注册,互联网公司排名2018背景 实际业务中经常需要展示某个网站, 并且希望在展示的时候单击网站可直接访问, 本节演示在表格中如何添加超链接支持. 需求 假设我需要渲染一个Study类, 它只有三个属性id,name和website, 其中id只支持展示, name只支持编辑, 而website只支持单击时跳转到相应的网站, 效果…背景 实际业务中经常需要展示某个网站, 并且希望在展示的时候单击网站可直接访问, 本节演示在表格中如何添加超链接支持. 需求 假设我需要渲染一个Study类, 它只有三个属性id,name和website, 其中id只支持展示, name只支持编辑, 而website只支持单击时跳转到相应的网站, 效果图如下: 方案 要在表格中添加超链接支持, 需要特殊的CellLableProvider, Jface提供了ColumnLabelProvider, 要想实现超链接, 只需要重新实现其中的update和getText方法. 方法名方法签名功能描述getTextString getText(Object element)提供表格渲染后展示的文本的内容updatevoid update(ViewerCell cell)提供表格对象的额外展示项, 比如背景颜色, 字体的设置等等 我们的超链接支持就可以放在update中来进行扩展实现: 创建Link对象, 并通过TableEditor将其与TableItem关联起来添加Link对象的单击事件监听, 点击时进行跳转 Link link new Link((Composite) cell.getControl(), SWT.NONE); link.setText(a study.website /a); TableItem item (TableItem) cell.getItem(); TableEditor editor new TableEditor(item.getParent()); editor.grabHorizontal true; editor.grabVertical true; editor.setEditor(link, item, cell.getColumnIndex()); editor.layout(); link.addListener(SWT.Selection, e - {try {Desktop.getDesktop().browse(new URI(study.website));} catch (IOException | URISyntaxException ex) {throw new RuntimeException(ex);} });注意实现 之前我们设置CellLabelProvider时是通过Tabel级别的对象进行的, 实际上我们往往是根据不同的Column来设置更为个性化的展示的, 因此, 在创建Column的同时设置CellLableProvider更为合理. 伪代码: TableViewer tableViewer ...; Table table tableViewer.getTable(); TableColumn tableColumn TableColumnFactory.newTableColumn(SWT.NONE)....create(table); TableViewerColumn tableViewerColumn new TableViewerColumn(tableViewer, tableColumn); // 每一列设置一个特定的cellLabelProvider tableViewerColumn.setLabelProvider(cellLabelProvider);源码 import org.eclipse.jface.viewers.*; import org.eclipse.jface.widgets.TableColumnFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.*;import java.awt.*; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.util.Optional;public class Study {Column(value ID, labelProviderClass StudyLabelProvider.class)public int id;Column(value 名称, labelProviderClass StudyLabelProvider.class, width 200)TextEditorpublic String name;Column(value 网站, labelProviderClass StudyLabelProvider.class, width 300)public String website;public Study(int id, String name, String website) {this.id id;this.name name;this.website website;}private static Study[] studies() {return new Study[]{new Study(1, github, https://github.com), new Study(2, 死磕Java, https://skjava.com)};}public static void main(String[] args) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {Display display new Display();Shell shell new Shell(display);shell.setLayout(new FillLayout());var tableViewer new TableViewer(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);Table table tableViewer.getTable();table.setHeaderVisible(true);table.setLinesVisible(true);Field[] fields Study.class.getFields();for (Field field : fields) {Column column field.getAnnotation(Column.class);String columnText column.value();Class? extends CellLabelProvider labelProviderClass column.labelProviderClass();CellLabelProvider cellLabelProvider;if (!(CellLabelProvider.class labelProviderClass)) {Constructor? extends CellLabelProvider constructor labelProviderClass.getConstructor(String.class);cellLabelProvider constructor.newInstance(columnText);} else {cellLabelProvider new StudyLabelProvider(columnText);}TableColumn tableColumn TableColumnFactory.newTableColumn(SWT.NONE).width(column.width()).text(columnText).align(SWT.CENTER).create(table);TableViewerColumn tableViewerColumn new TableViewerColumn(tableViewer, tableColumn);tableViewerColumn.setLabelProvider(cellLabelProvider);EditingSupport editingSupport null;TextEditor textEditor field.getAnnotation(TextEditor.class);if (textEditor ! null) {Class? extends EditingSupport editingSupportClass textEditor.editingSupportClass();Constructor? extends EditingSupport constructor editingSupportClass.getConstructor(TableViewerColumn.class);editingSupport constructor.newInstance(tableViewerColumn);}Optional.ofNullable(editingSupport).ifPresent(tableViewerColumn::setEditingSupport);}ColumnViewerEditorActivationStrategy activationStrategy new ColumnViewerEditorActivationStrategy(tableViewer) {Overrideprotected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {// 只有双击事件才激活编辑器return event.eventType ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || event.eventType ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType ColumnViewerEditorActivationEvent.TRAVERSAL;}};table.setHeaderBackground(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND));table.setHeaderForeground(display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND));TableViewerFocusCellManager focusCellManager new TableViewerFocusCellManager(tableViewer, new FocusCellOwnerDrawHighlighter(tableViewer));TableViewerEditor.create(tableViewer, focusCellManager, activationStrategy, ColumnViewerEditor.DEFAULT);tableViewer.setContentProvider(ArrayContentProvider.getInstance());tableViewer.setInput(Study.studies());shell.open();while (!shell.isDisposed()) {if (!display.readAndDispatch()) {display.sleep();}}}public static class StudyEditingSupport extends EditingSupport {private final TableViewerColumn tableViewerColumn;private final String title;public StudyEditingSupport(TableViewerColumn tableViewerColumn) {super(tableViewerColumn.getViewer());this.tableViewerColumn tableViewerColumn;TableColumn tableColumn tableViewerColumn.getColumn();this.title tableColumn.getText();}Overrideprotected CellEditor getCellEditor(Object o) {return new TextCellEditor(tableViewerColumn.getColumn().getParent());}Overrideprotected boolean canEdit(Object o) {return true;}Overrideprotected Object getValue(Object o) {if (!(o instanceof Study study)) {return ;}return switch (title) {case 名称 - study.name;default - study.website;};}Overrideprotected void setValue(Object o, Object o1) {if (!(o instanceof Study study)) {return;}switch (title) {case 名称 - study.name String.valueOf(o1);default - study.website String.valueOf(o1);}getViewer().refresh(o);}}public static class StudyLabelProvider extends ColumnLabelProvider {private final String title;public StudyLabelProvider(String title) {super();this.title title;}Overridepublic void update(ViewerCell cell) {if (!(cell.getElement() instanceof Study study)) {return;}var text switch (title) {case ID - String.valueOf(study.id);case 名称 - study.name;default - {Link link new Link((Composite) cell.getControl(), SWT.NONE);link.setText(a study.website /a);TableItem item (TableItem) cell.getItem();TableEditor editor new TableEditor(item.getParent());editor.grabHorizontal true;editor.grabVertical true;editor.setEditor(link, item, cell.getColumnIndex());editor.layout();link.addListener(SWT.Selection, e - {try {Desktop.getDesktop().browse(new URI(study.website));} catch (IOException | URISyntaxException ex) {throw new RuntimeException(ex);}});yield ;}};cell.setText(text);}Overridepublic String getText(Object element) {if (!(element instanceof Study study)) {return ;}return switch (title) {case ID - String.valueOf(study.id);case 名称 - study.name;default - study.website;};}}Retention(RetentionPolicy.RUNTIME)Target(ElementType.FIELD)public interface Column {String value();Class? extends CellLabelProvider labelProviderClass() default CellLabelProvider.class;int width() default 100;}Retention(RetentionPolicy.RUNTIME)Target(ElementType.FIELD)public interface TextEditor {Class? extends EditingSupport editingSupportClass() default StudyEditingSupport.class;} }
http://www.zqtcl.cn/news/312767/

相关文章:

  • 有口碑的常州网站建设传统网站建设
  • 大学网站建设排名金乡网站建设
  • 手机网站开发步骤徐州网站制作怎么做
  • 南通网站优化找哪家推荐做素菜的网站
  • 中国十大网站域名界面设计最好的网站
  • 苍山做网站北京便宜网站建设
  • 广州公司网站制作招聘信息汕头网站推广哪家好
  • 登录建设官方网站品牌营销专家
  • 天津模板建站哪家好wordpress标题换行显示不全
  • 杭州房地产网站建设网站建设开发公司推荐指数
  • 建设部网站上怎样查询企业业绩做淘宝联盟网站要多少钱
  • 宣武上海网站建设网站导购话术
  • 天津北京网站建设公司大网站建设公司
  • 网站需要在哪些方面备案百度云建网站
  • 西安手机网站定制网站建设西安网站注册
  • 怎么做秒赞网站企业自己建设的营销网络
  • 一般网站建设需求有哪些wordpress脚注更改
  • 海报设计在线生成免费网站排名优化方案
  • 网站开发综合设计报告怎么制作浏览器网页
  • 做网站打广告青岛网站营销推广
  • 网站建设中首页模板本科 网站建设的基础教程
  • 推广网站优化seo教程上排名抖音营销
  • 创业园区网站建设wordpress对接公众号源码
  • 怎么设计公司的网站长沙seo结算
  • 参加网站建设项目人员保障体系镇江网站建设门户报价
  • 漯河网站优化景区网站建设方案
  • 辽宁智能网站建设价位wordpress 公司主题
  • zencart 网站入侵冲电气软件 网站建设
  • 在网上做黑彩网站会怎样wordpress自定义代码在哪里设置
  • 福州营销网站建设老品牌网站开通