Commit 058d530b authored by Axel Howind's avatar Axel Howind

result handling (in progress)

parent 7b34f11f
......@@ -11,9 +11,9 @@ import javafx.scene.control.DialogPane;
* @param <B> the type of the builder
* @param <R> the result type
*/
public class StandardDialogPaneBuilder<D extends DialogPane, B extends StandardDialogPaneBuilder<D,B,R>,R>
public class AbstractPaneBuilder<D extends DialogPane & Supplier<R>, B extends AbstractPaneBuilder<D,B,R>,R>
extends AbstractDialogPaneBuilder<D, B,R> {
protected StandardDialogPaneBuilder(Supplier<D> supplier) {
protected AbstractPaneBuilder(Supplier<D> supplier) {
super(supplier, DialogPane::setHeaderText, DialogPane::setContentText);
}
......
......@@ -15,8 +15,6 @@
package com.dua3.fx.util.controls;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
/**
* Builder for Alert Dialogs.
......@@ -24,13 +22,18 @@ import javafx.scene.control.DialogPane;
* Provides a fluent interface to create Alerts.
*/
public class AlertPaneBuilder
extends StandardDialogPaneBuilder<DialogPane, AlertPaneBuilder, ButtonType> {
extends AbstractPaneBuilder<TypedDialogPane<Void>, AlertPaneBuilder, Void> {
public AlertPaneBuilder(AlertType type) {
super(() -> createPane(type));
}
public static DialogPane createPane(AlertType type) {
return new DialogPane();
public static TypedDialogPane<Void> createPane(AlertType type) {
return new TypedDialogPane<Void>() {
@Override
public Void get() {
return null;
}
};
}
/**
......@@ -38,9 +41,8 @@ extends StandardDialogPaneBuilder<DialogPane, AlertPaneBuilder, ButtonType> {
* @return Alert instance
*/
@Override
public DialogPane build() {
DialogPane dlg = super.build();
public TypedDialogPane<Void> build() {
TypedDialogPane<Void> dlg = super.build();
return dlg;
}
......
......@@ -31,8 +31,7 @@ public class InputDialog extends Dialog<Map<String, Object>> {
if (btn != ButtonType.OK) {
return null;
}
return ((InputDialogPane) getDialogPane()).convertResult();
return ((InputDialogPane) getDialogPane()).get();
});
}
......
......@@ -15,12 +15,11 @@ import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
public class InputDialogPane extends DialogPane {
public class InputDialogPane extends TypedDialogPane<Map<String,Object>> {
/** Logger */
protected static final Logger LOG = Logger.getLogger(InputDialogPane.class.getSimpleName());
......@@ -67,7 +66,8 @@ public class InputDialogPane extends DialogPane {
private Collection<Meta<?>> data = null;
public Map<String, Object> convertResult() {
@Override
public Map<String, Object> get() {
// Collecors.toMap() does not support null values!
Map<String,Object> result = new HashMap<>();
data.stream().forEach(e -> result.put(e.id, e.control.get()));
......
......@@ -41,7 +41,7 @@ import javafx.scene.control.TextField;
* Provides a fluent interface to create Alerts.
*/
public class InputDialogPaneBuilder
extends StandardDialogPaneBuilder<InputDialogPane, InputDialogPaneBuilder, Map<String, Object>>
extends AbstractPaneBuilder<InputDialogPane, InputDialogPaneBuilder, Map<String, Object>>
implements InputBuilder<InputDialogPaneBuilder> {
public InputDialogPaneBuilder() {
......
package com.dua3.fx.util.controls;
import java.util.function.Supplier;
import javafx.scene.control.DialogPane;
public abstract class TypedDialogPane<R> extends DialogPane implements Supplier<R> {
}
......@@ -21,7 +21,7 @@ public class WizardDialogBuilder {
LinkedHashMap<String, Page<?,?>> pages = new LinkedHashMap<>();
public <D extends DialogPane,B extends StandardDialogPaneBuilder<D,B,R>,R> WizardDialogBuilder page(String name, B builder) {
public <D extends TypedDialogPane<R>,B extends AbstractPaneBuilder<D,B,R>,R> WizardDialogBuilder page(String name, B builder) {
Page<D,R> page = new Page<>();
page.setNext(builder.next);
D pane = builder.build();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment