Class ALcdObjectSelectionAction
- All Implemented Interfaces:
ILcdAction
,ILcdUndoableSource
,ILcdPropertyChangeSource
,ActionListener
,Serializable
,EventListener
- Direct Known Subclasses:
TLcdDeleteSelectionAction
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:
-
Field Summary
Fields inherited from class com.luciad.gui.ALcdAction
changeSupport
Fields inherited from interface com.luciad.gui.ILcdAction
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE
-
Constructor Summary
ConstructorDescriptionALcdObjectSelectionAction
(ILcdView aView, ILcdFilter<TLcdDomainObjectContext> aObjectFilter) Constructs a newALcdObjectSelectionAction
.ALcdObjectSelectionAction
(ILcdView aView, ILcdFilter<TLcdDomainObjectContext> aObjectFilter, int aMinObjectCount, int aMaxObjectCount, boolean aStrict) Constructs a newALcdObjectSelectionAction
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected abstract void
actionPerformed
(ActionEvent aActionEvent, List<TLcdDomainObjectContext> aSelection) Performs what the action should do.void
addUndoableListener
(ILcdUndoableListener aUndoableListener) Adds a listener to this source, so this listener is notified when something undoable has happened.protected final void
fireUndoableHappened
(ILcdUndoable aUndoable) Fires the givenILcdUndoable
to all associatedILcdUndoableListener
s.Returns the object filter as it was provided to the constructor.getView()
Returns the view as it was provided to the constructor.boolean
Returns the auto hide property, seesetAutoHide(boolean)
.void
removeUndoableListener
(ILcdUndoableListener aUndoableListener) Removes the specified listener so it is no longer notified.void
setAutoHide
(boolean aAutoHide) Sets if the action should hide itself when it is disabled.Methods inherited from class com.luciad.gui.ALcdAction
addPropertyChangeListener, firePropertyChange, getDisplayName, getIcon, getLongDescription, getName, getShortDescription, getValue, isEnabled, isTraceOn, putValue, registerInstance, removePropertyChangeListener, setClassTraceOn, setDisplayName, setEnabled, setIcon, setLongDescription, setName, setShortDescription, setTraceOn
-
Constructor Details
-
ALcdObjectSelectionAction
Constructs a newALcdObjectSelectionAction
. 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 nevernull
.
-
ALcdObjectSelectionAction
public ALcdObjectSelectionAction(ILcdView aView, ILcdFilter<TLcdDomainObjectContext> aObjectFilter, int aMinObjectCount, int aMaxObjectCount, boolean aStrict) Constructs a newALcdObjectSelectionAction
. 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 implementILcdTreeLayered
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 nevernull
.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 forInteger.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. Whenfalse
, the action simply ignores the objects that weren't accepted by the filter.
-
-
Method Details
-
getView
Returns the view as it was provided to the constructor.- Returns:
- the view as it was provided to the constructor.
-
getObjectFilter
Returns the object filter as it was provided to the constructor.- Returns:
- the object filter as it was provided to the constructor.
-
addUndoableListener
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 interfaceILcdUndoableSource
- Parameters:
aUndoableListener
- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSource
Removes the specified listener so it is no longer notified.- Specified by:
removeUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aUndoableListener
- The listener to remove.
-
fireUndoableHappened
Fires the givenILcdUndoable
to all associatedILcdUndoableListener
s. Extensions of this class should use this method if they want to support undo/redo.- Parameters:
aUndoable
- TheILcdUndoable
to fire. All registeredILcdUndoableListener
instances will be notified of this undoable.
-
isAutoHide
public boolean isAutoHide()Returns the auto hide property, seesetAutoHide(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 tofalse
, 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
- Specified by:
actionPerformed
in interfaceActionListener
-
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 asTLcdDomainObjectContext
instances, so that their layer and model is also available. Never containsnull
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.
-