ptolemy.vergil.basic
Class RunnableGraphController

java.lang.Object
  extended by diva.graph.AbstractGraphController
      extended by ptolemy.vergil.basic.BasicGraphController
          extended by ptolemy.vergil.basic.WithIconGraphController
              extended by ptolemy.vergil.basic.RunnableGraphController
All Implemented Interfaces:
GraphController, ExecutionListener, DebugListener, ValueListener
Direct Known Subclasses:
ActorViewerGraphController, FSMViewerGraphController, FSMViewerGraphController

public abstract class RunnableGraphController
extends WithIconGraphController
implements ExecutionListener

A graph controller for models that can be executed. This controller provides toolbar buttons for executing the model. If the model being controlled is not a top-level model, then execution commands are propagated up to the top level.

Since:
Ptolemy II 2.1
Version:
$Id: RunnableGraphController.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Nested Class Summary
private  class RunnableGraphController.ButtonFigureAction
          An action to run the model that includes a button.
private  class RunnableGraphController.PauseModelAction
          An action to pause the model.
private  class RunnableGraphController.RunModelAction
          An action to run the model.
private  class RunnableGraphController.StopModelAction
          An action to stop the model.
 
Nested classes/interfaces inherited from class ptolemy.vergil.basic.WithIconGraphController
WithIconGraphController.NewPortAction
 
Nested classes/interfaces inherited from class ptolemy.vergil.basic.BasicGraphController
BasicGraphController.OpenBaseClassAction, BasicGraphController.SchematicContextMenuFactory, BasicGraphController.UnitSolverDialogAction
 
Field Summary
private  java.util.List<Attribute> _errorHighlights
          List of error highlight attributes we have created.
private  Manager _manager
          The manager we are currently listening to.
private  javax.swing.Action _pauseModelAction
          Action for pausing the model.
private  Manager.State _previousState
          The previous state of the manager, to avoid reporting it if it hasn't changed.
private  javax.swing.Action _runModelAction
          Action for running the model.
private  javax.swing.Action _stopModelAction
          Action for stopping the model.
 
Fields inherited from class ptolemy.vergil.basic.WithIconGraphController
_editIconAction, _portController, _removeIconAction
 
Fields inherited from class ptolemy.vergil.basic.BasicGraphController
_animated, _animationRenderer, _configureAction, _configureMenuFactory, _menuCreator, _menuFactory, _openBaseClassAction, _unitSolverDialogAction
 
Constructor Summary
RunnableGraphController()
          Create a new controller.
 
Method Summary
private  void _addErrorHighlightIfNeeded(Nameable culprit)
          Add an error highlight color to the specified culprit if it is not already present.
protected  void _addHotKeys(JGraph jgraph)
          Add hot keys to the actions in the given JGraph.
protected  Manager _getManager()
          Get the manager for the top-level of the associated model, if there is one, or create one if there is not.
private  void _highlightError(Nameable culprit)
          Highlight the specified object and all its containers to indicate that it is the source of an error.
 void addToMenuAndToolbar(javax.swing.JMenu menu, javax.swing.JToolBar toolbar)
          Add execution commands to the toolbar.
 void executionError(Manager manager, java.lang.Throwable throwable)
          Report that an execution error has occurred.
 void executionFinished(Manager manager)
          Report that execution of the model has finished.
 void managerStateChanged(Manager manager)
          Report that a manager state has changed.
 
Methods inherited from class ptolemy.vergil.basic.WithIconGraphController
_createControllers, getNewPortLocation, initializeInteraction, setConfiguration
 
Methods inherited from class ptolemy.vergil.basic.BasicGraphController
_initializeInteraction, clearAnimation, event, getAnimationDelay, getConfiguration, getConfigureMenuFactory, getFrame, getNodeController, message, setAnimationDelay, setFigure, setFrame, valueChanged
 
Methods inherited from class diva.graph.AbstractGraphController
addEdge, addEdge, addGraphViewListener, addNode, addNode, addNode, addNode, clear, clearEdge, clearNode, dispatch, drawEdge, drawNode, drawNode, getEdgeController, getFigure, getGraphModel, getGraphPane, getSelectionModel, removeEdge, removeGraphViewListener, removeNode, rerender, rerenderEdge, rerenderNode, setGraphModel, setGraphPane, setSelectionModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_errorHighlights

private java.util.List<Attribute> _errorHighlights
List of error highlight attributes we have created.


_manager

private Manager _manager
The manager we are currently listening to.


_pauseModelAction

private javax.swing.Action _pauseModelAction
Action for pausing the model.


_previousState

private Manager.State _previousState
The previous state of the manager, to avoid reporting it if it hasn't changed.


_runModelAction

private javax.swing.Action _runModelAction
Action for running the model.


_stopModelAction

private javax.swing.Action _stopModelAction
Action for stopping the model.

Constructor Detail

RunnableGraphController

public RunnableGraphController()
Create a new controller.

Method Detail

addToMenuAndToolbar

public void addToMenuAndToolbar(javax.swing.JMenu menu,
                                javax.swing.JToolBar toolbar)
Add execution commands to the toolbar.

Overrides:
addToMenuAndToolbar in class BasicGraphController
Parameters:
menu - The menu to add to, which is ignored.
toolbar - The toolbar to add to, or null if none.

executionError

public void executionError(Manager manager,
                           java.lang.Throwable throwable)
Report that an execution error has occurred. This method is called by the specified manager.

Specified by:
executionError in interface ExecutionListener
Parameters:
manager - The manager calling this method.
throwable - The throwable being reported.

executionFinished

public void executionFinished(Manager manager)
Report that execution of the model has finished.

Specified by:
executionFinished in interface ExecutionListener
Parameters:
manager - The manager calling this method.

managerStateChanged

public void managerStateChanged(Manager manager)
Report that a manager state has changed. This method is called by the specified manager.

Specified by:
managerStateChanged in interface ExecutionListener
Parameters:
manager - The manager calling this method.
See Also:
Manager.getState()

_addHotKeys

protected void _addHotKeys(JGraph jgraph)
Add hot keys to the actions in the given JGraph.

Overrides:
_addHotKeys in class BasicGraphController
Parameters:
jgraph - The JGraph to which hot keys are to be added.

_getManager

protected Manager _getManager()
                       throws IllegalActionException
Get the manager for the top-level of the associated model, if there is one, or create one if there is not.

Returns:
The manager.
Throws:
IllegalActionException - If the associated model is not a CompositeActor, or if the manager cannot be created.

_addErrorHighlightIfNeeded

private void _addErrorHighlightIfNeeded(Nameable culprit)
                                 throws IllegalActionException,
                                        NameDuplicationException
Add an error highlight color to the specified culprit if it is not already present.

Parameters:
culprit - The culprit to highlight.
Throws:
IllegalActionException - If the highlight cannot be added.
NameDuplicationException - Should not be thrown.

_highlightError

private void _highlightError(Nameable culprit)
Highlight the specified object and all its containers to indicate that it is the source of an error.

Parameters:
culprit - The culprit.