org.argouml.kernel
Class Project

java.lang.Object
  extended byorg.argouml.kernel.Project
All Implemented Interfaces:
EventListener, Serializable, TargetListener

public class Project
extends Object
implements Serializable, TargetListener

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

See Also:
Serialized Form

Constructor Summary
Project()
          Constructor.
Project(URL theProjectUrl)
          Constructor.
 
Method Summary
 void addDiagram(ArgoDiagram d)
           
 void addMember(Object m)
           
 void addModel(Object model)
           
 void addSearchPath(String searchPathElement)
           
 Collection findAllPresentationsFor(Object obj)
          Returns a list with all figs for some UML object on all diagrams.
 Collection findFigsForMember(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).
 Object findType(String s)
          Searches for a type/classifier with name s.
 Object findType(String s, boolean defineNew)
          Searches for a type/classifier with name s.
 Object findTypeInDefaultModel(String name)
          Find a type by name in the default model.
 Object findTypeInModel(String s, Object ns)
          Finds a classifier with a certain name.
 ArgoDiagram getActiveDiagram()
          Get the current viewed diagram.
 String getAuthoremail()
          Get the author name.
 String getAuthorname()
          Get the author name.
 String getBaseName()
          Find the base name of this project.
 GenerationPreferences getCgPrefs()
          Deprecated. use getGenerationPrefs() instead
 Object getCurrentNamespace()
           
 Object getDefaultModel()
          Get the default model.
 String getDescription()
          Get the description.
 ArgoDiagram getDiagram(String name)
          Finds a diagram with a specific name or UID.
 int getDiagramCount()
          Get the number of diagrams in this project.
 Vector getDiagrams()
           
 GenerationPreferences getGenerationPrefs()
           
 String getHistoryFile()
          Get the history file.
 Object getInitialTarget()
           
 MemberList getMembers()
          Get all members of the project.
 Object getModel()
          Return the model.
 Collection getModels()
          Returns all models, including the default model (default.xmi).
 String getName()
           
 int getPersistenceVersion()
           
 int getPresentationCountFor(Object me)
           
 Profile getProfile()
           
 ProjectSettings getProjectSettings()
           
 Object getRoot()
          Returns the root.
 Vector getSearchpath()
          Returns the searchpath.
 Vector getSearchPath()
           
 URL getUrl()
          Returns the url.
 URL getURL()
          Get the URL for this project.
 Vector getUserDefinedModels()
          Returns all models defined by the user.
 HashMap getUUIDRefs()
          Returns the uUIDRefs.
 String getVersion()
          Get the version.
 VetoableChangeSupport getVetoSupport()
           
 boolean isInTrash(Object obj)
           
 boolean isValidDiagramName(String name)
          Returns true if the given name is a valid name for a diagram.
 void moveToTrash(Object obj)
          Moves some object to trash, i.e.
 void postLoad()
          This is executed after a load.
 void postSave()
          This is execcuted 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.
 String repair()
          Repair all parts of the project before a save takes place.
 void setActiveDiagram(ArgoDiagram theDiagram)
           
 void setAuthoremail(String s)
          Set the author name.
 void setAuthorname(String s)
          Set the author name.
 void setCgPrefs(GenerationPreferences theCgPrefs)
          Deprecated. use setGenerationPrefs() instead
 void setCurrentNamespace(Object m)
           
 void setDefaultModel(Object theDefaultModel)
           
 void setDescription(String s)
          Set a new description.
 void setFile(File file)
          Set the project file.
 void setGenerationPrefs(GenerationPreferences cgp)
           
 void setHistoryFile(String s)
          Set the history file.
 void setName(String n)
          Set the project URL.
 void setPersistenceVersion(int pv)
           
 void setRoot(Object root)
          Sets the root.
 void setSearchpath(Vector theSearchpath)
          Sets the searchpath.
 void setUrl(URL theUrl)
          Sets the url.
 void setURL(URL theUrl)
          Set the URL for this project.
 void setUUIDRefs(HashMap uUIDRefs)
          Sets the uUIDRefs.
 void setVersion(String s)
          Set the new version.
 void setVetoSupport(VetoableChangeSupport theVetoSupport)
          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(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

Project

public Project(URL theProjectUrl)
Constructor.

Parameters:
theProjectUrl - Url to read the project from.

Project

public Project()
Constructor.

Method Detail

getBaseName

public String getBaseName()
Find the base name of this project.

This is the name minus any valid file extension.

Returns:
The name (a String).

getName

public String getName()
Returns:
the name of the project

setName

public void setName(String n)
             throws MalformedURLException
Set the project URL.

Parameters:
n - The new URL (as a String).
Throws:
MalformedURLException - if the argument cannot be converted to an URL.

getURL

public URL getURL()
Get the URL for this project.

Returns:
The URL.

setURL

public void setURL(URL theUrl)
Set the URL for this project.

Parameters:
theUrl - The URL to set.

setFile

public void setFile(File file)
Set the project file. This only works if it is possible to convert the File to an url.

Parameters:
file - File to set the project to.

getSearchPath

public Vector getSearchPath()
Returns:
the search path

addSearchPath

public void addSearchPath(String searchPathElement)
Parameters:
searchPathElement - the element to be added to the searchpath

getMembers

public MemberList getMembers()
Get all members of the project.

Returns:
a Vector with all members.

addMember

public void addMember(Object m)
Parameters:
m - the member to be added

addModel

public void addModel(Object model)
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 String getAuthorname()
Get the author name.

Returns:
The author name.

setAuthorname

public void setAuthorname(String s)
Set the author name.

Parameters:
s - The new author name.

getAuthoremail

public String getAuthoremail()
Get the author name.

Returns:
The author name.

setAuthoremail

public void setAuthoremail(String s)
Set the author name.

Parameters:
s - The new author name.

getVersion

public String getVersion()
Get the version.

Returns:
the version.

setVersion

public void setVersion(String s)
Set the new version.

Parameters:
s - The new version.

getDescription

public String getDescription()
Get the description.

Returns:
the description.

setDescription

public void setDescription(String s)
Set a new description.

Parameters:
s - The new description.

getHistoryFile

public String getHistoryFile()
Get the history file.

Returns:
The history file.

setHistoryFile

public void setHistoryFile(String s)
Set the history file.

Parameters:
s - The new history file.

getUserDefinedModels

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

Returns:
A Vector of all user defined models.

getModels

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

Returns:
A Collection containing all models.

getModel

public Object getModel()
Return the model.

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

Returns:
the model.

findType

public Object findType(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 - the name of the type/classifier to be found
Returns:
MClassifier

findType

public Object findType(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 - the name of the type/classifier to be found
defineNew - if true, define a new one
Returns:
MClassifier the found classifier

findFigsForMember

public Collection findFigsForMember(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 model element object but also another object.
Returns:
Collection The collection with the figs.

findAllPresentationsFor

public Collection findAllPresentationsFor(Object obj)
Returns a list with all figs for some UML object on all diagrams.

Parameters:
obj - the given UML object
Returns:
List the list of figs

findTypeInModel

public Object findTypeInModel(String s,
                              Object ns)
Finds a classifier with a certain name.

Will only return first classifier with the matching name.

Parameters:
s - is short name.
ns - Namespace where we do the search.
Returns:
the found classifier (or null if not found).

setCurrentNamespace

public void setCurrentNamespace(Object m)
Parameters:
m - the namespace

getCurrentNamespace

public Object getCurrentNamespace()
Returns:
the namespace

getDiagrams

public Vector getDiagrams()
Returns:
the diagrams

getDiagramCount

public int getDiagramCount()
Get the number of diagrams in this project. Used by argo2.tee!!

Returns:
the number of diagrams in this project.

getDiagram

public ArgoDiagram getDiagram(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)
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(Object me)
Parameters:
me - the given modelelement
Returns:
the total number of presentation for the given modelelement in the project

getInitialTarget

public Object getInitialTarget()
Returns:
an initial target, in casu a diagram or a model

setGenerationPrefs

public void setGenerationPrefs(GenerationPreferences cgp)
Parameters:
cgp - the generation preferences

getGenerationPrefs

public GenerationPreferences getGenerationPrefs()
Returns:
the generation preferences

getVetoSupport

public VetoableChangeSupport getVetoSupport()
Returns:
the VetoableChangeSupport

preSave

public void preSave()
This is executed before a save.


postSave

public void postSave()
This is execcuted after a save.


postLoad

public void postLoad()
This is executed after a load.


moveToTrash

public void moveToTrash(Object obj)
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
 

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

trashInternal

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

Parameters:
obj - the object to be thrown away

isInTrash

public boolean isInTrash(Object obj)
Parameters:
obj - the object
Returns:
true if the object is trashed

setDefaultModel

public void setDefaultModel(Object theDefaultModel)
Parameters:
theDefaultModel - a uml model

getDefaultModel

public Object getDefaultModel()
Get the default model.

Returns:
A model.

findTypeInDefaultModel

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

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

getRoot

public Object getRoot()
Returns the root.

Returns:
MModel

setRoot

public void setRoot(Object root)
Sets the root.

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

isValidDiagramName

public boolean isValidDiagramName(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()
Deprecated. use getGenerationPrefs() instead

Returns the cgPrefs.

Returns:
GenerationPreferences

getSearchpath

public Vector getSearchpath()
Returns the searchpath.

Returns:
Vector

getUrl

public URL getUrl()
Returns the url.

Returns:
URL

getUUIDRefs

public HashMap getUUIDRefs()
Returns the uUIDRefs.

Returns:
HashMap

setCgPrefs

public void setCgPrefs(GenerationPreferences theCgPrefs)
Deprecated. use setGenerationPrefs() instead

Sets the cgPrefs.

Parameters:
theCgPrefs - The cgPrefs to set

setSearchpath

public void setSearchpath(Vector theSearchpath)
Sets the searchpath.

Parameters:
theSearchpath - The searchpath to set

setUrl

public void setUrl(URL theUrl)
Sets the url.

Parameters:
theUrl - The url to set

setUUIDRefs

public void setUUIDRefs(HashMap uUIDRefs)
Sets the uUIDRefs.

Parameters:
uUIDRefs - The uUIDRefs to set

setVetoSupport

public void setVetoSupport(VetoableChangeSupport theVetoSupport)
Sets the vetoSupport.

Parameters:
theVetoSupport - The vetoSupport to set

getActiveDiagram

public ArgoDiagram getActiveDiagram()
Get the current viewed diagram.

Returns:
the current viewed diagram

setActiveDiagram

public void setActiveDiagram(ArgoDiagram theDiagram)
Parameters:
theDiagram - the ArgoDiagram

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)

remove

public void remove()
Remove the project.


getPersistenceVersion

public int getPersistenceVersion()
Returns:
Returns the persistenceVersion.

setPersistenceVersion

public void setPersistenceVersion(int pv)
Parameters:
pv - The persistenceVersion to set.

getProfile

public Profile getProfile()
Returns:
Returns the profile.

repair

public String repair()
Repair all parts of the project before a save takes place.

Returns:
a report of any fixes

getProjectSettings

public ProjectSettings getProjectSettings()
Returns:
the settings of this project


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook