Class FieldsDialogBuilder
java.lang.Object
com.amalgamasimulation.desktop.ui.editor.dialogs.FieldsDialogBuilder
Builder of a dialog with any number of fields, created by
Dialogues.fields(Shell, String).
Each field reads its value from valueExtractor when the dialog opens. Handlers get the new values
only after OK, in the order of the fields. Cancel calls no handler.- Author:
- Ionov Ivan
-
Method Summary
Modifier and TypeMethodDescriptionbutton(String label, ISimpleButtonProperties button) Sets the button of the field with the label.Adds adoublefield.Adds a file path field with theButtons.openFile()button.Adds a folder path field with theButtons.openDirectory()button.Adds anintfield.Sets the message under the title.booleanopen()Opens the dialog and waits until it is closed.strategy(String label, ValidationStrategy<?, String> strategy) Replaces the validation strategy of the field with the label.Adds aStringfield.
-
Method Details
-
integer
public FieldsDialogBuilder integer(String label, Supplier<Integer> valueExtractor, Consumer<Integer> handler) Adds anintfield. The default strategy isValidationStrategies.integerPositive().- Parameters:
label- label of the fieldvalueExtractor- reads the initial value;nullleaves the field emptyhandler- gets the new value after OK- Returns:
- this builder
-
doubleValue
public FieldsDialogBuilder doubleValue(String label, Supplier<Double> valueExtractor, Consumer<Double> handler) Adds adoublefield. The default strategy isValidationStrategies.doublePositive().- Parameters:
label- label of the fieldvalueExtractor- reads the initial value;nullleaves the field emptyhandler- gets the new value after OK- Returns:
- this builder
-
string
public FieldsDialogBuilder string(String label, Supplier<String> valueExtractor, Consumer<String> handler) Adds aStringfield. The default strategy isValidationStrategies.stringIsNotEmpty().- Parameters:
label- label of the fieldvalueExtractor- reads the initial value;nullleaves the field emptyhandler- gets the new value after OK- Returns:
- this builder
-
file
public FieldsDialogBuilder file(String label, Supplier<String> valueExtractor, Consumer<String> handler) Adds a file path field with theButtons.openFile()button. The default strategy isValidationStrategies.stringIsNotEmpty().- Parameters:
label- label of the fieldvalueExtractor- reads the initial path;nullleaves the field emptyhandler- gets the new path after OK- Returns:
- this builder
-
folder
public FieldsDialogBuilder folder(String label, Supplier<String> valueExtractor, Consumer<String> handler) Adds a folder path field with theButtons.openDirectory()button. The default strategy isValidationStrategies.stringIsNotEmpty().- Parameters:
label- label of the fieldvalueExtractor- reads the initial path;nullleaves the field emptyhandler- gets the new path after OK- Returns:
- this builder
-
strategy
Replaces the validation strategy of the field with the label. The model type of the strategy must be the type of the field.- Parameters:
label- label of the fieldstrategy- checks and converts the text of the field- Returns:
- this builder
- Throws:
IllegalArgumentException- if no field has the label
-
button
Sets the button of the field with the label. For a file or folder field it replaces the default button, for example withButtons.openFile().extensions(...).- Parameters:
label- label of the fieldbutton- the button; one instance belongs to one field- Returns:
- this builder
- Throws:
IllegalArgumentException- if no field has the label
-
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 handlers have got the new values;falseafter Cancel
-