GEF v2.0

org.eclipse.gef.ui.actions
Class EditorPartAction

java.lang.Object
  |
  +--org.eclipse.jface.action.Action
        |
        +--org.eclipse.gef.ui.actions.EditorPartAction
All Implemented Interfaces:
Disposable, IAction
Direct Known Subclasses:
SaveAction, SelectionAction, StackAction

public abstract class EditorPartAction
extends Action
implements Disposable

Base class for actions used by GEF editors.


Field Summary
static int DYNAMIC
          The default style.
protected  int style
          A style bitmask.
 
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, CHECKED, DESCRIPTION, ENABLED, IMAGE, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
EditorPartAction(IEditorPart editor)
          Creates a new EditorPartAction and sets the editor.
EditorPartAction(IEditorPart editor, int style)
          Creates a new EditorPartAction and sets the editor and style.
 
Method Summary
protected  boolean calculateEnabled()
          Calculates and returns the enabled state of this action.
protected  int checkStyle(int style)
          Checks the given style to ensure it is not invalid.
 void dispose()
          Called when the action is about to be disposed.
protected  void execute(Command command)
          Executes the given Command.
protected  CommandStack getCommandStack()
          Returns the editor's command stack.
protected  IEditorPart getEditorPart()
          Returns the editor associated with this action.
protected  void hookEditorPart()
          Adds any needed listeners.
protected  void init()
          Initializes this action.
protected  boolean isDynamic()
           
 boolean isEnabled()
          If this action uses the default DYNAMIC style, Action.isEnabled() is called.
protected  void refresh()
          Refreshes the properties of this action.
protected  void setEditorPart(IEditorPart part)
          Sets the editor.
protected  void unhookEditorPart()
          Remove any needed listeners.
 
Methods inherited from class org.eclipse.jface.action.Action
addPropertyChangeListener, convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, firePropertyChange, firePropertyChange, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, removeAcceleratorText, removePropertyChangeListener, run, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DYNAMIC

public static final int DYNAMIC
The default style. Uses Action.isEnabled() to determine an action's enabled state. If an action is not dynamic, calculateEnabled() is used.

style

protected final int style
A style bitmask.
Constructor Detail

EditorPartAction

public EditorPartAction(IEditorPart editor,
                        int style)
Creates a new EditorPartAction and sets the editor and style.

EditorPartAction

public EditorPartAction(IEditorPart editor)
Creates a new EditorPartAction and sets the editor. Sets the style to DYNAMIC.
Parameters:
editor - The editor to be associated with this action.
Method Detail

calculateEnabled

protected boolean calculateEnabled()
Calculates and returns the enabled state of this action. Subclasses that don't use the default DYNAMIC style should override this method.

checkStyle

protected int checkStyle(int style)
Checks the given style to ensure it is not invalid.

dispose

public void dispose()
Called when the action is about to be disposed. Subclasses should override unhookEditorPart() instead of this method to perform any final clean-up.
Specified by:
dispose in interface Disposable

execute

protected void execute(Command command)
Executes the given Command.

getCommandStack

protected CommandStack getCommandStack()
Returns the editor's command stack.

getEditorPart

protected IEditorPart getEditorPart()
Returns the editor associated with this action.

hookEditorPart

protected void hookEditorPart()
Adds any needed listeners.

init

protected void init()
Initializes this action.

isDynamic

protected boolean isDynamic()

isEnabled

public boolean isEnabled()
If this action uses the default DYNAMIC style, Action.isEnabled() is called. Otherwise, calculateEnabled() is used to determine the enabled state of this action.
Overrides:
isEnabled in class Action

refresh

protected void refresh()
Refreshes the properties of this action.

setEditorPart

protected void setEditorPart(IEditorPart part)
Sets the editor.

unhookEditorPart

protected void unhookEditorPart()
Remove any needed listeners.

GEF v2.0