org.argouml.kernel
Class Project

java.lang.Object
  |
  +--org.argouml.kernel.Project
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, TargetListener

public class Project
extends java.lang.Object
implements java.io.Serializable, TargetListener

A datastructure that represents the designer's current project. A Project consists of diagrams and UML models.

See Also:
Serialized Form

Field Summary
protected  MNamespace _currentNamespace
           
protected  MModel _defaultModel
           
protected  ChangeRegistry _saveRegistry
           
static java.lang.String ARGO_TEE
           
protected static Category cat
           
protected static OCLExpander expander
           
static java.lang.String TEMPLATES
           
static java.lang.String UNTITLED_FILE
           
 
Constructor Summary
Project()
           
Project(java.io.File file)
           
Project(java.net.URL url)
           
 
Method Summary
 void addDiagram(ArgoDiagram d)
           
 void addMember(ArgoDiagram d)
           
 void addMember(ProjectMemberTodoList pm)
           
 void addMember(java.lang.String name, java.lang.String type)
           
 void addModel(MNamespace m)
           
 void addSearchPath(java.lang.String searchpath)
           
static void addStat(java.util.Vector stats, java.lang.String name, int value)
           
 java.util.Collection findFigsForMember(java.lang.Object member)
          Finds all figs on the diagrams for some project member, including the figs containing the member (so for some operation, the containing figclass is returned).
 ProjectMember findMemberByName(java.lang.String name)
           
 java.net.URL findMemberURLInSearchPath(java.lang.String name)
           
 MClassifier findType(java.lang.String s)
          Searches for a type/classifier with name s.
 MClassifier findType(java.lang.String s, boolean defineNew)
          Searches for a type/classifier with name s.
 java.lang.Object findTypeInDefaultModel(java.lang.String name)
          Find a type by name in the default model.
 MClassifier findTypeInModel(java.lang.String s, MNamespace ns)
          Will only return first classifier with the matching name
 ArgoDiagram getActiveDiagram()
           
 java.lang.String getAuthorname()
           
 java.lang.String getBaseName()
          Added Eugenio's patches to load 0.8.1 projects.
 GenerationPreferences getCgPrefs()
          Returns the cgPrefs.
 MNamespace getCurrentNamespace()
           
 MModel getDefaultModel()
           
 java.lang.String getDescription()
           
 ArgoDiagram getDiagram(java.lang.String name)
          Finds a diagram with a specific name or UID.
 java.util.Vector getDiagrams()
           
 GenerationPreferences getGenerationPrefs()
           
 java.lang.String getHistoryFile()
           
 java.lang.Object getInitialTarget()
           
 java.util.Vector getMembers()
           
 MNamespace getModel()
           
 java.util.Collection getModels()
          Returns all models, including the default model (default.xmi).
 java.lang.String getName()
           
 int getPresentationCountFor(MModelElement me)
           
 MModel getRoot()
          Returns the root.
 ChangeRegistry getSaveRegistry()
          Returns the saveRegistry.
 java.util.Vector getSearchpath()
          Returns the searchpath.
 java.util.Vector getSearchPath()
           
static java.util.Vector getStats()
           
 java.net.URL getUrl()
          Returns the url.
 java.net.URL getURL()
           
 java.util.Vector getUserDefinedModels()
          Returns all models defined by the user.
 java.util.HashMap getUUIDRefs()
          Returns the uUIDRefs.
 java.lang.String getVersion()
           
 java.beans.VetoableChangeSupport getVetoSupport()
           
 boolean isInTrash(java.lang.Object dm)
           
 boolean isNeedsSave()
          Returns the needsSave.
 boolean isValidDiagramName(java.lang.String name)
          Returns true if the given name is a valid name for a diagram.
 void loadAllMembers()
           
 void loadMembersOfType(java.lang.String type)
           
protected  MModel loadModelFromXMI(java.net.URL url)
          Deprecated. As of ArgoUml version unknown, replaced by unknown.
protected  void loadZippedProjectMembers(java.net.URL url)
          Loads all the members from a zipped input stream.
protected  void makeUntitledProject()
          Makes a just created project to an untitled project with a class diagram and a usecase diagram and an untitled model.
 void moveFromTrash(java.lang.Object obj)
           
 void moveToTrash(java.lang.Object obj)
          Moves some object to trash.
 boolean needsSave()
           
 void postLoad()
          Deprecated. As of 28 Apr 2003 (ArgoUml version 0.13.5). Will be protected in future. TODO: Replace by?
protected  void removeDiagram(ArgoDiagram d)
          Removes a diagram from the list with diagrams.
protected  void removeProjectMemberDiagram(ArgoDiagram d)
          Removes a project member diagram completely from the project.
static void resetStats()
           
 void save(boolean overwrite, java.io.File file)
          There are known issues with saving, particularly losing the xmi at save time. see issue http://argouml.tigris.org/issues/show_bug.cgi?
 void setActiveDiagram(ArgoDiagram diagram)
           
 void setAuthorname(java.lang.String s)
           
 void setCgPrefs(GenerationPreferences cgPrefs)
          Sets the cgPrefs.
 void setCurrentNamespace(MNamespace m)
           
 void setDefaultModel(MModel defaultModel)
           
 void setDescription(java.lang.String s)
           
 void setDiagrams(java.util.Vector diagrams)
          Sets the diagrams.
 void setFile(java.io.File file)
           
 void setGenerationPrefs(GenerationPreferences cgp)
           
 void setHistoryFile(java.lang.String s)
           
 void setMembers(java.util.Vector members)
          Sets the members.
 void setModels(java.util.Vector models)
          Sets the models.
 void setName(java.lang.String n)
           
 void setNeedsSave(boolean newValue)
           
 void setRoot(MModel root)
          Sets the root.
 void setSaveRegistry(ChangeRegistry saveRegistry)
          Sets the saveRegistry.
 void setSearchpath(java.util.Vector searchpath)
          Sets the searchpath.
static void setStat(java.lang.String n, int v)
           
 void setUrl(java.net.URL url)
          Sets the url.
 void setURL(java.net.URL url)
           
 void setUUIDRefs(java.util.HashMap uUIDRefs)
          Sets the uUIDRefs.
 void setVersion(java.lang.String s)
           
 void setVetoSupport(java.beans.VetoableChangeSupport vetoSupport)
          Sets the vetoSupport.
 void targetAdded(TargetEvent e)
          Fired when a target is added to the list of targets.
 void targetRemoved(TargetEvent e)
          Fired when a target is removed from the list of targets
 void targetSet(TargetEvent e)
          Fired when a total new set of targets is set
protected  void trashInternal(java.lang.Object obj)
          Removes some object from the project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMPLATES

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

ARGO_TEE

public static java.lang.String ARGO_TEE

UNTITLED_FILE

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

expander

protected static OCLExpander expander

_saveRegistry

protected ChangeRegistry _saveRegistry

_defaultModel

protected MModel _defaultModel

_currentNamespace

protected MNamespace _currentNamespace

cat

protected static Category cat
Constructor Detail

Project

public Project(java.io.File file)
        throws java.net.MalformedURLException,
               java.io.IOException

Project

public Project(java.net.URL url)

Project

public Project()
Method Detail

makeUntitledProject

protected void makeUntitledProject()
Makes a just created project to an untitled project with a class diagram and a usecase diagram and an untitled model.


loadModelFromXMI

protected MModel loadModelFromXMI(java.net.URL url)
                           throws java.io.IOException,
                                  org.xml.sax.SAXException,
                                  javax.xml.parsers.ParserConfigurationException
Deprecated. As of ArgoUml version unknown, replaced by unknown.

Loads a model (XMI only) from a .zargo file. BE ADVISED this method has a side effect. It sets _UUIDREFS to the model. If there is a problem with the xmi file, an error is set in the ArgoParser.SINGLETON.getLastLoadStatus() field. This needs to be examined by the calling function.

Parameters:
url - The url with the .zargo file
Returns:
MModel The model loaded
Throws:
java.io.IOException - Thrown if the model or the .zargo file is corrupted.
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

loadZippedProjectMembers

protected void loadZippedProjectMembers(java.net.URL url)
                                 throws java.io.IOException,
                                        javax.xml.parsers.ParserConfigurationException,
                                        org.xml.sax.SAXException
Loads all the members from a zipped input stream.

Throws:
java.io.IOException - if there is something wrong with the zipped archive or with the model.
java.beans.PropertyVetoException - if the adding of a diagram is vetoed.
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

getBaseName

public java.lang.String getBaseName()
Added Eugenio's patches to load 0.8.1 projects.


getName

public java.lang.String getName()

setName

public void setName(java.lang.String n)
             throws java.beans.PropertyVetoException,
                    java.net.MalformedURLException
java.beans.PropertyVetoException
java.net.MalformedURLException

getURL

public java.net.URL getURL()

setURL

public void setURL(java.net.URL url)

setFile

public void setFile(java.io.File file)

getSearchPath

public java.util.Vector getSearchPath()

addSearchPath

public void addSearchPath(java.lang.String searchpath)

findMemberURLInSearchPath

public java.net.URL findMemberURLInSearchPath(java.lang.String name)

getMembers

public java.util.Vector getMembers()

addMember

public void addMember(java.lang.String name,
                      java.lang.String type)

addMember

public void addMember(ArgoDiagram d)

addMember

public void addMember(ProjectMemberTodoList pm)

addModel

public void addModel(MNamespace m)

removeProjectMemberDiagram

protected void removeProjectMemberDiagram(ArgoDiagram d)
Removes a project member diagram completely from the project.

Parameters:
d -

findMemberByName

public ProjectMember findMemberByName(java.lang.String name)

loadMembersOfType

public void loadMembersOfType(java.lang.String type)

loadAllMembers

public void loadAllMembers()

save

public void save(boolean overwrite,
                 java.io.File file)
          throws java.io.IOException,
                 java.lang.Exception
There are known issues with saving, particularly losing the xmi at save time. see issue http://argouml.tigris.org/issues/show_bug.cgi?id=410 It is also being considered to save out individual xmi's from individuals diagrams to make it easier to modularize the output of Argo.

java.io.IOException
java.lang.Exception

getAuthorname

public java.lang.String getAuthorname()

setAuthorname

public void setAuthorname(java.lang.String s)

getVersion

public java.lang.String getVersion()

setVersion

public void setVersion(java.lang.String s)

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String s)

getHistoryFile

public java.lang.String getHistoryFile()

setHistoryFile

public void setHistoryFile(java.lang.String s)

setNeedsSave

public void setNeedsSave(boolean newValue)

needsSave

public boolean needsSave()

getUserDefinedModels

public java.util.Vector getUserDefinedModels()
Returns all models defined by the user. I.e. this does not return the default model but all other models.

Returns:
Vector

getModels

public java.util.Collection getModels()
Returns all models, including the default model (default.xmi).

Returns:
Collection

getModel

public MNamespace getModel()

findType

public MClassifier findType(java.lang.String s)
Searches for a type/classifier with name s. If the type is not found, a new type is created and added to the current namespace.

Parameters:
s -
Returns:
MClassifier

findType

public MClassifier findType(java.lang.String s,
                            boolean defineNew)
Searches for a type/classifier with name s. If defineNew is true, a new type is defined if the type/classifier is not found. The newly created type is added to the currentNamespace and given the name s.

Parameters:
s -
defineNew -
Returns:
MClassifier

findFigsForMember

public java.util.Collection findFigsForMember(java.lang.Object member)
Finds all figs on the diagrams for some project member, including the figs containing the member (so for some operation, the containing figclass is returned).

Parameters:
member - The member we are looking for. This can be a NSUML object but also another object.
Returns:
Collection The collection with the figs.

findTypeInModel

public MClassifier findTypeInModel(java.lang.String s,
                                   MNamespace ns)
Will only return first classifier with the matching name

Parameters:
s - is short name

setCurrentNamespace

public void setCurrentNamespace(MNamespace m)

getCurrentNamespace

public MNamespace getCurrentNamespace()

getDiagrams

public java.util.Vector getDiagrams()

getDiagram

public ArgoDiagram getDiagram(java.lang.String name)
Finds a diagram with a specific name or UID.

Parameters:
name - is the name to search for.

addDiagram

public void addDiagram(ArgoDiagram d)

removeDiagram

protected void removeDiagram(ArgoDiagram d)
Removes a diagram from the list with diagrams. Removes (hopefully) the event listeners for this diagram. Does not remove the diagram from the project members. This should not be called directly. Use moveToTrash if you want to remove a diagram.

Parameters:
d -

getPresentationCountFor

public int getPresentationCountFor(MModelElement me)

getInitialTarget

public java.lang.Object getInitialTarget()

setGenerationPrefs

public void setGenerationPrefs(GenerationPreferences cgp)

getGenerationPrefs

public GenerationPreferences getGenerationPrefs()

getVetoSupport

public java.beans.VetoableChangeSupport getVetoSupport()

postLoad

public void postLoad()
Deprecated. As of 28 Apr 2003 (ArgoUml version 0.13.5). Will be protected in future. TODO: Replace by?


moveToTrash

public void moveToTrash(java.lang.Object obj)
Moves some object to trash. TODO: This mechanism must be rethought since it only deletes an object completely from the project

Parameters:
obj - The object to be deleted
See Also:
trashInternal(java.lang.Object)

trashInternal

protected void trashInternal(java.lang.Object obj)
Removes some object from the project. Does not update GUI since this method only handles project management.

Parameters:
obj -

moveFromTrash

public void moveFromTrash(java.lang.Object obj)

isInTrash

public boolean isInTrash(java.lang.Object dm)

resetStats

public static void resetStats()

setStat

public static void setStat(java.lang.String n,
                           int v)

getStats

public static java.util.Vector getStats()

addStat

public static void addStat(java.util.Vector stats,
                           java.lang.String name,
                           int value)

setDefaultModel

public void setDefaultModel(MModel defaultModel)

getDefaultModel

public MModel getDefaultModel()

findTypeInDefaultModel

public java.lang.Object findTypeInDefaultModel(java.lang.String name)
Find a type by name in the default model.


getRoot

public MModel getRoot()
Returns the root.

Returns:
MModel

setRoot

public void setRoot(MModel root)
Sets the root.

Parameters:
root - The root to set

isValidDiagramName

public boolean isValidDiagramName(java.lang.String name)
Returns true if the given name is a valid name for a diagram. Valid means that it does not occur as a name for a diagram yet.

Parameters:
name - The name to test
Returns:
boolean True if there are no problems with this name, false if it's not valid.

getCgPrefs

public GenerationPreferences getCgPrefs()
Returns the cgPrefs.

Returns:
GenerationPreferences

isNeedsSave

public boolean isNeedsSave()
Returns the needsSave.

Returns:
boolean

getSaveRegistry

public ChangeRegistry getSaveRegistry()
Returns the saveRegistry.

Returns:
ChangeRegistry

getSearchpath

public java.util.Vector getSearchpath()
Returns the searchpath.

Returns:
Vector

getUrl

public java.net.URL getUrl()
Returns the url.

Returns:
URL

getUUIDRefs

public java.util.HashMap getUUIDRefs()
Returns the uUIDRefs.

Returns:
HashMap

setCgPrefs

public void setCgPrefs(GenerationPreferences cgPrefs)
Sets the cgPrefs.

Parameters:
cgPrefs - The cgPrefs to set

setDiagrams

public void setDiagrams(java.util.Vector diagrams)
Sets the diagrams.

Parameters:
diagrams - The diagrams to set

setMembers

public void setMembers(java.util.Vector members)
Sets the members.

Parameters:
members - The members to set

setModels

public void setModels(java.util.Vector models)
Sets the models.

Parameters:
models - The models to set

setSaveRegistry

public void setSaveRegistry(ChangeRegistry saveRegistry)
Sets the saveRegistry.

Parameters:
saveRegistry - The saveRegistry to set

setSearchpath

public void setSearchpath(java.util.Vector searchpath)
Sets the searchpath.

Parameters:
searchpath - The searchpath to set

setUrl

public void setUrl(java.net.URL url)
Sets the url.

Parameters:
url - The url to set

setUUIDRefs

public void setUUIDRefs(java.util.HashMap uUIDRefs)
Sets the uUIDRefs.

Parameters:
uUIDRefs - The uUIDRefs to set

setVetoSupport

public void setVetoSupport(java.beans.VetoableChangeSupport vetoSupport)
Sets the vetoSupport.

Parameters:
vetoSupport - The vetoSupport to set

getActiveDiagram

public ArgoDiagram getActiveDiagram()
Returns:

setActiveDiagram

public void setActiveDiagram(ArgoDiagram diagram)
Parameters:
diagram -

targetAdded

public void targetAdded(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is added to the list of targets.

Specified by:
targetAdded in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_ADDED
See Also:
TargetListener.targetAdded(org.argouml.ui.targetmanager.TargetEvent)

targetRemoved

public void targetRemoved(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is removed from the list of targets

Specified by:
targetRemoved in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_REMOVED
See Also:
TargetListener.targetRemoved(org.argouml.ui.targetmanager.TargetEvent)

targetSet

public void targetSet(TargetEvent e)
Description copied from interface: TargetListener
Fired when a total new set of targets is set

Specified by:
targetSet in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_SET
See Also:
TargetListener.targetSet(org.argouml.ui.targetmanager.TargetEvent)


ArgoUML © 1996-2003 (20030919)ArgoUML Project HomeArgoUML Cookbook