org.eclipse.amp.escape.ide
Class EclipseEscapeRunner

java.lang.Object
  extended by org.ascape.runtime.Runner
      extended by org.ascape.runtime.NonGraphicRunner
          extended by org.eclipse.amp.escape.ide.EclipseEscapeRunner
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable, IEngine

public class EclipseEscapeRunner
extends NonGraphicRunner
implements IEngine

Create a new instance of a model (scape) and start it running in the eclipse environment.

See Also:
Serialized Form

Field Summary
protected  ProjectLoader delegateLoader
           
static long KILL_AFTER_NO_RESPONSE_TIME
           
protected  org.eclipse.core.runtime.IProgressMonitor modelMonitor
           
 
Fields inherited from class org.ascape.runtime.Runner
environment
 
Constructor Summary
EclipseEscapeRunner()
           
 
Method Summary
 void close()
          Close.
 void closeFinally()
          Closes the application; allowing views to close themseleves gracefully.
 void control(EngineControl control)
          Control.
 org.eclipse.core.runtime.IStatus getFinishStatus()
          Gets the finish status.
 int getIterationsPerRedraw()
           
 IModel getModel()
          Gets the model.
 org.eclipse.core.runtime.IProgressMonitor getMonitor()
          Gets the monitor.
 Scape getScape()
          Gets the scape.
 ITimeGranularity getUpdateGranularity()
          Returns the update granularity.
 java.lang.Object instanceFromName(java.lang.String className)
          Create an object instance using loadclass on the current thread's context class loader.
 boolean isCloseOnStop()
          Should the model exit upon a stop command?
 void notify(ScapeEvent event, ScapeListener listener)
           
 void observationComplete(ILifeCycleListener observer)
          Observation complete.
 void open(org.eclipse.core.resources.IResource modelResource, java.lang.String scapeClassName, java.lang.String scapeName)
          Open a workspace model with no args.
 void open(org.eclipse.core.resources.IResource projectResource, java.lang.String scapeClassName, java.lang.String scapeName, java.lang.String[] args)
          Open a workspace model with supplied args.
 void open(org.eclipse.core.resources.IResource projectResource, java.lang.String scapeClassName, java.lang.String scapeName, java.lang.String[] args, boolean block)
          Open a workspace model with supplied args.
 void open(java.lang.String scapeClassName, java.lang.String scapeName)
          Open a model with no args.
 void open(java.lang.String scapeClassName, java.lang.String scapeName, java.lang.String[] args)
          Open a model with supplied args.
 void open(java.lang.String scapeClassName, java.lang.String scapeName, java.lang.String[] args, boolean block)
          Open a model.
 void respondControl(ControlEvent control)
          Responds to any control events fired at this scape.
 void setCloseOnStop(boolean closeOnStop)
          Specifies whether the runner should exit upon a model stop.
 void setFinishStatus(org.eclipse.core.runtime.IStatus finishStatus)
          Sets the finish status.
 void setIterationsPerRedraw(int iterations)
           
 void setMonitor(org.eclipse.core.runtime.IProgressMonitor modelMonitor)
          Sets the monitor.
 void setUpdateGranularity(ITimeGranularity granularity)
          Sets the update granularity.
 void start()
          Requests the scape to start.
 
Methods inherited from class org.ascape.runtime.NonGraphicRunner
closeAndOpenSavedFinally, main, saveChoose
 
Methods inherited from class org.ascape.runtime.Runner
assignEnvironmentParameter, assignEnvironmentParameters, closeAndOpenNew, closeAndOpenNewFinally, closeAndOpenSaved, createEnvironment, exit, getData, getDescription, getEarliestPeriod, getEnvironment, getHome, getHTMLDescription, getIteration, getLatestPeriod, getModelThread, getPausePeriod, getPeriod, getPeriodName, getRestartingViews, getRootScape, getStartPeriod, getStopPeriod, initialize, isAutoRestart, isBeginningDeserializedRun, isCloseAndOpenNewRequested, isCloseAndOpenSavedRequested, isCloseRequested, isDisplayGraphics, isInMainLoop, isMultiWinEnvironment, isOpenRequested, isPaused, isQuitRequested, isRestartRequested, isRunning, isSaveRequested, isServeGraphics, isStartOnOpen, isStep, isValidPeriod, launch, open, open, open, open, open, open, open, open, open, open, open, openChoose, openChoose, openImplementation, openInstance, openSavedChoose, openSavedRun, openSavedRun, openSavedRun, pause, quit, quitFinally, requestRestart, restart, resume, run, run, runMainLoop, save, setAutoRestart, setBeginningDeserializedRun, setCloseAndOpenNewRequested, setCloseAndOpenSavedRequested, setCloseRequested, setDescription, setDisplayGraphics, setEarliestPeriod, setEnvironment, setHome, setHTMLDescription, setInMainLoop, setInternalRunning, setIteration, setLatestPeriod, setMultiWinEnvironment, setOpenRequested, setPaused, setPausePeriod, setPeriod, setPeriodName, setQuitRequested, setRestartingViews, setRestartRequested, setRootScape, setRunning, setSaveRequested, setServeGraphics, setStartOnOpen, setStartPeriod, setStep, setStopPeriod, stop, testRun, waitForViewsUpdate, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.amp.axf.core.IEngine
getModelThread, isCloseRequested, isPaused, isRunning, stop
 

Field Detail

delegateLoader

protected ProjectLoader delegateLoader

modelMonitor

protected org.eclipse.core.runtime.IProgressMonitor modelMonitor

KILL_AFTER_NO_RESPONSE_TIME

public static final long KILL_AFTER_NO_RESPONSE_TIME
See Also:
Constant Field Values
Constructor Detail

EclipseEscapeRunner

public EclipseEscapeRunner()
Method Detail

open

public void open(org.eclipse.core.resources.IResource modelResource,
                 java.lang.String scapeClassName,
                 java.lang.String scapeName)
Open a workspace model with no args. Sets up the ProjectLoader class loader that loads workspace resources. Waits until execution has stopped before returning (ie: this method blocks).

Parameters:
modelResource - the model resource
scapeClassName - the model class name
scapeName - the model name

open

public void open(org.eclipse.core.resources.IResource projectResource,
                 java.lang.String scapeClassName,
                 java.lang.String scapeName,
                 java.lang.String[] args)
Open a workspace model with supplied args. Sets up the ProjectLoader class loader that loads workspace resources. Waits until execution has stopped before returning (ie: this method blocks).

Parameters:
projectResource - the project resource
scapeClassName - the scape class name
scapeName - the scape name
args - parameter arguments for the scape

open

public void open(org.eclipse.core.resources.IResource projectResource,
                 java.lang.String scapeClassName,
                 java.lang.String scapeName,
                 java.lang.String[] args,
                 boolean block)
Open a workspace model with supplied args. Sets up the ProjectLoader class loader that loads workspace resources.

Parameters:
projectResource - the project resource
scapeClassName - the scape class name
scapeName - the scape name
args - parameter arguments for the scape
block - true if this method should only return on execution completion.

open

public void open(java.lang.String scapeClassName,
                 java.lang.String scapeName)
Open a model with no args. Waits until execution has stopped before returning (ie: this method blocks).

Parameters:
scapeClassName - the scape class name
scapeName - the scape name

open

public void open(java.lang.String scapeClassName,
                 java.lang.String scapeName,
                 java.lang.String[] args)
Open a model with supplied args. Waits until execution has stopped before returning (ie: this method blocks).

Parameters:
scapeClassName - the scape class name
scapeName - the scape name
args - parameter arguments for the scape

open

public void open(java.lang.String scapeClassName,
                 java.lang.String scapeName,
                 java.lang.String[] args,
                 boolean block)
Open a model. A instance of the scape specified is created using the using the current thread's context class loader. This will be ProjectLoader if open is used or otherwise org.eclipse.core.runtime.internal.adaptor.ContextFinder.

If the org.eclipse.core.runtime.internal.adaptor.ContextFinder class loader is in use then this search logic is used to locate the scape class. For this to work the bundle containing the scape class ought to have the following in its MANIFEST.MF:

 Eclipse-RegisterBuddy: org.ascape.core
 Import-Package: org.ascape.runtime
 

Parameters:
scapeClassName - the class name of the scape
scapeName - the name of the scape
args - parameter arguments for the scape
block - true if this method should only return on execution completion.

instanceFromName

public java.lang.Object instanceFromName(java.lang.String className)
Create an object instance using loadclass on the current thread's context class loader. If that fails, use Class.forName. NB: This is a duplicate of Runner.instanceFromName(String) from org.ascape.core. It is duplicated here so that the Eclipse-BuddyPolicy of org.eclipse.amp.escape.ide is used instead of the Eclipse-BuddyPolicy of org.ascape.core.

Overrides:
instanceFromName in class Runner
Parameters:
className - class name of object to create
Returns:
new instance of className

start

public void start()
Description copied from class: Runner
Requests the scape to start. Note that the scape may not start immeadiatly.

Overrides:
start in class Runner
See Also:
Runner.start()

close

public void close()
Description copied from interface: IEngine
Close.

Specified by:
close in interface IEngine
Overrides:
close in class Runner
See Also:
Runner.close()

closeFinally

public void closeFinally()
Description copied from class: Runner
Closes the application; allowing views to close themseleves gracefully. Do not call this method directly unless you want to force close; call close() instead, allowing a running scape to stop gracefully. Override this method if you want to provide any scape related pre-quit finalization or clean-up.

Specified by:
closeFinally in interface IEngine
Overrides:
closeFinally in class Runner
See Also:
Runner.closeFinally()

getFinishStatus

public org.eclipse.core.runtime.IStatus getFinishStatus()
Gets the finish status.

Returns:
the finish status

setFinishStatus

public void setFinishStatus(org.eclipse.core.runtime.IStatus finishStatus)
Sets the finish status.

Parameters:
finishStatus - the new finish status

getModel

public IModel getModel()
Description copied from interface: IEngine
Gets the model.

Specified by:
getModel in interface IEngine
Returns:
the model
See Also:
IEngine.getModel()

getIterationsPerRedraw

public int getIterationsPerRedraw()
See Also:
org.eclipse.amp.axf.core.IEngine#getIterationsPerRedraw()

respondControl

public void respondControl(ControlEvent control)
Description copied from class: Runner
Responds to any control events fired at this scape. Currently reacts to start, stop, pause, resume, step, quit, and restart events, as well as listener update report events. All control events except listener updates are passed up to the root. Any other events trigger an untrapped exception.

Overrides:
respondControl in class Runner
See Also:
Runner.respondControl(org.ascape.model.event.ControlEvent)

control

public void control(EngineControl control)
Description copied from interface: IEngine
Control.

Specified by:
control in interface IEngine
Parameters:
control - the model control
See Also:
IEngine.control(org.eclipse.amp.axf.core.EngineControl)

notify

public void notify(ScapeEvent event,
                   ScapeListener listener)
Overrides:
notify in class Runner
See Also:
Runner.notify(org.ascape.model.event.ScapeEvent, org.ascape.model.event.ScapeListener)

setIterationsPerRedraw

public void setIterationsPerRedraw(int iterations)
See Also:
org.eclipse.amp.axf.core.IEngine#setIterationsPerRedraw(int)

getScape

public Scape getScape()
Gets the scape.

Returns:
the scape

getMonitor

public org.eclipse.core.runtime.IProgressMonitor getMonitor()
Gets the monitor.

Returns:
the monitor

setMonitor

public void setMonitor(org.eclipse.core.runtime.IProgressMonitor modelMonitor)
Sets the monitor.

Parameters:
modelMonitor - the new monitor

observationComplete

public void observationComplete(ILifeCycleListener observer)
Description copied from interface: IEngine
Observation complete.

Specified by:
observationComplete in interface IEngine
Parameters:
observer - the observer
See Also:
IEngine.observationComplete(org.eclipse.amp.axf.core.ILifeCycleListener)

getUpdateGranularity

public ITimeGranularity getUpdateGranularity()
Description copied from interface: IEngine
Returns the update granularity.

Specified by:
getUpdateGranularity in interface IEngine
Returns:
granularity
See Also:
IEngine.getUpdateGranularity()

setUpdateGranularity

public void setUpdateGranularity(ITimeGranularity granularity)
Description copied from interface: IEngine
Sets the update granularity. This defines how often observers expect to receive state change notifications. Regardless of this value, engines should always provide life-cycle notifications.

Specified by:
setUpdateGranularity in interface IEngine
Parameters:
granularity -
See Also:
IEngine.setUpdateGranularity(org.eclipse.amp.axf.time.ITimeGranularity)

isCloseOnStop

public boolean isCloseOnStop()
Should the model exit upon a stop command?

Returns:
whether to complete run on model stop; default is false
See Also:
setCloseOnStop(boolean)

setCloseOnStop

public void setCloseOnStop(boolean closeOnStop)
Specifies whether the runner should exit upon a model stop. The default behavior is false, which leaves the model open (and typically able to restart) until explicitly closed. For batch runs we don't want the model to stay open as that requires a view notification and response to close it. It's probably cleaner to allow the runner to exit immediately rather than wait for a listener to trigger one. Note that the model will not stop in the case where a restart has been requested, and listener's will be notified of a model stop before actually closing. This gives output control listeners -- for a parameter sweep control, for example -- an opportunity to set restart to request a restart. It also implies that it makes no sense to have autoRestart true if this value is also true. Since auto-restart is by default true, be sure to set it to false. This setting can be safely changed during a model run.

Parameters:
closeOnStop - whether to complete run on model stop; default is false