protected void setUpCellEditor(ColumnViewer viewer){ // set up validation of the cell editors textCellEditor = new TextCellEditor((Composite) viewer.getControl()); textCellEditor.addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState){ if (newValidState) { textCellEditor.getControl().setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } else { textCellEditor.getControl().setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } } @Override public void cancelEditor(){ textCellEditor.getControl().setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } @Override public void applyEditorValue(){ textCellEditor.getControl().setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } }); focusCell = new TableViewerFocusCellManager((TableViewer) viewer, new FocusCellHighlighter(viewer) { }); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event){ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.KEYPAD_CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; TableViewerEditor.create((TableViewer) viewer, focusCell, actSupport, ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); }
protected void setUpCellEditor(ColumnViewer viewer){ // set up validation of the cell editors textCellEditor = new TextCellEditor((Composite) viewer.getControl()); textCellEditor.addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState){ if (newValidState) { textCellEditor.getControl() .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } else { textCellEditor.getControl() .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } } @Override public void cancelEditor(){ textCellEditor.getControl() .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } @Override public void applyEditorValue(){ textCellEditor.getControl() .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); } }); focusCell = new TreeViewerFocusCellManager((TreeViewer) viewer, new FocusCellHighlighter(viewer) { }); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event){ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.KEYPAD_CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; TreeViewerEditor.create((TreeViewer) viewer, focusCell, actSupport, ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); }