Class AbstractOption

All Implemented Interfaces:
Serializable, Option, OptionElement, OptionProperties
Direct Known Subclasses:
AbstractTreeTableOption, BooleanOption, ButtonOption, CodeEditorOption, ComboBoxOption, FileChooserOption, FillerOption, FormattedNumberOption, GraphOption, JavaOption, LabelOption, ListOption, PickListOption, PluggableViewOption, RadioButtonOption, SpinnerNumberOption, TextAreaOption, TextOption, ToolbarSeparatorOption

public abstract class AbstractOption extends AbstractOptionElement implements Option
Default abstract implementation of the Option interface.
Author:
Laurent Cohen
See Also:
  • Field Details

    • value

      protected Object value
      The value of this option.
    • listeners

      protected List<ValueChangeListener> listeners
      List of listeners that are notified when the value of this option changes.
    • persistent

      protected boolean persistent
      Determines whether the value of this option should be saved in the user preferences.
  • Constructor Details

    • AbstractOption

      public AbstractOption()
      Constructor provided as a convenience to facilitate the creation of option elements through reflexion.
  • Method Details

    • getValue

      public Object getValue()
      The value of this option.
      Specified by:
      getValue in interface Option
      Returns:
      the value as an Object instance.
    • setValue

      public void setValue(Object value)
      Set the value of this option.
      Parameters:
      value - the value as an Object instance.
    • addValueChangeListener

      public void addValueChangeListener(ValueChangeListener listener)
      Add a value change listener to this option's list of listeners.
      Parameters:
      listener - the listener to add to the list.
    • removeValueChangeListener

      public void removeValueChangeListener(ValueChangeListener listener)
      Remove a value change listener from this option's list of listeners.
      Parameters:
      listener - the listener to remove from the list.
    • fireValueChanged

      public void fireValueChanged()
      Notify all registered listeners that the value of this option has changed.
    • setupValueChangeNotifications

      protected abstract void setupValueChangeNotifications()
      Concrete subclasses should implement this method to properly forward changes in the value edited by the underlying UI component/editor.
    • layoutComponents

      protected JPanel layoutComponents(JComponent comp1, JComponent comp2)
      Layout 2 components according to the specified layout constraints.
      Parameters:
      comp1 - the first component to layout.
      comp2 - the second component to layout.
      Returns:
      a JPanel instance, enclosing the 2 components plus the filler.
    • layoutComponents

      protected JPanel layoutComponents(JComponent comp1, String constraint1, JComponent comp2, String constraint2)
      Layout 2 components according to the specified layout constraints.
      Parameters:
      comp1 - the first component to layout.
      constraint1 - the layout constraint for the 1st component.
      comp2 - the second component to layout.
      constraint2 - the layout constraint for the 2nd component.
      Returns:
      a JPanel instance, enclosing the 2 components plus the filler.
    • isPersistent

      public boolean isPersistent()
      Determine whether the value of this option should be saved in the user preferences.
      Specified by:
      isPersistent in interface Option
      Returns:
      true if the value should be saved, false otherwise.
    • setPersistent

      public void setPersistent(boolean persistent)
      Set whether the value of this option should be saved in the user preferences.
      Parameters:
      persistent - true if the value should be saved, false otherwise.
    • toString

      public String toString()
      Description copied from class: AbstractOptionElement
      Get a string representation of this element.
      Overrides:
      toString in class AbstractOptionElement
      Returns:
      a string providing information about this option element.
      See Also: