Class SelectObjectsFromTableToolItemProperties<V,X>

java.lang.Object
com.amalgamasimulation.desktop.ui.editor.sections.descriptors.toolitems.ToolItemProperties<SelectObjectsFromTableToolItemProperties<V,X>>
com.amalgamasimulation.desktop.ui.editor.sections.descriptors.toolitems.SelectObjectsFromTableToolItemProperties<V,X>
Type Parameters:
V - the type of elements managed by the table
X - the type of objects that can be selected in the dialog

public class SelectObjectsFromTableToolItemProperties<V,X> extends ToolItemProperties<SelectObjectsFromTableToolItemProperties<V,X>>
A builder class for configuring properties of a select objects from table tool item in table toolbars. The tool item opens a dialog with a table of objects whose type can differ from the type of the table rows, and passes the checked objects to the handler.
Author:
Ionov Ivan
  • Method Details

    • newInstance

      public static <V, X> SelectObjectsFromTableToolItemProperties<V,X> newInstance()
      Creates a new SelectObjectsFromTableToolItemProperties instance.
      Type Parameters:
      V - the type of elements in the table
      X - the type of objects to select
      Returns:
      a new SelectObjectsFromTableToolItemProperties instance
    • getAllObjects

      public Supplier<List<? extends X>> getAllObjects()
      Returns the supplier of all objects available for selection.
      Returns:
      a Supplier providing a List of all selectable objects
    • allObjects

      public SelectObjectsFromTableToolItemProperties<V,X> allObjects(List<? extends X> allObjects)
      Sets a static list of all objects available for selection.
      Parameters:
      allObjects - a List of all selectable objects
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining
    • allObjects

      public SelectObjectsFromTableToolItemProperties<V,X> allObjects(Supplier<List<? extends X>> allObjects)
      Sets a dynamic supplier of all objects available for selection.
      Parameters:
      allObjects - a Supplier providing a List of all selectable objects
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining
    • getColumnsForDialog

      public Consumer<Table<X>> getColumnsForDialog()
      Returns the column configuration consumer for the selection dialog table.
      Returns:
      a Consumer that configures columns for the selection dialog table
    • columns

      public SelectObjectsFromTableToolItemProperties<V,X> columns(Consumer<Table<X>> columnsForDialog)
      Sets the column configuration for the selection dialog table.
      Parameters:
      columnsForDialog - a Consumer that configures columns for the selection dialog table
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining
    • getTitleDialog

      public String getTitleDialog()
      Returns the title for the selection dialog.
      Returns:
      the dialog title, or null if not set
    • title

      public SelectObjectsFromTableToolItemProperties<V,X> title(String titleDialog)
      Sets the title for the selection dialog.
      Parameters:
      titleDialog - the title to display in the selection dialog
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining
    • getSelectedObjects

      public Function<List<V>,List<? extends X>> getSelectedObjects()
      Returns the function that gives the objects checked when the dialog opens.
      Returns:
      a Function from the current table rows to the checked objects
    • selectedObjects

      public SelectObjectsFromTableToolItemProperties<V,X> selectedObjects(Function<List<V>,List<? extends X>> selectedObjects)
      Sets which objects are checked when the dialog opens. The function receives the current table rows. By default nothing is checked.
      Parameters:
      selectedObjects - a Function from the current table rows to the checked objects
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining
    • getHandler

      public BiConsumer<Table<V>,List<X>> getHandler()
      Returns the handler that receives the objects checked in the dialog.
      Returns:
      a BiConsumer that receives the table and the checked objects
    • handler

      Sets the handler that receives the objects checked in the dialog. It is called only when the dialog is closed with OK, and the table is refreshed afterwards. In EMF tables, make changes through the CommandsManager command stack so they can be undone.
      Parameters:
      handler - a BiConsumer that receives the table and the checked objects
      Returns:
      this SelectObjectsFromTableToolItemProperties instance for method chaining