Class CreateElementToolItemProperties<V>

java.lang.Object
com.amalgamasimulation.desktop.ui.editor.sections.descriptors.toolitems.ToolItemProperties<CreateElementToolItemProperties<V>>
com.amalgamasimulation.desktop.ui.editor.sections.descriptors.toolitems.CreateElementToolItemProperties<V>
Type Parameters:
V - the type of elements that can be created

public class CreateElementToolItemProperties<V> extends ToolItemProperties<CreateElementToolItemProperties<V>>
A builder class for configuring properties of a create element tool item in table toolbars. Provides methods to set create actions, icons, text, and tooltips for adding new elements to tables. This class is designed to be used by end users to configure create functionality in table toolbars within their applications.
Author:
Ionov Ivan
  • Constructor Details

    • CreateElementToolItemProperties

      public CreateElementToolItemProperties()
      Constructs a new CreateElementToolItemProperties instance with default values. Sets default add icon, text, and tooltip from platform resources.
  • Method Details

    • isExistAddElementToolItem

      public boolean isExistAddElementToolItem()
      Checks if a create element action is configured for this tool item.
      Returns:
      true if either a default or custom create action is configured, false otherwise
    • getDefaultCreateElementAction

      public Supplier<V> getDefaultCreateElementAction()
      Returns the default create element action supplier.
      Returns:
      a Supplier that creates a new element of type V
    • defaultCreateElementAction

      public CreateElementToolItemProperties<V> defaultCreateElementAction(Supplier<V> defaultCreateElementAction)
      Sets a default create element action using a Supplier. This method is mutually exclusive with customCreateElementAction().
      Parameters:
      defaultCreateElementAction - a Supplier that creates a new element of type V
      Returns:
      this CreateElementToolItemProperties instance for method chaining
      Throws:
      IllegalStateException - if a custom create action is already configured
    • getCustomCreateElementAction

      public Function<Table<V>,V> getCustomCreateElementAction()
      Returns the custom create element action function.
      Returns:
      a Function that creates a new element of type V with table context
    • customCreateElementAction

      public CreateElementToolItemProperties<V> customCreateElementAction(Function<Table<V>,V> customCreateElementAction)
      Sets a custom create element action using a Function that includes table context. This method is mutually exclusive with defaultCreateElementAction().
      Parameters:
      customCreateElementAction - a Function that creates a new element with table context
      Returns:
      this CreateElementToolItemProperties instance for method chaining
      Throws:
      IllegalStateException - if a default create action is already configured