Runtime

org.eclipse.gmf.runtime.emf.ui.action
Class AbstractModelActionDelegate

java.lang.Object
  extended by org.eclipse.gmf.runtime.common.ui.action.AbstractActionDelegate
      extended by org.eclipse.gmf.runtime.emf.ui.action.AbstractModelActionDelegate
All Implemented Interfaces:
org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress, IPartListener

public abstract class AbstractModelActionDelegate
extends org.eclipse.gmf.runtime.common.ui.action.AbstractActionDelegate

The abstract parent of all concrete action delegates that execute model commands. Concrete subclasses must provide a definition of the doRun() method to gather any required input and execute a model command.

Subclasses that execute a command must return falsefrom isReadOnly(). The superclass performs the AbstractActionDelegate.doRun(IProgressMonitor) method in an EMF operation executed on the operation history. Subclasses should set the action delegate status using setStatus(IStatus) to their command execution status.

Subclasses that only want to read from the model must return true from isReadOnly().


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress
org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress.WorkIndicatorType
 
Constructor Summary
protected AbstractModelActionDelegate()
          Intializes me with the singleton editing domain.
 
Method Summary
protected  IStatus execute(IUndoableOperation operation, IProgressMonitor progressMonitor, IAdaptable info)
          Convenience method for subclasses to execute an undoable operation on the action manager's operation history.
protected abstract  TransactionalEditingDomain getEditingDomain()
          Gets my editing domain.
protected  IStatus getStatus()
          Gets the status of running this action delegate.
protected  boolean isReadOnly()
          Answers whether or not I am a read-only action.
 void run(IProgressMonitor progressMonitor)
          Runs this model action delegate as a read action.
protected  void setStatus(IStatus status)
          Sets the action delegate status.
 
Methods inherited from class org.eclipse.gmf.runtime.common.ui.action.AbstractActionDelegate
dispose, doRun, getAction, getActionManager, getLabel, getOperationHistory, getSelection, getStructuredSelection, getWorkbenchPart, getWorkbenchWindow, getWorkIndicatorType, handle, init, init, init, isRunnable, isSetup, needsSetup, openErrorDialog, partActivated, partBroughtToTop, partClosed, partDeactivated, partOpened, refresh, run, runWithEvent, selectionChanged, setAction, setActiveEditor, setActivePart, setSetup, setup, setWorkbenchPart, setWorkbenchWindow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractModelActionDelegate

protected AbstractModelActionDelegate()
Intializes me with the singleton editing domain.

Method Detail

run

public final void run(IProgressMonitor progressMonitor)
Runs this model action delegate as a read action.

Specified by:
run in interface org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress
Overrides:
run in class org.eclipse.gmf.runtime.common.ui.action.AbstractActionDelegate
See Also:
IActionWithProgress.run(IProgressMonitor)

getEditingDomain

protected abstract TransactionalEditingDomain getEditingDomain()
Gets my editing domain. Can be null if I don't modify model resources.

Returns:
my editing domain.

isReadOnly

protected boolean isReadOnly()
Answers whether or not I am a read-only action. Returns false by default. Subclasses may override.

Returns:
false

getStatus

protected IStatus getStatus()
Gets the status of running this action delegate.

Returns:
my status

setStatus

protected void setStatus(IStatus status)
Sets the action delegate status. Subclasses should set the status when they execute a command.

Parameters:
status - the new status

execute

protected IStatus execute(IUndoableOperation operation,
                          IProgressMonitor progressMonitor,
                          IAdaptable info)
Convenience method for subclasses to execute an undoable operation on the action manager's operation history. Sets my status to the status of the operation execution, and returns that status.

Parameters:
operation - the operation to be executed
progressMonitor - the progress monitor
info - the adaptable info, may be null
Returns:
the status of the operation execution.

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.