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:
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.locks.ReentrantReadWriteLock
ReentrantReadWriteLock.ReadLock, ReentrantReadWriteLock.WriteLock
-
Constructor Summary
ConstructorDescriptionAbstractMenuToolCompositeComponentPrototypeProvisionStrategy
(CompositeComponent parentComponent, PrototypeProvider... defaultPrototypeProviders) Parent component and prototype providers constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.protected abstract Menu
getMenu()
protected abstract Toolbar
protected void
processPrototypeProvisions
(Set<PrototypeProvision<?>> prototypeProvisions) Processes prototype provisions.protected static void
synchronizePrototypeProvisionMap
(com.globalmentor.collections.ReverseMap<PrototypeProvision<?>, Component> prototypeProvisionComponentMap, CompositeComponent parentComponent, 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 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 isnull
.
-
-
Method Details
-
getMenu
- Returns:
- The menu being managed, or
null
if no menu is being managed.
-
getToolbar
- Returns:
- The toolbar being managed, or
null
if no toolbar is being managed.
-
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
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:
-
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 isnull
.
-
add
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:
-