Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-02-06 15:28:12 +0000
committercletavernie2012-02-06 15:28:12 +0000
commitfae3fe539d03674f5024ed8272220370bb5b891f (patch)
tree2bde689200b2b6c6046ed3c646c35274cb27f40b
parent983f9d8fb0f89b632888b898929e6f2ee9f88e32 (diff)
downloadorg.eclipse.papyrus-fae3fe539d03674f5024ed8272220370bb5b891f.tar.gz
org.eclipse.papyrus-fae3fe539d03674f5024ed8272220370bb5b891f.tar.xz
org.eclipse.papyrus-fae3fe539d03674f5024ed8272220370bb5b891f.zip
370412: ClassCastException in PackageUtil, when Package is contained in a component
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370412
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
index d740e150704..702c8b21429 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
@@ -143,10 +143,20 @@ public class PackageUtil {
* @return the top {@link Package} for the specified element
*/
public static Package getRootPackage(Package package_) {
- if(package_.getOwner() == null) {
+ Element owner = package_.getOwner();
+
+ //Bug 370412: The package might not be contained in a Package
+ //(e.g. it can be contained in a Component). Search for the nearest
+ //package, excluding self (Package#getNearestPackage() returns self)
+ while(owner != null && !(owner instanceof Package)) {
+ owner = owner.getOwner();
+ }
+
+ if(owner == null) {
return package_;
}
- return getRootPackage((Package)package_.getOwner());
+
+ return getRootPackage((Package)owner);
}
/**

Back to the top