public abstract class ALcyCreateLayersAction<S extends ILcdView & ILcdTreeLayered,T extends ILcdLayer> extends ALcdAction implements ILcdUndoableSource
Abstract base class to create and add layers onto an ILcyGenericMapComponent
.
It uses the available ALcyDefaultModelDescriptorFactory
instances to create a model descriptor and the ILcdModelFactory
instances to create an ILcdModel
. The
available factories are retrieved from the Lucy back-end.
After the ILcdModel
is created, the end-user is given a chance to modify it, using an
ILcyCustomizerPanel
for a TLcyModelMetaDataContext
. If no such ILcyCustomizerPanel
can be created, this step is
skipped.
If multiple ALcyDefaultModelDescriptorFactory
instances are available, the end-user is
asked to choose one of them. Alternatively, one can be set to this action.
This action provides undo support through its addUndoableListener
method. One
could for example attach ILcyLucyEnv.getUndoManager()
to enable it.
Extensions of this class should still implement the layer creation part. When layer(s) can be created, they will be added to the specified map component factory.
changeSupport
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE
Modifier | Constructor and Description |
---|---|
protected |
ALcyCreateLayersAction(ILcyLucyEnv aLucyEnv,
ILcyGenericMapComponent<S,T> aMapComponent)
Create a new action which will add the created layers to
aMapComponent |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Behaves equivalent to
createAndInsertLayers(java.awt.Component) |
void |
addUndoableListener(ILcdUndoableListener aListener)
Adds a listener to this source, so this listener is notified when something undoable has
happened.
|
List<T> |
createAndInsertLayers(Component aParentComponent)
Creates and insert new
ILcdLayer instances into the map component. |
protected abstract List<T> |
createLayersForModel(ILcdModel aModel,
Component aParentComponent)
Create a list of layers for
aModel |
protected ILcdModel |
createModel(Component aParentComponent)
Creates the
ILcdModel . |
protected void |
fireUndoableHappened(ILcdUndoable aUndoable)
Fires the given
ILcdUndoable to the associated listeners. |
ALcyDefaultModelDescriptorFactory |
getDefaultModelDescriptorFactory()
Returns the
ALcyDefaultModelDescriptorFactory . |
protected ILcyLucyEnv |
getLucyEnv()
Returns the Lucy back-end
|
protected ILcyGenericMapComponent<S,T> |
getMapComponent()
Returns the
ILcyGenericMapComponent to which the created layers will be added. |
void |
removeUndoableListener(ILcdUndoableListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
setDefaultModelDescriptorFactory(ALcyDefaultModelDescriptorFactory aDefaultModelDescriptorFactory)
Sets the
ALcyDefaultModelDescriptorFactory to use. |
addPropertyChangeListener, firePropertyChange, getDisplayName, getIcon, getLongDescription, getName, getShortDescription, getValue, isEnabled, isTraceOn, putValue, registerInstance, removePropertyChangeListener, setClassTraceOn, setDisplayName, setEnabled, setIcon, setLongDescription, setName, setShortDescription, setTraceOn
protected ALcyCreateLayersAction(ILcyLucyEnv aLucyEnv, ILcyGenericMapComponent<S,T> aMapComponent)
aMapComponent
aLucyEnv
- The Lucy back-endaMapComponent
- The map component to which the layers will be addedpublic void actionPerformed(ActionEvent e)
createAndInsertLayers(java.awt.Component)
actionPerformed
in interface ActionListener
e
- The event objectpublic List<T> createAndInsertLayers(Component aParentComponent) throws IllegalArgumentException
Creates and insert new ILcdLayer
instances into the map component. Please refer to
the class comment for more details about how the layers are created.
aParentComponent
- The parent component, used to parent dialogs.null
if
the end-user cancelled the operation.IllegalArgumentException
- If no ALcyDefaultModelDescriptorFactory
could be found
in ILcyLucyEnv
, and none was set, or if no ILcdModelFactory
was found that could create an
ILcdModel
for the descriptor. Will also be thrown
when no layer(s) could be created for the ILcdModel
createModel(java.awt.Component)
,
createLayersForModel(com.luciad.model.ILcdModel, java.awt.Component)
protected ILcdModel createModel(Component aParentComponent) throws IllegalArgumentException
ILcdModel
. Please refer to the class comment for more details about how the
model is createdaParentComponent
- The parent component, used to parent dialogs.ILcdModel
, or null
if the end-user canceled the
operation.IllegalArgumentException
- If no ALcyDefaultModelDescriptorFactory
could be found
in ILcyLucyEnv
, and none was set, or if no ILcdModelFactory
was found that could create an
ILcdModel
for the descriptor.protected abstract List<T> createLayersForModel(ILcdModel aModel, Component aParentComponent)
aModel
aModel
- The model to create the layers foraParentComponent
- The parent component, used to parent dialogs.aModel
. This list should not
be empty, nor should it contain null
. Can be null
in case the end-user
cancelled the operation.IllegalArgumentException
- when no layer could be created for aModel
protected ILcyLucyEnv getLucyEnv()
protected ILcyGenericMapComponent<S,T> getMapComponent()
ILcyGenericMapComponent
to which the created layers will be added.ILcyGenericMapComponent
to which the created layers will be added.public void addUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
addUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to be notified when something undoable has happened.public void removeUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
removeUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to remove.protected void fireUndoableHappened(ILcdUndoable aUndoable)
ILcdUndoable
to the associated listeners.aUndoable
- The undoable to fire.public ALcyDefaultModelDescriptorFactory getDefaultModelDescriptorFactory()
ALcyDefaultModelDescriptorFactory
.ALcyDefaultModelDescriptorFactory
.setDefaultModelDescriptorFactory(com.luciad.lucy.model.ALcyDefaultModelDescriptorFactory)
public void setDefaultModelDescriptorFactory(ALcyDefaultModelDescriptorFactory aDefaultModelDescriptorFactory)
ALcyDefaultModelDescriptorFactory
to use. If set, that factory is used
to create an ILcdModelDescriptor
, which in turn is used to create an
ILcdModel
and ILcdLayer
s. If set to null
, the end-user
is asked to choose from the factories that are available at the ILcyLucyEnv
.aDefaultModelDescriptorFactory
- The factory to use, or null
for automatic
behavior.getDefaultModelDescriptorFactory()