Commit 02652045 authored by Axel Howind's avatar Axel Howind

buttons (wip)

parent bbaef948
Pipeline #52324439 passed with stages
in 17 minutes and 22 seconds
......@@ -14,15 +14,18 @@
package com.dua3.fx.util.controls;
import com.dua3.utility.options.OptionSet;
import com.dua3.utility.options.OptionValues;
import javafx.beans.binding.Bindings;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import com.dua3.utility.options.OptionSet;
import com.dua3.utility.options.OptionValues;
/**
* Builder for Alert Dialogs.
*
......@@ -42,6 +45,11 @@ implements InputBuilder<InputDialogBuilder> {
InputDialog dlg = new InputDialog();
InputPane dialogPane = pb.build();
dialogPane.init();
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
final Button okButton = (Button) dialogPane.lookupButton(ButtonType.OK);
okButton.disableProperty().bind(Bindings.not(dialogPane.validProperty()));
dlg.setDialogPane(dialogPane);
return dlg;
}
......
......@@ -8,8 +8,6 @@ import javafx.beans.value.ObservableBooleanValue;
import javafx.geometry.Dimension2D;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
......@@ -83,12 +81,6 @@ public class InputPane extends InputDialogPane<Map<String,Object>> {
void setContent(Collection<Meta<?>> data, int columns) {
this.data = Objects.requireNonNull(data);
this.columns = columns;
// buttons
getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
final Button okButton = (Button) lookupButton(ButtonType.OK);
okButton.disableProperty().bind(Bindings.not(valid));
}
@Override
......
......@@ -14,18 +14,15 @@
package com.dua3.fx.util.controls;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import com.dua3.fx.util.controls.InputPane.Meta;
import com.dua3.utility.lang.LangUtil;
import com.dua3.utility.options.OptionSet;
import com.dua3.utility.options.OptionValues;
import javafx.scene.control.ButtonType;
import java.util.*;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Builder for Alert Dialogs.
......@@ -44,6 +41,7 @@ implements InputBuilder<InputPaneBuilder> {
private int columns = 1;
private LinkedHashMap<String, InputPane.Meta<?>> data = new LinkedHashMap<>();
private List<ButtonType> buttons = Collections.emptyList();
/* (non-Javadoc)
* @see com.dua3.fx.util.controls.InputBuilder#add(java.lang.String, java.lang.String, java.lang.Class, T, com.dua3.fx.util.controls.InputDialogPane.InputControl)
......@@ -137,7 +135,12 @@ implements InputBuilder<InputPaneBuilder> {
}
// TODO: add date and time inputs
public InputPaneBuilder buttons(ButtonType... b) {
buttons = List.of(b);
return this;
}
/* (non-Javadoc)
* @see com.dua3.fx.util.controls.InputBuilder#build()
*/
......
......@@ -129,7 +129,7 @@ public class WizardDialog extends Dialog<Map<String,Object>> {
}
// prepare buttons
pane.getButtonTypes().clear();
pane.getButtonTypes().clear();
// cancel button
if (isCancelable()) {
......
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