1.自定义编辑器激活方式
/**
* Create a customized editor whose activation process is customized * * @param viewer * the viewer the editor is created for * @param editorActivationStrategy * activation strategy to control if an editor activated * @param feature * bit mask controlling the editor * <ul> * <li>{@link ColumnViewerEditor#DEFAULT}</li> * <li>{@link ColumnViewerEditor#TABBING_CYCLE_IN_ROW}</li> * <li>{@link ColumnViewerEditor#TABBING_HORIZONTAL}</li> * <li>{@link ColumnViewerEditor#TABBING_MOVE_TO_ROW_NEIGHBOR}</li> * <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li> * </ul> */ public static void create(TableViewer viewer, ColumnViewerEditorActivationStrategy editorActivationStrategy, int feature) {}
附例子:
TableViewerEditor .create(viewer,
new DoubleClickColumnViewerEditorActivationStrategy( viewer), ColumnViewerEditor.DEFAULT);/**
* 双击编辑策略 * * @author pang * */public class DoubleClickColumnViewerEditorActivationStrategy extends ColumnViewerEditorActivationStrategy implements CommonUse { public DoubleClickColumnViewerEditorActivationStrategy(TableViewer viewer) { super(viewer); } /** * 設置編輯器觸發方式 */ @Override protected boolean isEditorActivationEvent( ColumnViewerEditorActivationEvent event) { boolean singleSelect = ((IStructuredSelection) getViewer() .getSelection()).size() == 1; return singleSelect && (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL); }}