[408612] Ensuring static stereotype applications can be pasted.
diff --git a/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java b/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
index 50b993a..0b85cd5 100644
--- a/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
+++ b/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
@@ -9,7 +9,7 @@
* IBM - initial API and implementation
* Kenn Hussey (Embarcadero Technologies) - 204200, 215418, 156879, 227392, 226178, 232332, 247980
* Kenn Hussey - 286329, 323181
- * Kenn Hussey (CEA) - 327039, 351774, 364419, 292633, 397324, 204658, 173565
+ * Kenn Hussey (CEA) - 327039, 351774, 364419, 292633, 397324, 204658, 173565, 408612
* Christian W. Damus - 355218
*
*/
@@ -2136,6 +2136,26 @@
protected static class UMLPasteFromClipboardCommand
extends PasteFromClipboardCommand {
+ private static class PrivateUMLUtil
+ extends UMLUtil {
+
+ private static Stereotype getStereotype(
+ EObject stereotypeApplication, Object context) {
+ return UMLUtil.getStereotype(stereotypeApplication.eClass(),
+ context instanceof EObject
+ ? (EObject) context
+ : null);
+ }
+
+ private static Element getBaseElement(
+ EObject stereotypeApplication, Object context) {
+ return getStereotype(stereotypeApplication, context) != null
+ ? getBaseElement(stereotypeApplication.eClass(),
+ stereotypeApplication)
+ : null;
+ }
+ }
+
protected UMLPasteFromClipboardCommand(EditingDomain domain,
Object owner, Object feature, int index, boolean optimize) {
super(domain, owner, feature, index, optimize);
@@ -2205,12 +2225,13 @@
if (object instanceof EObject) {
EObject stereotypeApplication = (EObject) object;
- Stereotype stereotype = UMLUtil
- .getStereotype(stereotypeApplication);
+ Stereotype stereotype = PrivateUMLUtil
+ .getStereotype(stereotypeApplication, owner);
if (stereotype != null) {
- Element baseElement = UMLUtil
- .getBaseElement(stereotypeApplication);
+ Element baseElement = PrivateUMLUtil
+ .getBaseElement(stereotypeApplication,
+ owner);
if (baseElement != null) {
EClass definition = stereotypeApplication
@@ -2249,8 +2270,10 @@
for (EObject stereotypeApplication : stereotypeApplicationsToAdd) {
UMLUtil.StereotypeApplicationHelper.INSTANCE.addToContainmentList(
- UMLUtil
- .getBaseElement(stereotypeApplication),
+ PrivateUMLUtil
+ .getBaseElement(
+ stereotypeApplication,
+ owner),
stereotypeApplication);
}
}
@@ -2314,7 +2337,8 @@
for (Object object : clipboard) {
if (object instanceof EObject
- && UMLUtil.getStereotype((EObject) object) != null) {
+ && PrivateUMLUtil
+ .getStereotype((EObject) object, owner) != null) {
continue;
}
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 6edf1be..f0f95fe 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
@@ -10,7 +10,7 @@
* Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396, 271470
* Nicolas Rouquette (JPL) - 260120, 313837
* Kenn Hussey - 286329, 313601, 314971, 344907, 236184, 335125
- * Kenn Hussey (CEA) - 327039, 358792, 364419, 366350, 307343, 382637, 273949, 389542, 389495, 316165, 392833, 399544, 322715, 163556, 212765, 397324, 204658
+ * Kenn Hussey (CEA) - 327039, 358792, 364419, 366350, 307343, 382637, 273949, 389542, 389495, 316165, 392833, 399544, 322715, 163556, 212765, 397324, 204658, 408612
* Yann Tanguy (CEA) - 350402
* Christian W. Damus (CEA) - 392833
*
@@ -9455,6 +9455,26 @@
return null;
}
+ protected static Element getBaseElement(EClass definition,
+ EObject stereotypeApplication) {
+
+ for (EStructuralFeature eStructuralFeature : definition
+ .getEAllStructuralFeatures()) {
+
+ if (eStructuralFeature.getName().startsWith(
+ Extension.METACLASS_ROLE_PREFIX)) {
+
+ Object value = stereotypeApplication.eGet(eStructuralFeature);
+
+ if (value instanceof Element) {
+ return (Element) value;
+ }
+ }
+ }
+
+ return null;
+ }
+
/**
* Retrieves the base element for the specified stereotype application, i.e.
* the element to which the stereotype is applied.
@@ -9469,21 +9489,7 @@
EClass eClass = stereotypeApplication.eClass();
if (getStereotype(eClass, stereotypeApplication) != null) {
-
- for (EStructuralFeature eStructuralFeature : eClass
- .getEAllStructuralFeatures()) {
-
- if (eStructuralFeature.getName().startsWith(
- Extension.METACLASS_ROLE_PREFIX)) {
-
- Object value = stereotypeApplication
- .eGet(eStructuralFeature);
-
- if (value instanceof Element) {
- return (Element) value;
- }
- }
- }
+ return getBaseElement(eClass, stereotypeApplication);
}
}