[161647] Ensuring all related stereotype applications are destroyed when a stereotype is unapplied or a stereotype application is destroyed.
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
index e48a0a6..429f048 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
@@ -8,11 +8,12 @@
* Contributors:
* IBM - initial API and implementation
*
- * $Id: ElementOperations.java,v 1.44.2.3 2006/09/06 20:56:30 khussey Exp $
+ * $Id: ElementOperations.java,v 1.44.2.4 2006/10/20 16:00:43 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -43,6 +44,7 @@
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.DirectedRelationship;
import org.eclipse.uml2.uml.Element;
@@ -1466,18 +1468,29 @@
* @generated NOT
*/
public static void destroy(Element element) {
+ destroy((EObject) element);
+ }
- for (Iterator allContents = getAllContents(element, true, false); allContents
+ protected static void destroy(EObject eObject) {
+
+ for (Iterator allContents = getAllContents(eObject, true, false); allContents
.hasNext();) {
- EObject eObject = (EObject) allContents.next();
+ Object object = allContents.next();
- if (eObject instanceof Element) {
- destroyAll(((Element) eObject).getStereotypeApplications());
+ if (object instanceof Element) {
+ destroyAll(((Element) object).getStereotypeApplications());
}
}
- destroy((EObject) element);
+ UML2Util.destroy(eObject);
+ }
+
+ protected static void destroyAll(Collection eObjects) {
+
+ for (Iterator o = eObjects.iterator(); o.hasNext();) {
+ destroy((EObject) o.next());
+ }
}
protected static EList allOwnedElements(Element element,