List of usage examples for org.eclipse.jface.viewers ICellEditorListener ICellEditorListener
ICellEditorListener
From source file:ac.soton.fmusim.components.ui.controls.AbstractVariableValueCellEditor.java
License:Open Source License
/** * Adds cell editor validation listener. *///ww w.java 2 s .c om private void createListener() { addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState) { if (!newValidState) { decorator.setDescriptionText(getErrorMessage()); decorator.show(); } else { decorator.hide(); } } @Override public void applyEditorValue() { } @Override public void cancelEditor() { decorator.hide(); } }); }
From source file:ca.uwaterloo.gp.fmp.constraints.ui.ConstraintTableEditor.java
License:Open Source License
private void createEditorListener() { editorListener = new ICellEditorListener() { public void cancelEditor() { deactivateCellEditor();//from w ww .j a va 2 s . com } public void editorValueChanged(boolean oldValidState, boolean newValidState) { //Do nothing } public void applyEditorValue() { if (cellEditor == null) return; // Check if editor has a valid value if (!cellEditor.isValueValid()) { return; } // See if the value changed and if so update Object newValue = cellEditor.getValue(); boolean changed = false; if (editValue == null) { if (newValue != null) changed = true; } else if (!editValue.equals(newValue)) changed = true; // Set the editor value if (changed && constraint != null) { // apply change in model constraint.setText((String) newValue); // apply change in view tableViewer.update(constraint, null); deactivateCellEditor(); } } }; }
From source file:ca.uwaterloo.gp.fmp.presentation.FmpAdapterFactoryTreeEditor.java
License:Open Source License
private void createEditorListener() { editorListener = new ICellEditorListener() { public void cancelEditor() { deactivateCellEditor();/* w w w .j a v a 2 s .c o m*/ } public void editorValueChanged(boolean oldValidState, boolean newValidState) { //Do nothing } public void applyEditorValue() { if (cellEditor == null) return; // Check if editor has a valid value if (!cellEditor.isValueValid()) { return; } // See if the value changed and if so update Object newValue = cellEditor.getValue(); boolean changed = false; if (editValue == null) { if (newValue != null) changed = true; } else if (!editValue.equals(newValue)) changed = true; // Set the editor value if (changed) { // See if the value is valid int locationType = RoleQuery.INSTANCE.getLocationType((Node) owner); if (locationType == RoleQuery.MODEL_PROPERTIES || locationType == RoleQuery.CONFIGURATION_PROPERTIES || locationType == RoleQuery.METAMODEL_PROPERTIES) { // so the owner is a property feature (id, name, min, max, etc.) int propertyRole = RoleQuery.INSTANCE.getPropertyRole((Node) owner); // check that 0 <= minOccur <= maxOccur if (propertyRole == RoleQuery.MIN_OCCUR) { if (newValue instanceof Integer) { int min = ((Integer) newValue).intValue(); if (min < 0) return; // retrieve maxOccur EList parentChildren = ((Node) owner.eContainer()).getChildren(); int index = parentChildren.indexOf(owner); Feature maxFeature = (Feature) parentChildren.get(index + 1); int max = maxFeature.getTypedValue().getIntegerValue().intValue(); if (min > max && max != -1) return; } else return; } else if (propertyRole == RoleQuery.MAX_OCCUR) { if (newValue instanceof Integer) { int max = ((Integer) newValue).intValue(); if (max < 0 && max != -1) return; // retrieve maxOccur EList parentChildren = ((Node) owner.eContainer()).getChildren(); int index = parentChildren.indexOf(owner); Feature minFeature = (Feature) parentChildren.get(index - 1); if (max < minFeature.getTypedValue().getIntegerValue().intValue() && max != -1) return; // for groups max < count(children) // get the described node Feature config = ModelNavigation.INSTANCE.navigateToRootFeature((Node) owner); Node describedNode = config.getDescribedNode(); if (describedNode instanceof FeatureGroup) { FeatureGroup group = (FeatureGroup) describedNode; if (group.getChildren().size() < max || max == -1) return; } } else return; } } Command cmd = ModelManipulation.createDirectEditSetCommand(adapterFactory, editingDomain, owner, newValue); if (cmd.canExecute()) editingDomain.getCommandStack().execute(cmd); deactivateCellEditor(); } } }; }
From source file:cg.editor.propertysheet.PropertySheetViewer.java
License:Open Source License
/** * Creates a new cell editor listener./*from ww w . j a va 2 s . c om*/ */ private void createEditorListener() { editorListener = new ICellEditorListener() { public void cancelEditor() { deactivateCellEditor(); } public void editorValueChanged(boolean oldValidState, boolean newValidState) { //Do nothing } public void applyEditorValue() { //Do nothing } }; }
From source file:com.appnativa.studio.properties.PropertySheetViewer.java
License:Open Source License
/** * Creates a new cell editor listener.//from w ww. ja v a2 s . c om */ private void createEditorListener() { editorListener = new ICellEditorListener() { public void cancelEditor() { //DD: deactivateCellEditor(); } public void editorValueChanged(boolean oldValidState, boolean newValidState) { //Do nothing } public void applyEditorValue() { //Do nothing } }; }
From source file:com.architexa.org.eclipse.gef.tools.DirectEditManager.java
License:Open Source License
private void hookListeners() { ancestorListener = new AncestorListener.Stub() { public void ancestorMoved(IFigure ancestor) { placeCellEditor();//from www. j a va 2s. com } }; getEditPart().getFigure().addAncestorListener(ancestorListener); Control control = getControl(); controlListener = new ControlAdapter() { public void controlMoved(ControlEvent e) { // This must be handled async because during scrolling, the CellEditor moves // first, but then afterwards the viewport Scrolls, which would cause the // shadow to move twice Display.getCurrent().asyncExec(new Runnable() { public void run() { placeBorder(); } }); } public void controlResized(ControlEvent e) { placeBorder(); } }; control.addControlListener(controlListener); cellEditorListener = new ICellEditorListener() { public void applyEditorValue() { commit(); } public void cancelEditor() { bringDown(); } public void editorValueChanged(boolean old, boolean newState) { handleValueChanged(); } }; getCellEditor().addListener(cellEditorListener); editPartListener = new EditPartListener.Stub() { public void partDeactivated(EditPart editpart) { bringDown(); } }; getEditPart().addEditPartListener(editPartListener); }
From source file:com.codeaffine.home.control.admin.ui.util.viewer.property.PropertySheetViewer.java
License:Open Source License
/** * Creates a new cell editor listener.// www .j av a 2s . co m */ @SuppressWarnings("serial") private void createEditorListener() { editorListener = new ICellEditorListener() { @Override public void cancelEditor() { deactivateCellEditor(); } @Override public void editorValueChanged(boolean oldValidState, boolean newValidState) { //Do nothing } @Override public void applyEditorValue() { //Do nothing } }; }
From source file:com.iw.plugins.spindle.ui.propertysheet.PropertySheetViewer.java
License:Open Source License
/** * Creates a new cell editor listener.// w w w . ja v a 2 s .co m */ private void createEditorListener() { editorListener = new ICellEditorListener() { public void cancelEditor() { deactivateCellEditor(); } public void editorValueChanged(boolean oldValidState, boolean newValidState) { } public void applyEditorValue() { } }; }
From source file:com.kopson.cite.smartlogmodel.TagEditingSupport.java
License:Open Source License
@Override protected CellEditor getCellEditor(Object element) { TextCellEditor editor = new TextCellEditor(viewer.getTable()); editor.setValidator(new ICellEditorValidator() { @Override//from w w w . ja v a2s. co m public String isValid(Object value) { if (SmartLogProvider.getTagList().contains((String) value)) return null; else return "Invalid type: " + value.toString(); } }); editor.addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState) { if (!newValidState) { MessageDialog.openError(viewer.getControl().getShell(), "No did not work", "Question"); } } @Override public void cancelEditor() { } @Override public void applyEditorValue() { } }); return editor; }
From source file:com.mentor.nucleus.bp.model.compare.contentmergeviewer.ElementEditingSupport.java
License:Open Source License
@Override protected CellEditor getCellEditor(Object element) { if (element instanceof ObjectElementComparable) { ObjectElement objEle = (ObjectElement) ((ObjectElementComparable) element).getRealElement(); CellEditor editor = null; if (((NonRootModelElement) objEle.getParent()).getModelRoot() instanceof Ooaofooa) { editor = CellModifierProvider.getCellEditor((NonRootModelElement) objEle.getParent(), viewer.getTree(), objEle); } else {/*from w w w . ja v a2 s . c o m*/ editor = com.mentor.nucleus.bp.ui.canvas.cells.CellModifierProvider .getCellEditor((NonRootModelElement) objEle.getParent(), viewer.getTree(), objEle); } final CellEditor finalEditor = editor; editor.addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState) { if (!newValidState) { viewer.setErrorMessage(finalEditor.getErrorMessage()); } else { viewer.setErrorMessage(""); } } @Override public void cancelEditor() { viewer.setErrorMessage(""); } @Override public void applyEditorValue() { viewer.setErrorMessage(""); } }); return editor; } return null; }