Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbblajer2007-05-21 16:38:32 +0000
committerbblajer2007-05-21 16:38:32 +0000
commite1aa814256ca5f84b4011b80fa176dca6561f1dd (patch)
tree247d032794ef640e2149f5ff8f9a239dcac87a82 /plugins/org.eclipse.gmf.runtime.lite/src/org
parent817e54a19eb69bb6c0c2af330febee70c4e82864 (diff)
downloadorg.eclipse.gmf-tooling-e1aa814256ca5f84b4011b80fa176dca6561f1dd.tar.gz
org.eclipse.gmf-tooling-e1aa814256ca5f84b4011b80fa176dca6561f1dd.tar.xz
org.eclipse.gmf-tooling-e1aa814256ca5f84b4011b80fa176dca6561f1dd.zip
Phantoms support
Diffstat (limited to 'plugins/org.eclipse.gmf.runtime.lite/src/org')
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/commands/DestroyElementCommand.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/commands/DestroyElementCommand.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/commands/DestroyElementCommand.java
index 5f2b9c589..de2fb692e 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/commands/DestroyElementCommand.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/commands/DestroyElementCommand.java
@@ -13,11 +13,13 @@ package org.eclipse.gmf.runtime.lite.commands;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -97,7 +99,35 @@ public class DestroyElementCommand extends CompoundCommand {
}
protected void prepareCommand() {
- append(RemoveCommand.create(domain, collection));
+ HashMap<Resource, Collection<Object>> uncontainedObjects = null;
+ Collection<Object> otherObjects = new BasicEList<Object>();
+ for (Object next : collection) {
+ if (next instanceof EObject) {
+ EObject nextEObject = (EObject) next;
+ if (nextEObject.eContainer() == null && nextEObject.eResource() != null) {
+ //Object directly contained within a resource should be removed differently
+ if (uncontainedObjects == null) {
+ uncontainedObjects = new HashMap<Resource, Collection<Object>>();
+ }
+ Collection<Object> uncontainedObjectsForResource = uncontainedObjects.get(nextEObject.eResource());
+ if (uncontainedObjectsForResource == null) {
+ uncontainedObjectsForResource = new BasicEList<Object>();
+ uncontainedObjects.put(nextEObject.eResource(), uncontainedObjectsForResource);
+ }
+ uncontainedObjectsForResource.add(nextEObject);
+ continue;
+ }
+ }
+ otherObjects.add(next);
+ }
+ if (!otherObjects.isEmpty()) {
+ append(RemoveCommand.create(domain, otherObjects));
+ }
+ if (uncontainedObjects != null) {
+ for (Map.Entry<Resource, Collection<Object>> nextEntry : uncontainedObjects.entrySet()) {
+ append(new RemoveCommand(domain, nextEntry.getKey().getContents(), nextEntry.getValue()));
+ }
+ }
}
@Override

Back to the top