List of usage examples for org.eclipse.jface.viewers CellEditor getValidator
public ICellEditorValidator getValidator()
From source file:com.mentor.nucleus.bp.ui.properties.test.PropertiesViewTest2.java
License:Open Source License
/** * Checks that after adding a space to the given model-element name, * the modified name is considered invalid/valid (according to the * spaceAllowed parameter) by the cell editor for the model-element's * name property. The editor is created by the property-descriptor * returned by the given property-source for the given property-id. *//*from ww w. j a v a 2s.com*/ private void checkSpaceInModelElementNameProperty(IPropertySource propertySource, String propertyId, String name, boolean spaceAllowed, boolean duplicateName, boolean component) { // create a cell-editor for the name property's value IPropertyDescriptor descriptor = PropertiesUtil.getDescriptor(propertySource, propertyId); CellEditor editor = descriptor.createPropertyEditor(new Shell()); // validate this test by checking that the editor says that the // given name is invalid since it is a duplicate ICellEditorValidator validator = editor.getValidator(); String result = validator.isValid(name); // must use different message when working against a PMC root String message = CorePlugin.DUPLICATE_NAME_ERROR; if (component) { message = "A model element with the same name already exists.\n\n" + "This is most likely due to uncommitted renames or deletions." + " If this is the case, please commit any outstanding changes before proceeding.\n\n" + "If the project is not connected to a configuration management system" + ", you will need to remove the target manually."; } assertTrue("Property cell editor says original name is invalid", duplicateName ? result.equals(message) : result == null); // check that the editor says that a name containing a space is // invalid/valid result = validator.isValid(name + " "); assertTrue("Property cell editor says name with spaces is valid", spaceAllowed ? result == null : result != null); }
From source file:com.nokia.sdt.component.symbian.actions.EditImageActionFilterDelegate.java
License:Open Source License
@Override protected void executeActionCommand(IAction action, EObject instance, CommandStack commandStack) { String propertyPath = getPrimaryImageProperty(instance); IPropertyDescriptor descriptor = getImagePropertyDescriptor(instance, propertyPath); Check.checkState(descriptor != null); CellEditor cellEditor = descriptor.createPropertyEditor(shell); IDialogCellEditorActivator activator = (IDialogCellEditorActivator) cellEditor; NodePathLookupResult result = ModelUtils.readProperty(instance, propertyPath, true); cellEditor.setValue(result.result);/* w w w . jav a2 s . c om*/ Object newValue = activator.invokeEditor(shell); if (newValue != null) { ChangePropertyCommand command = new ChangePropertyCommand(instance, propertyPath, newValue, cellEditor.getValidator()); commandStack.execute(command); } }
From source file:com.nokia.sdt.component.symbian.properties.AbstractPropertyDescriptor.java
License:Open Source License
/** * Checks for IComponentValidator adapter on the instance. If available * hooks up a cell editor validator for it. * @param instance/* w w w.ja v a2s . c o m*/ * @param cellEditor */ void enableComponentValidatorOnCellEditor(EObject instance, String propertyPath, ITypeDescriptor typeDescriptor, CellEditor cellEditor) { IComponentValidator validator = (IComponentValidator) EcoreUtil.getRegisteredAdapter(instance, IComponentValidator.class); ComposedCellEditorValidator composedValidator = new ComposedCellEditorValidator(this, validator, cellEditor.getValidator()); cellEditor.setValidator(composedValidator); }
From source file:com.nokia.sdt.symbian.ui.images.DirectEditingUtilities.java
License:Open Source License
/** * Edit the given image property in a dialog and return the command. * @param shell// w w w.j ava2 s. c o m * @param instance * @param propertyPath * @return command, or null if no change */ public static Command editImageProperty(Shell shell, EObject instance, String propertyPath) { IDialogCellEditorActivator activator = getCellEditorActivator(shell, instance, propertyPath); if (activator == null) return null; NodePathLookupResult result = ModelUtils.readProperty(instance, propertyPath, true); CellEditor cellEditor = (CellEditor) activator; cellEditor.setValue(result.result); Object newValue = activator.invokeEditor(shell); if (newValue != null) { ChangePropertyCommand command = new ChangePropertyCommand(instance, propertyPath, newValue, cellEditor.getValidator()); return command; } return null; }