org.argouml.kernel
Class ProjectImpl

java.lang.Object
  extended by org.argouml.kernel.ProjectImpl
All Implemented Interfaces:
java.io.Serializable, Project

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

The ProjectImpl is a data structure that represents the designer's current project. It manages the list of diagrams and UML models.

NOTE: This was named Project until 0.25.4 when it was replaced by an interface of the same name and renamed to ProjectImpl.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.argouml.kernel.Project
PROFILE_PROJECT, UML_PROJECT
 
Constructor Summary
ProjectImpl()
          Constructor.
ProjectImpl(int type)
          Constructor.
ProjectImpl(int type, java.net.URI theProjectUri)
          Constructor.
 
Method Summary
 void addDiagram(ArgoDiagram d)
           
 void addMember(java.lang.Object m)
          Add a member: ArgoDiagram, a UML Model, or a ProjectMemberTodoList.
 void addModel(java.lang.Object model)
           
 void addSearchPath(java.lang.String searchPathElement)
           
 java.util.Collection findAllPresentationsFor(java.lang.Object obj)
          Returns a list with all figs for some UML object on all diagrams.
 java.util.Collection<Fig> 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).
 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 typeName, java.lang.Object namespace)
          Finds a classifier with a certain name.
 ArgoDiagram getActiveDiagram()
          Deprecated. 
 java.lang.String getAuthoremail()
          Get the author e-mail address.
 java.lang.String getAuthorname()
          Get the author name.
 java.lang.Object getCurrentNamespace()
          Deprecated. 
 java.lang.Object getDefaultAttributeType()
          Return the default type for an attribute.
 java.lang.Object getDefaultParameterType()
          Return the default type for a parameter.
 java.lang.Object getDefaultReturnType()
          Return the default type for the return parameter of a method.
 java.lang.String getDescription()
          Get the description.
 ArgoDiagram getDiagram(java.lang.String name)
          Finds a diagram with a specific name or UID.
 int getDiagramCount()
          Get the number of diagrams in this project.
 java.util.List<ArgoDiagram> getDiagramList()
           
 java.lang.String getHistoryFile()
          Get the history file name.
 java.lang.Object getInitialTarget()
           
 java.util.List<ProjectMember> getMembers()
          Get all members of the project.
 java.lang.Object getModel()
          Deprecated. 
 java.util.Collection getModels()
          Returns all top level Packages (e.g.
 java.lang.String getName()
          Get the project name.
 int getPersistenceVersion()
          Used by "argo.tee".
 int getPresentationCountFor(java.lang.Object me)
           
 ProfileConfiguration getProfileConfiguration()
           
 ProjectSettings getProjectSettings()
          Used by "argo.tee".
 int getProjectType()
          Get the project type.
 java.lang.Object getRoot()
          Deprecated. 
 java.util.Collection getRoots()
          Return a collection of top level Model Elements.
 java.util.List<java.lang.String> getSearchPathList()
          Used by "argo.tee".
 UndoManager getUndoManager()
          Return the UndoManager for this project.
 java.net.URI getUri()
          Returns the uri.
 java.net.URI getURI()
          Get the URI for this project.
 java.util.List getUserDefinedModelList()
          Returns all models defined by the user.
 java.util.Map<java.lang.String,java.lang.Object> getUUIDRefs()
          Returns the uUIDRefs.
 java.lang.String getVersion()
          Get the version.
 java.beans.VetoableChangeSupport getVetoSupport()
          Deprecated. 
 boolean isDirty()
           
 boolean isInTrash(java.lang.Object obj)
          Deprecated. 
 boolean isValidDiagramName(java.lang.String name)
          Returns true if the given name is a valid name for a diagram.
 void moveToTrash(java.lang.Object obj)
          Moves some object to trash, i.e.
 void postLoad()
          This is executed after a load.
 void postSave()
          This is executed after a save.
 void preSave()
          This is executed before a save.
 void remove()
          Remove the project.
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.
 java.lang.String repair()
          Repair all parts of the project before a save takes place.
 void setActiveDiagram(ArgoDiagram theDiagram)
          Deprecated. 
 void setAuthoremail(java.lang.String s)
          Set the author e-mail address.
 void setAuthorname(java.lang.String s)
          Set the author name.
 void setCurrentNamespace(java.lang.Object m)
          Deprecated. 
 void setDescription(java.lang.String s)
          Set a new description.
 void setDirty(boolean isDirty)
          Set the dirty flag for the project.
 void setFile(java.io.File file)
          Set the project file.
 void setHistoryFile(java.lang.String s)
          Set the history file name.
 void setPersistenceVersion(int pv)
           
 void setProfileConfiguration(ProfileConfiguration pc)
          Set the profile configuration.
 void setProjectType(int projectType)
          Set the project type.
 void setRoot(java.lang.Object theRoot)
          Deprecated. 
 void setRoots(java.util.Collection elements)
          Set the top level ModelElements for this project.
 void setSavedDiagramName(java.lang.String diagramName)
           
 void setSearchPath(java.util.List<java.lang.String> theSearchpath)
          Sets the searchpath.
 void setUri(java.net.URI theUri)
          Set the URI for this project.
 void setUUIDRefs(java.util.Map<java.lang.String,java.lang.Object> uUIDRefs)
          Sets the uUIDRefs.
 void setVersion(java.lang.String s)
          Set the new version.
 void setVetoSupport(java.beans.VetoableChangeSupport theVetoSupport)
          Deprecated. 
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
 

Constructor Detail

ProjectImpl

public ProjectImpl(int type,
                   java.net.URI theProjectUri)
Constructor.

Parameters:
theProjectUri - Uri to read the project from.

ProjectImpl

public ProjectImpl()
Constructor.


ProjectImpl

public ProjectImpl(int type)
Constructor.

Method Detail

getName

public java.lang.String getName()
Description copied from interface: Project
Get the project name. This is just the name part of the full filename.

Specified by:
getName in interface Project
Returns:
the name of the project

getProjectType

public int getProjectType()
Description copied from interface: Project
Get the project type. (Currently needed for profile project; probably no longer needed when ArgoUML supports multimodel projects.)

Specified by:
getProjectType in interface Project
Returns:
The URI.

setProjectType

public void setProjectType(int projectType)
Description copied from interface: Project
Set the project type. (Currently needed for profile project; probably no longer needed when ArgoUML supports multimodel projects.)

Specified by:
setProjectType in interface Project
Parameters:
projectType - The new project type.

getUri

public java.net.URI getUri()
Description copied from interface: Project
Returns the uri.

Specified by:
getUri in interface Project
Returns:
URI

getURI

public java.net.URI getURI()
Description copied from interface: Project
Get the URI for this project.

Specified by:
getURI in interface Project
Returns:
The URI.

setUri

public void setUri(java.net.URI theUri)
Description copied from interface: Project
Set the URI for this project.

Don't use this directly! Use instead: #setProjectURI(URI, Project)

TODO: Why isn't this deprecated or private if it is not to be used?

Specified by:
setUri in interface Project
Parameters:
theUri - the URI for the project

setFile

public void setFile(java.io.File file)
Description copied from interface: Project
Set the project file. This only works if it is possible to convert the File to an uri.

Specified by:
setFile in interface Project
Parameters:
file - File to set the project to.

getSearchPathList

public java.util.List<java.lang.String> getSearchPathList()
Description copied from interface: Project
Used by "argo.tee".

Specified by:
getSearchPathList in interface Project
Returns:
the search path

addSearchPath

public void addSearchPath(java.lang.String searchPathElement)
Specified by:
addSearchPath in interface Project
Parameters:
searchPathElement - the element to be added to the searchpath

getMembers

public java.util.List<ProjectMember> getMembers()
Description copied from interface: Project
Get all members of the project. Used by "argo.tee".

Specified by:
getMembers in interface Project
Returns:
all members.

addMember

public void addMember(java.lang.Object m)
Description copied from interface: Project
Add a member: ArgoDiagram, a UML Model, or a ProjectMemberTodoList.

Specified by:
addMember in interface Project
Parameters:
m - the member to be added

addModel

public void addModel(java.lang.Object model)
Specified by:
addModel in interface Project
Parameters:
model - a namespace

removeProjectMemberDiagram

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

Parameters:
d - the ArgoDiagram

getAuthorname

public java.lang.String getAuthorname()
Description copied from interface: Project
Get the author name. Used by "argo.tee".

Specified by:
getAuthorname in interface Project
Returns:
The author name.

setAuthorname

public void setAuthorname(java.lang.String s)
Description copied from interface: Project
Set the author name.

Specified by:
setAuthorname in interface Project
Parameters:
s - The new author name.

getAuthoremail

public java.lang.String getAuthoremail()
Description copied from interface: Project
Get the author e-mail address. Used by "argo.tee".

Specified by:
getAuthoremail in interface Project
Returns:
the author e-mail address

setAuthoremail

public void setAuthoremail(java.lang.String s)
Description copied from interface: Project
Set the author e-mail address.

Specified by:
setAuthoremail in interface Project
Parameters:
s - the new author e-mail address

getVersion

public java.lang.String getVersion()
Description copied from interface: Project
Get the version. This is the ArgoUML version that last saved this project. This field is not editable by the user. Used by "argo.tee".

Specified by:
getVersion in interface Project
Returns:
the version.

setVersion

public void setVersion(java.lang.String s)
Description copied from interface: Project
Set the new version. This is the ArgoUML version that last saved this project. This field is not editable by the user.

Specified by:
setVersion in interface Project
Parameters:
s - The new version.

getDescription

public java.lang.String getDescription()
Description copied from interface: Project
Get the description. This is the description of the project, as entered by the user. Used by "argo.tee".

Specified by:
getDescription in interface Project
Returns:
the description.

setDescription

public void setDescription(java.lang.String s)
Description copied from interface: Project
Set a new description. This is the description of the project. It is freely editable by the user.

Specified by:
setDescription in interface Project
Parameters:
s - The new description.

getHistoryFile

public java.lang.String getHistoryFile()
Description copied from interface: Project
Get the history file name. Not used. Used by "argo.tee".

Specified by:
getHistoryFile in interface Project
Returns:
The history file.

setHistoryFile

public void setHistoryFile(java.lang.String s)
Description copied from interface: Project
Set the history file name.

Specified by:
setHistoryFile in interface Project
Parameters:
s - The new history file.

getUserDefinedModelList

public java.util.List getUserDefinedModelList()
Description copied from interface: Project
Returns all models defined by the user. I.e. this does not return any profile packages but all other top level Packages (usually Models).

Specified by:
getUserDefinedModelList in interface Project
Returns:
A List of all user defined models.

getModels

public java.util.Collection getModels()
Description copied from interface: Project
Returns all top level Packages (e.g. Models), including the profile packages.

WARNING: The models returned by this method are not ordered. Any code which makes the assumption that the user model is first (or any other ordering assumption) is broken!

NOTE: Since user defined models and profiles are handled quite differently, you normally want to use Project.getUserDefinedModelList() instead of this method.

Specified by:
getModels in interface Project
Returns:
A Collection containing all models.

getModel

@Deprecated
public java.lang.Object getModel()
Deprecated. 

Description copied from interface: Project
Return the model.

If there isn't exactly one model, null is returned.

Specified by:
getModel in interface Project
Returns:
the model.

findType

public java.lang.Object findType(java.lang.String s)
Description copied from interface: Project
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.

TODO: Move to Model subsystem - tfm 20070307

Specified by:
findType in interface Project
Parameters:
s - the name of the type/classifier to be found
Returns:
Classifier

getDefaultAttributeType

public java.lang.Object getDefaultAttributeType()
Description copied from interface: Project
Return the default type for an attribute.

Specified by:
getDefaultAttributeType in interface Project
Returns:
a Classifier to use as the default type TODO: This belongs in ProjectSettings. - tfm

getDefaultParameterType

public java.lang.Object getDefaultParameterType()
Description copied from interface: Project
Return the default type for a parameter.

Specified by:
getDefaultParameterType in interface Project
Returns:
a Classifier to use as the default type TODO: This belongs in ProjectSettings. - tfm

getDefaultReturnType

public java.lang.Object getDefaultReturnType()
Description copied from interface: Project
Return the default type for the return parameter of a method.

Specified by:
getDefaultReturnType in interface Project
Returns:
a Classifier to use as the default type TODO: This belongs in ProjectSettings. - tfm

findType

public java.lang.Object findType(java.lang.String s,
                                 boolean defineNew)
Description copied from interface: Project
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.

TODO: Move to Model subsystem - tfm 20070307

Specified by:
findType in interface Project
Parameters:
s - the name of the type/classifier to be found
defineNew - if true, define a new one
Returns:
Classifier the found classifier

findFigsForMember

public java.util.Collection<Fig> findFigsForMember(java.lang.Object member)
Description copied from interface: Project
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).

Specified by:
findFigsForMember in interface Project
Parameters:
member - The member we are looking for. This can be a model element object but also another object.
Returns:
Collection The collection with the figs.

findAllPresentationsFor

public java.util.Collection findAllPresentationsFor(java.lang.Object obj)
Description copied from interface: Project
Returns a list with all figs for some UML object on all diagrams.

Specified by:
findAllPresentationsFor in interface Project
Parameters:
obj - the given UML object
Returns:
List the list of figs

findTypeInModel

public java.lang.Object findTypeInModel(java.lang.String typeName,
                                        java.lang.Object namespace)
Description copied from interface: Project
Finds a classifier with a certain name.

Will only return first classifier with the matching name. TODO: Move to Model subsystem - tfm 20070307

Specified by:
findTypeInModel in interface Project
Parameters:
typeName - is short name.
namespace - Namespace where we do the search.
Returns:
the found classifier (or null if not found).

setCurrentNamespace

@Deprecated
public void setCurrentNamespace(java.lang.Object m)
Deprecated. 

Specified by:
setCurrentNamespace in interface Project
Parameters:
m - the namespace

getCurrentNamespace

@Deprecated
public java.lang.Object getCurrentNamespace()
Deprecated. 

Specified by:
getCurrentNamespace in interface Project
Returns:
the namespace

getDiagramList

public java.util.List<ArgoDiagram> getDiagramList()
Specified by:
getDiagramList in interface Project
Returns:
the diagrams

getDiagramCount

public int getDiagramCount()
Description copied from interface: Project
Get the number of diagrams in this project. Used by argo2.tee!!

Specified by:
getDiagramCount in interface Project
Returns:
the number of diagrams in this project.

getDiagram

public ArgoDiagram getDiagram(java.lang.String name)
Description copied from interface: Project
Finds a diagram with a specific name or UID.

Specified by:
getDiagram in interface Project
Parameters:
name - is the name to search for.
Returns:
the diagram object (if found). Otherwise null.

addDiagram

public void addDiagram(ArgoDiagram d)
Specified by:
addDiagram in interface Project
Parameters:
d - the diagram to be added

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 - the ArgoDiagram

getPresentationCountFor

public int getPresentationCountFor(java.lang.Object me)
Specified by:
getPresentationCountFor in interface Project
Parameters:
me - the given modelelement
Returns:
the total number of presentation for the given modelelement in the project

getInitialTarget

public java.lang.Object getInitialTarget()
Specified by:
getInitialTarget in interface Project
Returns:
an initial target, in casu a diagram or a model

getVetoSupport

@Deprecated
public java.beans.VetoableChangeSupport getVetoSupport()
Deprecated. 

Specified by:
getVetoSupport in interface Project
Returns:
the VetoableChangeSupport object
See Also:
VetoableChangeSupport

preSave

public void preSave()
Description copied from interface: Project
This is executed before a save.

Specified by:
preSave in interface Project

postSave

public void postSave()
Description copied from interface: Project
This is executed after a save.

Specified by:
postSave in interface Project

postLoad

public void postLoad()
Description copied from interface: Project
This is executed after a load.

Specified by:
postLoad in interface Project

moveToTrash

public void moveToTrash(java.lang.Object obj)
Description copied from interface: Project
Moves some object to trash, i.e. deletes it completely with all dependent structures.

Deleting an object involves:

 - Removing Target history
 - Deleting all Fig representations for the object
 - Deleting the UML element
 - Deleting all dependent UML modelelements
 - Deleting CommentEdges (which are not UML elements)
 - Move to trash for enclosed objects, i.e. graphically drawn on top of
 - Move to trash subdiagrams for the object
 - Saveguard that there is always at least 1 diagram left
 - If the current diagram has been deleted, select a new one to show
 - Trigger the explorer when a diagram is deleted
 - Set the needsSave (dirty) flag of the projectmanager
 

Specified by:
moveToTrash in interface Project
Parameters:
obj - The object to be deleted
See Also:

TODO: This should just be named delete() or something which better tells what it does (since there really isn't a trash can).


trashInternal

protected void trashInternal(java.lang.Object obj)
Removes some object from the project.

Parameters:
obj - the object to be thrown away

isInTrash

@Deprecated
public boolean isInTrash(java.lang.Object obj)
Deprecated. 

Specified by:
isInTrash in interface Project
Parameters:
obj - the object
Returns:
true if the object is trashed

findTypeInDefaultModel

public java.lang.Object findTypeInDefaultModel(java.lang.String name)
Description copied from interface: Project
Find a type by name in the default model.

NOTE:The behavior of this method changed after version 0.24. Earlier versions copied the type from the profile or default model into the user model. The type is now returned directly and HREFs are used to link to it when the model is written out.

Specified by:
findTypeInDefaultModel in interface Project
Parameters:
name - the name.
Returns:
the type.

getRoot

@Deprecated
public final java.lang.Object getRoot()
Deprecated. 

Description copied from interface: Project
Returns the root package.

Specified by:
getRoot in interface Project
Returns:
the Package which is the root

setRoot

@Deprecated
public void setRoot(java.lang.Object theRoot)
Deprecated. 

Description copied from interface: Project
Sets the root package.

Specified by:
setRoot in interface Project
Parameters:
theRoot - The root to set, a UML Package

getRoots

public final java.util.Collection getRoots()
Description copied from interface: Project
Return a collection of top level Model Elements. Normally for ArgoUML created models, this will be a single Package or Model, but other tools may allow more liberal structures.

Specified by:
getRoots in interface Project
Returns:
Collection of top level ModelElements

setRoots

public void setRoots(java.util.Collection elements)
Description copied from interface: Project
Set the top level ModelElements for this project.

Specified by:
setRoots in interface Project
Parameters:
elements - Collection of top level ModelElements

isValidDiagramName

public boolean isValidDiagramName(java.lang.String name)
Description copied from interface: Project
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.

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

getUUIDRefs

public java.util.Map<java.lang.String,java.lang.Object> getUUIDRefs()
Description copied from interface: Project
Returns the uUIDRefs.

Specified by:
getUUIDRefs in interface Project
Returns:
HashMap

setSearchPath

public void setSearchPath(java.util.List<java.lang.String> theSearchpath)
Description copied from interface: Project
Sets the searchpath.

Specified by:
setSearchPath in interface Project
Parameters:
theSearchpath - The searchpath to set

setUUIDRefs

public void setUUIDRefs(java.util.Map<java.lang.String,java.lang.Object> uUIDRefs)
Description copied from interface: Project
Sets the uUIDRefs.

Specified by:
setUUIDRefs in interface Project
Parameters:
uUIDRefs - The uUIDRefs to set

setVetoSupport

@Deprecated
public void setVetoSupport(java.beans.VetoableChangeSupport theVetoSupport)
Deprecated. 

Description copied from interface: Project
Sets the VetoableChangeSupport object. This will be returned by Project.getVetoSupport() but is otherwise unused.

TODO: Why is this here since it's never used? - tfm

Specified by:
setVetoSupport in interface Project
Parameters:
theVetoSupport - The vetoSupport to set
See Also:
VetoableChangeSupport

getActiveDiagram

@Deprecated
public ArgoDiagram getActiveDiagram()
Deprecated. 

Description copied from interface: Project
Get the current viewed diagram.

Used by "argo.tee" to save the name of this diagram, so that the same diagram can be initially shown when reloading this project. This probably needs to be converted to an ordered list of open diagram windows to support MDI.

Specified by:
getActiveDiagram in interface Project
Returns:
the current viewed diagram

setActiveDiagram

@Deprecated
public void setActiveDiagram(ArgoDiagram theDiagram)
Deprecated. 

Specified by:
setActiveDiagram in interface Project
Parameters:
theDiagram - the ArgoDiagram

setSavedDiagramName

public void setSavedDiagramName(java.lang.String diagramName)
Specified by:
setSavedDiagramName in interface Project
Parameters:
diagramName - the name of the diagram to show by default after loading

remove

public void remove()
Description copied from interface: Project
Remove the project.

Specified by:
remove in interface Project

getPersistenceVersion

public int getPersistenceVersion()
Description copied from interface: Project
Used by "argo.tee".

Specified by:
getPersistenceVersion in interface Project
Returns:
Returns the persistenceVersion.

setPersistenceVersion

public void setPersistenceVersion(int pv)
Specified by:
setPersistenceVersion in interface Project
Parameters:
pv - The persistenceVersion to set.

repair

public java.lang.String repair()
Description copied from interface: Project
Repair all parts of the project before a save takes place.

Specified by:
repair in interface Project
Returns:
a report of any fixes

getProjectSettings

public ProjectSettings getProjectSettings()
Description copied from interface: Project
Used by "argo.tee".

Specified by:
getProjectSettings in interface Project
Returns:
the settings of this project

getUndoManager

public UndoManager getUndoManager()
Description copied from interface: Project
Return the UndoManager for this project. Undo is managed on a per-project basis.

Specified by:
getUndoManager in interface Project
Returns:
the UndoManager for this project

getProfileConfiguration

public ProfileConfiguration getProfileConfiguration()
Specified by:
getProfileConfiguration in interface Project
Returns:
Returns the profile configuration.

setProfileConfiguration

public void setProfileConfiguration(ProfileConfiguration pc)
Description copied from interface: Project
Set the profile configuration.

Specified by:
setProfileConfiguration in interface Project
Parameters:
pc - the profile configuration

isDirty

public boolean isDirty()
Specified by:
isDirty in interface Project
Returns:
true if Project has been modified since last save

setDirty

public void setDirty(boolean isDirty)
Description copied from interface: Project
Set the dirty flag for the project. This has no direct effect other than setting the flag.

Specified by:
setDirty in interface Project
Parameters:
isDirty - true if the project should be marked as dirty


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook