svn commit: r17441 - trunk/src/argouml-app: src/org/argouml/kernel src/org/argouml/ui tests/org/argouml/kernel
Thomas Neustupny <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: thn
Date: 2009-11-01 11:38:45-0700
New Revision: 17441
Modified:
trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java
trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java
Log:
needed change: in UML2, the user model is involved when profiles are applied/unapplied; for this always pass the user model when adding/removing a profile to/from the profile configuration
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java?view=diff&pathrev=17441&r1=17440&r2=17441
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java 2009-11-01 11:38:45-0700
@@ -91,8 +91,10 @@
*/
public ProfileConfiguration(Project project) {
super(EXTENSION, project);
+ List c = project.getUserDefinedModelList();
+ Object m = c.isEmpty() ? null : c.get(0);
for (Profile p : ProfileFacade.getManager().getDefaultProfiles()) {
- addProfile(p);
+ addProfile(p, m);
}
updateStrategies();
@@ -108,8 +110,10 @@
public ProfileConfiguration(Project project,
Collection<Profile> configuredProfiles) {
super(EXTENSION, project);
+ List c = project.getUserDefinedModelList();
+ Object m = c.isEmpty() ? null : c.get(0);
for (Profile profile : configuredProfiles) {
- addProfile(profile);
+ addProfile(profile, m);
}
updateStrategies();
}
@@ -169,15 +173,20 @@
}
/**
- * Applies a new profile to this configuration
+ * Applies a new profile to this configuration and to the given model (or
+ * other profile, which could be later a collection).
*
* @param p the profile to be applied
+ * @param m the model (or profile) to which the profile will be applied
*/
@SuppressWarnings("unchecked")
- public void addProfile(Profile p) {
+ public void addProfile(Profile p, Object m) {
if (!profiles.contains(p)) {
profiles.add(p);
try {
+ for (Object profile : p.getProfilePackages()) {
+ Model.getExtensionMechanismsHelper().applyProfile(m, profile);
+ }
profileModels.addAll(p.getProfilePackages());
} catch (ProfileException e) {
LOG.warn("Error retrieving profile's " + p + " packages.", e);
@@ -189,7 +198,7 @@
}
for (Profile dependency : p.getDependencies()) {
- addProfile(dependency);
+ addProfile(dependency, m);
}
updateStrategies();
@@ -207,13 +216,18 @@
}
/**
- * Removes the passed profile from the configuration.
+ * Removes the passed profile from the configuration and unapplies it from
+ * the given model (or other profile, which could be later a collection).
*
- * @param p the profile to be removed
+ * @param p the profile to be removed/unapplied
+ * @param m the model (or profile) to which the profile will be unapplied
*/
- public void removeProfile(Profile p) {
+ public void removeProfile(Profile p, Object m) {
profiles.remove(p);
try {
+ for (Object profile : p.getProfilePackages()) {
+ Model.getExtensionMechanismsHelper().unapplyProfile(m, profile);
+ }
profileModels.removeAll(p.getProfilePackages());
} catch (ProfileException e) {
LOG.error("Exception", e);
@@ -236,7 +250,7 @@
}
for (Profile profile : markForRemoval) {
- removeProfile(profile);
+ removeProfile(profile, m);
}
updateStrategies();
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=17441&r1=17440&r2=17441
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java 2009-11-01 11:38:45-0700
@@ -461,6 +461,7 @@
assert p != null;
List<Profile> toRemove = new ArrayList<Profile>();
ProfileConfiguration pc = p.getProfileConfiguration();
+ Object m = p.getUserDefinedModelList().get(0);
List<Profile> usedItens = new ArrayList<Profile>();
@@ -478,12 +479,12 @@
}
for (Profile profile : toRemove) {
- pc.removeProfile(profile);
+ pc.removeProfile(profile, m);
}
for (Profile profile : usedItens) {
if (!pc.getProfiles().contains(profile)) {
- pc.addProfile(profile);
+ pc.addProfile(profile, m);
}
}
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=17441&r1=17440&r2=17441
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java 2009-11-01 11:38:45-0700
@@ -174,7 +174,7 @@
Model.getCoreHelper().setName(foo, "foo");
Model.getCoreHelper().addStereotype(foo, theStereotype);
// remove the MetaProfile from the project's profile configuration
- project.getProfileConfiguration().removeProfile(metaProfile);
+ project.getProfileConfiguration().removeProfile(metaProfile, model);
// assert that the project's model element that had a dependency to
// the MetaProfile doesn't get inconsistent
theStereotype =
@@ -252,12 +252,12 @@
profileManager.registerProfile(userDefinedProfile);
profileManager.addSearchPathDirectory(testCaseDir.getAbsolutePath());
Project project = ProjectManager.getManager().makeEmptyProject();
- project.getProfileConfiguration().addProfile(userDefinedProfile);
- // create a dependency between the project's model and the user defined
- // profile
Object model = project.getUserDefinedModelList().get(0);
Model.getCoreHelper().setName(model,
"testProjectWithUserDefinedProfilePersistency-model");
+ // create a dependency between the project's model and the user defined
+ // profile
+ project.getProfileConfiguration().addProfile(userDefinedProfile, model);
Object fooClass = getCoreFactory().buildClass(
"testProjectWithUserDefinedProfilePersistency-class", model);
Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
@@ -332,10 +332,10 @@
profileManager.registerProfile(userDefinedProfile);
profileManager.addSearchPathDirectory(testCaseDir.getAbsolutePath());
Project project = ProjectManager.getManager().makeEmptyProject();
- project.getProfileConfiguration().addProfile(userDefinedProfile);
+ Object model = project.getUserDefinedModelList().get(0);
// create a dependency between the project's model and the user defined
// profile
- Object model = project.getUserDefinedModelList().get(0);
+ project.getProfileConfiguration().addProfile(userDefinedProfile, model);
final String className = "Foo4" + testName;
Object fooClass = getCoreFactory().buildClass(className, model);
Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2413481
To unsubscribe from this discussion, e-mail: [[email protected]].