Class EmfDialogBuilder
java.lang.Object
com.amalgamasimulation.desktop.ui.editor.dialogs.EmfDialogBuilder
Builder of a dialog with one field per feature of an EMF object, created by
Dialogues.emf(Shell, String, EObject).
The field kind depends on the attribute type: int and Integer give an integer field,
double and Double a double field, String a text field.
The fields show the values of the object when the dialog opens. After OK one CompoundCommand of SetCommands
sets all the features on the command stack of CommandsManager.getEditingDomain(), so one Undo restores them.
Cancel changes neither the object nor the command stack.
- Author:
- Ionov Ivan
-
Method Summary
Modifier and TypeMethodDescriptionbutton(org.eclipse.emf.ecore.EStructuralFeature feature, ISimpleButtonProperties button) Sets the button of the field of the feature.Adds a field for the feature.Adds a file path field with theButtons.openFile()button for aStringfeature.Adds a folder path field with theButtons.openDirectory()button for aStringfeature.Sets the message under the title.booleanopen()Opens the dialog and waits until it is closed.strategy(org.eclipse.emf.ecore.EStructuralFeature feature, ValidationStrategy<?, String> strategy) Replaces the validation strategy of the field of the feature.
-
Method Details
-
feature
Adds a field for the feature. The default strategy isValidationStrategies.integerPositive(),ValidationStrategies.doublePositive()orValidationStrategies.stringIsNotEmpty().- Parameters:
feature- single-valuedint,Integer,double,DoubleorStringattribute of the class of the object; notnulllabel- label of the field; notnull- Returns:
- this builder
- Throws:
IllegalArgumentException- if the feature is of another type or not of the class of the object; the message names the feature
-
file
Adds a file path field with theButtons.openFile()button for aStringfeature. The default strategy isValidationStrategies.stringIsNotEmpty().- Parameters:
feature- single-valuedStringattribute of the class of the object; notnulllabel- label of the field; notnull- Returns:
- this builder
- Throws:
IllegalArgumentException- if the feature is not aStringattribute of the class of the object
-
folder
Adds a folder path field with theButtons.openDirectory()button for aStringfeature. The default strategy isValidationStrategies.stringIsNotEmpty().- Parameters:
feature- single-valuedStringattribute of the class of the object; notnulllabel- label of the field; notnull- Returns:
- this builder
- Throws:
IllegalArgumentException- if the feature is not aStringattribute of the class of the object
-
strategy
public EmfDialogBuilder strategy(org.eclipse.emf.ecore.EStructuralFeature feature, ValidationStrategy<?, String> strategy) Replaces the validation strategy of the field of the feature. The strategy must take and return the type of the feature, and not returnnullfor anintordoublefeature. A strategy of another type throwsClassCastExceptionwhen the dialog opens or on OK; the object and the command stack stay the same.- Parameters:
feature- the feature of an added fieldstrategy- checks and converts the text of the field- Returns:
- this builder
- Throws:
IllegalArgumentException- if no field was added for the feature
-
button
public EmfDialogBuilder button(org.eclipse.emf.ecore.EStructuralFeature feature, ISimpleButtonProperties button) Sets the button of the field of the feature. For a file or folder field it replaces the default button, for example withButtons.openFile().extensions(...).- Parameters:
feature- the feature of an added fieldbutton- the button; one instance belongs to one field- Returns:
- this builder
- Throws:
IllegalArgumentException- if no field was added for the feature
-
message
Sets the message under the title.- Parameters:
message- the message;nullshows no message- Returns:
- this builder
-
open
public boolean open()Opens the dialog and waits until it is closed.- Returns:
trueafter OK, when the features have got the new values;falseafter Cancel
-