Class RecordDialogBuilder<R extends Record>
java.lang.Object
com.amalgamasimulation.desktop.ui.editor.dialogs.RecordDialogBuilder<R>
- Type Parameters:
R- type of the record
Builder of a dialog with one field per record component, created by
Dialogues.record(Shell, String, Record).
The field kind depends on the component type: int and Integer give an integer field,
double and Double a double field, String a text field, Path a file field.
The label of a field is the component name until label(String, String) replaces it.
The fields show the values of the given record. After OK open() returns a new record made by the
canonical constructor; the given record stays the same.
- Author:
- Ionov Ivan
-
Method Summary
Modifier and TypeMethodDescriptionTurns the field of aStringorPathcomponent into a folder field with theButtons.openDirectory()button.Sets the label of the field of a component.Sets the message under the title.open()Opens the dialog and waits until it is closed.strategy(String component, ValidationStrategy<?, String> strategy) Replaces the validation strategy of the field of a component.
-
Method Details
-
label
Sets the label of the field of a component.- Parameters:
component- name of the record componentlabel- label of the field- Returns:
- this builder
- Throws:
IllegalArgumentException- if the record has no such component
-
folder
Turns the field of aStringorPathcomponent into a folder field with theButtons.openDirectory()button.- Parameters:
component- name of the record component- Returns:
- this builder
- Throws:
IllegalArgumentException- if the record has no such component or its type is notStringorPath
-
strategy
Replaces the validation strategy of the field of a component. The defaults areValidationStrategies.integerPositive(),ValidationStrategies.doublePositive()andValidationStrategies.stringIsNotEmpty().The model type of the strategy must be
Integerfor anintorIntegercomponent,DoublefordoubleorDouble, andStringforStringandPathcomponents. The type cannot be checked here. With a wrong typeopen()throwsClassCastExceptionwhen the component has a value; when the value isnull, OK throws it and the dialog stays open.- Parameters:
component- name of the record componentstrategy- checks and converts the text of the field- Returns:
- this builder
- Throws:
IllegalArgumentException- if the record has no such component
-
message
Sets the message under the title.- Parameters:
message- the message;nullshows no message- Returns:
- this builder
-
open
Opens the dialog and waits until it is closed. Each time the fields show the values of the record given toDialogues.record(Shell, String, Record).The text of a
Pathfield becomes a path byPath.of(String, String...), which throwsInvalidPathExceptionon OK for an invalid path.- Returns:
- a new record with the entered values after OK; an empty
Optionalafter Cancel - Throws:
RuntimeException- the exception of the canonical constructor, for example its check of the values
-