Example usage for org.eclipse.jface.viewers ICellEditorListener applyEditorValue

List of usage examples for org.eclipse.jface.viewers ICellEditorListener applyEditorValue

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ICellEditorListener applyEditorValue.

Prototype

public void applyEditorValue();

Source Link

Document

Notifies that the end user has requested applying a value.

Usage

From source file:net.rim.ejde.internal.ui.editors.locale.ResourceCellEditor.java

License:Open Source License

private void fireApplyEvent() {
    for (ICellEditorListener listener : _listeners) {
        listener.applyEditorValue();
    }
}

From source file:org.jkiss.dbeaver.ui.properties.PropertyTreeViewer.java

License:Open Source License

private void showEditor(final TreeItem item, boolean isDef) {
    // Clean up any previous editor control
    disposeOldEditor();// w w w  .  j a  v a2s  .  c o  m
    if (item == null) {
        return;
    }

    // Identify the selected row
    if (item.getData() instanceof TreeNode) {
        final Tree treeControl = super.getTree();
        final TreeNode prop = (TreeNode) item.getData();
        if (prop.property == null || !prop.isEditable()) {
            return;
        }
        final CellEditor cellEditor = UIUtils.createPropertyEditor(DBeaverUI.getActiveWorkbenchWindow(),
                treeControl, prop.propertySource, prop.property);
        if (cellEditor == null) {
            return;
        }
        final Object propertyValue = prop.propertySource.getPropertyValue(null, prop.property.getId());
        final ICellEditorListener cellEditorListener = new ICellEditorListener() {
            @Override
            public void applyEditorValue() {
                //editorValueChanged(true, true);
                final Object value = cellEditor.getValue();
                final Object oldValue = prop.propertySource.getPropertyValue(null, prop.property.getId());
                if (!CommonUtils.equalObjects(oldValue, value)) {
                    prop.propertySource.setPropertyValue(null, prop.property.getId(), value);
                    handlePropertyChange(prop);
                }
            }

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

            @Override
            public void editorValueChanged(boolean oldValidState, boolean newValidState) {
            }
        };
        cellEditor.addListener(cellEditorListener);
        if (propertyValue != null) {
            cellEditor.setValue(propertyValue);
        }
        curCellEditor = cellEditor;
        selectedProperty = prop.property;

        cellEditor.activate();
        final Control editorControl = cellEditor.getControl();
        if (editorControl != null) {
            editorControl.addTraverseListener(new TraverseListener() {
                @Override
                public void keyTraversed(TraverseEvent e) {
                    if (e.detail == SWT.TRAVERSE_RETURN) {
                        e.doit = false;
                        e.detail = SWT.TRAVERSE_NONE;
                        cellEditorListener.applyEditorValue();
                        disposeOldEditor();
                    } else if (e.detail == SWT.TRAVERSE_ESCAPE) {
                        e.doit = false;
                        e.detail = SWT.TRAVERSE_NONE;
                        disposeOldEditor();
                        if (prop.isEditable()) {
                            new ActionResetProperty(prop, false).run();
                        }
                    }
                }
            });
            treeEditor.setEditor(editorControl, item, 1);
        }
        if (isDef) {
            // Selected by mouse
            cellEditor.setFocus();
        }
    }
}

From source file:org.xmind.ui.texteditor.MEmbeddedEditor.java

License:Open Source License

protected void fireApplyEditorValue() {
    Object[] listeners = editorListeners.getListeners();
    for (int i = 0; i < listeners.length; i++) {
        final ICellEditorListener l = (ICellEditorListener) listeners[i];
        SafeRunner.run(new SafeRunnable() {
            public void run() throws Exception {
                l.applyEditorValue();
            }//from  ww  w. j  a  va  2 s.  c o m
        });
    }
}