Author: mvw
Date: 2007-12-23 10:38:08-0800
New Revision: 13988
Modified:
trunk/src_new/org/argouml/kernel/Project.java
trunk/src_new/org/argouml/kernel/ProjectImpl.java
trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java
trunk/src_new/org/argouml/persistence/PersistenceManager.java
trunk/src_new/org/argouml/uml/ProjectMemberModel.java
Log:
Preparations to remove the circular dependency between org.argouml.persistence and org.argouml.kernel.
The persistence should depend on the kernel and not vice versa.
See the new figure in the cookbook!
This will have impact on argoeclipse.
Modified: trunk/src_new/org/argouml/kernel/Project.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/Project.java?view=diff&rev=13988&p1=trunk/src_new/org/argouml/kernel/Project.java&p2=trunk/src_new/org/argouml/kernel/Project.java&r1=13987&r2=13988
==============================================================================
--- trunk/src_new/org/argouml/kernel/Project.java (original)
+++ trunk/src_new/org/argouml/kernel/Project.java 2007-12-23 10:38:08-0800
@@ -58,6 +58,9 @@
* This is the name minus any valid file extension.
*
* @return The name (a String).
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link org.argouml.persistence.PersistenceManager#getProjectBaseName(Project)}
+ * Rationale: Remove dependency on persistence subsystem.
*/
public String getBaseName();
@@ -73,6 +76,9 @@
* @param n The new URI (as a String).
* @throws URISyntaxException if the argument cannot be converted to
* an URI.
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link org.argouml.persistence.PersistenceManager#setProjectName(String, Project)}
+ * Rationale: Remove dependency on persistence subsystem.
*/
public void setName(final String n) throws URISyntaxException;
@@ -87,10 +93,23 @@
* Set the URI for this project.
*
* @param theUri The URI to set.
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link org.argouml.persistence.PersistenceManager#setProjectURI(URI, Project)}
+ * Rationale: Remove dependency on persistence subsystem.
*/
public void setURI(final URI theUri);
/**
+ * Set the URI for this project. <p>
+ *
+ * Don't use this directly! Use instead:
+ * {@link org.argouml.persistence.PersistenceManager#setProjectURI(URI, Project)}
+ *
+ * @param theUri The URI to set.
+ */
+ public void setUri(final URI theUri);
+
+ /**
* Set the project file.
*
* This only works if it is possible to convert the File to an uri.
Modified: trunk/src_new/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectImpl.java?view=diff&rev=13988&p1=trunk/src_new/org/argouml/kernel/ProjectImpl.java&p2=trunk/src_new/org/argouml/kernel/ProjectImpl.java&r1=13987&r2=13988
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectImpl.java (original)
+++ trunk/src_new/org/argouml/kernel/ProjectImpl.java 2007-12-23 10:38:08-0800
@@ -155,7 +155,8 @@
*/
public ProjectImpl(URI theProjectUri) {
this();
- uri = PersistenceManager.getInstance().fixUriExtension(theProjectUri);
+ /* TODO: Why was this next line in the code so long? */
+// uri = PersistenceManager.getInstance().fixUriExtension(theProjectUri);
uri = theProjectUri;
}
@@ -182,11 +183,13 @@
addSearchPath("PROJECT_DIR");
}
-
+ /*
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link PersistenceManager#getProjectBaseName(Project)}
+ * Rationale: Remove dependency on persistence subsystem.
+ */
public String getBaseName() {
- String n = getName();
- n = PersistenceManager.getInstance().getBaseName(n);
- return n;
+ return PersistenceManager.getInstance().getProjectBaseName(this);
}
@@ -198,42 +201,46 @@
return new File(uri).getName();
}
-
+ /*
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link PersistenceManager#setProjectName(String, Project)}
+ * Rationale: Remove dependency on persistence subsystem.
+ */
public void setName(final String n)
throws URISyntaxException {
- String s = "";
- if (getURI() != null) {
- s = getURI().toString();
- }
- s = s.substring(0, s.lastIndexOf("/") + 1) + n;
- setURI(new URI(s));
+ PersistenceManager.getInstance().setProjectName(n, this);
}
public URI getUri() {
return uri;
}
-
+
public URI getURI() {
return uri;
}
-
+ /*
+ * @deprecated by MVW in V0.25.4 - replaced by
+ * {@link PersistenceManager#setProjectUri(URI, Project)}
+ * Rationale: Remove dependency on persistence subsystem.
+ */
public void setURI(URI theUri) {
- if (theUri != null) {
- theUri = PersistenceManager.getInstance().fixUriExtension(theUri);
- }
+ PersistenceManager.getInstance().setProjectURI(theUri, this);
+ }
+ /**
+ * @param theUri the URI for the project
+ */
+ public void setUri(URI theUri) {
if (LOG.isDebugEnabled()) {
LOG.debug("Setting project URI from \"" + uri
+ "\" to \"" + theUri + "\".");
}
-
uri = theUri;
}
-
public void setFile(final File file) {
URI theProjectUri = file.toURI();
Modified: trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java?view=diff&rev=13988&p1=trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java&p2=trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java&r1=13987&r2=13988
==============================================================================
--- trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java (original)
+++ trunk/src_new/org/argouml/persistence/OldZargoFilePersister.java 2007-12-23 10:38:08-0800
@@ -134,7 +134,8 @@
// Save the .argo entry
ZipEntry zipEntry =
- new ZipEntry(project.getBaseName()
+ new ZipEntry(PersistenceManager.getInstance()
+ .getProjectBaseName(project)
+ FileConstants.UNCOMPRESSED_FILE_EXT);
stream.putNextEntry(zipEntry);
Modified: trunk/src_new/org/argouml/persistence/PersistenceManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/PersistenceManager.java?view=diff&rev=13988&p1=trunk/src_new/org/argouml/persistence/PersistenceManager.java&p2=trunk/src_new/org/argouml/persistence/PersistenceManager.java&r1=13987&r2=13988
==============================================================================
--- trunk/src_new/org/argouml/persistence/PersistenceManager.java (original)
+++ trunk/src_new/org/argouml/persistence/PersistenceManager.java 2007-12-23 10:38:08-0800
@@ -30,6 +30,7 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -288,6 +289,45 @@
}
/**
+ * @param p the project
+ * @return the basename of the project
+ */
+ public String getProjectBaseName(Project p) {
+ URI uri = p.getUri();
+ String name = Translator.localize("label.projectbrowser-title");
+ if (uri != null) {
+ name = new File(uri).getName();
+ }
+ return getBaseName(name);
+ }
+
+ /**
+ * @param n the new project name
+ * @param p the project that receives the name
+ * @throws URISyntaxException if the URI is malformed
+ */
+ public void setProjectName(final String n, Project p)
+ throws URISyntaxException {
+ String s = "";
+ if (p.getURI() != null) {
+ s = p.getURI().toString();
+ }
+ s = s.substring(0, s.lastIndexOf("/") + 1) + n;
+ setProjectURI(new URI(s), p);
+ }
+
+ /**
+ * @param theUri the URI for the project
+ * @param p the project that receives the URI
+ */
+ public void setProjectURI(URI theUri, Project p) {
+ if (theUri != null) {
+ theUri = fixUriExtension(theUri);
+ }
+ p.setUri(theUri);
+ }
+
+ /**
* Generates a String dump of the current model for quick viewing.
*
* @param project The project to generate.
Modified: trunk/src_new/org/argouml/uml/ProjectMemberModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ProjectMemberModel.java?view=diff&rev=13988&p1=trunk/src_new/org/argouml/uml/ProjectMemberModel.java&p2=trunk/src_new/org/argouml/uml/ProjectMemberModel.java&r1=13987&r2=13988
==============================================================================
--- trunk/src_new/org/argouml/uml/ProjectMemberModel.java (original)
+++ trunk/src_new/org/argouml/uml/ProjectMemberModel.java 2007-12-23 10:38:08-0800
@@ -27,6 +27,7 @@
import org.argouml.kernel.AbstractProjectMember;
import org.argouml.kernel.Project;
import org.argouml.model.Model;
+import org.argouml.persistence.PersistenceManager;
/**
* @author Piotr Kaminski
@@ -46,7 +47,8 @@
*/
public ProjectMemberModel(Object m, Project p) {
- super(p.getBaseName() + FILE_EXT, p);
+ super(PersistenceManager.getInstance().getProjectBaseName(p)
+ + FILE_EXT, p);
if (!Model.getFacade().isAModel(m))
throw new IllegalArgumentException();
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.