Package io.guise.framework.prototype
Class AbstractMenuToolCompositeComponentPrototypeProvisionStrategy
- java.lang.Object
-
- java.util.concurrent.locks.ReentrantReadWriteLock
-
- io.guise.framework.prototype.AbstractPrototypeProvisionStrategy
-
- io.guise.framework.prototype.AbstractCompositeComponentPrototypeProvisionStrategy
-
- io.guise.framework.prototype.AbstractMenuToolCompositeComponentPrototypeProvisionStrategy
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.concurrent.locks.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 callingAbstractPrototypeProvisionStrategy.processPrototypeProvisions()
. This class is thread safe based upon its exposed read and write locks.- Author:
- Garret Wilson
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractMenuToolCompositeComponentPrototypeProvisionStrategy(CompositeComponent parentComponent, PrototypeProvider... defaultPrototypeProviders)
Parent component and prototype providers constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.java.util.Set<Component>
getLastComponents()
protected abstract Menu
getMenu()
protected abstract Toolbar
getToolbar()
protected void
processPrototypeProvisions(java.util.Set<PrototypeProvision<?>> prototypeProvisions)
Processes prototype provisions.protected static void
synchronizePrototypeProvisionMap(com.globalmentor.collections.ReverseMap<PrototypeProvision<?>,Component> prototypeProvisionComponentMap, CompositeComponent parentComponent, java.util.Set<PrototypeProvision<?>> prototypeProvisionSet)
Synchronizes the map of prototype provision component associations.-
Methods inherited from class io.guise.framework.prototype.AbstractCompositeComponentPrototypeProvisionStrategy
getParentComponent
-
Methods inherited from class io.guise.framework.prototype.AbstractPrototypeProvisionStrategy
addPrototypeProvider, gatherPrototypeProvisions, getPrototypeProviders, processPrototypeProvisions, removePrototypeProvider
-
Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock
getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, readLock, toString, writeLock
-
-
-
-
Constructor Detail
-
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:
java.lang.NullPointerException
- if the given parent component, prototype providers, and/or one or more prototype provider isnull
.
-
-
Method Detail
-
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 java.util.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(java.util.Set<PrototypeProvision<?>> prototypeProvisions)
Processes prototype provisions.This implementation merges prototype provisions into the given menu and/or toolbar, if any.
- Specified by:
processPrototypeProvisions
in classAbstractPrototypeProvisionStrategy
- Parameters:
prototypeProvisions
- The mutable set of prototype provisions to be used.- See Also:
getMenu()
,getToolbar()
-
synchronizePrototypeProvisionMap
protected static void synchronizePrototypeProvisionMap(com.globalmentor.collections.ReverseMap<PrototypeProvision<?>,Component> prototypeProvisionComponentMap, CompositeComponent parentComponent, java.util.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:
java.lang.NullPointerException
- if the given map, parent component, or prototype provision set isnull
.
-
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 bygetLastComponents()
.- 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:
PrototypeProvision.getOrder()
,getLastComponents()
-
-