Interface InputBuilder<B extends InputBuilder<B>>

Type Parameters:
B - the generic type of the InputBuilder
All Known Implementing Classes:
InputDialogBuilder, InputGridBuilder, InputPaneBuilder

public interface InputBuilder<B extends InputBuilder<B>>
A builder class for creating input controls.

The InputBuilder class provides methods to add various types of labeled and unlabeled input controls such as text fields, checkboxes, and combo boxes to a UI form. It allows customization of the control's ID, label text, default value, and validation rules. The builder pattern allows chaining of method calls to create complex input forms with ease.

  • Method Details

    • add

      <T> B add(String id, String label, Class<T> type, Supplier<T> dflt, InputControl<T> control)
      Add labeled input control.
      Type Parameters:
      T - the result type
      Parameters:
      id - the control's ID
      label - the label text
      type - the result type
      dflt - supplier of default value
      control - the control
      Returns:
      this
    • add

      <T> B add(String id, Class<T> type, Supplier<T> dflt, InputControl<T> control)
      Add unlabeled input control.
      Type Parameters:
      T - the result type
      Parameters:
      id - the control's ID
      type - the result type
      dflt - supplier of default value
      control - the control
      Returns:
      this
    • addNode

      B addNode(String id, String label, Node node)
      Add labeled input control.
      Parameters:
      id - the node's ID
      label - the label text
      node - the node
      Returns:
      this
    • addNode

      B addNode(String id, Node node)
      Add unlabeled input control.
      Parameters:
      id - the node's ID
      node - the node
      Returns:
      this
    • columns

      B columns(int columns)
      Set number of columns for layout (default is 1).
      Parameters:
      columns - the number of columns for laying out the input controls
      Returns:
      this
    • string

      default B string(String id, String label, Supplier<String> dflt)
      Add labeled string input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      Returns:
      this
    • string

      B string(String id, String label, Supplier<String> dflt, Function<String,Optional<String>> validate)
      Add labeled string input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      validate - validation callback, return error message if invalid, empty optional if valid
      Returns:
      this
    • integer

      default B integer(String id, String label, Supplier<Integer> dflt)
      Add labeled integer input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      Returns:
      this
    • integer

      B integer(String id, String label, Supplier<Integer> dflt, Function<Integer,Optional<String>> validate)
      Add labeled integer input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      validate - validation callback, return error message if invalid, empty optional if valid
      Returns:
      this
    • decimal

      default B decimal(String id, String label, Supplier<Double> dflt)
      Add labeled decimal input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      Returns:
      this
    • decimal

      B decimal(String id, String label, Supplier<Double> dflt, Function<Double,Optional<String>> validate)
      Add labeled decimal input.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      validate - validation callback, return error message if invalid, empty optional if valid
      Returns:
      this
    • checkBox

      default B checkBox(String id, String label, Supplier<Boolean> dflt, String text)
      Add labeled checkbox.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      text - the checkbox text
      Returns:
      this
    • checkBox

      B checkBox(String id, String label, Supplier<Boolean> dflt, String text, Function<Boolean,Optional<String>> validate)
      Creates a checkbox with the given parameters.
      Parameters:
      id - the ID of the checkbox
      label - the label for the checkbox
      dflt - the default value of the checkbox
      text - the text to display next to the checkbox
      validate - a function that takes a Boolean value and returns an optional validation message
      Returns:
      the created checkbox
    • comboBox

      default <T> B comboBox(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items)
      Add labeled combobox.
      Type Parameters:
      T - the item type
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      cls - the result class
      items - the items to choose from
      Returns:
      this
    • comboBox

      <T> B comboBox(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items, Function<T,Optional<String>> validate)
      Creates a comboBox widget with the given parameters.
      Type Parameters:
      T - the type of the comboBox items
      Parameters:
      id - the unique identifier for the comboBox
      label - the label to display with the comboBox
      dflt - the supplier function to provide the default value for the comboBox
      cls - the class type of the comboBox items
      items - the collection of items to populate the comboBox
      validate - the function to validate the selected item in the comboBox
      Returns:
      the comboBox widget
    • comboBoxEx

      default <T> B comboBoxEx(String id, String label, @Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>,T> remove, Function<T,String> format, Supplier<T> dflt, Class<T> cls, Collection<T> items)
      Adds a labeled combo box control with extended functionality.
      Type Parameters:
      T - the item type
      Parameters:
      id - the control's ID
      label - the label text
      edit - the action to be performed when an item is edited (optional)
      add - the action to be performed when a new item is added (optional)
      remove - the action to be performed when an item is removed (optional)
      format - the function to format the items in the combo box
      dflt - the supplier of the default value
      cls - the result class of the combo box items
      items - the collection of items to choose from
      Returns:
      the InputBuilder instance
    • comboBoxEx

      <T> B comboBoxEx(String id, String label, @Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>,T> remove, Function<T,String> format, Supplier<T> dflt, Class<T> cls, Collection<T> items, Function<T,Optional<String>> validate)
      Returns a custom combo box with the specified parameters.
      Type Parameters:
      T - the type of objects in the combo box
      Parameters:
      id - the ID of the combo box
      label - the label of the combo box
      edit - a function to modify the selected item in the combo box, or null if editing is not allowed
      add - a supplier to add a new item to the combo box, or null if adding is not allowed
      remove - a predicate to remove an item from the combo box, or null if removing is not allowed
      format - a function to format the items of the combo box as strings
      dflt - a supplier to provide a default item for the combo box
      cls - the class of objects in the combo box
      items - the collection of items to populate the combo box
      validate - a function to validate the items in the combo box and return an optional error message
      Returns:
      a custom combo box with the specified parameters
    • radioList

      default <T> B radioList(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items)
      Add labeled list of radiobuttons.
      Type Parameters:
      T - the item type
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      cls - the result class
      items - the items to choose from
      Returns:
      this
    • radioList

      <T> B radioList(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items, Function<T,Optional<String>> validate)
      Creates a radio list component.
      Type Parameters:
      T - the type of items in the radio list
      Parameters:
      id - the ID of the radio list
      label - the label text for the radio list
      dflt - a supplier that provides the default value for the radio list
      cls - the class of the items in the radio list
      items - a collection of items for the radio list
      validate - a function to validate the selected item, returning an optional error message
      Returns:
      a radio list component
    • options

      B options(String id, String label, Supplier<com.dua3.utility.options.Arguments> dflt, Supplier<Collection<com.dua3.utility.options.Option<?>>> options)
      Add labeled pane with options.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default values
      options - supplier of options
      Returns:
      this
    • options

      B options(String id, Supplier<com.dua3.utility.options.Arguments> dflt, Supplier<Collection<com.dua3.utility.options.Option<?>>> options)
      Add unlabeled pane with options.

      Note to implementers: Labels of the options should be aligned properly with labels of the input dialog.

      Parameters:
      id - the ID
      dflt - supplier of default values
      options - supplier of options
      Returns:
      this
    • chooseFile

      default B chooseFile(String id, String label, Supplier<Path> dflt, FileDialogMode mode, boolean existingOnly, Collection<FileChooser.ExtensionFilter> filter)
      Add File chooser.
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default value
      mode - the mode, either FileDialogMode.OPEN or FileDialogMode.SAVE
      existingOnly - only let the user choose existing files; i.e., no new files can be created
      filter - the extension filter to use
      Returns:
      this
    • chooseFile

      B chooseFile(String id, String label, Supplier<Path> dflt, FileDialogMode mode, boolean existingOnly, Collection<FileChooser.ExtensionFilter> filter, Function<Path,Optional<String>> validate)
      Opens a file chooser dialog to allow the user to select a file.
      Parameters:
      id - The identifier for the file chooser dialog.
      label - The label to display in the file chooser dialog.
      dflt - A function that provides the default path to preselect in the file chooser dialog.
      mode - The mode of the file dialog, such as OPEN or SAVE.
      existingOnly - Whether to only allow selection of existing files.
      filter - The file filters to apply in the file chooser dialog.
      validate - A function to perform additional validation on the selected file path. It returns an optional error message if the validation fails.
      Returns:
      The selected file path wrapped in an instance of B.