edu.cmu.sei.osate.ui.actions
Class AaxlReadOnlyActionAsJob

java.lang.Object
  extended by edu.cmu.sei.osate.ui.actions.AbstractAaxlAction
      extended by edu.cmu.sei.osate.ui.actions.AaxlReadOnlyActionAsJob
All Implemented Interfaces:
org.eclipse.ui.IActionDelegate, org.eclipse.ui.IObjectActionDelegate, org.eclipse.ui.IWorkbenchWindowActionDelegate
Direct Known Subclasses:
AaxlModifyActionAsJob, AbstractInstanceOrDeclarativeModelReadOnlyAction, CheckModelSanity, CheckModelSemantics, InstantiateAadl, UnparseAadl, UnparseAadlAs

public abstract class AaxlReadOnlyActionAsJob
extends AbstractAaxlAction

Abstract class for actions button/menu and context menu menu actions that operate on AAXL models. The body of the action is implemented in the AbstractAaxlAction.doAaxlAction(IProgressMonitor, AObject) method. The AbstractAaxlAction.getMarkerType() method should also be overridden to return the name of the marker type the analysis should use to report errors. The method getActionName() must be implemented to return the name of the analysis job. This name is used by the Eclipse UI when the showing information about the current job, or the list of active jobs, etc.

The action is invoked in a WorkspaceJob. As an workspace job, a single workspace event (if any) is sent at the end of the action, and, more importantly, the workspace is locked from the root object. Thus the action has exclusive access to all the models in the workspace. The job is not guaranteed to run in the SWT/UI thread. The user must use Display.asyncExec(java.lang.Runnable) or Display.syncExec(java.lang.Runnable) to ensure that dialog boxes (if any) are manipulated in the SWT/UI thread. OSATE provides the convenience class Dialog that opens up informative, warning, error, and question dialog boxes using the SWT/UI thread.

The body of the action, AbstractAaxlAction.doAaxlAction(IProgressMonitor, AObject) is passed the Eclipse progress monitor and the currently selected AObject in the workspace. It is the responsibility of the subclass to initialize and use the progress monitor. That is, at the minimum, the subclass is expected to call IProgressMonitor.beginTask(java.lang.String, int) and IProgressMonitor.done() on the progress monitor.

A long-running analysis should also periodically check if the user has cancelled the operation by polling IProgressMonitor.isCanceled(). Note that, the OSATE traversal class ForAllAObject supports cancellation via the protected cancelTraversal method. This is best used via the AadlProcessingSwitchWithProgress subclass that takes a reference to the progress monitor when it is constructed. Traversals can then poll the progress monitor and cancel the traversal if needed within "case" methods by using the method checkIfCancelled. Traversals can also update the progress monitor via IProgressMonitor.subTask(java.lang.String) and IProgressMonitor.worked(int) from within "case" methods.

If the action ends prematurely becuase it is responding to a cancellation request, doAaxlAction should throw an OperationCanceledException.

Author:
aarong

Constructor Summary
AaxlReadOnlyActionAsJob()
           
 
Method Summary
protected  org.eclipse.core.runtime.jobs.Job createJob(AObject root)
           
protected abstract  java.lang.String getActionName()
          Get the name of the action to display in the Job, etc.
 
Methods inherited from class edu.cmu.sei.osate.ui.actions.AbstractAaxlAction
actionBody, dispose, doAaxlAction, error, getAnalysisErrorReporterFactory, getBundle, getDefaultAnalysisErrorReporterFactory, getErrorManager, getMarkerType, getPropertyLookupErrors, getShell, getWindow, hasPropertyLookupErrors, info, init, initPropertyReferences, internalError, internalError, lookupEnumerationLiteral, lookupEnumerationLiteral, lookupOptionalPropertyConstant, lookupOptionalPropertyDefinition, lookupOptionalPropertyType, lookupPropertyConstant, lookupPropertyConstant, lookupPropertyDefinition, lookupPropertyDefinition, lookupPropertyType, lookupPropertyType, lookupUnitLiteral, lookupUnitLiteral, reportPropertyLookupErrors, run, selectionChanged, setActivePart, suppressErrorMessages, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AaxlReadOnlyActionAsJob

public AaxlReadOnlyActionAsJob()
Method Detail

getActionName

protected abstract java.lang.String getActionName()
Get the name of the action to display in the Job, etc.


createJob

protected org.eclipse.core.runtime.jobs.Job createJob(AObject root)
Specified by:
createJob in class AbstractAaxlAction