Class UserActorLibrary
- java.lang.Object
-
- ptolemy.actor.gui.UserActorLibrary
-
public class UserActorLibrary extends java.lang.Object
Access the User Actor Library.- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Christopher Brooks, based on work by Steve Neuendorffer, Edward A. Lee, Contributor: Chad Berkeley (Kepler)
- Pt.AcceptedRating:
- Red (neuendor)
- Pt.ProposedRating:
- Red (neuendor)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
USER_LIBRARY_NAME
The name of the user library.
-
Constructor Summary
Constructors Constructor Description UserActorLibrary()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
openLibrary(Configuration configuration, java.io.File file)
Open the MoML file at the given location as a new library in the actor library for this application.static void
openUserLibrary(Configuration configuration)
Open the user actor library as a new library in the actor library for this application.static void
saveComponentInLibrary(Configuration configuration, Entity entity)
Save the given entity in the user library in the given configuration.
-
-
-
Method Detail
-
openUserLibrary
public static void openUserLibrary(Configuration configuration) throws java.lang.Exception
Open the user actor library as a new library in the actor library for this application.The name of the user actor library consists of the values of
StringUtilities.preferencesDirectory()
andUSER_LIBRARY_NAME
and ".xml" concatenated.An alternate class can be used to build the library if reading the MoML is not desired. The class must extend ptolemy.moml.LibraryBuilder and the _alternateLibraryBuilder property must be set with the 'value' set to the class that extends LibraryBuilder.
- Parameters:
configuration
- The configuration where we look for the actor library.- Throws:
java.lang.Exception
- If there is a problem opening the configuration, opening the MoML file, or opening the MoML file as a new library.
-
openLibrary
public static void openLibrary(Configuration configuration, java.io.File file) throws java.lang.Exception
Open the MoML file at the given location as a new library in the actor library for this application.An alternate class can be used to build the library if reading the MoML is not desired. The class must extend ptolemy.moml.LibraryBuilder and the _alternateLibraryBuilder property must be set with the 'value' set to the class that extends LibraryBuilder.
A library of components is a .xml file that defines a MoML Class that extends ptolemy.moml.EntityLibrary, for example, the following file creates a library called "MyActors" that has an XYPlotter in the library:
<?xml version="1.0" standalone="no"?> <!DOCTYPE class PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd"> <class name="MyActors" extends="ptolemy.moml.EntityLibrary"> <configure> <group> <entity name="XY Plotter" class="ptolemy.actor.lib.gui.XYPlotter"/> </group> </configure> </class>
Note that one restriction is to see the new library, one must open a new Graph viewer (New -> Graph).
- Parameters:
configuration
- The configuration where we look for the actor library.file
- The MoML file to open.- Throws:
java.lang.Exception
- If there is a problem opening the configuration, opening the MoML file, or opening the MoML file as a new library.
-
saveComponentInLibrary
public static void saveComponentInLibrary(Configuration configuration, Entity entity) throws java.io.IOException, IllegalActionException, NameDuplicationException
Save the given entity in the user library in the given configuration.- Parameters:
configuration
- The configuration.entity
- The entity to save.- Throws:
java.io.IOException
- if the user library cannot be found.IllegalActionException
- If there is a problem creating the entity in the library.NameDuplicationException
- If a entity with the same name already exists in the library.- Since:
- Ptolemy II 5.2
-
-