Class ListSubsetProperty<T>

java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.properties.ListSubsetProperty<T>

public class ListSubsetProperty<T> extends AbstractProperty
Represents an AbstractProperty wrapper around the ListSubset form field.

Note: to avoid persisting the list of T items, this class simply persists the indexes of which item(s) are selected, relative to the list of all items that is supplied at construction time or via setAllItems(). Callers can still easily determine which item(s) are selected via the getSelectedItems() method, which returns a List<T> of the currently selected items.

Since:
swing-extras 2.6
Author:
scorbo2
  • Constructor Details

    • ListSubsetProperty

      public ListSubsetProperty(String fullyQualifiedName, String label)
    • ListSubsetProperty

      public ListSubsetProperty(String fullyQualifiedName, String label, List<T> allItems)
    • ListSubsetProperty

      public ListSubsetProperty(String fullyQualifiedName, String label, List<T> allItems, int[] selectedIndexes)
  • Method Details

    • getVisibleRowCount

      public int getVisibleRowCount()
    • setVisibleRowCount

      public ListSubsetProperty<T> setVisibleRowCount(int visibleRowCount)
    • getFixedCellWidth

      public int getFixedCellWidth()
    • setFixedCellWidth

      public ListSubsetProperty<T> setFixedCellWidth(int fixedCellWidth)
    • getAllItems

      public List<T> getAllItems()
    • setAllItems

      public ListSubsetProperty<T> setAllItems(List<T> allItems)
    • getSelectedItems

      public List<T> getSelectedItems()
    • setSelectedIndexes

      public ListSubsetProperty<T> setSelectedIndexes(int[] selectedIndexes)
    • saveToProps

      public void saveToProps(Properties props)
      Description copied from class: AbstractProperty
      Saves the current value(s) of this property to the given Properties instance.
      Specified by:
      saveToProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which will receive the value(s) of this property.
    • loadFromProps

      public void loadFromProps(Properties props)
      Description copied from class: AbstractProperty
      Loads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.
      Specified by:
      loadFromProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which contains value(s) for this property.
    • generateFormFieldImpl

      protected FormField generateFormFieldImpl()
      Description copied from class: AbstractProperty
      Descendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.
      Specified by:
      generateFormFieldImpl in class AbstractProperty
      Returns:
      A FormField associated with this property.
    • loadFromFormField

      public void loadFromFormField(FormField field)
      Description copied from class: AbstractProperty
      Populates this Property's value(s) from the given form field, assuming the field is of the correct type.
      Specified by:
      loadFromFormField in class AbstractProperty
      Parameters:
      field - The FormField containing a value for this property.