ptolemy.actor.gui
Class UserActorLibrary

java.lang.Object
  extended by ptolemy.actor.gui.UserActorLibrary

public class UserActorLibrary
extends java.lang.Object

Access the User Actor Library.

Since:
Ptolemy II 5.2
Version:
$Id: UserActorLibrary.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Brooks, based on work by Steve Neuendorffer, Edward A. Lee, Contributor: Chad Berkeley (Kepler)
Accepted Rating:
Red (neuendor)
Proposed Rating:
Red (neuendor)

Field Summary
static java.lang.String USER_LIBRARY_NAME
          The name of the user library.
 
Constructor Summary
UserActorLibrary()
           
 
Method Summary
private static void _instantiateLibrary(CompositeEntity library, ModelDirectory directory, Configuration configuration, java.io.File file, CompositeEntity libraryContainer, PtolemyEffigy finalLibraryEffigy)
          instantiate a ComponentEntity and create the changeRequest to implement it in the model
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_LIBRARY_NAME

public static java.lang.String USER_LIBRARY_NAME
The name of the user library. The default value is "UserLibrary". The value of this variable is what appears in the Vergil left hand tree menu.

This variable is not final so that users of this class may change it.

Constructor Detail

UserActorLibrary

public UserActorLibrary()
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() and USER_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.

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
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.
Since:
Ptolemy II 5.2

_instantiateLibrary

private static void _instantiateLibrary(CompositeEntity library,
                                        ModelDirectory directory,
                                        Configuration configuration,
                                        java.io.File file,
                                        CompositeEntity libraryContainer,
                                        PtolemyEffigy finalLibraryEffigy)
                                 throws java.lang.Exception
instantiate a ComponentEntity and create the changeRequest to implement it in the model

Throws:
java.lang.Exception