svn commit: r17935 - trunk/src/argouml-app: src/org/argouml/i18n src/org/argouml/persistence src/org/argouml/profile src/org/argouml/profile/init src/org/argouml/profile/internal src/org/argouml/ui src/org/argouml/ui/explorer tests/org/argouml/kernel tests/org/argouml/profile
Luis Sergio Oliveira <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: euluis
Date: 2010-01-30 04:43:37-0800
New Revision: 17935
Modified:
trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
trunk/src/argouml-app/src/org/argouml/persistence/XmlInputStream.java
trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java
trunk/src/argouml-app/src/org/argouml/profile/init/ProfileLoader.java
trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java
trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java
trunk/src/argouml-app/src/org/argouml/ui/explorer/ActionDeployProfile.java
trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java
trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java
Log:
issue 5506: injecting ProfileManager into UserDefinedProfile constructors
Modified: trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties 2010-01-30 04:43:37-0800
@@ -75,7 +75,9 @@
(1) Either load a module which contains that profile,\n\
(2) or make sure that the URL can be resolved,\n\
(3) or load it as a user defined profile in the profile configuration in \
- the edit->settings dialog.
+ the edit->settings dialog,\n\
+ (4) or use the Model recovery tool to replace the existing external \
+ references that may be obsolete to the correct references.
dialog.exception.link.report = Please report this problem at \
<a href="http://argouml.tigris.org/project_bugs.html">\
http://argouml.tigris.org/project_bugs.html</a>
Modified: trunk/src/argouml-app/src/org/argouml/persistence/XmlInputStream.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/XmlInputStream.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/XmlInputStream.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/XmlInputStream.java 2010-01-30 04:43:37-0800
@@ -132,6 +132,12 @@
* @param theTag the tag name
*/
public synchronized void reopen(String theTag) {
+ try {
+ reset();
+ } catch (IOException e) {
+ // TODO: Auto-generated catch block
+ LOG.error("Exception while reset().", e);
+ }
endStream = false;
xmlStarted = false;
inTag = false;
Modified: trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java 2010-01-30 04:43:37-0800
@@ -1,6 +1,6 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009 Contributors - see below
+ * Copyright (c) 2009-2010 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
*
* Contributors:
* thn
+ * euluis
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -60,6 +61,7 @@
import org.argouml.cognitive.Decision;
import org.argouml.cognitive.ToDoItem;
import org.argouml.cognitive.Translator;
+import org.argouml.kernel.ProfileConfiguration;
import org.argouml.model.Model;
import org.argouml.profile.internal.ocl.CrOCL;
import org.argouml.profile.internal.ocl.InvalidOclException;
@@ -126,9 +128,12 @@
* The default constructor for this class
*
* @param file the file from where the model should be read
+ * @param manager the profile manager which will be used to resolve
+ * dependencies
* @throws ProfileException if the profile could not be loaded
*/
- public UserDefinedProfile(File file) throws ProfileException {
+ public UserDefinedProfile(File file, ProfileManager manager)
+ throws ProfileException {
LOG.info("load " + file);
displayName = file.getName();
modelFile = file;
@@ -141,23 +146,104 @@
}
profilePackages = new FileModelLoader().loadModel(reference);
- finishLoading();
+ finishLoading(manager);
+ }
+
+ /**
+ * The default constructor for this class
+ *
+ * @param file the file from where the model should be read
+ * @throws ProfileException if the profile could not be loaded
+ * @deprecated for 0.30 by euluis. Use
+ * {@link UserDefinedProfile#UserDefinedProfile(File, ProfileManager)}
+ * instead.
+ */
+ @Deprecated
+ public UserDefinedProfile(File file) throws ProfileException {
+ this(file, getSomeProfileManager());
+ }
+
+ private static class NullProfileManager implements ProfileManager {
+
+ public void addSearchPathDirectory(String path) {
+ }
+
+ public void addToDefaultProfiles(Profile profile) {
+ }
+
+ public void applyConfiguration(ProfileConfiguration pc) {
+ }
+
+ public List<Profile> getDefaultProfiles() {
+ return new ArrayList<Profile>();
+ }
+
+ public Profile getProfileForClass(String className) {
+ return null;
+ }
+
+ public List<Profile> getRegisteredProfiles() {
+ return new ArrayList<Profile>();
+ }
+
+ public List<String> getSearchPathDirectories() {
+ return new ArrayList<String>();
+ }
+
+ public Profile getUMLProfile() {
+ return null;
+ }
+
+ public Profile lookForRegisteredProfile(String profile) {
+ return null;
+ }
+
+ public void refreshRegisteredProfiles() {
+ }
+
+ public void registerProfile(Profile profile) {
+ }
+
+ public void removeFromDefaultProfiles(Profile profile) {
+ }
+
+ public void removeProfile(Profile profile) {
+ }
+
+ public void removeSearchPathDirectory(String path) {
+ }
+
}
/**
* A constructor that reads a file from an URL
*
* @param url the URL
+ * @param manager the profile manager which will be used to resolve
+ * dependencies
* @throws ProfileException if the profile can't be read or is not valid
*/
- public UserDefinedProfile(URL url) throws ProfileException {
+ public UserDefinedProfile(URL url, ProfileManager manager)
+ throws ProfileException {
LOG.info("load " + url);
-
ProfileReference reference = null;
reference = new UserProfileReference(url.getPath(), url);
profilePackages = new URLModelLoader().loadModel(reference);
+ finishLoading(manager);
+ }
- finishLoading();
+ /**
+ * A constructor that reads a file from an URL
+ *
+ * @param url the URL
+ * @throws ProfileException if the profile could not be loaded
+ * @deprecated for 0.30 by euluis. Use
+ * {@link UserDefinedProfile#UserDefinedProfile(URL, ProfileManager)}
+ * instead.
+ */
+ @Deprecated
+ public UserDefinedProfile(URL url) throws ProfileException {
+ this(url, getSomeProfileManager());
}
/**
@@ -167,10 +253,13 @@
* @param url the URL of the profile mode
* @param critics the Critics defined by this profile
* @param dependencies the dependencies of this profile
+ * @param manager the profile manager which will be used to resolve
+ * dependencies
* @throws ProfileException if the model cannot be loaded
*/
public UserDefinedProfile(String dn, URL url, Set<Critic> critics,
- Set<String> dependencies) throws ProfileException {
+ Set<String> dependencies, ProfileManager manager)
+ throws ProfileException {
LOG.info("load " + url);
this.displayName = dn;
@@ -188,13 +277,41 @@
addProfileDependency(profileID);
}
- finishLoading();
+ finishLoading(manager);
+ }
+
+ /**
+ * A constructor that reads a file from an URL associated with some profiles
+ *
+ * @param dn the display name of the profile
+ * @param url the URL of the profile mode
+ * @param critics the Critics defined by this profile
+ * @param dependencies the dependencies of this profile
+ * @throws ProfileException if the model cannot be loaded
+ *
+ * @deprecated for 0.30 by euluis. Use
+ * {@link UserDefinedProfile#UserDefinedProfile(String, URL, Set, Set, ProfileManager)}
+ * instead.
+ */
+ @Deprecated
+ public UserDefinedProfile(String dn, URL url, Set<Critic> critics,
+ Set<String> dependencies) throws ProfileException {
+ this(dn, url, critics, dependencies, getSomeProfileManager());
+ }
+
+ private static ProfileManager getSomeProfileManager() {
+ if (ProfileFacade.isInitiated()) {
+ return ProfileFacade.getManager();
+ }
+ return new NullProfileManager();
}
/**
* Reads the informations defined as TaggedValues
+ * @param manager the profile manager which will be used to resolve
+ * dependencies
*/
- private void finishLoading() {
+ private void finishLoading(ProfileManager manager) {
Collection packagesInProfile = filterPackages();
for (Object obj : packagesInProfile) {
@@ -224,14 +341,23 @@
StringTokenizer st = new StringTokenizer(dependencyListStr,
" ,;:");
- String profile = null;
+ String dependencyName = null;
while (st.hasMoreTokens()) {
- profile = st.nextToken();
- if (profile != null) {
- LOG.debug("AddingDependency " + profile);
- this.addProfileDependency(ProfileFacade.getManager()
- .lookForRegisteredProfile(profile));
+ dependencyName = st.nextToken();
+ if (dependencyName != null) {
+ LOG.debug("Adding dependency " + dependencyName);
+ Profile profile =
+ manager.lookForRegisteredProfile(
+ dependencyName);
+ if (profile != null) {
+ addProfileDependency(profile);
+ } else {
+ LOG.warn("The profile \"" + displayName
+ + "\" has a dependency named \""
+ + dependencyName
+ + "\" which isn't solvable.");
+ }
}
}
}
Modified: trunk/src/argouml-app/src/org/argouml/profile/init/ProfileLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/profile/init/ProfileLoader.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/profile/init/ProfileLoader.java (original)
+++ trunk/src/argouml-app/src/org/argouml/profile/init/ProfileLoader.java 2010-01-30 04:43:37-0800
@@ -158,7 +158,8 @@
UserDefinedProfile udp = new UserDefinedProfile(entryName,
modelURL, critics,
- loadManifestDependenciesForProfile(attr));
+ loadManifestDependenciesForProfile(attr),
+ ProfileFacade.getManager());
ProfileFacade.getManager().registerProfile(udp);
LOG.debug("Registered Profile: " + udp.getDisplayName()
Modified: trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java (original)
+++ trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java 2010-01-30 04:43:37-0800
@@ -172,7 +172,7 @@
if (p == null) {
try {
- p = new UserDefinedProfile(file);
+ p = new UserDefinedProfile(file, this);
registerProfile(p);
} catch (ProfileException e) {
LOG.error("Error loading profile: " + file,
@@ -398,7 +398,7 @@
if (!found) {
UserDefinedProfile udp = null;
try {
- udp = new UserDefinedProfile(file);
+ udp = new UserDefinedProfile(file, this);
registerProfile(udp);
} catch (ProfileException e) {
// if an exception is raised file is unusable
Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java 2010-01-30 04:43:37-0800
@@ -358,7 +358,8 @@
File file = chooser.getSelectedFile();
chooser.setCurrentDirectory(file.getParentFile());
try {
- UserDefinedProfile profile = new UserDefinedProfile(file);
+ UserDefinedProfile profile = new UserDefinedProfile(file,
+ ProfileFacade.getManager());
ProfileFacade.getManager().registerProfile(profile);
modelAvailable.addElement(profile);
Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java 2010-01-30 04:43:37-0800
@@ -375,7 +375,8 @@
for (File file : files) {
try {
UserDefinedProfile profile =
- new UserDefinedProfile(file);
+ new UserDefinedProfile(file,
+ ProfileFacade.getManager());
ProfileFacade.getManager().registerProfile(profile);
modelAvl.addElement(profile);
} catch (ProfileException e) {
Modified: trunk/src/argouml-app/src/org/argouml/ui/explorer/ActionDeployProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/explorer/ActionDeployProfile.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/explorer/ActionDeployProfile.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/explorer/ActionDeployProfile.java 2010-01-30 04:43:37-0800
@@ -104,7 +104,8 @@
}
// register it as a user profile
try {
- profileManager.registerProfile(new UserDefinedProfile(f));
+ profileManager.registerProfile(new UserDefinedProfile(f,
+ profileManager));
} catch (ProfileException e) {
LOG.warn("failed to load profile from file " + f.getPath(), e);
}
Modified: trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java 2010-01-30 04:43:37-0800
@@ -262,9 +262,9 @@
File userDefinedProfileFile = createUserProfileFile(testCaseDir,
"testProjectWithUserDefinedProfilePersistency-TestUserProfile.xmi");
// add it to the project configuration
- Profile userDefinedProfile =
- new UserDefinedProfile(userDefinedProfileFile);
ProfileManager profileManager = ProfileFacade.getManager();
+ Profile userDefinedProfile =
+ new UserDefinedProfile(userDefinedProfileFile, profileManager);
profileManager.registerProfile(userDefinedProfile);
profileManager.addSearchPathDirectory(testCaseDir.getAbsolutePath());
Project project = ProjectManager.getManager().makeEmptyProject();
@@ -342,9 +342,9 @@
File userDefinedProfileFile = createUserProfileFile(testCaseDir,
testName + "-TestUserProfile.xmi");
// add it to the project configuration
- Profile userDefinedProfile =
- new UserDefinedProfile(userDefinedProfileFile);
ProfileManager profileManager = ProfileFacade.getManager();
+ Profile userDefinedProfile =
+ new UserDefinedProfile(userDefinedProfileFile, profileManager);
profileManager.registerProfile(userDefinedProfile);
profileManager.addSearchPathDirectory(testCaseDir.getAbsolutePath());
Project project = ProjectManager.getManager().makeEmptyProject();
Modified: trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java?view=diff&pathrev=17935&r1=17934&r2=17935
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java 2010-01-30 04:43:37-0800
@@ -54,7 +54,7 @@
* Some basic tests for the {@link UserDefinedProfile} class.
*
* @author Luis Sergio Oliveira (euluis)
- * @authos maurelio1234
+ * @author maurelio1234
*/
public class TestUserDefinedProfile extends TestCase {
@@ -88,7 +88,8 @@
// save the profile into a xmi file
File profileFile = new File(testDir, "testLoadingConstructor.xmi");
profileMother.saveProfileModel(model, profileFile);
- Profile profile = new UserDefinedProfile(profileFile);
+ Profile profile = new UserDefinedProfile(profileFile,
+ ProfileFacade.getManager());
assertTrue(profile.getDisplayName().contains(profileFile.getName()));
}
@@ -115,8 +116,8 @@
profiles.add(pm.getUMLProfile().getProfileIdentifier());
critics.add(critic);
- Profile profile = new UserDefinedProfile("displayName", profileFile
- .toURI().toURL(), critics, profiles);
+ Profile profile = new UserDefinedProfile("displayName",
+ profileFile.toURI().toURL(), critics, profiles, pm);
assertEquals(profile.getDisplayName(), "displayName");
assertTrue(profile.getDependencies().contains(pm.getUMLProfile()));
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2443304
To unsubscribe from this discussion, e-mail: [[email protected]].