org.argouml.kernel
Class ProjectManager

java.lang.Object
  extended by org.argouml.kernel.ProjectManager
All Implemented Interfaces:
ModelCommandCreationObserver

public final class ProjectManager
extends java.lang.Object
implements ModelCommandCreationObserver

This class manages the projects loaded in argouml, and what the current project is.

Classes in ArgoUML can ask this class for the current project and set the current project. Since we only have one project in ArgoUML at the moment, this class does not manage a list of projects like one would expect. This could be a nice extension for the future of ArgoUML. As soon as the current project is changed, a property changed event is fired.

TODO: Move everything related to the creation of a project into the ProjectFactory.

Since:
Nov 17, 2002
Stereotype:
singleton

Field Summary
static java.lang.String CURRENT_PROJECT_PROPERTY_NAME
          Deprecated. for 0.27.2 by tfmorris. Listeners of this event which expect it to indicate a new project being opened should listen for OPEN_PROJECTS_PROPERTY. Listeners who think they need to know a single global current project need to be changed to deal with things on a per-project basis.
static java.lang.String OPEN_PROJECTS_PROPERTY
          Property name for list of current open projects.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a listener to the listener list.
 java.lang.Object execute(ModelCommand command)
          Called when the model subsystem creates a command.
 Project getCurrentProject()
          Deprecated. for 0.27.2 by tfmorris. There is no longer the concept of a single global "current" project. In the future, multiple projects will be able to be open at a time, so all code should be prepared to deal with multiple projects and should require a Project to be passed as an argument if they need access. To get a list of all currently open projects, use getOpenProjects(). For settings which affect renderings in diagrams use ArgoFig.getSettings().
static ProjectManager getManager()
          The singleton accessor method of this class.
 java.util.List<Project> getOpenProjects()
           
 boolean isSaveActionEnabled()
          Deprecated. for 0.27.2 by tfmorris. Use Project.isDirty().
 Project makeEmptyProfileProject()
          Makes an empty profile project.
 Project makeEmptyProfileProject(boolean addDefaultDiagrams)
          Make a new empty profile project optionally including default diagrams.
 Project makeEmptyProject()
          Makes an empty project.
 Project makeEmptyProject(boolean addDefaultDiagrams)
          Make a new empty project optionally including default diagrams.
 void removeProject(Project oldProject)
          Remove the project.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a listener from the listener list.
 void setCurrentProject(Project newProject)
          Deprecated. for 0.27.2 by tfmorris. There is no longer the concept of a single global "current" project. In the future, multiple projects will be able to be open at a time, so all code should be prepared to deal with multiple projects and should require a Project to be passed as an argument if they need access.
 void setSaveAction(javax.swing.Action save)
          Set the save action.
 void setSaveEnabled(boolean newValue)
          Deprecated. for 0.27.2 by tfmorris. Use Project.setDirty(boolean).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_PROJECT_PROPERTY_NAME

@Deprecated
public static final java.lang.String CURRENT_PROJECT_PROPERTY_NAME
Deprecated. for 0.27.2 by tfmorris. Listeners of this event which expect it to indicate a new project being opened should listen for OPEN_PROJECTS_PROPERTY. Listeners who think they need to know a single global current project need to be changed to deal with things on a per-project basis.
The name of the property that defines the current project. The values passed are Projects, not Strings. The 'name' here refers to the name of this property, not the name of the project.

See Also:
Constant Field Values

OPEN_PROJECTS_PROPERTY

public static final java.lang.String OPEN_PROJECTS_PROPERTY
Property name for list of current open projects. Old and new property values are of type Project[] (arrays of Projects).

See Also:
Constant Field Values
Method Detail

getManager

public static ProjectManager getManager()
The singleton accessor method of this class.

Returns:
The singleton.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener to the listener list.

Parameters:
listener - The listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener from the listener list.

Parameters:
listener - The listener to remove.

setCurrentProject

public void setCurrentProject(Project newProject)
Deprecated. for 0.27.2 by tfmorris. There is no longer the concept of a single global "current" project. In the future, multiple projects will be able to be open at a time, so all code should be prepared to deal with multiple projects and should require a Project to be passed as an argument if they need access.

Sets the current project (the project that is viewable in the projectbrowser). Sets the current diagram for the project (if one exists). This method fires a propertychanged event.

If the argument is null, then the current project will be forgotten about.

Parameters:
newProject - The new project.

getCurrentProject

public Project getCurrentProject()
Deprecated. for 0.27.2 by tfmorris. There is no longer the concept of a single global "current" project. In the future, multiple projects will be able to be open at a time, so all code should be prepared to deal with multiple projects and should require a Project to be passed as an argument if they need access. To get a list of all currently open projects, use getOpenProjects(). For settings which affect renderings in diagrams use ArgoFig.getSettings().

Returns the current project (ie the project which must recently had the user focus) or null if there is no current project.

This should only be used by callers who need to know the global state. Most things which need a project want the project that contains them, which they can discover by traversing their containing elements (e.g. Fig->Diagram->DiagramSettings).

Returns:
Project the current project or null if none

getOpenProjects

public java.util.List<Project> getOpenProjects()
Returns:
a list of the currently open Projects in the order they were opened

makeEmptyProject

public Project makeEmptyProject()
Makes an empty project.

Returns:
Project the empty project

makeEmptyProject

public Project makeEmptyProject(boolean addDefaultDiagrams)
Make a new empty project optionally including default diagrams.

Historically new projects have been created with two default diagrams (Class and Use Case). NOTE: ArgoUML currently requires at least one diagram for proper operation.

Parameters:
addDefaultDiagrams - if true the project will be be created with the two standard default diagrams (Class and Use Case)
Returns:
Project the newly created project

makeEmptyProfileProject

public Project makeEmptyProfileProject()
Makes an empty profile project.

Returns:
Project the empty profile project

makeEmptyProfileProject

public Project makeEmptyProfileProject(boolean addDefaultDiagrams)
Make a new empty profile project optionally including default diagrams.

Historically new projects have been created with two default diagrams (Class and Use Case). NOTE: ArgoUML currently requires at least one diagram for proper operation.

Parameters:
addDefaultDiagrams - if true the project will be be created with the standard default diagram (Class)
Returns:
Project the newly created profile project

setSaveAction

public void setSaveAction(javax.swing.Action save)
Set the save action.

Parameters:
save - the action to be used

isSaveActionEnabled

public boolean isSaveActionEnabled()
Deprecated. for 0.27.2 by tfmorris. Use Project.isDirty().

Returns:
true is the save action is currently enabled


setSaveEnabled

public void setSaveEnabled(boolean newValue)
Deprecated. for 0.27.2 by tfmorris. Use Project.setDirty(boolean).

Notify the gui that the current project's save state has changed. There are 2 receivers: the SaveProject tool icon and the title bar (for showing a *).


removeProject

public void removeProject(Project oldProject)
Remove the project.

Parameters:
oldProject - The project to be removed.

execute

public java.lang.Object execute(ModelCommand command)
Called when the model subsystem creates a command. We must add this to the UndoManager.

Specified by:
execute in interface ModelCommandCreationObserver
Parameters:
command - the command.
Returns:
result of the command, if any
See Also:
ModelCommandCreationObserver.execute(ModelCommand)


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook