Commit aacabf58 authored by Axel Howind's avatar Axel Howind

adding buttons (wip)

parent 6e132421
Pipeline #52441171 failed with stages
in 16 minutes and 11 seconds
package com.dua3.fx.util.controls;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import java.util.ArrayList;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.function.Supplier;
public abstract class InputDialogPane<R> extends DialogPane implements Supplier<R> {
protected final BooleanProperty valid = new SimpleBooleanProperty(true);
protected ArrayList<ButtonType> buttons = new ArrayList<>();
public abstract void init();
/**
......@@ -32,4 +36,8 @@ public abstract class InputDialogPane<R> extends DialogPane implements Supplier<
protected void updateValidState(R r) {
valid.setValue(validate.test(r));
}
public void initButtons() {
getButtonTypes().setAll(buttons);
}
}
......@@ -8,6 +8,7 @@ import javafx.beans.value.ObservableBooleanValue;
import javafx.geometry.Dimension2D;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
......@@ -78,9 +79,10 @@ public class InputPane extends InputDialogPane<Map<String,Object>> {
GridPane.setMargin(child, insets);
}
void setContent(Collection<Meta<?>> data, int columns) {
void setContent(Collection<Meta<?>> data, int columns, List<ButtonType> buttons) {
this.data = Objects.requireNonNull(data);
this.columns = columns;
this.buttons = new ArrayList<>(buttons);
}
@Override
......
......@@ -148,7 +148,7 @@ implements InputBuilder<InputPaneBuilder> {
public InputPane build() {
InputPane pane = super.build();
pane.setContent(data.values(), columns);
pane.setContent(data.values(), columns, buttons);
return pane;
}
......
......@@ -129,7 +129,7 @@ public class WizardDialog extends Dialog<Map<String,Object>> {
}
// prepare buttons
pane.getButtonTypes().clear();
pane.initButtons();
// 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