java.lang.Object
com.inductiveautomation.ignition.designer.mvvm.binders.swing.util.AddRemoveItemSupport<T>
All Implemented Interfaces:
Disposable

public class AddRemoveItemSupport<T> extends Object implements Disposable
Algorithm for adding and removing items from lists and tables. Bind the add() and removeSelected() methods to click properties of the Add and Click buttons.
  • Constructor Details

    • AddRemoveItemSupport

      public AddRemoveItemSupport(PropertyPublisher<List<T>> data, PropertyPublisher<T> selection, Supplier<T> creator)
      Variant with the default minimumItemCount set at 0, that is all items can be removed from a list.
    • AddRemoveItemSupport

      public AddRemoveItemSupport(PropertyPublisher<List<T>> data, PropertyPublisher<T> selection, Supplier<T> creator, int minimumItemCount)
      Upon initialization, removeEnabled state will be evaluated.
      Parameters:
      data - List to which items will be added or removed.
      selection - The item selected for removal, or null (if there are no selection).
      creator - When add() is called, this method will supply new items for adding to the list.
      minimumItemCount - Threshold for which remove will not be enabled.
  • Method Details

    • reinitialize

      public void reinitialize()
    • add

      public void add()
    • removeSelected

      public T removeSelected()
      If an item was successfully removed, this will return the now current selected item.
      Returns:
      The item that's currently selected after the remove, or null, if the remove results in no new selection.
    • removeEnabled

      public PropertyPublisherReadOnly<Boolean> removeEnabled()
    • createBindingSource

      public AddRemoveItemSupport.BindingSource createBindingSource()
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable