List of usage examples for org.eclipse.jface.fieldassist FieldDecorationRegistry DEC_ERROR
String DEC_ERROR
To view the source code for org.eclipse.jface.fieldassist FieldDecorationRegistry DEC_ERROR.
Click Source Link
From source file:ac.soton.eventb.classdiagrams.diagram.sheet.custom.NewConstraintDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Group group = new Group(composite, SWT.SHADOW_ETCHED_IN); group.setText("Constraint"); GridLayout layout = new GridLayout(2, false); group.setLayout(layout);/*from w w w.j a v a 2 s . c om*/ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = 300; group.setLayoutData(gd); // predicate Label predicateLabel = new Label(group, SWT.NONE); predicateLabel.setText("Predicate:"); predicateLabel.setData(new GridData(SWT.TOP)); predicateText = new Text(group, SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH; predicateText.setLayoutData(data); predicateText.setFont(PropertySectionUtil.rodinFont); predicateText.addModifyListener(PropertySectionUtil.eventBListener); predicateText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validatePredicate(); } }); // name Label nameLabel = new Label(group, SWT.NONE); nameLabel.setText("Name:"); nameText = new Text(group, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); nameText.setFont(PropertySectionUtil.rodinFont); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(); } }); // comment Label commentLabel = new Label(group, SWT.NONE); commentLabel.setText("Comment:"); commentText = new Text(group, SWT.SINGLE | SWT.BORDER); commentText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); commentText.setFont(PropertySectionUtil.rodinFont); // theorem @SuppressWarnings("unused") Label theoremLabel = new Label(group, SWT.NONE); theoremButton = new Button(group, SWT.CHECK); theoremButton.setText("Theorem"); // validators predicateValidator = new DecoratedInputValidator(PropertySectionUtil.createDecorator(predicateText, "Please enter predicate", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String predicate) { if (predicate == null || predicate.trim().isEmpty()) return "Predicate cannot be empty"; return null; } }; nameValidator = new DecoratedInputValidator(PropertySectionUtil.createDecorator(nameText, "Please enter name", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String name) { if (name == null || name.trim().isEmpty()) return "Name cannot be empty"; return null; } }; return composite; }
From source file:ac.soton.eventb.classdiagrams.diagram.sheet.custom.NewEventDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Group group = new Group(composite, SWT.SHADOW_ETCHED_IN); group.setText("Event"); GridLayout layout = new GridLayout(2, false); group.setLayout(layout);//from w w w. j a v a 2 s . c o m GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = 300; group.setLayoutData(gd); // name Label nameLabel = new Label(group, SWT.NONE); nameLabel.setText("Name:"); nameText = new Text(group, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); nameText.setFont(PropertySectionUtil.rodinFont); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(); } }); // refines if (refinesNames != null) { Label refinesLabel = new Label(group, SWT.NONE); refinesLabel.setText("Refines:"); refinesCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); refinesCombo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); String[] items = new String[refinesNames.size() + 1]; int i = 0; items[i++] = ""; // empty item for non-refinement for (String name : refinesNames.keySet()) items[i++] = name; Arrays.sort(items); refinesCombo.setItems(items); } // comment Label commentLabel = new Label(group, SWT.NONE); commentLabel.setText("Comment:"); commentText = new Text(group, SWT.SINGLE | SWT.BORDER); commentText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); commentText.setFont(PropertySectionUtil.rodinFont); // validator nameValidator = new DecoratedInputValidator(PropertySectionUtil.createDecorator(nameText, "Please enter name", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String name) { if (name == null || name.trim().isEmpty()) return "Name cannot be empty"; if (conflictingNames != null && conflictingNames.contains(name.trim())) return "Event with such name already exists"; return null; } }; // initial name if (initialName != null) nameText.setText(initialName); return composite; }
From source file:ac.soton.eventb.statemachines.diagram.sheet.custom.NewInvariantDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Group group = new Group(composite, SWT.SHADOW_ETCHED_IN); group.setText("Invariant"); GridLayout layout = new GridLayout(2, false); group.setLayout(layout);//w w w .j a v a 2 s . c o m GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = 300; group.setLayoutData(gd); // predicate Label predicateLabel = new Label(group, SWT.NONE); predicateLabel.setText("Predicate:"); predicateLabel.setData(new GridData(SWT.TOP)); predicateText = new Text(group, SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH; predicateText.setLayoutData(data); predicateText.setFont(PropertySectionUtil.rodinFont); predicateText.addModifyListener(PropertySectionUtil.eventBListener); predicateText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validatePredicate(); } }); // name Label nameLabel = new Label(group, SWT.NONE); nameLabel.setText("Name:"); nameText = new Text(group, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); nameText.setFont(PropertySectionUtil.rodinFont); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(); } }); // comment Label commentLabel = new Label(group, SWT.NONE); commentLabel.setText("Comment:"); commentText = new Text(group, SWT.SINGLE | SWT.BORDER); commentText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); commentText.setFont(PropertySectionUtil.rodinFont); // theorem @SuppressWarnings("unused") Label theoremLabel = new Label(group, SWT.NONE); theoremButton = new Button(group, SWT.CHECK); theoremButton.setText("Theorem"); // validators predicateValidator = new DecoratedInputValidator(PropertySectionUtil.createDecorator(predicateText, "Please enter predicate", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String predicate) { if (predicate == null || predicate.trim().isEmpty()) return "Predicate cannot be empty"; return null; } }; nameValidator = new DecoratedInputValidator(PropertySectionUtil.createDecorator(nameText, "Please enter name", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String name) { if (name == null || name.trim().isEmpty()) return "Name cannot be empty"; return null; } }; return composite; }
From source file:ac.soton.fmusim.components.ui.controls.AbstractVariableValueCellEditor.java
License:Open Source License
/** * @param parent/*from w w w. jav a2s.c om*/ */ public AbstractVariableValueCellEditor(Composite parent, AbstractVariable var) { super(parent); variable = var; decorator = DecoratedInputValidator.createDecorator(getControl(), "abba", FieldDecorationRegistry.DEC_ERROR, false); createValidator(); createListener(); }
From source file:ac.soton.fmusim.components.ui.dialogs.EventBPortDialog.java
License:Open Source License
/** * Creates input validators.//from w w w .jav a 2 s . co m */ private void createValidators() { if (variableMap != null) { variableValidator = new DecoratedInputValidator(DecoratedInputValidator.createDecorator(variableCombo, "Please select variable", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String variable) { if (variable == null || variable.isEmpty()) return "Variable cannot be empty"; if (usedNames != null && usedNames.contains(variable.trim())) return "Port for this variable already exists"; return null; } }; } if (parameterMap != null) { parameterValidator = new DecoratedInputValidator(DecoratedInputValidator.createDecorator(parameterCombo, "Please select event parameter", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String parameter) { if (parameter == null || parameter.isEmpty()) return "Parameter cannot be empty"; if (usedNames != null && usedNames.contains(parameter.trim())) return "Port for this parameter already exists"; return null; } }; } }
From source file:ac.soton.fmusim.components.ui.dialogs.SimulationInputDialog.java
License:Open Source License
/** * Adds input field validators./*from w w w. j a v a 2s . c om*/ */ private void addValidators() { startTimeValidator = createTextValidator(startTimeText); stopTimeValidator = createTextValidator2(stopTimeText); stepSizeValidator = createTextValidator2(stepSizeText); timeErrorDecorator = DecoratedInputValidator.createDecorator(stopTimeText, "Stop time should be after start time", FieldDecorationRegistry.DEC_ERROR, false); stepTimeErrorDecorator = DecoratedInputValidator.createDecorator(stepSizeText, "Step size cannot exceed simulation time", FieldDecorationRegistry.DEC_ERROR, false); }
From source file:ac.soton.fmusim.components.ui.dialogs.SimulationInputDialog.java
License:Open Source License
/** * @return/*from www .j a va2 s. c o m*/ */ private DecoratedInputValidator createTextValidator(Text text) { return new DecoratedInputValidator(DecoratedInputValidator.createDecorator(text, "Please enter time in ms", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String timeString) { try { long input = Long.parseLong(timeString); if (input < 0) return "Time must be positive"; } catch (NumberFormatException e) { return "Invalid number format"; } return null; } }; }
From source file:ac.soton.fmusim.components.ui.dialogs.SimulationInputDialog.java
License:Open Source License
/** * @return//from ww w. j a v a 2s. c o m */ private DecoratedInputValidator createTextValidator2(Text text) { return new DecoratedInputValidator(DecoratedInputValidator.createDecorator(text, "Please enter time in ms", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String timeString) { try { long input = Long.parseLong(timeString); if (input <= 0) return "Time must be greater that zero"; } catch (NumberFormatException e) { return "Invalid number format"; } return null; } }; }
From source file:ac.soton.fmusim.components.ui.wizards.pages.EventBComponentParamDefinitionPage.java
License:Open Source License
/** * Creates and adds input validators for UI controls. *//*from w w w.ja va 2 s.c o m*/ private void addValidators() { stepPeriodValidator = new DecoratedInputValidator(DecoratedInputValidator.createDecorator(stepPeriodText, "Please enter simulation step period (ms)", FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String timeString) { try { long input = Long.parseLong(timeString); if (input <= 0) return "Simulation step period must be greater that zero"; } catch (NumberFormatException e) { return "Invalid double number format"; } return null; } }; //TODO: add decorators for invalid (absent) read/update events // stepToTimeErrorDecorator = DecoratedInputValidator.createDecorator(stepText, // "Step size cannot exceed simulation time", // FieldDecorationRegistry.DEC_ERROR, false); }
From source file:ac.soton.multisim.diagram.sheet.custom.common.EventBPortDialog.java
License:Open Source License
/** * Creates input validators.// w w w .j av a2 s. c om */ private void createValidators() { elementValidator = new DecoratedInputValidator( DecoratedInputValidator.createDecorator(elementCombo, FieldDecorationRegistry.DEC_ERROR, false)) { @Override public String isValidInput(String elementName) { if (elementName == null || elementName.isEmpty()) return "Selection cannot be empty"; // check if a port for this element already exists if (filterElements != null) { EventBNamedCommentedElement element = elementMap.get(elementName); if (element != null && filterElements.contains(element)) return "Port for this element already exists"; } return null; } }; }