Java 类org.eclipse.jface.viewers.FocusCellHighlighter 实例源码

项目:elexis-3-core    文件:LabOrderEditingSupport.java   
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);
}
项目:elexis-3-core    文件:LabResultEditingSupport.java   
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);
}