Example usage for org.eclipse.jface.viewers CellEditor performSelectAll

List of usage examples for org.eclipse.jface.viewers CellEditor performSelectAll

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers CellEditor performSelectAll.

Prototype

public void performSelectAll() 

Source Link

Document

Performs the select all action.

Usage

From source file:org.chrysalix.eclipse.focustree.FocusTreeCanvas.java

License:Open Source License

private void edit(final Label fieldEdited, final CellEditor editor, final EditorHandler editorHandler) {
    this.editor = editor;
    this.editorHandler = editorHandler;
    this.fieldEdited = fieldEdited;
    if (editor.getControl() == null)
        editor.create(this);
    final Cell cell = cell(fieldEdited);
    focusCell(column(cell), cell);/*from  w w  w. j  av a 2  s  . c om*/
    getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            editor.setValue(fieldEdited.getText());
            final Rectangle fieldBounds = fieldEdited.getBounds();
            final Point viewLocation = getViewport().getViewLocation();
            editor.getControl().setBounds(fieldBounds.x - viewLocation.x, fieldBounds.y - viewLocation.y,
                    fieldBounds.width, editor.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            editor.setValidator(new ICellEditorValidator() {

                private final Color originalForegroundColor = editor.getControl().getForeground();

                @Override
                public String isValid(final Object value) {
                    final String problem = editorHandler.problem();
                    if (problem == null) {
                        editor.getControl().setToolTipText(null);
                        editor.getControl().setForeground(originalForegroundColor);
                    } else {
                        editor.getControl().setToolTipText(problem);
                        editor.getControl().setForeground(getDisplay().getSystemColor(SWT.COLOR_RED));
                    }
                    return problem;
                }
            });
            editor.addListener(new ICellEditorListener() {

                @Override
                public void applyEditorValue() {
                    endEdit();
                }

                @Override
                public void cancelEditor() {
                    endEdit();
                }

                @Override
                public void editorValueChanged(final boolean oldValidState, final boolean newValidState) {
                }
            });
            editor.getControl().setVisible(true);
            editor.setFocus();
            editor.performSelectAll();
        }
    });
}