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
Modifier and TypeFieldDescriptionstatic final int
Constant defining the fallback priority.static final int
Constant defining the normal priority.Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT
-
Constructor Summary
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeCustomizerPanelFactory
working on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCustomizerPanelFactory
(ILcyCustomizerPanelFactory aCustomizerPanelFactory) This adds the specified factory to the list with normal priority.void
addCustomizerPanelFactory
(ILcyCustomizerPanelFactory aCustomizerPanelFactory, int aPriority) Adds the specifiedILcyCustomizerPanelFactory
to the list of associated factories.void
addFallbackCustomizerPanelFactory
(ILcyCustomizerPanelFactory aCustomizerPanelFactory) This adds the specified factory to the list with fallback priority.boolean
canCreateCustomizerPanel
(Object aObject) Consults the leafILcyCustomizerPanelFactory
instances to see if this composite factory can create anILcyCustomizerPanel
.createCustomizerPanel
(Object aObject) Creates a new instance ofILcyCustomizerPanel
.getCustomizerPanelFactory
(int aIndex) Returns the leafILcyCustomizerPanelFactory
at the specified index.int
Returns the number of leafs of this composite.int
getCustomizerPanelFactoryPriority
(int aIndex) Returns the priority for theILcyCustomizerPanelFactory
at the specified index.void
removeCustomizerPanelFactory
(ILcyCustomizerPanelFactory aCustomizerPanelFactory) Removes the specifiedILcyCustomizerPanelFactory
from the list of leaves.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
PRIORITY_NORMAL
public static final int PRIORITY_NORMALConstant defining the normal priority.
ILcyCustomizerPanelFactory
instances added with this priority constant have a higher priority than factories added with thePRIORITY_FALLBACK
constant. Its value is10000
.- See Also:
-
PRIORITY_FALLBACK
public static final int PRIORITY_FALLBACKConstant defining the fallback priority.
ILcyCustomizerPanelFactory
instances added with this priority constant have a lower priority than factories added with thePRIORITY_NORMAL
constant. Its value is20000
.- See Also:
-
-
Constructor Details
-
TLcyCompositeCustomizerPanelFactory
public TLcyCompositeCustomizerPanelFactory()Default constructor.
The created instance will only work on the
ILcyCustomizerPanelFactory
instances registered to it. If you want to use all registeredILcyCustomizerPanelFactory
instances of the Lucy back-end, useTLcyCompositeCustomizerPanelFactory(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeCustomizerPanelFactory
Construct a
TLcyCompositeCustomizerPanelFactory
working on the Lucy back-end.It will use all
ILcyCustomizerPanelFactory
instances registered to the back-end, and adding and/or removingILcyCustomizerPanelFactory
to/from thisTLcyCompositeCustomizerPanelFactory
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeCustomizerPanelFactory
which does not use the back-end, useTLcyCompositeCustomizerPanelFactory()
instead.- Parameters:
aLucyEnv
- The Lucy back-end- See Also:
-
-
Method Details
-
canCreateCustomizerPanel
Consults the leaf
ILcyCustomizerPanelFactory
instances to see if this composite factory can create anILcyCustomizerPanel
. It respects the priority of theILcyCustomizerPanelFactory
instances: factories with a higher priority will be consulted before factories with a lower priority.Returns
true
ifcreateObjectCustomizer
will return a customizer that can handle the given object,false
otherwise.- Specified by:
canCreateCustomizerPanel
in interfaceILcyCustomizerPanelFactory
- Parameters:
aObject
- The object to test if a customizer can be created for it.- Returns:
true
if createObjectCustomizer will return a customizer that can handle the given object,false
otherwise.- See Also:
-
createCustomizerPanel
Creates a new instance of
ILcyCustomizerPanel
. Users of this method will most likely set an object to the returnedILcyCustomizerPanel
usingILcyCustomizerPanel.setObject(Object)
. Whether that is possible can be verified in advance usingILcyCustomizerPanelFactory.canCreateCustomizerPanel(Object)
.This composite implementation consults all the leaf
ILcyCustomizerPanelFactory
instances to create anILcyCustomizerPanel
. It respects the priority of theILcyCustomizerPanelFactory
instances: 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*Context
objects are used such as:TLcyDomainObjectContext
: to customize an object of anILcdModel
TLcyLayerContext
: to customize an ILcdLayerTLcyModelContext
: to customize an ILcdModel
Please refer to the developer guide for more detailed information.
- Specified by:
createCustomizerPanel
in interfaceILcyCustomizerPanelFactory
- Parameters:
aObject
- The object to create anILcyCustomizerPanel
for.- 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
ILcyLucyEnv
is used, theILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
with normal priority. When callingILcyLucyEnv.getServices(Class)
afterwards,aCustomizerPanelFactory
will only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registeredILcyCustomizerPanelFactory
afterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aCustomizerPanelFactory
- TheILcyCustomizerPanelFactory
to 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
ILcyLucyEnv
is used, theILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
with fallback priority. When callingILcyLucyEnv.getServices(Class)
afterwards,aCustomizerPanelFactory
will only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registeredILcyCustomizerPanelFactory
afterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aCustomizerPanelFactory
- TheILcyCustomizerPanelFactory
to add to the list of associated factories. This must not benull
.- See Also:
-
addCustomizerPanelFactory
public void addCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory, int aPriority) Adds the specified
ILcyCustomizerPanelFactory
to the list of associated factories. This factory can be used when a client invokes thecanCreateCustomizerPanel
andcreateCustomizerPanel
methods.If the constructor specifying an
ILcyLucyEnv
is used, theILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
with priorityaPriority
. When callingILcyLucyEnv.getServices(Class)
afterwards,aCustomizerPanelFactory
will only be included in the returned list when the requested class wasILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registeredILcyCustomizerPanelFactory
afterwards, useremoveCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aCustomizerPanelFactory
- TheILcyCustomizerPanelFactory
to add to the list of associated factories. This must not benull
.aPriority
- The priority ofaCustomizerPanelFactory
.0
represents the highest priority,Integer.MAX_VALUE
the lowest. Negative values are not allowed.- See Also:
-
removeCustomizerPanelFactory
Removes the specified
ILcyCustomizerPanelFactory
from 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
ILcyLucyEnv
is used, theILcyCustomizerPanelFactory
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
.
Note: it is only possible to removeILcyCustomizerPanelFactory
instances which were registered using theaddCustomizerPanelFactory(ILcyCustomizerPanelFactory)
methods.- Parameters:
aCustomizerPanelFactory
- TheILcyCustomizerPanelFactory
to 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
ILcyCustomizerPanelFactory
at the specified index. This method respects the priority:ILcyCustomizerPanelFactory
instances with a higher priority have a lower index thanILcyCustomizerPanelFactory
instances with a lower priority.- Parameters:
aIndex
- The index of theILcyCustomizerPanelFactory
that needs to be returned. This should larger than or equal to 0, and less than the return value ofgetCustomizerPanelFactoryCount
.- Returns:
- The
ILcyCustomizerPanelFactory
at the specified index. This will never benull
. - See Also:
-
getCustomizerPanelFactoryPriority
public int getCustomizerPanelFactoryPriority(int aIndex) Returns the priority for the
ILcyCustomizerPanelFactory
at the specified index.- Parameters:
aIndex
- The index of theILcyCustomizerPanelFactory
for which the priority should be returned.- Returns:
- The priority for the
ILcyCustomizerPanelFactory
at the specified index - See Also:
-