org.argouml.kernel
Class ProjectManager

java.lang.Object
  extended byorg.argouml.kernel.ProjectManager
All Implemented Interfaces:
EventListener, PropertyChangeListener

public final class ProjectManager
extends Object
implements PropertyChangeListener

This class manages the projects loaded in argouml. 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.

Since:
Nov 17, 2002

Field Summary
private  boolean creatingCurrentProject
          Flag to indicate we are creating a new current project
static String CURRENT_PROJECT_PROPERTY_NAME
          The name of the property that defines the current project.
private static Project currentProject
          The project that is visible in the projectbrowser
private  PropertyChangeEvent event
          The event to fire.
private static ProjectManager instance
          The singleton instance of this class
private  EventListenerList listenerList
          The listener list
private static Logger LOG
          logger
static String NO_PROJECT
          The name of the property that there is no project.
static String SAVE_STATE_PROPERTY_NAME
          The name of the property that defines the save state.
 
Constructor Summary
private ProjectManager()
          Constructor for ProjectManager.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener to the listener list.
private  void firePropertyChanged(String propertyName, Object oldValue, Object newValue)
          Fire an event to all members of the listener list.
 Project getCurrentProject()
          Returns the current project.
static ProjectManager getManager()
          The singleton accessor method of this class.
 Project makeEmptyProject()
          Makes an empty project with two standard diagrams.
 boolean needsSave()
          Test if the model needs to be saved.
 void propertyChange(PropertyChangeEvent pce)
          React to PropertyChangeEvents, e.g.
 void removeProject(Project oldProject)
          Remove the project.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a listener from the listener list.
 void setCurrentProject(Project newProject)
          Sets the current project (the project that is viewable in the projectbrowser).
 void setNeedsSave(boolean newValue)
          Notify the gui that the current project's save state has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_PROJECT_PROPERTY_NAME

public static final String CURRENT_PROJECT_PROPERTY_NAME
The name of the property that defines the current project.

See Also:
Constant Field Values

NO_PROJECT

public static final String NO_PROJECT
The name of the property that there is no project.

See Also:
Constant Field Values

SAVE_STATE_PROPERTY_NAME

public static final String SAVE_STATE_PROPERTY_NAME
The name of the property that defines the save state.

See Also:
Constant Field Values

LOG

private static final Logger LOG
logger


instance

private static ProjectManager instance
The singleton instance of this class


currentProject

private static Project currentProject
The project that is visible in the projectbrowser


creatingCurrentProject

private boolean creatingCurrentProject
Flag to indicate we are creating a new current project


listenerList

private EventListenerList listenerList
The listener list


event

private PropertyChangeEvent event
The event to fire. TODO: Investigate! Is the purpose really to let the next call to firePropertyChanged(String, Object, Object) fire the old event again if the previous invocation resulted in an exception? If so, please document why. If not, fix it.

Constructor Detail

ProjectManager

private ProjectManager()
Constructor for ProjectManager.

Method Detail

getManager

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

Returns:
The singleton.

addPropertyChangeListener

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

Parameters:
listener - The listener to add.

removePropertyChangeListener

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

Parameters:
listener - The listener to remove.

firePropertyChanged

private void firePropertyChanged(String propertyName,
                                 Object oldValue,
                                 Object newValue)
Fire an event to all members of the listener list.

Parameters:
propertyName - The name of the event.
oldValue - The old value.
newValue - The new value.

setCurrentProject

public void setCurrentProject(Project newProject)
Sets the current project (the project that is viewable in the projectbrowser). 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()
Returns the current project.

If there is no project, a new one is created.

Returns:
Project The current project.

makeEmptyProject

public Project makeEmptyProject()
Makes an empty project with two standard diagrams.

Returns:
Project

needsSave

public boolean needsSave()
Test if the model needs to be saved.

Returns:
true if the model needs to be saved.

setNeedsSave

public void setNeedsSave(boolean newValue)
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 *).

Parameters:
newValue - The new state.

removeProject

public void removeProject(Project oldProject)
Remove the project.

Parameters:
oldProject - The project to be removed.

propertyChange

public void propertyChange(PropertyChangeEvent pce)
React to PropertyChangeEvents, e.g. send by the Designer.

Specified by:
propertyChange in interface PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook