com.dua3.utility.fx.controls.InputPaneBuilder Maven / Gradle / Ivy
// Copyright 2019 Axel Howind
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.dua3.utility.fx.controls;
import com.dua3.cabe.annotations.Nullable;
import com.dua3.utility.options.Arguments;
import com.dua3.utility.options.Option;
import javafx.scene.Node;
import javafx.stage.FileChooser;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
/**
* Builder for Alert Dialogs.
*
* Provides a fluent interface to create Alerts.
*/
public class InputPaneBuilder
extends AbstractPaneBuilder>
implements InputBuilder {
private final InputGridBuilder pb = new InputGridBuilder();
InputPaneBuilder() {
setDialogSupplier(() -> new InputPane(pb.build()));
}
@Override
public InputPaneBuilder add(String id, String label, Class type, Supplier dflt, InputControl control) {
pb.add(id, label, type, dflt, control);
return this;
}
@Override
public InputPaneBuilder add(String id, Class type, Supplier dflt, InputControl control) {
pb.add(id, type, dflt, control);
return this;
}
@Override
public InputPaneBuilder addNode(String id, String label, Node node) {
pb.addNode(id, label, node);
return this;
}
@Override
public InputPaneBuilder addNode(String id, Node node) {
pb.addNode(id, node);
return this;
}
@Override
public InputPaneBuilder columns(int columns) {
pb.columns(columns);
return this;
}
@Override
public InputPaneBuilder string(String id, String label, Supplier dflt, Function> validate) {
pb.string(id, label, dflt, validate);
return this;
}
@Override
public InputPaneBuilder integer(String id, String label, Supplier dflt, Function> validate) {
pb.integer(id, label, dflt, validate);
return this;
}
@Override
public InputPaneBuilder decimal(String id, String label, Supplier dflt, Function> validate) {
pb.decimal(id, label, dflt, validate);
return this;
}
@Override
public InputPaneBuilder checkBox(String id, String label, Supplier dflt, String text, Function> validate) {
pb.checkBox(id, label, dflt, text, validate);
return this;
}
@Override
public InputPaneBuilder comboBox(String id, String label, Supplier dflt, Class cls, Collection items, Function> validate) {
pb.comboBox(id, label, dflt, cls, items, validate);
return this;
}
@Override
public InputPaneBuilder comboBoxEx(
String id,
String label,
@Nullable UnaryOperator edit,
@Nullable Supplier add,
@Nullable BiPredicate, T> remove,
Function format,
Supplier dflt,
Class cls,
Collection items,
Function> validate) {
pb.comboBoxEx(id, label, edit, add, remove, format, dflt, cls, items, validate);
return this;
}
@Override
public InputPaneBuilder radioList(String id, String label, Supplier dflt, Class cls, Collection items, Function> validate) {
pb.radioList(id, label, dflt, cls, items, validate);
return this;
}
@Override
public InputPaneBuilder options(String id, String label, Supplier dflt, Supplier>> options) {
pb.options(id, label, dflt, options);
return this;
}
@Override
public InputPaneBuilder options(String id, Supplier dflt, Supplier>> options) {
pb.options(id, dflt, options);
return this;
}
@Override
public InputPaneBuilder chooseFile(String id, String label, Supplier dflt, FileDialogMode mode, boolean existingOnly, Collection filter, Function> validate) {
pb.chooseFile(id, label, dflt, mode, existingOnly, filter, validate);
return this;
}
}