List of usage examples for org.eclipse.jface.viewers CellEditor isValueValid
public boolean isValueValid()
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;/* w ww . j a va 2s .co m*/ 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.debug.internal.ui.viewers.TableEditorImpl.java
License:Open Source License
/** * Saves the value of the currently active cell editor, by delegating to the * cell modifier./*from w ww . j a v a2s . co m*/ */ private void saveEditorValue(CellEditor cellEditor, Item tableItem) { if (fCellModifier != null) { if (!cellEditor.isValueValid()) { // /Do what ??? } String property = null; if (fColumnProperties != null && fColumnNumber < fColumnProperties.length) property = fColumnProperties[fColumnNumber]; fCellModifier.modify(tableItem, property, cellEditor.getValue()); } }
From source file:org.eclipse.rcptt.tesla.internal.ui.processors.CellEditorSupport.java
License:Open Source License
protected Response handleApplyCellEditor(final ApplyCellEditor command) { final Element element = command.getElement(); final SWTUIElement uiElement = getMapper().get(element); if (uiElement != null) { final CellEditor cellEditor = cellEditorActivations.get(uiElement.widget); if (cellEditor != null) { getPlayer().exec("Apply direct edit", new Runnable() { public void run() { // TeslaCellEditorManager.getInstance().forceRemove( // cellEditor); TeslaSWTAccess.callMethodValueChanged(cellEditor, "valueChanged", cellEditor.isValueValid(), true);//from www. ja v a 2s .c om // Check if there is modal dialog, then no deactivate is // required. TeslaSWTAccess.callMethod(cellEditor, "fireApplyEditorValue"); if (cellEditor instanceof ComboBoxViewerCellEditor) { TeslaSWTAccess.callMethod(ComboBoxViewerCellEditor.class, cellEditor, "applyEditorValueAndDeactivate"); } if (command.isDeactivate()) { cellEditor.deactivate(); cellEditorActivations.remove(uiElement.widget); } } }); } } return ProtocolFactory.eINSTANCE.createBooleanResponse(); }
From source file:org.eclipse.rcptt.tesla.nebula.NebulaUIProcessor.java
License:Open Source License
@Override protected CellEditorSupport createCellEditorSupport() { return new CellEditorSupport(this) { protected Response handleActivateCellEditor(final ActivateCellEditor command) { Element element = command.getElement(); if (!element.getKind().equals(NebulaElementKinds.GRID)) return super.handleActivateCellEditor(command); SWTUIElement uiElement = getMapper().get(element); final Grid grid = (Grid) PlayerWrapUtils.unwrapWidget(uiElement); final ColumnViewer viewer = TeslaSWTAccess.getThis(ColumnViewer.class, grid, SWT.MouseDown); getPlayer().exec("Activate editor in Nebula Grid", new Runnable() { public void run() { Object item = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); if (item != null) viewer.editElement(item, command.getColumn()); }/*from w w w.jav a2s . c om*/ }); return factory.createBooleanResponse(); } protected Response handleCancelCellEditor(final CancelCellEditor command) { Element element = command.getElement(); if (!element.getKind().equals(NebulaElementKinds.GRID)) return super.handleCancelCellEditor(command); SWTUIElement uiElement = getMapper().get(element); final Grid grid = (Grid) PlayerWrapUtils.unwrapWidget(uiElement); final ColumnViewer viewer = TeslaSWTAccess.getThis(ColumnViewer.class, grid, SWT.MouseDown); getPlayer().exec("Cancel editing in Nebula Grid", new Runnable() { public void run() { viewer.cancelEditing(); } }); return factory.createBooleanResponse(); } @Override protected Response handleApplyCellEditor(final ApplyCellEditor command) { Element element = command.getElement(); if (!element.getKind().equals(NebulaElementKinds.GRID)) return super.handleApplyCellEditor(command); getPlayer().exec("Apply editing in Nebula Grid", new Runnable() { public void run() { CellEditor editor = TeslaCellEditorManager.getInstance().getLastActivatedByAnyMethod(); if (editor != null) { TeslaCellEditorManager.getInstance().forceRemove(editor); TeslaSWTAccess.callMethodValueChanged(editor, "valueChanged", editor.isValueValid(), true); TeslaSWTAccess.callMethod(editor, "fireApplyEditorValue"); if (editor instanceof ComboBoxViewerCellEditor) { TeslaSWTAccess.callMethod(ComboBoxViewerCellEditor.class, editor, "applyEditorValueAndDeactivate"); } editor.deactivate(); } } }); return factory.createBooleanResponse(); } }; }