Commit dad20f24 authored by Axel Howind's avatar Axel Howind

dialogs

parent 02cbb46a
......@@ -14,14 +14,7 @@
package com.dua3.fx.util;
import com.dua3.fx.util.controls.AboutDialogBuilder;
import com.dua3.fx.util.controls.AlertBuilder;
import com.dua3.fx.util.controls.AlertPaneBuilder;
import com.dua3.fx.util.controls.InputDialogBuilder;
import com.dua3.fx.util.controls.InputPaneBuilder;
import com.dua3.fx.util.controls.OptionsDialogBuilder;
import com.dua3.fx.util.controls.PromptBuilder;
import com.dua3.fx.util.controls.WizardDialogBuilder;
import com.dua3.fx.util.controls.*;
import javafx.scene.control.Alert.AlertType;
......@@ -131,13 +124,22 @@ public class Dialogs {
/**
* Start definition of new prompt dialog.
* @return
* @return
* new {@link PromptBuilder} instance
*/
public static PromptBuilder prompt() {
return new PromptBuilder();
}
/**
* Start definition of new prompt pane.
* @return
* new {@link PromptBuilder} instance
*/
public static PromptPaneBuilder promptPane() {
return new PromptPaneBuilder();
}
/**
* Start definition of new input dialog.
* @return
......
......@@ -203,7 +203,7 @@ public interface InputBuilder<B extends InputBuilder<B>> {
/**
* Add labeled pane with options.
*
*
* @param id
* the ID
* @param label
......@@ -216,5 +216,22 @@ public interface InputBuilder<B extends InputBuilder<B>> {
* {@code this}
*/
B options(String id, String label, Supplier<OptionValues> dflt, Supplier<OptionSet> options);
/**
* Add unlabeled pane with options.
* <p>
* <em>Note to implementers:</em> Labels of the options should be aligned properly with labels of the input dialog.
* </p>
*
* @param id
* the ID
* @param dflt
* supplier of default values
* @param options
* suppliuer of options
* @return
* {@code this}
*/
B options(String id, Supplier<OptionValues> dflt, Supplier<OptionSet> options);
}
\ No newline at end of file
......@@ -101,10 +101,16 @@ implements InputBuilder<InputDialogBuilder> {
return this;
}
@Override
public InputDialogBuilder options(String id, String label, Supplier<OptionValues> dflt, Supplier<OptionSet> options) {
pb.options(id, label, dflt, options);
return this;
}
@Override
public InputDialogBuilder options(String id, String label, Supplier<OptionValues> dflt, Supplier<OptionSet> options) {
pb.options(id, label, dflt, options);
return this;
}
@Override
public InputDialogBuilder options(String id, Supplier<OptionValues> dflt, Supplier<OptionSet> options) {
pb.options(id, dflt, options);
return this;
}
}
......@@ -275,7 +275,11 @@ implements InputBuilder<InputPaneBuilder> {
@Override
public InputPaneBuilder options(String id, String label, Supplier<OptionValues> dflt, Supplier<OptionSet> options) {
return add(id, label, OptionValues.class, dflt, new OptionsPane(options, dflt));
return add(id, label, OptionValues.class, dflt, new OptionsPane(options, dflt));
}
public InputPaneBuilder options(String id, Supplier<OptionValues> dflt, Supplier<OptionSet> options) {
return add(id, OptionValues.class, dflt, new OptionsPane(options, dflt));
}
// TODO: add date and time inputs
......
package com.dua3.fx.util.controls;
import com.dua3.fx.util.FxUtil;
import javafx.event.ActionEvent;
import javafx.geometry.Dimension2D;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import java.util.*;
import java.util.function.Supplier;
import java.util.logging.Logger;
public class PromptPane extends InputDialogPane<String> {
/** Logger */
protected static final Logger LOG = Logger.getLogger(PromptPane.class.getSimpleName());
private TextField text;
private Supplier<String> defaultValue = () -> "";
@Override
public String get() {
return text.getText();
}
public PromptPane() {
text = new TextField();
setContent(new StackPane(text));
}
@Override
public void init() {
// nop
}
}
// 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.fx.util.controls;
import javafx.scene.control.TextInputDialog;
/**
* Builder for Prompt Panes.
*
* Provides a fluent interface to create Prompts.
*/
public class PromptPaneBuilder extends AbstractPaneBuilder<PromptPane, PromptPaneBuilder, String> {
public PromptPaneBuilder() {
setDialogSupplier(PromptPane::new);
}
@Override
public PromptPane build() {
PromptPane pane = super.build();
pane.setGraphic(null);
return pane;
}
}
\ No newline at end of file
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