Class AbstractCompositeStateComponent<T,S extends AbstractCompositeStateComponent.ComponentState>

Type Parameters:
T - The type of object being represented.
S - The component state of each object.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, io.clogr.Clogged, Component, CompositeComponent, Displayable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject
Direct Known Subclasses:
AbstractCompositeStateControl

public abstract class AbstractCompositeStateComponent<T,S extends AbstractCompositeStateComponent.ComponentState> extends AbstractMultipleCompositeComponent
A composite component that represents the state of its child components.
Author:
Garret Wilson
  • Constructor Details

    • AbstractCompositeStateComponent

      public AbstractCompositeStateComponent(InfoModel infoModel)
      Info model constructor.
      Parameters:
      infoModel - The component info model.
      Throws:
      NullPointerException - if the given info model is null.
  • Method Details

    • getComponentStates

      protected Iterable<S> getComponentStates()
      Returns:
      An iterable of component states.
    • getComponentState

      protected S getComponentState(T object)
      Retrieves a component state for the given object.
      Parameters:
      object - The object for which a representation component should be returned.
      Returns:
      The state of the child component to represent the given object, or null if there is no component for the given object.
    • determineComponentState

      protected S determineComponentState(T object)
      Retrieves a component state for the given object. If no component yet exists for the given object, one will be created.
      Parameters:
      object - The object for which a representation component should be returned.
      Returns:
      The state of the child component to represent the given object.
      Throws:
      IllegalArgumentException - if the given object is not an appropriate object for a component state to be created.
      See Also:
    • putComponentState

      protected S putComponentState(T object, S componentState)
      Stores a child component state for the given object. The component's theme will be updated immediately, as the component state is likely to be generated dynamically during component view update.
      Parameters:
      object - The object with which the component state is associated.
      componentState - The child component state to represent the given object, or null if there is no component for the given object.
      Returns:
      The child component that previously represented the given tree node, or null if there was previously no component for the given object.
      See Also:
    • removeComponentState

      protected AbstractCompositeStateComponent.ComponentState removeComponentState(T object)
      Removes the child component state for the given object.
      Parameters:
      object - The object with which the representation component is associated.
      Returns:
      The child component state that previously represented the given object, or null if there was previously no component for the given object.
    • clearComponentStates

      protected void clearComponentStates()
      Removes all child component states.
    • getComponent

      protected Component getComponent(T object)
      Retrieves the component for the given object. If no component yet exists for the given object, one will be created.
      Parameters:
      object - The object for which a representation component should be returned.
      Returns:
      The child component representing the given object.
      Throws:
      IllegalArgumentException - if the given object is not an appropriate object for a component to be created.
    • getObject

      protected T getObject(Component component)
      Retrieves the object for the given component.
      Parameters:
      component - The child component representing an object.
      Returns:
      The object the child component represents.
      Throws:
      NullPointerException - if the given component is null.
      IllegalArgumentException - if the given component does not represent any object.
    • createComponentState

      protected abstract S createComponentState(T object)
      Creates a component state to represent the given object.
      Parameters:
      object - The object with which the component state is to be associated.
      Returns:
      The component state to represent the given object.
      Throws:
      IllegalArgumentException - if the given object is not an appropriate object for a component state to be created.