Class TLcyCompositeCustomizerPanelFactory
- All Implemented Interfaces:
ILcyCustomizerPanelFactory,Iterable<ILcyCustomizerPanelFactory>
ILcyCustomizerPanelFactory implementation that follows the composite design
pattern. As such, it delegates all the real work to the ILcyCustomizerPanel's added
to this factory.
The factories added to this composite can be given a priority. Factories with a higher priority will be consulted first when this composite performs any operation.
A typical usage of the priorities would be to add a ILcyCustomizerPanelFactory
implementation for a specific type of layer using say PRIORITY_NORMAL. For all other
types of layers, you could then add a general implementation using PRIORITY_FALLBACK. As
PRIORITY_NORMAL takes precedence over PRIORITY_FALLBACK, there is no
need to exclude the specific layer in the canCreateCustomizerPanel method of the
general implementation, and therefore the general implementation does not need to know anything
about the more specific one.
When creating a new TLcyCompositeCustomizerPanelFactory using the default
constructor (see TLcyCompositeCustomizerPanelFactory(), the created instance will only
work on/with the ILcyCustomizerPanelFactorys
registered on this composite instance (see addCustomizerPanelFactory(ILcyCustomizerPanelFactory, int) and removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)).
When creating a new TLcyCompositeCustomizerPanelFactory using the constructor
specifying an ILcyLucyEnv instance (see TLcyCompositeCustomizerPanelFactory(com.luciad.lucy.ILcyLucyEnv), the created instance will
work on the Lucy back-end
services. It will use all registered ILcyCustomizerPanelFactory
instances of the Lucy back-end, adding and/or removing an ILcyCustomizerPanelFactory
will add/remove the ILcyCustomizerPanelFactory as service from Lucy, ... .
Creating an ILcyCustomizerPanel using the back-end based implementation can be
done by creating a new instance of this class:
//Create a new instance whenever you need it
TLcyCompositeCustomizerPanelFactory factory = new TLcyCompositeCustomizerPanelFactory( aLucyEnv );
if ( factory.canCreateCustomizerPanel( aObject ){
ILcyCustomizerPanel customizerPanel = factory.createCustomizerPanel( aObject );
} else {
//none of the registered ILcyCustomizerPanelFactory could create a customizer panel for aObject
}
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
factory = null;
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant defining the fallback priority.static final intConstant defining the normal priority.Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Construct aTLcyCompositeCustomizerPanelFactoryworking on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory) This adds the specified factory to the list with normal priority.voidaddCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory, int aPriority) Adds the specifiedILcyCustomizerPanelFactoryto the list of associated factories.voidaddFallbackCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory) This adds the specified factory to the list with fallback priority.booleancanCreateCustomizerPanel(Object aObject) Consults the leafILcyCustomizerPanelFactoryinstances to see if this composite factory can create anILcyCustomizerPanel.createCustomizerPanel(Object aObject) Creates a new instance ofILcyCustomizerPanel.getCustomizerPanelFactory(int aIndex) Returns the leafILcyCustomizerPanelFactoryat the specified index.intReturns the number of leafs of this composite.intgetCustomizerPanelFactoryPriority(int aIndex) Returns the priority for theILcyCustomizerPanelFactoryat the specified index.voidremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory) Removes the specifiedILcyCustomizerPanelFactoryfrom the list of leaves.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
PRIORITY_NORMAL
public static final int PRIORITY_NORMALConstant defining the normal priority.
ILcyCustomizerPanelFactoryinstances added with this priority constant have a higher priority than factories added with thePRIORITY_FALLBACKconstant. Its value is10000.- See Also:
-
PRIORITY_FALLBACK
public static final int PRIORITY_FALLBACKConstant defining the fallback priority.
ILcyCustomizerPanelFactoryinstances added with this priority constant have a lower priority than factories added with thePRIORITY_NORMALconstant. Its value is20000.- See Also:
-
-
Constructor Details
-
TLcyCompositeCustomizerPanelFactory
public TLcyCompositeCustomizerPanelFactory()Default constructor.
The created instance will only work on the
ILcyCustomizerPanelFactoryinstances registered to it. If you want to use all registeredILcyCustomizerPanelFactoryinstances of the Lucy back-end, useTLcyCompositeCustomizerPanelFactory(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeCustomizerPanelFactory
Construct a
TLcyCompositeCustomizerPanelFactoryworking on the Lucy back-end.It will use all
ILcyCustomizerPanelFactoryinstances registered to the back-end, and adding and/or removingILcyCustomizerPanelFactoryto/from thisTLcyCompositeCustomizerPanelFactorywill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeCustomizerPanelFactorywhich does not use the back-end, useTLcyCompositeCustomizerPanelFactory()instead.- Parameters:
aLucyEnv- The Lucy back-end- See Also:
-
-
Method Details
-
canCreateCustomizerPanel
Consults the leaf
ILcyCustomizerPanelFactoryinstances to see if this composite factory can create anILcyCustomizerPanel. It respects the priority of theILcyCustomizerPanelFactoryinstances: factories with a higher priority will be consulted before factories with a lower priority.Returns
trueifcreateObjectCustomizerwill return a customizer that can handle the given object,falseotherwise.- Specified by:
canCreateCustomizerPanelin interfaceILcyCustomizerPanelFactory- Parameters:
aObject- The object to test if a customizer can be created for it.- Returns:
trueif createObjectCustomizer will return a customizer that can handle the given object,falseotherwise.- See Also:
-
createCustomizerPanel
Creates a new instance of
ILcyCustomizerPanel. Users of this method will most likely set an object to the returnedILcyCustomizerPanelusingILcyCustomizerPanel.setObject(Object). Whether that is possible can be verified in advance usingILcyCustomizerPanelFactory.canCreateCustomizerPanel(Object).This composite implementation consults all the leaf
ILcyCustomizerPanelFactoryinstances to create anILcyCustomizerPanel. It respects the priority of theILcyCustomizerPanelFactoryinstances: factories with a higher priority will be consulted before factories with a lower priority.Although any object can be used here, typically
com.luciad.lucy.util.context.TLcy*Contextobjects are used such as:TLcyDomainObjectContext: to customize an object of anILcdModelTLcyLayerContext: to customize an ILcdLayerTLcyModelContext: to customize an ILcdModel
Please refer to the developer guide for more detailed information.
- Specified by:
createCustomizerPanelin interfaceILcyCustomizerPanelFactory- Parameters:
aObject- The object to create anILcyCustomizerPanelfor.- Returns:
- a new instance of
ILcyCustomizerPanel. - See Also:
-
addCustomizerPanelFactory
This adds the specified factory to the list with normal priority.
If the constructor specifying an
ILcyLucyEnvis used, theILcyCustomizerPanelFactorywill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)with normal priority. When callingILcyLucyEnv.getServices(Class)afterwards,aCustomizerPanelFactorywill only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class.
Note: if you want to remove the registeredILcyCustomizerPanelFactoryafterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)and notILcyLucyEnv.removeService(Object).- Parameters:
aCustomizerPanelFactory- TheILcyCustomizerPanelFactoryto add to the list of associated factories. This must not benull.- See Also:
-
addFallbackCustomizerPanelFactory
This adds the specified factory to the list with fallback priority.
If the constructor specifying an
ILcyLucyEnvis used, theILcyCustomizerPanelFactorywill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)with fallback priority. When callingILcyLucyEnv.getServices(Class)afterwards,aCustomizerPanelFactorywill only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class.
Note: if you want to remove the registeredILcyCustomizerPanelFactoryafterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)and notILcyLucyEnv.removeService(Object).- Parameters:
aCustomizerPanelFactory- TheILcyCustomizerPanelFactoryto add to the list of associated factories. This must not benull.- See Also:
-
addCustomizerPanelFactory
public void addCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory, int aPriority) Adds the specified
ILcyCustomizerPanelFactoryto the list of associated factories. This factory can be used when a client invokes thecanCreateCustomizerPanelandcreateCustomizerPanelmethods.If the constructor specifying an
ILcyLucyEnvis used, theILcyCustomizerPanelFactorywill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)with priorityaPriority. When callingILcyLucyEnv.getServices(Class)afterwards,aCustomizerPanelFactorywill only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class.
Note: if you want to remove the registeredILcyCustomizerPanelFactoryafterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)and notILcyLucyEnv.removeService(Object).- Parameters:
aCustomizerPanelFactory- TheILcyCustomizerPanelFactoryto add to the list of associated factories. This must not benull.aPriority- The priority ofaCustomizerPanelFactory.0represents the highest priority,Integer.MAX_VALUEthe lowest. Negative values are not allowed.- See Also:
-
removeCustomizerPanelFactory
Removes the specified
ILcyCustomizerPanelFactoryfrom the list of leaves. This factory will no longer be used when this composite is asked to perform any operation.If the constructor specifying an
ILcyLucyEnvis used, theILcyCustomizerPanelFactorywill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object).
Note: it is only possible to removeILcyCustomizerPanelFactoryinstances which were registered using theaddCustomizerPanelFactory(ILcyCustomizerPanelFactory)methods.- Parameters:
aCustomizerPanelFactory- TheILcyCustomizerPanelFactoryto remove. If this factory was not in the list of leaves, nothing happens.
-
getCustomizerPanelFactoryCount
public int getCustomizerPanelFactoryCount()Returns the number of leafs of this composite.- Returns:
- The number of leafs of this composite. Will never be negative.
-
getCustomizerPanelFactory
Returns the leaf
ILcyCustomizerPanelFactoryat the specified index. This method respects the priority:ILcyCustomizerPanelFactoryinstances with a higher priority have a lower index thanILcyCustomizerPanelFactoryinstances with a lower priority.- Parameters:
aIndex- The index of theILcyCustomizerPanelFactorythat needs to be returned. This should larger than or equal to 0, and less than the return value ofgetCustomizerPanelFactoryCount.- Returns:
- The
ILcyCustomizerPanelFactoryat the specified index. This will never benull. - See Also:
-
getCustomizerPanelFactoryPriority
public int getCustomizerPanelFactoryPriority(int aIndex) Returns the priority for the
ILcyCustomizerPanelFactoryat the specified index.- Parameters:
aIndex- The index of theILcyCustomizerPanelFactoryfor which the priority should be returned.- Returns:
- The priority for the
ILcyCustomizerPanelFactoryat the specified index - See Also:
-