summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorIngo Weigelt2012-03-30 10:28:32 (EDT)
committer Michael Jastram2012-04-05 06:48:09 (EDT)
commit2c73da122d7ff43240f7b07771114ac99c4ebe92 (patch)
tree3d1f73bbf1f533193d24421852d1ae15b7ececf4
parentd6e94ee9babdf538af25e7605bd4b6856f488130 (diff)
downloadorg.eclipse.rmf-2c73da122d7ff43240f7b07771114ac99c4ebe92.zip
org.eclipse.rmf-2c73da122d7ff43240f7b07771114ac99c4ebe92.tar.gz
org.eclipse.rmf-2c73da122d7ff43240f7b07771114ac99c4ebe92.tar.bz2
Fixed Bug 375427 - IF a SpecHierarchy is dropped onto itself, nothing
should happen. Also dropping somewhere within its child hierarchy is forbidden
-rw-r--r--org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/provider/SpecHierarchyItemProvider.java13
-rw-r--r--org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/util/ProrUtil.java29
2 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/provider/SpecHierarchyItemProvider.java b/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/provider/SpecHierarchyItemProvider.java
index 2302570..2ba19a6 100644
--- a/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/provider/SpecHierarchyItemProvider.java
+++ b/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/provider/SpecHierarchyItemProvider.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
@@ -376,6 +377,18 @@ public class SpecHierarchyItemProvider extends
Object owner, float location, int operations, int operation,
Collection<?> collection) {
+ for (Object obj : collection) {
+ if (obj instanceof SpecHierarchy) {
+ SpecHierarchy specHierarchy = (SpecHierarchy) obj;
+
+ if (!ProrUtil.isValidDrop(specHierarchy, owner)){
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ }
+ }
+
+
Command cmd = ProrUtil.getPresentationHandleDragAndDropCommand(domain, owner, location,
operations, operation, collection);
if (cmd != null)
diff --git a/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/util/ProrUtil.java b/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/util/ProrUtil.java
index 8755d55..add1701 100644
--- a/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/util/ProrUtil.java
+++ b/org.eclipse.rmf.pror.reqif10.edit/src/org/eclipse/rmf/pror/reqif10/util/ProrUtil.java
@@ -686,4 +686,33 @@ public final class ProrUtil {
}
}
+
+ /**
+ * Helper function for drag and drop operations:
+ * Tests if the element source may be dropped onto the target object.
+ *
+ * @param source
+ * @param target
+ * @return true if the drop should be accepted, false otherwise
+ */
+ public static boolean isValidDrop(SpecHierarchy source, Object target) {
+ if (source == target){
+ return false;
+ }
+
+ if (source.getChildren().contains(target)){
+ return false;
+ }
+
+ for (EObject child : source.getChildren()) {
+ if (child instanceof SpecHierarchy){
+ if (!isValidDrop((SpecHierarchy) child, target)){
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
}