Configuration
ptolemy.actor.gui.Configuration

This is a base class for a composite entity that defines the configuration of an application that uses Ptolemy II classes. An instance of this class is in charge of the user interface, and coordinates multiple views of multiple models. One of its functions, for example, is to manage the opening of new models, ensuring that an appropriate view is used. It also makes sure that if a model is opened that is already open, then existing views are shown rather than creating new views.

The applications vergil and moml (at least) use configurations defined in MoML files, typically located in ptII/ptolemy/configs. The moml application takes as command line arguments a list of MoML files, the first of which is expected to define an instance of Configuration and its contents. That configuration is then used to open subsequent MoML files on the command line, and to manage the user interface.

Rather than performing all these functions itself, this class is a container for a model directory, effigy factories, and tableau factories that actually realize these functions. An application is configured by populating an instance of this class with a suitable set of these other classes. A minimal configuration defined in MoML is shown below:

 <?xml version="1.0" standalone="no"?>
 <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
 "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
 <entity name="configuration" class="ptolemy.actor.gui.Configuration">
 <doc>Configuration to run but not edit Ptolemy II models</doc>
 <entity name="directory" class="ptolemy.actor.gui.ModelDirectory"/>
 <entity name="effigyFactory" class="ptolemy.actor.gui.PtolemyEffigy$Factory"/>
 <property name="tableauFactory" class="ptolemy.actor.gui.RunTableau$Factory"/>
 </entity>
 

It must contain, at a minimum, an instance of ModelDirectory, named "directory", and an instance of EffigyFactory, named "effigyFactory". The openModel() method delegates to the effigy factory the opening of a model. It may also contain an instance of TextEditorTableauFactory, named "tableauFactory". A tableau is a visual representation of the model in a top-level window. The above minimal configuration can be used to run Ptolemy II models by opening a run panel only.

When the directory becomes empty (all models have been closed), it removes itself from the configuration. When this happens, the configuration calls System.exit() to exit the application.

To access the configuration from a random place, if you have a NamedObj, then you can call Configuration.findEffigy(). This is a static method. Then call Effigy.toplevel(). The result will always be the configuration.

Author(s): Steve Neuendorffer and Edward A. Lee
Version:$Id: Configuration.java,v 1.101 2006/05/22 20:50:59 cxh Exp $
Pt.Proposed Rating:Green (eal)
Pt.Accepted Rating:Yellow (celaine)