Class InputGridBuilder

java.lang.Object
com.dua3.utility.fx.controls.InputGridBuilder
All Implemented Interfaces:
InputBuilder<InputGridBuilder>

public class InputGridBuilder extends Object implements InputBuilder<InputGridBuilder>
Builder for Alert Dialogs.

Provides a fluent interface to create Alerts.

  • Method Details

    • build

      public InputGrid build()
      Builds and returns an InputGrid with the current data and column configuration.
      Returns:
      the constructed InputGrid
    • add

      public <T> InputGridBuilder add(String id, String label, Class<T> type, Supplier<T> dflt, InputControl<T> control)
      Description copied from interface: InputBuilder
      Add labeled input control.
      Specified by:
      add in interface InputBuilder<InputGridBuilder>
      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

      public <T> InputGridBuilder add(String id, Class<T> type, Supplier<T> dflt, InputControl<T> control)
      Description copied from interface: InputBuilder
      Add unlabeled input control.
      Specified by:
      add in interface InputBuilder<InputGridBuilder>
      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

      public InputGridBuilder addNode(String id, @Nullable String label, Node node)
      Description copied from interface: InputBuilder
      Add labeled input control.
      Specified by:
      addNode in interface InputBuilder<InputGridBuilder>
      Parameters:
      id - the node's ID
      label - the label text
      node - the node
      Returns:
      this
    • addNode

      public InputGridBuilder addNode(String id, Node node)
      Description copied from interface: InputBuilder
      Add unlabeled input control.
      Specified by:
      addNode in interface InputBuilder<InputGridBuilder>
      Parameters:
      id - the node's ID
      node - the node
      Returns:
      this
    • columns

      public InputGridBuilder columns(int columns)
      Description copied from interface: InputBuilder
      Set number of columns for layout (default is 1).
      Specified by:
      columns in interface InputBuilder<InputGridBuilder>
      Parameters:
      columns - the number of columns for laying out the input controls
      Returns:
      this
    • string

      public InputGridBuilder string(String id, String label, Supplier<String> dflt, Function<String,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Add labeled string input.
      Specified by:
      string in interface InputBuilder<InputGridBuilder>
      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

      public InputGridBuilder integer(String id, String label, Supplier<Integer> dflt, Function<Integer,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Add labeled integer input.
      Specified by:
      integer in interface InputBuilder<InputGridBuilder>
      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

      public InputGridBuilder decimal(String id, String label, Supplier<Double> dflt, Function<Double,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Add labeled decimal input.
      Specified by:
      decimal in interface InputBuilder<InputGridBuilder>
      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

      public InputGridBuilder checkBox(String id, String label, Supplier<Boolean> dflt, String text, Function<Boolean,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Creates a checkbox with the given parameters.
      Specified by:
      checkBox in interface InputBuilder<InputGridBuilder>
      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

      public <T> InputGridBuilder comboBox(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items, Function<T,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Creates a comboBox widget with the given parameters.
      Specified by:
      comboBox in interface InputBuilder<InputGridBuilder>
      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

      public <T> InputGridBuilder 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)
      Description copied from interface: InputBuilder
      Returns a custom combo box with the specified parameters.
      Specified by:
      comboBoxEx in interface InputBuilder<InputGridBuilder>
      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

      public <T> InputGridBuilder radioList(String id, String label, Supplier<T> dflt, Class<T> cls, Collection<T> items, Function<T,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Creates a radio list component.
      Specified by:
      radioList in interface InputBuilder<InputGridBuilder>
      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

      public InputGridBuilder options(String id, String label, Supplier<com.dua3.utility.options.Arguments> dflt, Supplier<Collection<com.dua3.utility.options.Option<?>>> options)
      Description copied from interface: InputBuilder
      Add labeled pane with options.
      Specified by:
      options in interface InputBuilder<InputGridBuilder>
      Parameters:
      id - the ID
      label - the label text
      dflt - supplier of default values
      options - supplier of options
      Returns:
      this
    • options

      public InputGridBuilder options(String id, Supplier<com.dua3.utility.options.Arguments> dflt, Supplier<Collection<com.dua3.utility.options.Option<?>>> options)
      Description copied from interface: InputBuilder
      Add unlabeled pane with options.

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

      Specified by:
      options in interface InputBuilder<InputGridBuilder>
      Parameters:
      id - the ID
      dflt - supplier of default values
      options - supplier of options
      Returns:
      this
    • chooseFile

      public InputGridBuilder chooseFile(String id, String label, Supplier<Path> dflt, FileDialogMode mode, boolean existingOnly, Collection<FileChooser.ExtensionFilter> filter, Function<Path,Optional<String>> validate)
      Description copied from interface: InputBuilder
      Opens a file chooser dialog to allow the user to select a file.
      Specified by:
      chooseFile in interface InputBuilder<InputGridBuilder>
      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.