Class AbstractMenuToolCompositeComponentPrototypeProvisionStrategy

All Implemented Interfaces:
Serializable, ReadWriteLock
Direct Known Subclasses:
DefaultMenuToolPrototypeProvisionStrategy, FrameMenuToolPrototypeProvisionStrategy

public abstract class AbstractMenuToolCompositeComponentPrototypeProvisionStrategy extends AbstractCompositeComponentPrototypeProvisionStrategy
Abstract strategy for keeping track of prototype providers and working with provisioned prototypes, merging them into a menu and/or a toolbar of a frame. When the prototype providers change provided prototypes, those provided prototypes are processed. This version monitors the parent composite component children and automatically uses top-level prototype providers added to or removed from the hierarchy. Prototype provisions are not processed initially; this strategy should be initialized after construction by calling AbstractPrototypeProvisionStrategy.processPrototypeProvisions(). This class is thread safe based upon its exposed read and write locks.
Author:
Garret Wilson
See Also:
  • Constructor Details

    • AbstractMenuToolCompositeComponentPrototypeProvisionStrategy

      public AbstractMenuToolCompositeComponentPrototypeProvisionStrategy(CompositeComponent parentComponent, PrototypeProvider... defaultPrototypeProviders)
      Parent component and prototype providers constructor.
      Parameters:
      parentComponent - The composite component the top-level prototype provider children of which will be monitored.
      defaultPrototypeProviders - The default prototype providers that will provide prototypes for processing, outside the children of the composite component parent.
      Throws:
      NullPointerException - if the given parent component, prototype providers, and/or one or more prototype provider is null.
  • Method Details

    • getMenu

      protected abstract Menu getMenu()
      Returns:
      The menu being managed, or null if no menu is being managed.
    • getToolbar

      protected abstract Toolbar getToolbar()
      Returns:
      The toolbar being managed, or null if no toolbar is being managed.
    • getLastComponents

      public Set<Component> getLastComponents()
      Returns:
      The weak set of static components in the menu or the toolbar that should be displayed last; all components based upon prototypes will be inserted before the components.
    • processPrototypeProvisions

      protected void processPrototypeProvisions(Set<PrototypeProvision<?>> prototypeProvisions)
      Processes prototype provisions.

      This implementation merges prototype provisions into the given menu and/or toolbar, if any.

      Specified by:
      processPrototypeProvisions in class AbstractPrototypeProvisionStrategy
      Parameters:
      prototypeProvisions - The mutable set of prototype provisions to be used.
      See Also:
    • synchronizePrototypeProvisionMap

      protected static void synchronizePrototypeProvisionMap(com.globalmentor.collections.ReverseMap<PrototypeProvision<?>,Component> prototypeProvisionComponentMap, CompositeComponent parentComponent, Set<PrototypeProvision<?>> prototypeProvisionSet)
      Synchronizes the map of prototype provision component associations. For each prototype provision association, the association is removed if the associated component no longer exists in the component tree, or if the associated prototype provision is not given; if the latter, the associated component is removed from its parent.
      Parameters:
      prototypeProvisionComponentMap - The map from which to remove values.
      parentComponent - The parent of the component tree in which published prototypes are represented.
      prototypeProvisionSet - The set to indicate which key entries to retain.
      Throws:
      NullPointerException - if the given map, parent component, or prototype provision set is null.
    • add

      protected Component add(Container container, PrototypeProvision<?> prototypeProvision)
      Adds a prototype to a container in the correct order by examining the prototype information of the other components added to the container The prototype is inserted before the first component that was created from prototype info with a larger order. The prototype will be inserted before any component present in the set returned by getLastComponents().
      Parameters:
      container - The container to which the prototype should be added.
      prototypeProvision - The prototype information to add.
      Returns:
      The component that was created to represent the prototype.
      See Also: