de.jreality.ui.viewerapp.actions
Class AbstractSelectionListenerAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by de.jreality.ui.viewerapp.actions.AbstractJrAction
          extended by de.jreality.ui.viewerapp.actions.AbstractSelectionListenerAction
All Implemented Interfaces:
SelectionListener, ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
AddTool, AssignFaceAABBTree, CreateAppearance, CurrentSelection, ExportOBJ, LoadFileToNode, LoadReflectionMap, LoadTexture, Remove, Rename, RotateReflectionMapSides, SaveSelected, ToggleAppearance, TogglePickable, ToggleVisibility

public abstract class AbstractSelectionListenerAction
extends AbstractJrAction
implements SelectionListener

Abstract class for actions used in jReality applications which do something if the selection given by the underlying selection manager changes (e.g. which act on specific scene tree or scene graph nodes and need to disable or enable themselves based on the current selection).

Author:
msommer
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractSelectionListenerAction(String name, SelectionManager sm)
          Default constructor.
AbstractSelectionListenerAction(String name, SelectionManager sm, Component parentComp)
          Constructor for actions which need a parent component e.g.
 
Method Summary
 Selection getSelection()
          Get the current selection.
 SelectionManager getSelectionManager()
          Get the underlying selection manager.
 boolean isEnabled(SelectionEvent e)
          Override this method to specify when to disable or enable the action based on the current selection.
 void selectionChanged(SelectionEvent e)
          Override this method to specify what to do when the selection changes.
 
Methods inherited from class de.jreality.ui.viewerapp.actions.AbstractJrAction
actionPerformed, createMenuItem, createToolboxItem, getIcon, setAcceleratorKey, setIcon, setName, setShortDescription
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSelectionListenerAction

public AbstractSelectionListenerAction(String name,
                                       SelectionManager sm)
Default constructor.

Parameters:
name - the name of the action
sm - the underlying selection manager
Throws:
IllegalArgumentException - if sm is null

AbstractSelectionListenerAction

public AbstractSelectionListenerAction(String name,
                                       SelectionManager sm,
                                       Component parentComp)
Constructor for actions which need a parent component e.g. for displaying dialogs.

Parameters:
name - the name of the action
sm - the underlying selection manager
parentComp - the parent component
Throws:
IllegalArgumentException - if sm is null
Method Detail

selectionChanged

public void selectionChanged(SelectionEvent e)
Override this method to specify what to do when the selection changes.

Specified by:
selectionChanged in interface SelectionListener
Parameters:
e - the selection event
See Also:
isEnabled(SelectionEvent)

isEnabled

public boolean isEnabled(SelectionEvent e)
Override this method to specify when to disable or enable the action based on the current selection.
This method is called in selectionChanged(SelectionEvent).

Parameters:
e - the selection event
Returns:
true iff the action is enabled based on the current selection
See Also:
selectionChanged(SelectionEvent)

getSelection

public Selection getSelection()
Get the current selection.

Returns:
the current Selection object

getSelectionManager

public SelectionManager getSelectionManager()
Get the underlying selection manager.

Returns:
the selection manager