Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-07-02 13:41:47 +0000
committerThomas Schindl2010-07-02 13:41:47 +0000
commitfac7a2ab29229940a3c08b4461626e7340bee720 (patch)
treebe9ade5c8ade9b08bc35b2d830824c89ca86f0f3
parent061a51d532073169c998b51573b06e3d326e443b (diff)
downloadorg.eclipse.e4.tools-fac7a2ab29229940a3c08b4461626e7340bee720.tar.gz
org.eclipse.e4.tools-fac7a2ab29229940a3c08b4461626e7340bee720.tar.xz
org.eclipse.e4.tools-fac7a2ab29229940a3c08b4461626e7340bee720.zip
Bug 318246 - [Model Tooling] Drag and drop for Parts into container
* a first version which needs testing, ...
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index 9d7e37d4..7d7dfdf5 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -689,7 +689,6 @@ public class ModelEditor {
} else if (getCurrentLocation() == LOCATION_AFTER || getCurrentLocation() == LOCATION_BEFORE) {
EStructuralFeature feature = null;
EObject parent = null;
- int index = CommandParameter.NO_INDEX;
TreeItem item = (TreeItem) getCurrentEvent().item;
if (item != null) {
@@ -705,21 +704,27 @@ public class ModelEditor {
feature = UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN;
}
}
-
- index = parentItem.indexOf(item);
}
}
if (feature != null && parent != null) {
+ List<Object> list = (List<Object>) parent.eGet(feature);
+ int index = list.indexOf(getCurrentTarget());
+
+ // if (getCurrentLocation() == LOCATION_AFTER) {
+ // index += 1;
+ // }
+
+ if (index >= list.size()) {
+ index = CommandParameter.NO_INDEX;
+ }
+
if (parent == ((EObject) data).eContainer()) {
Command cmd = MoveCommand.create(domain, parent, feature, data, index);
if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
} else {
- if (index >= ((List<?>) parent.eGet(feature)).size()) {
- index = CommandParameter.NO_INDEX;
- }
Command cmd = AddCommand.create(domain, parent, feature, data, index);
if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);

Back to the top