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

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

Introduction

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

Prototype

public boolean isActivated() 

Source Link

Document

Returns whether this cell editor is activated.

Usage

From source file:org.eclipse.cdt.utils.ui.controls.ControlFactory.java

License:Open Source License

public static void deactivateCellEditor(TableViewer viewer) {
    if (null == viewer)
        return;/*from w  w w.  j  a  v a  2  s .com*/
    CellEditor[] es = viewer.getCellEditors();
    TableItem[] items = viewer.getTable().getSelection();
    if (items.length >= 0) {
        for (int i = 0; i < es.length; ++i) {
            CellEditor e = es[i];
            if (e.isActivated()) {
                if (e.isValueValid()) {
                    Object[] properties = viewer.getColumnProperties();
                    Object value = e.getValue();
                    viewer.cancelEditing();
                    viewer.getCellModifier().modify(items[0], (String) properties[i], value);
                } else
                    viewer.cancelEditing();
                break;
            }
        }
    }
}

From source file:org.eclipse.datatools.sqltools.routineeditor.parameter.internal.ParameterTableDialog.java

License:Open Source License

/**
 * Deals with pressing the OK button. The main reason for overriding this
 * method is to make sure that any editors that are still active and haven't
 * committed their changes now save their values.
 * /*from ww  w .j av a  2 s. c  o m*/
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 */
protected void okPressed() {
    CellEditor[] cellEditors = _parameterTable.getCellEditors();
    for (CellEditor ed : cellEditors) {
        if (ed != null && ed.isActivated()) {
            /*
             * Fixing BZ 311067.
             * 
             * It seems that on the Mac, if a user is editing a field and
             * presses the OK button without having that field first lose focus,
             * its value is not committed. The following syncExec is forcing
             * the OK button to receive focus, thus making the cell editor
             * to lose focus. That makes the cell editor commit its value.
             * 
             * (This is probably just a workaround for a bug in the Mac SWT
             * but it seems to work)
             */
            getContents().getDisplay().syncExec(new Runnable() {
                public void run() {
                    // force the active editor to lose focus.
                    getButton(IDialogConstants.OK_ID).setFocus();
                }
            });
        }
    }
    super.okPressed();
}

From source file:org.eclipse.rcptt.tesla.internal.ui.player.viewers.Viewers.java

License:Open Source License

public static boolean setSelection(SWTUIElement element, String[] selection, String pattern, Integer index,
        boolean selectAll) {

    // Skip selection event if there is cell editor active and same
    // selection are tryed to be set
    CellEditor[] editors = TeslaCellEditorManager.getInstance().getEditors();
    boolean checkForSameSelection = false;
    for (CellEditor cellEditor : editors) {
        Control ctrl = cellEditor.getControl();
        if (cellEditor.isActivated() && ctrl != null && !ctrl.isDisposed()) {
            if (element.unwrap() instanceof Control) {
                List<Widget> parents = SWTUIPlayer.collectParents(ctrl, null,
                        ((Control) element.unwrap()).getParent());
                if (parents.contains(element.unwrap())) {
                    checkForSameSelection = true;
                    // Yes cell editor are active
                    break;
                }//from   www  . j a  v  a 2s. c  o m
            }
        }
    }
    if (checkForSameSelection) {
        String[] currentSelection = getPathSelection(element);
        if (currentSelection != null) {
            if (Arrays.equals(selection, currentSelection)) {
                return true;// Already selected
            }
        }
    }
    Boolean result = null;
    Widget widget = unwrapWidget(element);
    if (widget instanceof Tree || widget instanceof Table) {
        if (selection == null && pattern != null) {
            selection = new String[] { pattern };
        }
        result = selectItem(element, new String[][] { selection }, selectAll);
    }
    if (widget instanceof org.eclipse.swt.widgets.List) {
        if (pattern == null && selection != null && selection.length == 1) {
            pattern = selection[0];
        }
        result = selectListItem(element, new String[] { pattern });
    }
    if (result != null && !result.booleanValue()) {
        // makeScreenShot();
    }
    return result != null && result.booleanValue();
}

From source file:org.talend.commons.ui.swt.tableviewer.TableViewerCreator.java

License:Open Source License

/**
 * DOC amaumont Comment method "applyActivatedCellEditor".
 *///from  ww w . ja v  a  2s. c om
public void applyActivatedCellEditor() {
    TableViewer tableViewer = getTableViewer();
    if (tableViewer != null && !tableViewer.getTable().isDisposed()) {
        CellEditor activatedCellEditor = null;
        if (tableViewer.isCellEditorActive()) {
            CellEditor[] cellEditors = tableViewer.getCellEditors();
            for (CellEditor cellEditor : cellEditors) {
                if (cellEditor != null && cellEditor.isActivated()
                        && cellEditor instanceof ExtendedTextCellEditorWithProposal) {
                    ((ExtendedTextCellEditorWithProposal) cellEditor).fireApplyEditorValue();
                    activatedCellEditor = cellEditor;
                }
            }
        }
        if (activatedCellEditor != null) {
            Object currentModifiedBean = getModifiedObjectInfo().getCurrentModifiedBean();
            tableViewer.refresh(currentModifiedBean, true);
        }
    }

}