[271470] Some extra extensibility is needed in the UML2 Profile framework
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
index e55991f..8d61781 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation, Embarcadero Technologies, and others.
* 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
@@ -7,8 +7,9 @@
*
* Contributors:
* IBM - initial API and implementation
+ * Kenn Hussey (Embarcadero Technologies) - 271470
*
- * $Id: PackageOperations.java,v 1.38 2008/11/04 14:30:41 khussey Exp $
+ * $Id: PackageOperations.java,v 1.39 2009/04/24 14:28:01 jbruck Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
@@ -756,13 +757,13 @@
if (appliedProfile == null && recurse) {
- for (Element owner = package_.getOwner(); owner != null
- && appliedProfile == null; owner = owner.getOwner()) {
+ for (Iterator<org.eclipse.uml2.uml.Package> otherApplyingPackages = ProfileApplicationHelper.INSTANCE
+ .getOtherApplyingPackages(package_).iterator(); otherApplyingPackages
+ .hasNext()
+ && appliedProfile == null;) {
- if (owner instanceof org.eclipse.uml2.uml.Package) {
- appliedProfile = ((org.eclipse.uml2.uml.Package) owner)
- .getAppliedProfile(qualifiedName);
- }
+ appliedProfile = otherApplyingPackages.next()
+ .getAppliedProfile(qualifiedName);
}
}
@@ -783,10 +784,10 @@
EList<ProfileApplication> allProfileApplications = new UniqueEList.FastCompare<ProfileApplication>(
package_.getProfileApplications());
- for (org.eclipse.uml2.uml.Package owningPackage : package_
- .allOwningPackages()) {
+ for (org.eclipse.uml2.uml.Package applyingPackage : ProfileApplicationHelper.INSTANCE
+ .getOtherApplyingPackages(package_)) {
- allProfileApplications.addAll(owningPackage
+ allProfileApplications.addAll(applyingPackage
.getProfileApplications());
}
@@ -835,14 +836,14 @@
.getProfileApplication(profile);
if (profileApplication == null && recurse) {
+
+ for (Iterator<org.eclipse.uml2.uml.Package> otherApplyingPackages = ProfileApplicationHelper.INSTANCE
+ .getOtherApplyingPackages(package_).iterator(); otherApplyingPackages
+ .hasNext()
+ && profileApplication == null;) {
- for (Element owner = package_.getOwner(); owner != null
- && profileApplication == null; owner = owner.getOwner()) {
-
- if (owner instanceof org.eclipse.uml2.uml.Package) {
- profileApplication = ((org.eclipse.uml2.uml.Package) owner)
- .getProfileApplication(profile);
- }
+ profileApplication = otherApplyingPackages.next()
+ .getProfileApplication(profile);
}
}
@@ -893,10 +894,10 @@
EList<Profile> allAppliedProfiles = getAppliedProfiles(package_,
new UniqueEList.FastCompare<Profile>());
- for (org.eclipse.uml2.uml.Package owningPackage : package_
- .allOwningPackages()) {
+ for (org.eclipse.uml2.uml.Package applyingPackage : ProfileApplicationHelper.INSTANCE
+ .getOtherApplyingPackages(package_)) {
- getAppliedProfiles(owningPackage, allAppliedProfiles);
+ getAppliedProfiles(applyingPackage, allAppliedProfiles);
}
return ECollections.unmodifiableEList(allAppliedProfiles);
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index 734db6a..ba5d50c 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -7,10 +7,10 @@
*
* Contributors:
* IBM - initial API and implementation
- * Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396
+ * Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396, 271470
* Nicolas Rouquette (JPL) - 260120
*
- * $Id: UMLUtil.java,v 1.82 2009/04/23 20:31:13 jbruck Exp $
+ * $Id: UMLUtil.java,v 1.83 2009/04/24 14:28:00 jbruck Exp $
*/
package org.eclipse.uml2.uml.util;
@@ -131,6 +131,34 @@
extends UML2Util {
/**
+ * The ProfileApplicationHelper can be overridden to change the way packages
+ * are traversed when looking for profile applications relevant to an
+ * element in a given package.
+ *
+ * @since 3.0
+ */
+ public static class ProfileApplicationHelper {
+
+ public static final ProfileApplicationHelper INSTANCE = createProfileApplicationHelper();
+
+ private static ProfileApplicationHelper createProfileApplicationHelper() {
+ ProfileApplicationHelper profileApplicationHelper = UML2Util
+ .loadClassFromSystemProperty("org.eclipse.uml2.uml.util.UMLUtil$ProfileApplicationHelper.INSTANCE"); //$NON-NLS-1$
+
+ if (profileApplicationHelper != null) {
+ return profileApplicationHelper;
+ }
+
+ return new ProfileApplicationHelper();
+ }
+
+ public Iterable<org.eclipse.uml2.uml.Package> getOtherApplyingPackages(
+ org.eclipse.uml2.uml.Package package_) {
+ return package_.allOwningPackages();
+ }
+ }
+
+ /**
* The StereotypeApplicationHelper can be overridden to change the default
* location of applied stereotypes.
* Typically, stereotype applications are placed in the same location as
@@ -7141,7 +7169,7 @@
&& !source.equals(ANNOTATION__UNION)) {
StringBuffer stringBuffer = new StringBuffer(
- escapeString(source, " ="));
+ escapeString(source, " =")); //$NON-NLS-1$
for (Map.Entry<String, String> entry : eAnnotation
.getDetails()) {