public class TLcyCompositeCustomizerPanelFactory extends TLcyGenericComposite<ILcyCustomizerPanelFactory> implements 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;
Modifier and Type | Field and Description |
---|---|
static int |
PRIORITY_FALLBACK
Constant defining the fallback priority.
|
static int |
PRIORITY_NORMAL
Constant defining the normal priority.
|
PRIORITY_DEFAULT
Constructor and Description |
---|
TLcyCompositeCustomizerPanelFactory()
Default constructor.
|
TLcyCompositeCustomizerPanelFactory(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeCustomizerPanelFactory working on the Lucy
back-end. |
Modifier and Type | Method and Description |
---|---|
void |
addCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory)
This adds the specified factory to the list with normal
priority.
|
void |
addCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory,
int aPriority)
Adds the specified
ILcyCustomizerPanelFactory 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 leaf
ILcyCustomizerPanelFactory instances to see if this composite
factory can create an ILcyCustomizerPanel . |
ILcyCustomizerPanel |
createCustomizerPanel(Object aObject)
Creates a new instance of
ILcyCustomizerPanel . |
ILcyCustomizerPanelFactory |
getCustomizerPanelFactory(int aIndex)
Returns the leaf
ILcyCustomizerPanelFactory at the specified index. |
int |
getCustomizerPanelFactoryCount()
Returns the number of leafs of this composite.
|
int |
getCustomizerPanelFactoryPriority(int aIndex)
Returns the priority for the
ILcyCustomizerPanelFactory at the specified
index. |
void |
removeCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory)
Removes the specified
ILcyCustomizerPanelFactory from the list of leaves. |
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final int PRIORITY_NORMAL
Constant defining the normal priority. ILcyCustomizerPanelFactory
instances
added with this priority constant have a higher priority than factories added with the
PRIORITY_FALLBACK
constant. Its value is 10000
.
public static final int PRIORITY_FALLBACK
Constant defining the fallback priority. ILcyCustomizerPanelFactory
instances
added with this priority constant have a lower priority than factories added with the
PRIORITY_NORMAL
constant. Its value is 20000
.
public TLcyCompositeCustomizerPanelFactory()
Default constructor.
The created instance will only work on the ILcyCustomizerPanelFactory
instances
registered to it. If you want to use all registered ILcyCustomizerPanelFactory
instances of the Lucy back-end, use TLcyCompositeCustomizerPanelFactory(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeCustomizerPanelFactory(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeCustomizerPanelFactory
working on the Lucy
back-end.
It will use all ILcyCustomizerPanelFactory
instances registered to the
back-end, and adding and/or removing ILcyCustomizerPanelFactory
to/from this
TLcyCompositeCustomizerPanelFactory
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, use TLcyCompositeCustomizerPanelFactory()
instead.
aLucyEnv
- The Lucy back-endTLcyCompositeCustomizerPanelFactory()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public boolean canCreateCustomizerPanel(Object aObject)
Consults the leaf ILcyCustomizerPanelFactory
instances to see if this composite
factory can create an ILcyCustomizerPanel
. It respects the priority of the
ILcyCustomizerPanelFactory
instances: factories with a higher priority will be
consulted before factories with a lower priority.
Returns true
if createObjectCustomizer
will return a customizer that
can handle the given object, false
otherwise.
canCreateCustomizerPanel
in interface ILcyCustomizerPanelFactory
aObject
- The object to test if a customizer can be created for it.true
if createObjectCustomizer will return a customizer that can handle the given
object, false
otherwise.createCustomizerPanel(Object)
public ILcyCustomizerPanel createCustomizerPanel(Object aObject)
Creates a new instance of ILcyCustomizerPanel
. Users of this method will most
likely set an object to the returned ILcyCustomizerPanel
using ILcyCustomizerPanel.setObject(Object)
. Whether that is possible can be verified in advance
using ILcyCustomizerPanelFactory.canCreateCustomizerPanel(Object)
.
This composite implementation consults all the leaf ILcyCustomizerPanelFactory
instances to create an ILcyCustomizerPanel
. It respects the priority of the
ILcyCustomizerPanelFactory
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 an ILcdModel
TLcyLayerContext
: to customize an
ILcdLayerTLcyModelContext
: to customize an
ILcdModelPlease refer to the developer guide for more detailed information.
createCustomizerPanel
in interface ILcyCustomizerPanelFactory
aObject
- The object to create an ILcyCustomizerPanel
for.ILcyCustomizerPanel
.ILcyCustomizerPanelFactory.canCreateCustomizerPanel(java.lang.Object)
public void addCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory)
This adds the specified factory to the list with normal priority.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
with normal priority. When calling ILcyLucyEnv.getServices(Class)
afterwards, aCustomizerPanelFactory
will only be included in the returned list
when the requested class was ILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registered ILcyCustomizerPanelFactory
afterwards, use removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and not
ILcyLucyEnv.removeService(Object)
.
aCustomizerPanelFactory
- The ILcyCustomizerPanelFactory
to add to the list
of associated factories. This must not be null
.addCustomizerPanelFactory(ILcyCustomizerPanelFactory, int)
,
removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
public void addFallbackCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory)
This adds the specified factory to the list with fallback priority.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
with fallback priority. When calling ILcyLucyEnv.getServices(Class)
afterwards, aCustomizerPanelFactory
will only be included in the returned list
when the requested class was ILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registered ILcyCustomizerPanelFactory
afterwards, use removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and not
ILcyLucyEnv.removeService(Object)
.
aCustomizerPanelFactory
- The ILcyCustomizerPanelFactory
to add to the list
of associated factories. This must not be null
.addCustomizerPanelFactory(ILcyCustomizerPanelFactory, int)
,
removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
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 the canCreateCustomizerPanel
and createCustomizerPanel
methods.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcyCustomizerPanelFactory
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
with priority
aPriority
. When calling ILcyLucyEnv.getServices(Class)
afterwards, aCustomizerPanelFactory
will only be included in the returned list
when the requested class was ILcyCustomizerPanelFactory.class
.
Note: if you want to remove the registered ILcyCustomizerPanelFactory
afterwards, use removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
and not
ILcyLucyEnv.removeService(Object)
.
aCustomizerPanelFactory
- The ILcyCustomizerPanelFactory
to add to the list
of associated factories. This must not be null
.aPriority
- The priority of aCustomizerPanelFactory
.
0
represents the highest priority,
Integer.MAX_VALUE
the lowest. Negative values are
not allowed.removeCustomizerPanelFactory(ILcyCustomizerPanelFactory)
public void removeCustomizerPanelFactory(ILcyCustomizerPanelFactory aCustomizerPanelFactory)
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, the ILcyCustomizerPanelFactory
will be removed as service from the Lucy back-end (see ILcyLucyEnv.removeService(Object)
.
Note: it is only possible to remove ILcyCustomizerPanelFactory
instances which
were registered using the addCustomizerPanelFactory(ILcyCustomizerPanelFactory)
methods.
aCustomizerPanelFactory
- The ILcyCustomizerPanelFactory
to remove. If this
factory was not in the list of leaves, nothing happens.public int getCustomizerPanelFactoryCount()
public ILcyCustomizerPanelFactory getCustomizerPanelFactory(int aIndex)
Returns the leaf ILcyCustomizerPanelFactory
at the specified index. This method
respects the priority: ILcyCustomizerPanelFactory
instances with a higher priority
have a lower index than ILcyCustomizerPanelFactory
instances with a lower
priority.
aIndex
- The index of the ILcyCustomizerPanelFactory
that needs to be
returned. This should larger than or equal to 0, and less than the return value
of getCustomizerPanelFactoryCount
.ILcyCustomizerPanelFactory
at the specified index. This will never be
null
.addCustomizerPanelFactory(ILcyCustomizerPanelFactory, int)
public int getCustomizerPanelFactoryPriority(int aIndex)
Returns the priority for the ILcyCustomizerPanelFactory
at the specified
index.
aIndex
- The index of the ILcyCustomizerPanelFactory
for which the priority
should be returned.ILcyCustomizerPanelFactory
at the specified indexaddCustomizerPanelFactory(ILcyCustomizerPanelFactory, int)