Class Dialogues
java.lang.Object
com.amalgamasimulation.desktop.ui.editor.dialogs.Dialogues
Simple dialogs with input fields. You build a dialog with a chain of calls and open it with open.
Kinds of dialog:
- one field: integer, doubleValue, string, file, folder. open returns the entered value. If the user clicks Cancel, open returns an empty Optional.
- any number of fields: fields. Each field reads its value from the supplier. After OK, each field passes the new value to its handler.
- one field for each record component: record. open returns a new record with the entered values.
- one field for each feature of an EMF object: emf. After OK, the dialog sets all features with one command.
Example with one field:
Optional<Integer> trucks = Dialogues.integer(shell, "Count")
.label("Trucks")
.value(5)
.open();
Example with several fields:
Dialogues.fields(shell, "Settings")
.integer("Trucks", () -> trucks, value -> trucks = value)
.doubleValue("Speed", () -> speed, value -> speed = value)
.open();
- Author:
- Ionov Ivan
-
Method Summary
Modifier and TypeMethodDescriptionstatic ValueDialogBuilder<Double> doubleValue(org.eclipse.swt.widgets.Shell shell, String title) static EmfDialogBuilderDialog with one field per added feature of the EMF object, seeEmfDialogBuilder.static FieldsDialogBuilderDialog with any number of fields, added by the builder in the given order.static ValueDialogBuilder<String> Dialog with one file path field, seeFieldsDialogBuilder.file(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).static ValueDialogBuilder<String> Dialog with one folder path field, seeFieldsDialogBuilder.folder(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).static ValueDialogBuilder<Integer> static <R extends Record>
RecordDialogBuilder<R> Dialog with one field per component of the record, seeRecordDialogBuilder.static ValueDialogBuilder<String> Dialog with oneStringfield, seeFieldsDialogBuilder.string(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).
-
Method Details
-
integer
public static ValueDialogBuilder<Integer> integer(org.eclipse.swt.widgets.Shell shell, String title) Dialog with oneintfield, seeFieldsDialogBuilder.integer(java.lang.String, java.util.function.Supplier<java.lang.Integer>, java.util.function.Consumer<java.lang.Integer>).- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
doubleValue
public static ValueDialogBuilder<Double> doubleValue(org.eclipse.swt.widgets.Shell shell, String title) Dialog with onedoublefield, seeFieldsDialogBuilder.doubleValue(java.lang.String, java.util.function.Supplier<java.lang.Double>, java.util.function.Consumer<java.lang.Double>).- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
string
Dialog with oneStringfield, seeFieldsDialogBuilder.string(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
file
Dialog with one file path field, seeFieldsDialogBuilder.file(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
folder
Dialog with one folder path field, seeFieldsDialogBuilder.folder(java.lang.String, java.util.function.Supplier<java.lang.String>, java.util.function.Consumer<java.lang.String>).- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
fields
Dialog with any number of fields, added by the builder in the given order.- Parameters:
shell- parent shelltitle- title of the dialog- Returns:
- the builder of the dialog
-
record
public static <R extends Record> RecordDialogBuilder<R> record(org.eclipse.swt.widgets.Shell shell, String title, R value) Dialog with one field per component of the record, seeRecordDialogBuilder.- Type Parameters:
R- type of the record- Parameters:
shell- parent shelltitle- title of the dialogvalue- the record whose values the fields show; notnull- Returns:
- the builder of the dialog
- Throws:
IllegalArgumentException- if a component is notint,Integer,double,Double,StringorPath; the message names the component
-
emf
public static EmfDialogBuilder emf(org.eclipse.swt.widgets.Shell shell, String title, org.eclipse.emf.ecore.EObject eObject) Dialog with one field per added feature of the EMF object, seeEmfDialogBuilder.- Parameters:
shell- parent shelltitle- title of the dialogeObject- the object whose features the fields show and set; notnull- Returns:
- the builder of the dialog
-