org.argouml.kernel
Class ProjectManager

java.lang.Object
  extended byorg.argouml.kernel.ProjectManager

public final class ProjectManager
extends java.lang.Object

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
private static Project _currentProject
          The project that is visible in the projectbrowser
private  java.beans.PropertyChangeEvent _event
          The event to fire
private static ProjectManager _instance
          The singleton instance of this class
private  javax.swing.event.EventListenerList _listenerList
          The listener list
private static org.apache.log4j.Logger cat
          logger
static java.lang.String CURRENT_PROJECT_PROPERTY_NAME
           
static java.lang.String SAVE_STATE_PROPERTY_NAME
           
 
Constructor Summary
private ProjectManager()
          Constructor for ProjectManager.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds an instance implementing propertychangelistener to the listener list
private  void firePropertyChanged(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 Project getCurrentProject()
          Returns the current project.
static ProjectManager getManager()
          The singleton accessor method of this class
 Project loadProject(java.net.URL url)
          This method creates a project from the specified URL Unlike the constructor which forces an .argo extension This method will attempt to load a raw XMI file This method can fail in several different ways.
private  Project loadProjectFromArgo(java.net.URL url)
          Loads a project from an url of the argo format.
private  Project loadProjectFromXMI(java.net.URL url)
          Reads an XMI file.
private  Project loadProjectFromZargo(java.net.URL url)
          Reads an url of the .zargo format.
 Project makeEmptyProject()
          Makes an empty project with two standard diagrams.
 void notifySavePropertyChanged(boolean newValue)
          notify the gui from the project manager that the current project's save state has changed.
 void removeProject(Project oldProject)
          prepare project for gc
 void removePropertyChangeListener(java.beans.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).
 
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 java.lang.String CURRENT_PROJECT_PROPERTY_NAME
See Also:
Constant Field Values

SAVE_STATE_PROPERTY_NAME

public static final java.lang.String SAVE_STATE_PROPERTY_NAME
See Also:
Constant Field Values

cat

private static org.apache.log4j.Logger cat
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 javax.swing.event.EventListenerList _listenerList
The listener list


_event

private java.beans.PropertyChangeEvent _event
The event to fire

Constructor Detail

ProjectManager

private ProjectManager()
Constructor for ProjectManager.

Method Detail

getManager

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


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds an instance implementing propertychangelistener to the listener list

Parameters:
listener -

removePropertyChangeListener

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

Parameters:
listener -

firePropertyChanged

private void firePropertyChanged(java.lang.String propertyName,
                                 java.lang.Object oldValue,
                                 java.lang.Object newValue)

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.

Returns:
Project

makeEmptyProject

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

Returns:
Project

loadProject

public Project loadProject(java.net.URL url)
                    throws java.io.IOException,
                           IllegalFormatException,
                           org.xml.sax.SAXException,
                           javax.xml.parsers.ParserConfigurationException
This method creates a project from the specified URL Unlike the constructor which forces an .argo extension This method will attempt to load a raw XMI file This method can fail in several different ways. Either by throwing an exception or by having the ArgoParser.SINGLETON.getLastLoadStatus() set to not true. TODO: The exception in the throws clause should be splitted in several other types of exceptions to handle errors better

Throws:
java.io.IOException
IllegalFormatException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

loadProjectFromXMI

private Project loadProjectFromXMI(java.net.URL url)
                            throws java.io.IOException
Reads an XMI file.

This could be used to import models from other tools.

Parameters:
url - is the file name of the file
Returns:
Project is a new project containing the read model
Throws:
java.io.IOException - is thrown if some error occurs

loadProjectFromZargo

private Project loadProjectFromZargo(java.net.URL url)
                              throws java.io.IOException,
                                     org.xml.sax.SAXException,
                                     javax.xml.parsers.ParserConfigurationException
Reads an url of the .zargo format.

Parameters:
url -
Returns:
Project
Throws:
java.lang.Exception - if there is an exception during load. Should be handled by the GUI.
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

loadProjectFromArgo

private Project loadProjectFromArgo(java.net.URL url)
                             throws java.io.IOException,
                                    javax.xml.parsers.ParserConfigurationException,
                                    org.xml.sax.SAXException
Loads a project from an url of the argo format.

Parameters:
url -
Returns:
Project
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

notifySavePropertyChanged

public void notifySavePropertyChanged(boolean newValue)
notify the gui from the project manager that the current project's save state has changed.


removeProject

public void removeProject(Project oldProject)
prepare project for gc



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