Package ptolemy.moml
Class LibraryAttribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.ConfigurableAttribute
-
- ptolemy.moml.LibraryAttribute
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Configurable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
public class LibraryAttribute extends ConfigurableAttribute
This class is a configurable singleton attribute that associates a component library with a model. By convention, it is typically named "_library". A visual editor that opens a model containing this attribute will offer the contents of its library as the component library for editing the model. "Singleton" means that if this attribute is placed in a model, it will replace any previous singleton attribute that has the same name. "Configurable" means that the contents of the library can be set in a configure element in MoML, or via the configure() method. The library can also be set by calling setLibrary(); this will override any library specified by configure.When creating a library to associate with this attribute, the library should be created in the same workspace as this attribute (as returned by the workspace() method). Normally, it will have no container. The text specified in the configure element (or a call to the configure() method) is not parsed until the getLibrary() method is called. Thus, the overhead of creating the library is avoided if the library is not used.
- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (janneck)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
-
-
Field Summary
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
-
-
Constructor Summary
Constructors Constructor Description LibraryAttribute()
Construct a new attribute with no container and an empty string as its name.LibraryAttribute(NamedObj container, java.lang.String name)
Construct an attribute with the given container and name.LibraryAttribute(Workspace workspace)
Construct a new attribute with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompositeEntity
getLibrary()
Return the library specified by the configure() method or the setLibrary() method, or null if it has not been set.void
setLibrary(CompositeEntity library)
Specify the library, overriding any library that might have been or might later be specified by a call to configure().-
Methods inherited from class ptolemy.kernel.util.ConfigurableAttribute
_exportMoMLContents, _propagateValue, addValueListener, clone, configure, getBase, getConfigureSource, getConfigureText, getDefaultExpression, getExpression, getValueAsString, getVisibility, removeValueListener, setExpression, setVisibility, validate, value
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.kernel.util.Settable
getDisplayName
-
-
-
-
Constructor Detail
-
LibraryAttribute
public LibraryAttribute()
Construct a new attribute with no container and an empty string as its name. Add the attribute to the workspace directory. Increment the version number of the workspace.
-
LibraryAttribute
public LibraryAttribute(Workspace workspace)
Construct a new attribute with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. Add the attribute to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the attribute.
-
LibraryAttribute
public LibraryAttribute(NamedObj container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an attribute with the given container and name. If an attribute already exists with the same name as the one specified here, that is an instance of class LibraryAttribute (or a derived class), then that attribute is removed before this one is inserted in the container.- Parameters:
container
- The container.name
- The name of this attribute.- Throws:
IllegalActionException
- If the attribute cannot be contained by the proposed container.NameDuplicationException
- If the container already has an attribute with this name, and the class of that container is not LibraryAttribute.
-
-
Method Detail
-
getLibrary
public CompositeEntity getLibrary() throws java.lang.Exception
Return the library specified by the configure() method or the setLibrary() method, or null if it has not been set. If the configure() method has defined the library, then calling this method will parse the MoML in specified in the configure() call to create the library. The parser for the top-level container of this attribute will be used, if there is one. Otherwise, a new parser will be used. Note that the library will be reparsed each time this is called. This method ensures that the library that is returned contains an attribute called "_libraryMarker" so that a user interface recognizes it as a library.- Returns:
- The library, or null if none.
- Throws:
java.lang.Exception
- If the library specification is invalid, for example because the MoML cannot be parsed, or because it does not define an instance of CompositeEntity.- See Also:
setLibrary(CompositeEntity)
-
setLibrary
public void setLibrary(CompositeEntity library)
Specify the library, overriding any library that might have been or might later be specified by a call to configure(). This method ensures that the library contains an attribute named "_libraryMarker" by creating one if it is not there.- Parameters:
library
- The library.- See Also:
getLibrary()
-
-