|
Runtime | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.gmf.runtime.common.ui.action.AbstractActionDelegate
The abstract parent of all concrete action delegates that execute commands.
Logging and exception handling are done in a uniform way in the
run() method. Concrete subclasses must provide a definition of
the doRun() method to gather any required input and execute a
command. As an implementer of the IRepeatableAction interface,
this class implements the isRepeatable() method to return
true if its plug-in action is enabled, and implements the
repeat() method to run the delegate's action. Subclasses that
aren't repeatable or require special repeat behavior must override the
default implementations of these interface methods.
This class provides definitions for the methods that are found in four of the five action delegate interfaces in Eclipse. Hence, in most cases, adding a new action delegate is simply a matter of subclassing this class and declaring that the new class implements the desired action delegate interface.
IActionDelegate,
IEditorActionDelegate,
IObjectActionDelegate,
IViewActionDelegate,
IWorkbenchWindowActionDelegate,
IActionDelegate2| Nested Class Summary |
| Nested classes inherited from class org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress |
IActionWithProgress.WorkIndicatorType |
| Constructor Summary | |
protected |
AbstractActionDelegate()
Constructs a new action delegate. |
| Method Summary | |
void |
dispose()
Disposes this action delegate. |
protected abstract void |
doRun(IProgressMonitor progressMonitor)
Performs the actual work when this action delegate is run. |
protected IAction |
getAction()
Retrieves the value of the action instance variable. |
protected ActionManager |
getActionManager()
Retrieves the action manager for this action delegate from its workbench part. |
java.lang.String |
getLabel()
Retrieves the label for this action delegate. |
protected IOperationHistory |
getOperationHistory()
Gets the operation history for this action delegate from its action manager. |
protected ISelection |
getSelection()
Retrieves the current selection. |
protected IStructuredSelection |
getStructuredSelection()
Retrieves the current structured selection. |
protected IWorkbenchPart |
getWorkbenchPart()
Retrieves the value of the workbenchPart instance variable. |
protected IWorkbenchWindow |
getWorkbenchWindow()
Retrieves the value of the workbenchWindow instance
variable. |
IActionWithProgress.WorkIndicatorType |
getWorkIndicatorType()
Gets type of work indicator (progress monitor, hourglass, or none). |
protected void |
handle(java.lang.Exception exception)
Handles the specified exception. |
void |
init(IAction anAction)
Allows the action delegate to initialize itself after being created by the proxy action. |
void |
init(IViewPart view)
Initializes this action delegate with the view it will work in. |
void |
init(IWorkbenchWindow window)
Initializes this action delegate with the workbench window it will work in. |
boolean |
isRunnable()
Retrieves a Boolean indicating whether this action delegate can be run. |
boolean |
isSetup()
Returns the setup state of this action. |
protected boolean |
needsSetup()
Answers whether or not this action should be setup before it is run. |
protected void |
openErrorDialog(IStatus status)
Opens an error dialog for the specified status object. |
void |
partActivated(IWorkbenchPart part)
Notifies this action delegate that the given part has been activated. |
void |
partBroughtToTop(IWorkbenchPart part)
Notifies this action delegate that the given part has been brought to the top. |
void |
partClosed(IWorkbenchPart part)
Notifies this action delegate that the given part has been closed. |
void |
partDeactivated(IWorkbenchPart part)
Notifies this action delegate that the given part has been deactivated. |
void |
partOpened(IWorkbenchPart part)
Notifies this action delegate that the given part has been opened. |
void |
refresh()
Refreshes various aspects of this action, such as its label and whether or not it is enabled. |
void |
run(IAction act)
Performs this action. |
void |
run(IProgressMonitor progressMonitor)
Runs this action delegate. |
void |
runWithEvent(IAction anAction,
Event event)
Performs this action, passing the SWT event which triggered it. |
void |
selectionChanged(IAction act,
ISelection selection)
Notifies this action delegate that the selection in the workbench has changed. |
protected void |
setAction(IAction action)
Sets the action instance variable to the specified value. |
void |
setActiveEditor(IAction action,
IEditorPart targetEditor)
Sets the active editor for this action delegate. |
void |
setActivePart(IAction action,
IWorkbenchPart targetPart)
Sets the active part for this delegate. |
protected void |
setSetup(boolean setup)
Sets the setup state of this action. |
boolean |
setup()
Sets up the action. |
protected void |
setWorkbenchPart(IWorkbenchPart workbenchPart)
Sets the workbenchPart instance variable to the specified
value. |
protected void |
setWorkbenchWindow(IWorkbenchWindow workbenchWindow)
Sets the workbenchWindow instance variable to the specified
value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected AbstractActionDelegate()
| Method Detail |
protected final IAction getAction()
action instance variable.
action instance variable.protected final void setAction(IAction action)
action instance variable to the specified value.
action - The new value for the action instance
variable.protected final IWorkbenchPart getWorkbenchPart()
workbenchPart instance variable.
workbenchPart instance variable.protected final void setWorkbenchPart(IWorkbenchPart workbenchPart)
workbenchPart instance variable to the specified
value.
workbenchPart - The new value for the workbenchPart instance
variable.protected final IWorkbenchWindow getWorkbenchWindow()
workbenchWindow instance
variable.
workbenchWindow instance variable.protected final void setWorkbenchWindow(IWorkbenchWindow workbenchWindow)
workbenchWindow instance variable to the specified
value.
workbenchWindow - The new value for the workbenchWindow
instance variable.protected ActionManager getActionManager()
protected IOperationHistory getOperationHistory()
protected ISelection getSelection()
protected IStructuredSelection getStructuredSelection()
public void run(IAction act)
act - The action proxy that handles the presentation portion of
the action.
public void selectionChanged(IAction act,
ISelection selection)
act - The action proxy that handles presentation portion of the
action.selection - The current selection, or null if there is
no selection.
public void setActiveEditor(IAction action,
IEditorPart targetEditor)
action - The action proxy that handles presentation portion of the
action.targetEditor - The new editor target.
public void setActivePart(IAction action,
IWorkbenchPart targetPart)
action - The action proxy that handles presentation portion of the
action.targetPart - The new part target.public void partActivated(IWorkbenchPart part)
partActivated in interface IPartListenerpart - The part that was activated.public void partBroughtToTop(IWorkbenchPart part)
partBroughtToTop in interface IPartListenerpart - The part that was surfaced.public void partClosed(IWorkbenchPart part)
partClosed in interface IPartListenerpart - The part that was closed.public void partDeactivated(IWorkbenchPart part)
partDeactivated in interface IPartListenerpart - The part that was deactivated.public void partOpened(IWorkbenchPart part)
partOpened in interface IPartListenerpart - The part that was opened.public void init(IViewPart view)
view - The view that provides the context for this delegate.public void dispose()
public void init(IWorkbenchWindow window)
window - The window that provides the context for this delegate.public java.lang.String getLabel()
getLabel in interface IActionWithProgresspublic boolean isRunnable()
isRunnable in interface IActionWithProgresstrue if the action for this delegate is enabled;
false otherwise.public void refresh()
IActionWithProgress
refresh in interface IActionWithProgresspublic void run(IProgressMonitor progressMonitor)
run in interface IActionWithProgressprogressMonitor - IProgressMonitor monitoring the execution of this actionprotected boolean needsSetup()
true if the action has a setup, false
otherwise.protected void handle(java.lang.Exception exception)
exception - The exception to be handled.protected void openErrorDialog(IStatus status)
status - The status object for which to open an error dialog.protected abstract void doRun(IProgressMonitor progressMonitor)
progressMonitor - A progress monitor for tracking the progress of the action's
execution.public IActionWithProgress.WorkIndicatorType getWorkIndicatorType()
IActionWithProgress
getWorkIndicatorType in interface IActionWithProgressIActionWithProgress.getWorkIndicatorType()public boolean setup()
IActionWithProgressIActionWithProgress.run(IProgressMonitor) is called.
setup in interface IActionWithProgresstrue if the setup completed successfully,
false otherwise.IActionWithProgress.setup()public boolean isSetup()
true if the action has been setup, false
otherwise.protected void setSetup(boolean setup)
setup - true if the action has been setup, false
otherwise.public void init(IAction anAction)
anAction - the proxy action that handles the presentation portion of
the action.
public void runWithEvent(IAction anAction,
Event event)
Note: This method is called instead of run(IAction).
anAction - the action proxy that handles the presentation portion of
the actionevent - the SWT event which triggered this action being run
|
Runtime | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.