Class ALcdObjectSelectionAction

java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.view.ALcdObjectSelectionAction
All Implemented Interfaces:
ILcdAction, ILcdUndoableSource, ILcdPropertyChangeSource, ActionListener, Serializable, EventListener
Direct Known Subclasses:
TLcdDeleteSelectionAction

public abstract class ALcdObjectSelectionAction extends ALcdAction implements ILcdUndoableSource

Action that works on the current map selection. It is typically used as an action in a right click menu.

Extensions can provide a filter that decides on which objects to work. The action disables itself when no suitable objects are selected. Depending on isAutoHide(), the action also makes itself invisible when not applicable (useful for pop-up menus, enabled by default).

Optionally, implementations can support undo/redo by invoking fireUndoableHappened(com.luciad.gui.ILcdUndoable) when they change state.

Since:
2012.1
See Also:
  • Constructor Details

    • ALcdObjectSelectionAction

      public ALcdObjectSelectionAction(ILcdView aView, ILcdFilter<TLcdDomainObjectContext> aObjectFilter)
      Constructs a new ALcdObjectSelectionAction. It takes a filter to decide which objects should be taken into account. The action is enabled when exactly one object is selected and when that object is accepted by the filter, disabled otherwise.
      Parameters:
      aView - The view to work on.
      aObjectFilter - Sets the object filter. The filter is used to detect if the objects of the map selection are recognized (accepted) by this action. The object given to the filter is never null.
    • ALcdObjectSelectionAction

      public ALcdObjectSelectionAction(ILcdView aView, ILcdFilter<TLcdDomainObjectContext> aObjectFilter, int aMinObjectCount, int aMaxObjectCount, boolean aStrict)
      Constructs a new ALcdObjectSelectionAction. It takes a filter to decide which objects should be taken into account. The action is enabled if the number of objects that are accepted by the filter is in the given min/max interval, disabled otherwise.
      Parameters:
      aView - The view to work on. Must implement ILcdTreeLayered as well.
      aObjectFilter - Sets the object filter. The filter is used to detect if the objects of the map selection are recognized (accepted) by this action. If all objects of the map selection are recognized, the action is enabled. The given object is never null.
      aMinObjectCount - Defines the minimum number of objects that should pass the filter for the action to be enabled.
      aMaxObjectCount - Defines the maximum number of objects that should pass the filter for the action to be enabled. You can use -1 as a short cut for Integer.MAX_VALUE, to leave the maximum unbounded.
      aStrict - True means the action disables itself when one or more objects that are selected, were not accepted by the filter. When false, the action simply ignores the objects that weren't accepted by the filter.
  • Method Details

    • getView

      public ILcdView getView()
      Returns the view as it was provided to the constructor.
      Returns:
      the view as it was provided to the constructor.
    • getObjectFilter

      public ILcdFilter<TLcdDomainObjectContext> getObjectFilter()
      Returns the object filter as it was provided to the constructor.
      Returns:
      the object filter as it was provided to the constructor.
    • addUndoableListener

      public void addUndoableListener(ILcdUndoableListener aUndoableListener)
      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:
      aUndoableListener - The listener to be notified when something undoable has happened.
    • removeUndoableListener

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

      protected final void fireUndoableHappened(ILcdUndoable aUndoable)
      Fires the given ILcdUndoable to all associated ILcdUndoableListeners. Extensions of this class should use this method if they want to support undo/redo.
      Parameters:
      aUndoable - The ILcdUndoable to fire. All registered ILcdUndoableListener instances will be notified of this undoable.
    • isAutoHide

      public boolean isAutoHide()
      Returns the auto hide property, see setAutoHide(boolean).
      Returns:
      the auto hide property.
    • setAutoHide

      public void setAutoHide(boolean aAutoHide)

      Sets if the action should hide itself when it is disabled. This is convenient when used in a context menu.

      Hiding means the ILcdAction.VISIBLE key is changed to false, it is up to the container of this action to effectively hide it from the UI.

      Parameters:
      aAutoHide - True to automatically hide the action when it is disabled, false to avoid that the action changes its visibility.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Specified by:
      actionPerformed in interface ActionListener
    • actionPerformed

      protected abstract void actionPerformed(ActionEvent aActionEvent, List<TLcdDomainObjectContext> aSelection)
      Performs what the action should do. Only invoked when the selection is compliant with the restrictions imposed by the filter, min/max interval and the strict setting of the constructor.
      Parameters:
      aActionEvent - The action event.
      aSelection - The list with selected objects that were accepted by the filter. They are provided as TLcdDomainObjectContext instances, so that their layer and model is also available. Never contains null values. The size of the list is within the min/max interval specified in the constructor. When using the constructor that does not specify this interval, the list size is always 1.