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
private  ArgoDiagram _activeDiagram
          The active diagram, pointer to a diagram in the list with diagrams.
private  java.lang.String _authorname
           
private  GenerationPreferences _cgPrefs
           
protected  java.lang.Object _currentNamespace
           
protected  java.lang.Object _defaultModel
           
private  java.util.HashMap _defaultModelCache
          Cache for the default model.
private  java.lang.String _description
           
private  java.util.Vector _diagrams
          Instances of the uml diagrams.
private  java.lang.String _historyFile
           
private  java.util.Vector _members
           
private  java.util.Vector _models
          Instances of the uml model.
private  boolean _needsSave
           
private  java.lang.Object _root
          The root of the modeltree the user is working on.
protected  ChangeRegistry _saveRegistry
           
private  java.util.Vector _searchpath
           
private  java.net.URL _url
          TODO: should just be the directory to write
private  java.util.HashMap _UUIDRefs
           
private  java.lang.String _version
           
private  java.beans.VetoableChangeSupport _vetoSupport
           
static java.lang.String ARGO_TEE
           
private static Logger cat
          logger
protected static OCLExpander expander
          This is used in the save process for PGML.
(package private) static long serialVersionUID
           
static java.lang.String TEMPLATES
           
static java.lang.String UNTITLED_FILE
           
 
Constructor Summary
Project()
           
Project(java.io.File file)
           
Project(java.lang.Object model)
           
Project(java.net.URL url)
           
 
Method Summary
 void addDiagram(ArgoDiagram d)
           
 void addMember(ArgoDiagram d)
           
 void addMember(java.lang.Object m)
           
 void addMember(ProjectMemberTodoList pm)
           
 void addMember(java.lang.String name, java.lang.String type)
           
 void addModel(java.lang.Object m)
           
 void addSearchPath(java.lang.String searchpath)
           
static void addStat(java.util.Vector stats, java.lang.String name, int value)
          Deprecated. since 0.15.1.
private  java.io.File copyFile(java.io.File dest, java.io.File src)
          copies one file src to another, raising file exceptions if there are some problems
 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)
           
 java.lang.Object findType(java.lang.String s)
          Searches for a type/classifier with name s.
 java.lang.Object 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.
 java.lang.Object findTypeInModel(java.lang.String s, java.lang.Object ns)
          Will only return first classifier with the matching name
 ArgoDiagram getActiveDiagram()
          Get the current viewed diagram
 java.lang.String getAuthorname()
           
 java.lang.String getBaseName()
          Added Eugenio's patches to load 0.8.1 projects.
 GenerationPreferences getCgPrefs()
          Returns the cgPrefs.
 java.lang.Object getCurrentNamespace()
           
 java.lang.Object 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()
           
 java.lang.Object getModel()
           
 java.util.Collection getModels()
          Returns all models, including the default model (default.xmi).
 java.lang.String getName()
           
 int getPresentationCountFor(java.lang.Object me)
           
 java.lang.Object 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()
          Deprecated. since 0.15.1.
 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  java.lang.Object loadModelFromXMI(java.net.URL url)
          Deprecated. As of ArgoUml version 0.15.3, TODO: What is this replaced by?
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?
private  void postSave()
           
private  void preSave()
           
 void remove()
          prepare project for gc.
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()
          Deprecated. since 0.15.1.
 void save(boolean overwrite, java.io.File file)
          There are known issues with saving, particularly losing the xmi at save time.
 void setActiveDiagram(ArgoDiagram diagram)
           
 void setAuthorname(java.lang.String s)
           
 void setCgPrefs(GenerationPreferences cgPrefs)
          Sets the cgPrefs.
 void setCurrentNamespace(java.lang.Object m)
           
 void setDefaultModel(java.lang.Object 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(java.lang.Object 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)
          Deprecated. since 0.15.1.
private  void setTarget(java.lang.Object target)
          Called to update the current namespace and active diagram after the target has changed.
 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

cat

private static Logger cat
logger


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
This is used in the save process for PGML.


serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

_url

private java.net.URL _url
TODO: should just be the directory to write


_saveRegistry

protected ChangeRegistry _saveRegistry

_authorname

private java.lang.String _authorname

_description

private java.lang.String _description

_version

private java.lang.String _version

_searchpath

private java.util.Vector _searchpath

_members

private java.util.Vector _members

_historyFile

private java.lang.String _historyFile

_models

private java.util.Vector _models
Instances of the uml model.


_diagrams

private java.util.Vector _diagrams
Instances of the uml diagrams.


_defaultModel

protected java.lang.Object _defaultModel

_needsSave

private boolean _needsSave

_currentNamespace

protected java.lang.Object _currentNamespace

_UUIDRefs

private java.util.HashMap _UUIDRefs

_cgPrefs

private GenerationPreferences _cgPrefs

_vetoSupport

private transient java.beans.VetoableChangeSupport _vetoSupport

_root

private java.lang.Object _root
The root of the modeltree the user is working on. (The untitled_model in the navpane).


_activeDiagram

private ArgoDiagram _activeDiagram
The active diagram, pointer to a diagram in the list with diagrams.


_defaultModelCache

private java.util.HashMap _defaultModelCache
Cache for the default model.

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()

Project

public Project(java.lang.Object model)
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 java.lang.Object loadModelFromXMI(java.net.URL url)
                                     throws java.io.IOException,
                                            org.xml.sax.SAXException,
                                            javax.xml.parsers.ParserConfigurationException
Deprecated. As of ArgoUml version 0.15.3, TODO: What is this replaced by?

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.
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)

addMember

public void addMember(java.lang.Object m)

addModel

public void addModel(java.lang.Object m)
Parameters:
m - a namespace

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()

copyFile

private java.io.File copyFile(java.io.File dest,
                              java.io.File src)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
copies one file src to another, raising file exceptions if there are some problems

java.io.FileNotFoundException
java.io.IOException

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 java.lang.Object getModel()

findType

public java.lang.Object 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 java.lang.Object 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 java.lang.Object findTypeInModel(java.lang.String s,
                                        java.lang.Object ns)
Will only return first classifier with the matching name

Parameters:
s - is short name

setCurrentNamespace

public void setCurrentNamespace(java.lang.Object m)

getCurrentNamespace

public java.lang.Object 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.
Returns:
the diagram object (if found). Otherwize null.

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(java.lang.Object me)

getInitialTarget

public java.lang.Object getInitialTarget()

setGenerationPrefs

public void setGenerationPrefs(GenerationPreferences cgp)

getGenerationPrefs

public GenerationPreferences getGenerationPrefs()

getVetoSupport

public java.beans.VetoableChangeSupport getVetoSupport()

preSave

private void preSave()

postSave

private void postSave()

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 -

Attention: whole Trash mechanism should be rethought concerning nsuml

Note that at present these are all if, not else-if. Rather than make a big change, I've just explicitly dealt with the case where we have a use case that is not classifier.


moveFromTrash

public void moveFromTrash(java.lang.Object obj)

isInTrash

public boolean isInTrash(java.lang.Object dm)

resetStats

public static void resetStats()
Deprecated. since 0.15.1.


setStat

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


getStats

public static java.util.Vector getStats()
Deprecated. since 0.15.1.


addStat

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


setDefaultModel

public void setDefaultModel(java.lang.Object defaultModel)
Parameters:
defaultModel - a uml model

getDefaultModel

public java.lang.Object getDefaultModel()

findTypeInDefaultModel

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

Parameters:
name - the name.
Returns:
the type.

getRoot

public java.lang.Object getRoot()
Returns the root.

Returns:
MModel

setRoot

public void setRoot(java.lang.Object root)
Sets the root.

Parameters:
root - The root to set, a uml model

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()
Get the current viewed diagram

Returns:
the current viewed diagram

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(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(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(TargetEvent)

setTarget

private void setTarget(java.lang.Object target)
Called to update the current namespace and active diagram after the target has changed.

Parameters:
target -

remove

public void remove()
prepare project for gc.



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