Class ALcyCreateLayersAction<S extends ILcdView & ILcdTreeLayered,T extends ILcdLayer>

java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.lucy.map.action.ALcyCreateLayersAction<S,T>
All Implemented Interfaces:
ILcdAction, ILcdUndoableSource, ILcdPropertyChangeSource, ActionListener, Serializable, EventListener
Direct Known Subclasses:
TLcyCreateGXYLayerAction, TLcyLspCreateLayerAction

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.

Since:
2012.1
See Also:
  • Constructor Details

    • ALcyCreateLayersAction

      protected ALcyCreateLayersAction(ILcyLucyEnv aLucyEnv, ILcyGenericMapComponent<S,T> aMapComponent)
      Create a new action which will add the created layers to aMapComponent
      Parameters:
      aLucyEnv - The Lucy back-end
      aMapComponent - The map component to which the layers will be added
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - The event object
    • createAndInsertLayers

      public 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.

      Parameters:
      aParentComponent - The parent component, used to parent dialogs.
      Returns:
      A list containing the layers that were created and inserted, or null if the end-user cancelled the operation.
      Throws:
      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
      See Also:
    • createModel

      protected ILcdModel createModel(Component aParentComponent) throws IllegalArgumentException
      Creates the ILcdModel. Please refer to the class comment for more details about how the model is created
      Parameters:
      aParentComponent - The parent component, used to parent dialogs.
      Returns:
      The created ILcdModel, or null if the end-user canceled the operation.
      Throws:
      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.
    • createLayersForModel

      protected abstract List<T> createLayersForModel(ILcdModel aModel, Component aParentComponent)
      Create a list of layers for aModel
      Parameters:
      aModel - The model to create the layers for
      aParentComponent - The parent component, used to parent dialogs.
      Returns:
      A list containing the layers that were created for aModel. This list should not be empty, nor should it contain null. Can be null in case the end-user cancelled the operation.
      Throws:
      IllegalArgumentException - when no layer could be created for aModel
    • getLucyEnv

      protected ILcyLucyEnv getLucyEnv()
      Returns the Lucy back-end
      Returns:
      the Lucy back-end
    • getMapComponent

      protected ILcyGenericMapComponent<S,T> getMapComponent()
      Returns the ILcyGenericMapComponent to which the created layers will be added.
      Returns:
      the ILcyGenericMapComponent to which the created layers will be added.
    • addUndoableListener

      public void addUndoableListener(ILcdUndoableListener aListener)
      Description copied from interface: ILcdUndoableSource
      Adds a listener to this source, so this listener is notified when something undoable has happened.
      Specified by:
      addUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to be notified when something undoable has happened.
    • removeUndoableListener

      public void removeUndoableListener(ILcdUndoableListener aListener)
      Description copied from interface: ILcdUndoableSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to remove.
    • fireUndoableHappened

      protected void fireUndoableHappened(ILcdUndoable aUndoable)
      Fires the given ILcdUndoable to the associated listeners.
      Parameters:
      aUndoable - The undoable to fire.
    • getDefaultModelDescriptorFactory

      public ALcyDefaultModelDescriptorFactory getDefaultModelDescriptorFactory()
      Returns the ALcyDefaultModelDescriptorFactory.
      Returns:
      the ALcyDefaultModelDescriptorFactory.
      See Also:
    • setDefaultModelDescriptorFactory

      public void setDefaultModelDescriptorFactory(ALcyDefaultModelDescriptorFactory aDefaultModelDescriptorFactory)
      Sets the ALcyDefaultModelDescriptorFactory to use. If set, that factory is used to create an ILcdModelDescriptor, which in turn is used to create an ILcdModel and ILcdLayers. If set to null, the end-user is asked to choose from the factories that are available at the ILcyLucyEnv.
      Parameters:
      aDefaultModelDescriptorFactory - The factory to use, or null for automatic behavior.
      See Also: