List of usage examples for org.eclipse.jface.viewers CheckboxCellEditor getValue
public final Object getValue()
From source file:org.dawnsci.plotting.tools.region.RegionEditorEditingSupport.java
License:Open Source License
protected CellEditor createBooleanEditor(final RegionEditorNode node) { final CheckboxCellEditor fse = new CheckboxCellEditor((Composite) viewer.getControl(), SWT.NONE); fse.addListener(new ICellEditorListener() { @Override//from w w w . j a va2 s. c o m public void editorValueChanged(boolean oldValidState, boolean newValidState) { setValue(node, newValidState); } @Override public void cancelEditor() { } @Override public void applyEditorValue() { switch (column) { case 3: node.setVisible((Boolean) fse.getValue()); break; case 4: node.setActive((Boolean) fse.getValue()); break; case 5: node.setMobile((Boolean) fse.getValue()); break; default: break; } } }); return fse; }
From source file:org.eclipse.rcptt.tesla.recording.core.swt.JFaceRecordingProcessor.java
License:Open Source License
public void activateCellEditor(CellEditor cellEditor, ColumnViewerEditorActivationEvent activationEvent) { if (cellEditor == null) return;//from ww w.java 2 s . com if (checkCellEditorOP()) { return; } if (activeCellEditors.contains(cellEditor)) { return; } boolean checkbox = cellEditor instanceof CheckboxCellEditor; Control control = cellEditor.getControl(); lastCellEditorControl = null; if (control == null && !checkbox) { return; } Composite parent = null; if (checkbox) { parent = getCheckboxCellEditorSource(activationEvent); } else { parent = control.getParent(); } if (parent == null) { return; } activeCellEditors.add(cellEditor); // Control[] children = parent.getChildren(); if (parent instanceof Tree || parent instanceof Table) { String[][] selection = Viewers.getMultiPathSelection(getPlayer().wrap(parent)); ControlEditor editor = TeslaSWTAccess.getControlEditor(parent); int column = -1; if (activationEvent.getSource() instanceof ViewerCell) { ViewerCell cell = (ViewerCell) activationEvent.getSource(); column = cell.getColumnIndex(); Widget item = cell.getItem(); if (item instanceof TreeItem) { selection = new String[][] { Viewers.getPathByTreeItem((TreeItem) item) }; } else if (item instanceof TableItem) { selection = new String[][] { Viewers.getPathByTableItem((TableItem) item) }; } } else { if (editor instanceof TreeEditor) { column = ((TreeEditor) editor).getColumn(); } else if (editor instanceof TableEditor) { column = ((TableEditor) editor).getColumn(); } } FindResult result = getLocator().findElement(parent, true, false, false); if (result != null && (result.realElement.isTable() || result.realElement.isTree())) { ViewerUIElement e = new ViewerUIElement(result.element, getRecorder()); if (!checkbox) { e.setMultiSelection(selection); e.activateCellEditor(column); } else { CheckboxCellEditor checkboxCellEditor = (CheckboxCellEditor) cellEditor; int row = -1; if (parent instanceof Tree) { Tree tree = (Tree) parent; if (tree.getSelectionCount() > 0) row = tree.indexOf(tree.getSelection()[0]); } else if (parent instanceof Table) { Table table = (Table) parent; row = table.getSelectionIndex(); } if (row != -1 && checkboxCellEditor.getValue() != null) { ItemUIElement item = e.item(column, row); CheckItem checkItem = ProtocolFactory.eINSTANCE.createCheckItem(); checkItem.setElement(item.getElement()); checkItem.setState((Boolean) checkboxCellEditor.getValue()); getRecorder().safeExecuteCommand(checkItem); } } } } else { List<ICellEditsProcessor> processors = TeslaRecorder.getInstance() .getProcessors(ICellEditsProcessor.class); for (ICellEditsProcessor p : processors) if (p.activateCellEdit(cellEditor, activationEvent)) break; } }