Class AbstractBooleanSelectActionControl

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.MutableValued<Boolean>, com.globalmentor.model.Valued<Boolean>, ActionControl, ActionValueControl<Boolean>, Component, Control, InputFocusableComponent, LabelDisplayableComponent, SelectActionControl, ValueControl<Boolean>, ValuedComponent<Boolean>, ActionListenable, ActionModel, Displayable, Enableable, InfoModel, LabelModel, Model, Selectable, PresentationModel, ValueModel<Boolean>, DepictedObject
Direct Known Subclasses:
BooleanSelectButton, BooleanSelectLink, BooleanSelectToolButton, ImageBooleanSelectActionControl

public abstract class AbstractBooleanSelectActionControl extends AbstractActionValueControl<Boolean> implements SelectActionControl
Selectable action control that stores a Boolean value in its model representing the selected state. The selected property and the Boolean value will be kept synchronized. When the value and/or changes, separate property change events for both ValueModel.VALUE_PROPERTY and for Selectable.SELECTED_PROPERTY will be fired. A validator requiring a non-null value is automatically installed.

The selected and unselected icons are set by default to Theme.GLYPH_SELECTED and Theme.GLYPH_UNSELECTED, respectively.

Author:
Garret Wilson
  • Constructor Details

    • AbstractBooleanSelectActionControl

      public AbstractBooleanSelectActionControl(InfoModel infoModel, ActionModel actionModel, ValueModel<Boolean> valueModel, Enableable enableable)
      Info model, action model, value model, and enableable object constructor.
      Parameters:
      infoModel - The component info model.
      actionModel - The component action model.
      valueModel - The component value model.
      enableable - The enableable object in which to store enabled status.
      Throws:
      NullPointerException - if the given info model, action model, and/or enableable object is null.
  • Method Details

    • isAutoSelect

      public boolean isAutoSelect()
      Specified by:
      isAutoSelect in interface SelectActionControl
      Returns:
      Whether this control automatically sets or toggles the selection state when the action occurs.
    • setAutoSelect

      public void setAutoSelect(boolean newAutoSelect)
      Description copied from interface: SelectActionControl
      Sets whether this control automatically sets or toggles the selection state when the action occurs. This is a bound property of type Boolean.
      Specified by:
      setAutoSelect in interface SelectActionControl
      Parameters:
      newAutoSelect - true if the control should automatically set or toggle the selection state when an action occurs.
      See Also:
    • isSelected

      public boolean isSelected()

      This implementation returns the value of the value model.

      Specified by:
      isSelected in interface Selectable
      Returns:
      Whether the object is selected.
    • setSelected

      public void setSelected(boolean newSelected)
      Sets whether the object is selected. This is a bound property of type Boolean.

      This implementation delegates to he value model.

      Specified by:
      setSelected in interface Selectable
      Parameters:
      newSelected - true if the object should be selected, else false.
      See Also:
    • getSelectedGlyphURI

      public URI getSelectedGlyphURI()
      Specified by:
      getSelectedGlyphURI in interface SelectActionControl
      Returns:
      The selected icon URI, which may be a resource URI, or null if there is no selected icon URI.
    • setSelectedGlyphURI

      public void setSelectedGlyphURI(URI newSelectedIcon)
      Description copied from interface: SelectActionControl
      Sets the URI of the selected icon. This is a bound property of type URI.
      Specified by:
      setSelectedGlyphURI in interface SelectActionControl
      Parameters:
      newSelectedIcon - The new URI of the selected icon, which may be a resource URI.
      See Also:
    • isToggle

      public boolean isToggle()
      Specified by:
      isToggle in interface SelectActionControl
      Returns:
      Whether this control acts as a toggle, switching its value between true and false, or whether the action always sets the value to true.
    • setToggle

      public void setToggle(boolean newToggle)
      Description copied from interface: SelectActionControl
      Sets whether this control acts as a toggle, switching its value between true and false, or whether the action always sets the value to true. This is a bound property of type Boolean.
      Specified by:
      setToggle in interface SelectActionControl
      Parameters:
      newToggle - true if the component should act as a toggle, else false if the action should unconditionally set the value to true.
      See Also:
    • getUnselectedGlyphURI

      public URI getUnselectedGlyphURI()
      Specified by:
      getUnselectedGlyphURI in interface SelectActionControl
      Returns:
      The unselected icon URI, which may be a resource URI, or null if there is no unselected icon URI.
    • setUnselectedGlyphURI

      public void setUnselectedGlyphURI(URI newUnselectedIcon)
      Description copied from interface: SelectActionControl
      Sets the URI of the unselected icon. This is a bound property of type URI.
      Specified by:
      setUnselectedGlyphURI in interface SelectActionControl
      Parameters:
      newUnselectedIcon - The new URI of the unselected icon, which may be a resource URI.
      See Also: