org.formaria.aria
Class ProjectManager

java.lang.Object
  extended by org.formaria.aria.ProjectManager
Direct Known Subclasses:
EditorProjectManager

public class ProjectManager
extends java.lang.Object

A central repository for Projects. Several projects may be run within a single VM instance, for example in the case of a browser where a shared VM is used with multiple applets. The project manager allows only one active or current project.

Since:
1.03

Copyright (c) Formaria Ltd., 2008

$Revision: 2.4 $

License: see License.txt


Field Summary
protected static Project currentProject
          The current Project being used
protected static java.util.Hashtable globalObjects
           
protected static java.util.Hashtable projects
          A store for projects.
 
Constructor Summary
ProjectManager()
          null ctor
 
Method Summary
static java.lang.String addProject(java.lang.String name, Project proj)
          Add a new project
static Project getCurrentProject()
          Get the current or active project, in most cases getCurrentProject( StartupObject ) should be called instead of getCurrentProject.
static Project getCurrentProject(StartupObject so)
          Get the current or active project.
static DataModel getModel()
          Deprecated. please use currentProject.getModel() instead
static java.lang.Object getObject(java.lang.String key)
          Get a manager object
static PageManager getPageManager()
          Deprecated. please use currentProject.getPageManager() instead
static Project getProject(java.lang.String name)
          Get a named project, the project is then set as the current project.
 java.lang.String[] getProjectNames()
          Get the names of the projects currently loaded
static StyleManager getStyleManager()
          Deprecated. please use currentProject.getStyleManager() instead
static XmlParserFactory getXmlParserFactory()
          Deprecated. please use currentProject.getXmlParserFactory() instead
static void removeObject(java.lang.String key)
          Remove a manager object value
static void setCurrentProject(Project proj)
          Set the current project
static void setObject(java.lang.String key, java.lang.Object obj)
          Set an manager object value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentProject

protected static Project currentProject
The current Project being used


projects

protected static java.util.Hashtable projects
A store for projects.


globalObjects

protected static java.util.Hashtable globalObjects
Constructor Detail

ProjectManager

public ProjectManager()
null ctor

Method Detail

getCurrentProject

public static Project getCurrentProject()
Get the current or active project, in most cases getCurrentProject( StartupObject ) should be called instead of getCurrentProject. Care should be taken when calling this project as the current project may not correspond to the project that 'owns' the calling object. The best point to call this method is when an object is being instantiated and thereafter the object should hold a reference to the project.

Returns:
the current project

getCurrentProject

public static Project getCurrentProject(StartupObject so)
Get the current or active project. This method will instantiate a new project if one down't already exist. Care should be taken when calling this project as the current project may not correspond to the project that 'owns' the calling object. The best point to call this method is when an object is being instantiated and thereafter the object should hold a reference to the project.

Parameters:
so - the startup object that initiates/owns the project
Returns:
the current project

setCurrentProject

public static void setCurrentProject(Project proj)
Set the current project

Parameters:
proj - the new current project

getStyleManager

public static StyleManager getStyleManager()
Deprecated. please use currentProject.getStyleManager() instead

Get a reference to the StyleManager in the current project

Returns:
the style manager

getPageManager

public static PageManager getPageManager()
Deprecated. please use currentProject.getPageManager() instead

Gets an instance of the page manager in the current project

Returns:
the PageManager instance

getModel

public static DataModel getModel()
Deprecated. please use currentProject.getModel() instead

Gets the root instance of the DataModel in the current project

Returns:
the root DataModel node

getXmlParserFactory

public static XmlParserFactory getXmlParserFactory()
Deprecated. please use currentProject.getXmlParserFactory() instead

Gets the root instance of the DataModel in the current project

Returns:
the root DataModel node

getProjectNames

public java.lang.String[] getProjectNames()
Get the names of the projects currently loaded

Returns:
an array of project names

getProject

public static Project getProject(java.lang.String name)
Get a named project, the project is then set as the current project.

Returns:
the named project or null if it is not found

addProject

public static java.lang.String addProject(java.lang.String name,
                                          Project proj)
Add a new project

Parameters:
name - the name by which the project will be know, if null is passed a name will be synthesized for the project.
proj - the project
Returns:
the name of the project

getObject

public static java.lang.Object getObject(java.lang.String key)
Get a manager object

Parameters:
key - the name of the object e.g. "Routes", "Services"
Returns:
the object instance or null if it hasn't been added

setObject

public static void setObject(java.lang.String key,
                             java.lang.Object obj)
Set an manager object value

Parameters:
key - the name of the object e.g. "Routes", "Services"
obj - the object instance

removeObject

public static void removeObject(java.lang.String key)
Remove a manager object value

Parameters:
key - the name of the object e.g. "Routes", "Services"