public class Configuration extends CompositeEntity implements ApplicationConfigurer, InstanceOpener
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 foo
, then you can call:
Effigy effigy = Configuration.findEffigy(foo.toplevel()); Configuration configuration = effigy.toplevel();
EffigyFactory
,
ModelDirectory
,
Tableau
,
TextEditorTableau
CompositeEntity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_DIRECTORY_NAME
The name of the model directory.
|
Parameter |
classesToRemove
A Parameter that is an array of Strings where each element
names a class to be removed.
|
Parameter |
removeGraphicalClasses
A Parameter that if set to true adds
RemoveGraphicalClasses to the list of
MoMLFilters. |
_levelCrossingLinks
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
Configuration(Workspace workspace)
Construct an instance in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_removeEntity(ComponentEntity entity)
Remove the specified entity; if that entity is the model directory,
then exit the application.
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
java.lang.String |
check()
Check the configuration for common style problems.
|
static java.lang.String |
checkCloneFields(NamedObj namedObj)
Check that clone(Workspace) method properly sets the fields.
|
static void |
closeAllTableaux()
Close all the tableaux.
|
static java.util.List<Configuration> |
configurations()
Return a list of all the configurations that have been created.
|
Tableau |
createPrimaryTableau(Effigy effigy)
Create the first tableau for the given effigy, using the
tableau factory.
|
static Effigy |
findEffigy(NamedObj model)
Find an effigy for the specified model by searching all the
configurations that have been created.
|
ModelDirectory |
getDirectory()
Get the model directory.
|
PtolemyEffigy |
getEffigy(NamedObj model)
Get the effigy for the specified Ptolemy model.
|
java.lang.Object |
getStringParameterAsClass(java.lang.String parameterName,
java.lang.Class[] constructorParameterTypes,
java.lang.Object[] constructorParameterClass)
Instantiate the class named by a StringParameter in the configuration.
|
void |
openAnInstance(NamedObj entity)
Open the specified instance.
|
Tableau |
openInstance(NamedObj entity)
Open the specified instance.
|
Tableau |
openInstance(NamedObj entity,
CompositeEntity container)
Open the specified instance.
|
Tableau |
openModel(NamedObj entity)
Open the specified Ptolemy II model.
|
Tableau |
openModel(NamedObj entity,
CompositeEntity container)
Open the specified Ptolemy II model.
|
Tableau |
openModel(java.net.URL base,
java.net.URL in,
java.lang.String identifier)
Open the specified URL.
|
Tableau |
openModel(java.net.URL base,
java.net.URL in,
java.lang.String identifier,
EffigyFactory factory)
Open the specified URL using the specified effigy factory.
|
(package private) void |
removeConfiguration(Configuration configuration)
Remove the configuration from the list of configurations.
|
void |
setContainer(CompositeEntity container)
If the argument is not null, then throw an exception.
|
void |
showAll()
Find all instances of Tableau deeply contained in the directory
and call show() on them.
|
_addEntity, _addRelation, _adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, clone, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, isOpaque, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, newRelation, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
_addPort, _removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDerivedLevel, getDerivedList, propagateValue
description, getDisplayName, getFullName, getName, getName
public Parameter classesToRemove
Kepler uses this parameter to remove certain classes:
<property name="_classesToRemove" class="ptolemy.data.expr.Parameter" value="{"ptolemy.codegen.kernel.StaticSchedulingCodeGenerator","ptolemy.codegen.c.kernel.CCodeGenerator"}"> <doc>An array of Strings, where each element names a class to removed by the MoMLFilter.</doc> >/property>
public Parameter removeGraphicalClasses
RemoveGraphicalClasses
to the list of
MoMLFilters. Use this to run non-graphical classes. Note that
setting this parameter and using MoMLApplication is not likely
to work as MoMLApplication sets the look and feel which invokes
the graphical system. The initial value is a boolean with the
value false, indicating that RemoveGraphicalClasses should not
be added to the filter list.public static final java.lang.String _DIRECTORY_NAME
public Configuration(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace that will list the entity.IllegalActionException
- If the container is incompatible
with this entity.NameDuplicationException
- If the name coincides with
an entity already in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public java.lang.String check() throws java.lang.Exception
java.lang.Exception
- If there is a problem cloning the configuration.public static java.lang.String checkCloneFields(NamedObj namedObj) throws java.lang.CloneNotSupportedException, java.lang.IllegalAccessException, IllegalActionException, NameDuplicationException, java.lang.ClassNotFoundException
namedObj
- The NamedObj, usually a Director, Attribute
or actor to be checked.java.lang.CloneNotSupportedException
- If namedObj does not support
clone(Workspace).java.lang.IllegalAccessException
- If there is a problem getting
a field.java.lang.ClassNotFoundException
- If a class cannot be found.IllegalActionException
NameDuplicationException
public static void closeAllTableaux() throws IllegalActionException
IllegalActionException
- If thrown while accessing the Configuration
or while closing the tableaux.public static java.util.List<Configuration> configurations()
public Tableau createPrimaryTableau(Effigy effigy)
effigy
- The effigy for which to create a tableau.public static Effigy findEffigy(NamedObj model)
model
- The model for which to find an effigy.public java.lang.Object getStringParameterAsClass(java.lang.String parameterName, java.lang.Class[] constructorParameterTypes, java.lang.Object[] constructorParameterClass) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, IllegalActionException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
parameterName
- The name of the StringParameter in the configuration.constructorParameterTypes
- An array of parameter types, null if there
are no parametersconstructorParameterClass
- An array of objects to pass to the constructor.java.lang.ClassNotFoundException
- If the class named by
parameterName cannot be found.java.lang.IllegalAccessException
- If the constructor is not accessible.IllegalActionException
- If thrown while reading the
parameter named by parameterName.java.lang.InstantiationException
- If the object cannot be instantiatedjava.lang.reflect.InvocationTargetException
- If
there is problem invoking the constructor.java.lang.NoSuchMethodException
- If there is no constructor with the type.public ModelDirectory getDirectory()
public PtolemyEffigy getEffigy(NamedObj model)
model
- The Ptolemy model.public void openAnInstance(NamedObj entity) throws IllegalActionException, NameDuplicationException
openAnInstance
in interface InstanceOpener
entity
- The entity to open.IllegalActionException
- If constructing an effigy or tableau
fails.NameDuplicationException
- If a name conflict occurs (this
should not be thrown).public Tableau openInstance(NamedObj entity) throws IllegalActionException, NameDuplicationException
entity
- The entity to open.IllegalActionException
- If constructing an effigy or tableau
fails.NameDuplicationException
- If a name conflict occurs (this
should not be thrown).public Tableau openInstance(NamedObj entity, CompositeEntity container) throws IllegalActionException, NameDuplicationException
entity
- The model.container
- The container for any new effigy.IllegalActionException
- If constructing an effigy or tableau
fails.NameDuplicationException
- If a name conflict occurs (this
should not be thrown).public Tableau openModel(java.net.URL base, java.net.URL in, java.lang.String identifier) throws java.lang.Exception
base
- The base for relative file references, or null if
there are no relative file references.in
- The input URL.identifier
- The identifier that uniquely identifies the model.java.lang.Exception
- If the URL cannot be read.public Tableau openModel(java.net.URL base, java.net.URL in, java.lang.String identifier, EffigyFactory factory) throws java.lang.Exception
base
- The base for relative file references, or null if
there are no relative file references.in
- The input URL.identifier
- The identifier that uniquely identifies the model.factory
- The effigy factory to use.java.lang.Exception
- If the URL cannot be read.public Tableau openModel(NamedObj entity) throws IllegalActionException, NameDuplicationException
entity
- The model.IllegalActionException
- If constructing an effigy or tableau
fails.NameDuplicationException
- If a name conflict occurs (this
should not be thrown).public Tableau openModel(NamedObj entity, CompositeEntity container) throws IllegalActionException, NameDuplicationException
entity
- The model.container
- The container for any new effigy.IllegalActionException
- If constructing an effigy or tableau
fails.NameDuplicationException
- If a name conflict occurs (this
should not be thrown).public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class CompositeEntity
container
- The proposed container. If the proposed
container is null, then super.setContainer(null) is invoked,
which may free up memory.IllegalActionException
- If the argument is not null.NameDuplicationException
- If thrown by a parent class.ComponentEntity.getContainer()
public void showAll()
void removeConfiguration(Configuration configuration)
configuration
- The configuration to be removed.protected void _removeEntity(ComponentEntity entity)
_removeEntity
in class CompositeEntity
entity
- The entity to remove.