Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2014-12-04 15:34:56 +0000
committerFlorian Barbin2015-01-23 08:28:23 +0000
commitcd7b07fa675c4bcfdb123f50643aad993a2885d4 (patch)
tree734b8c4158e6a3ce7a2d277b1d148552d5123c8a
parent138384d9fa802ea679a40aaefc1055a11860ef14 (diff)
downloadorg.eclipse.sirius-cd7b07fa675c4bcfdb123f50643aad993a2885d4.tar.gz
org.eclipse.sirius-cd7b07fa675c4bcfdb123f50643aad993a2885d4.tar.xz
org.eclipse.sirius-cd7b07fa675c4bcfdb123f50643aad993a2885d4.zip
[428079] Fixes class cast exception on drag and drop tool.
* We did not handle cases where the dropped element will have a different kind of mapping; * Move some code within the DropinForNodeTaskCommand. * Move some code within the new Command DropinForContainerTaskCommand * Add a new SWTBot test that checks combinations we did not handle. Bug: 428079 Change-Id: Ia52e51ef40bc9b2eefee276f6af10fa14305a1d2 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DnDTasksOperations.java174
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForContainerTaskCommand.java115
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForNodeTaskCommand.java209
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.aird130
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.ecore10
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.odesign81
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragAndDropDifferentElementsTest.java162
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java1
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DropinForNodeTaskCommand.java34
9 files changed, 738 insertions, 178 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DnDTasksOperations.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DnDTasksOperations.java
index 244a29be47..0e6cd315a2 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DnDTasksOperations.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DnDTasksOperations.java
@@ -23,18 +23,15 @@ import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
import org.eclipse.sirius.business.api.logger.RuntimeLoggerManager;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
-import org.eclipse.sirius.business.internal.helper.task.DropinForNodeTaskCommand;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterSiriusVariables;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
-import org.eclipse.sirius.diagram.DDiagramElementContainer;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.DNodeContainer;
import org.eclipse.sirius.diagram.DNodeList;
-import org.eclipse.sirius.diagram.DNodeListElement;
import org.eclipse.sirius.diagram.DSemanticDiagram;
import org.eclipse.sirius.diagram.DragAndDropTarget;
import org.eclipse.sirius.diagram.EdgeTarget;
@@ -46,9 +43,6 @@ import org.eclipse.sirius.diagram.business.api.query.IEdgeMappingQuery;
import org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramElementSynchronizer;
import org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer;
import org.eclipse.sirius.diagram.business.internal.experimental.sync.DEdgeCandidate;
-import org.eclipse.sirius.diagram.business.internal.metamodel.description.extensions.IContainerMappingExt;
-import org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContainerMappingHelper;
-import org.eclipse.sirius.diagram.business.internal.metamodel.helper.NodeMappingHelper;
import org.eclipse.sirius.diagram.business.internal.metamodel.operations.DDiagramElementContainerSpecOperations;
import org.eclipse.sirius.diagram.description.ContainerMapping;
import org.eclipse.sirius.diagram.description.DiagramDescription;
@@ -82,7 +76,14 @@ public final class DnDTasksOperations {
}
- private static DDiagram getParentDiagram(final DragAndDropTarget target) {
+ /**
+ * Provides the diagram containing the given target.
+ *
+ * @param target
+ * the drag and drop target.
+ * @return the diagram.
+ */
+ public static DDiagram getParentDiagram(final DragAndDropTarget target) {
DDiagram parentDiagram = null;
if (target instanceof DDiagram) {
parentDiagram = (DDiagram) target;
@@ -115,103 +116,7 @@ public final class DnDTasksOperations {
*/
public static AbstractCommandTask createDropinForNodeTask(final DragAndDropTarget target, final NodeMapping mapping, final DDiagramElement droppedDiagramElement, final EObject droppedElement,
final EObject semanticContainer, final boolean moveEdges) {
- AbstractCommandTask result = new DropinForNodeTaskCommand();
- final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
- if (target instanceof DNodeList) {
- result = new DropinForNodeTaskCommand() {
- @Override
- public void execute() {
- DNodeListElement viewNodeListElement;
- if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
- // The mapping is the same so we don't create a new DNode
- viewNodeListElement = (DNodeListElement) droppedDiagramElement;
- } else {
- IInterpreter interpreter = SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(droppedElement);
- viewNodeListElement = new NodeMappingHelper(interpreter).createListElement(mapping, droppedElement, parentDiagram);
- }
- ((DNodeList) target).getOwnedElements().add(viewNodeListElement);
- if (!viewNodeListElement.equals(droppedDiagramElement)) {
- if (moveEdges) {
- DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, viewNodeListElement);
- }
-
- DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
- }
- }
- };
- } else if (target instanceof DNodeContainer) {
- result = new DropinForNodeTaskCommand() {
- @Override
- public void execute() {
- DNode dNode;
- if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
- // The mapping is the same so we don't create a new DNode
- dNode = (DNode) droppedDiagramElement;
- } else {
- dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
- }
-
- final DNodeContainer dNodeContainer = (DNodeContainer) target;
- if (dNodeContainer.getActualMapping().getAllBorderedNodeMappings().contains(mapping)) {
- dNodeContainer.getOwnedBorderedNodes().add(dNode);
- } else {
- dNodeContainer.getOwnedDiagramElements().add(dNode);
- }
- if (!dNode.equals(droppedDiagramElement)) {
- if (moveEdges) {
- DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
- }
-
- DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
- }
- }
- };
- } else if (target instanceof DNode) {
- result = new DropinForNodeTaskCommand() {
- @Override
- public void execute() {
- DNode dNode;
- if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
- // The mapping is the same so we don't create a new
- // DNode
- dNode = (DNode) droppedDiagramElement;
- } else {
- dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
- }
- ((DNode) target).getOwnedBorderedNodes().add(dNode);
- if (!dNode.equals(droppedDiagramElement)) {
- if (moveEdges) {
- DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
- }
-
- DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
- }
- }
- };
- } else if (target instanceof DDiagram) {
- result = new DropinForNodeTaskCommand() {
- @Override
- public void execute() {
- DNode dNode;
- if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
- // The mapping is the same so we don't create a new
- // DNode
- dNode = (DNode) droppedDiagramElement;
- } else {
- dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
- }
- parentDiagram.getOwnedDiagramElements().add(dNode);
- if (!dNode.equals(droppedDiagramElement)) {
- if (moveEdges) {
- DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
- }
-
- DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
- }
- }
- };
- }
- return result;
+ return new DropinForNodeTaskCommand(target, mapping, droppedDiagramElement, droppedElement, semanticContainer, moveEdges);
}
/**
@@ -234,45 +139,18 @@ public final class DnDTasksOperations {
*/
public static AbstractCommandTask createDropinForContainerTask(final DragAndDropTarget target, final ContainerMapping mapping, final DDiagramElement droppedDiagramElement,
final EObject droppedElement, final EObject semanticContainer, final ContainerDropDescription tool) {
- return new AbstractCommandTask() {
- @Override
- public void execute() {
- final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
- DDiagramElementContainer newDiagramElementContainer = null;
- if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
- // The mapping is the same so we don't create a new DDiagramElementContainer
- newDiagramElementContainer = (DDiagramElementContainer) droppedDiagramElement;
- } else if (mapping instanceof IContainerMappingExt) {
- IInterpreter interpreter = SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(semanticContainer);
- newDiagramElementContainer = new ContainerMappingHelper(interpreter).createContainer((IContainerMappingExt) mapping, droppedElement, semanticContainer, parentDiagram);
- }
- if (newDiagramElementContainer != null) {
- if (target instanceof DDiagram) {
- ((DDiagram) target).getOwnedDiagramElements().add(newDiagramElementContainer);
- } else if (target instanceof DNodeContainer) {
- ((DNodeContainer) target).getOwnedDiagramElements().add(newDiagramElementContainer);
- }
- // move contains children
- if (droppedDiagramElement instanceof DNodeContainer && newDiagramElementContainer instanceof DNodeContainer) {
- DnDTasksOperations.moveSubNodes((DNodeContainer) droppedDiagramElement, droppedElement, tool, (DNodeContainer) newDiagramElementContainer);
- }
- // move edges
- if (!newDiagramElementContainer.equals(droppedDiagramElement)) {
- if (tool.isMoveEdges()) {
- DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, newDiagramElementContainer);
- }
- DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
- }
- }
- }
-
- public String getLabel() {
- return "DropIn task for container";
- }
- };
+ return new DropinForContainerTaskCommand(target, mapping, droppedDiagramElement, droppedElement, semanticContainer, tool);
}
- private static void deletePreviousEdges(final DragAndDropTarget target, final DDiagramElement droppedDiagramElement) {
+ /**
+ * Deletes edges previously attached to the current dropped element.
+ *
+ * @param target
+ * the DragAndDropTarget
+ * @param droppedDiagramElement
+ * the dropped diagram element.
+ */
+ static void deletePreviousEdges(final DragAndDropTarget target, final DDiagramElement droppedDiagramElement) {
final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
@@ -299,6 +177,8 @@ public final class DnDTasksOperations {
}
/**
+ * Updates edges according to the new created diagram element.
+ *
* @param target
* the drop target
* @param semanticTarget
@@ -310,7 +190,7 @@ public final class DnDTasksOperations {
* for the dropped element (it can be equals to the
* droppedDiagramElement if the mapping is the same)
*/
- private static void moveEdges(final DragAndDropTarget target, final EObject semanticTarget, final DDiagramElement droppedDiagramElement, final DDiagramElement createdDiagramElement) {
+ static void moveEdges(final DragAndDropTarget target, final EObject semanticTarget, final DDiagramElement droppedDiagramElement, final DDiagramElement createdDiagramElement) {
final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
@@ -411,7 +291,7 @@ public final class DnDTasksOperations {
* @param tool
* @param diagramElementContainer
*/
- private static void moveSubNodes(final DNodeContainer oldDiagramElementContainer, final EObject containerDroppedElement, final ContainerDropDescription tool,
+ static void moveSubNodes(final DNodeContainer oldDiagramElementContainer, final EObject containerDroppedElement, final ContainerDropDescription tool,
final DNodeContainer newDiagramElementContainer) {
final EList<DDiagramElement> ownedDiagramElementsToDrop = oldDiagramElementContainer.getOwnedDiagramElements();
for (DDiagramElement diagramElementToDrop : ownedDiagramElementsToDrop) {
@@ -497,7 +377,13 @@ public final class DnDTasksOperations {
if (viewContainer instanceof DDiagram) {
((DDiagram) viewContainer).getOwnedDiagramElements().remove(element);
} else if (viewContainer instanceof DNodeList) {
- ((DNodeList) viewContainer).getOwnedElements().remove(element);
+ DNodeList dNodeList = (DNodeList) viewContainer;
+ if (dNodeList.getOwnedBorderedNodes().contains(element)) {
+ dNodeList.getOwnedBorderedNodes().remove(element);
+ } else if (dNodeList.getOwnedElements().contains(element)) {
+ dNodeList.getOwnedElements().remove(element);
+ }
+
} else if (viewContainer instanceof DNodeContainer) {
final DNodeContainer viewNodeContainer = (DNodeContainer) viewContainer;
if (viewNodeContainer.getOwnedBorderedNodes().contains(element)) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForContainerTaskCommand.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForContainerTaskCommand.java
new file mode 100644
index 0000000000..2d09e694ce
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForContainerTaskCommand.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.business.internal.helper.task;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
+import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.DDiagramElement;
+import org.eclipse.sirius.diagram.DDiagramElementContainer;
+import org.eclipse.sirius.diagram.DNodeContainer;
+import org.eclipse.sirius.diagram.DragAndDropTarget;
+import org.eclipse.sirius.diagram.business.internal.metamodel.description.extensions.IContainerMappingExt;
+import org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContainerMappingHelper;
+import org.eclipse.sirius.diagram.description.ContainerMapping;
+import org.eclipse.sirius.diagram.description.tool.ContainerDropDescription;
+import org.eclipse.sirius.ecore.extender.business.api.accessor.exception.FeatureNotFoundException;
+import org.eclipse.sirius.ecore.extender.business.api.accessor.exception.MetaClassNotFoundException;
+import org.eclipse.sirius.viewpoint.SiriusPlugin;
+
+/**
+ * Command that performs the dropin for a Container.
+ *
+ * @author Florian Barbin
+ *
+ */
+public class DropinForContainerTaskCommand extends AbstractCommandTask {
+
+ private DragAndDropTarget target;
+
+ private ContainerMapping mapping;
+
+ private DDiagramElement droppedDiagramElement;
+
+ private EObject droppedElement;
+
+ private EObject semanticContainer;
+
+ private ContainerDropDescription tool;
+
+ /**
+ * Constructor.
+ *
+ * @param target
+ * the drop container target
+ * @param mapping
+ * the mapping
+ * @param droppedDiagramElement
+ * the diagram dropped element (can be null if the drop element
+ * doesn't comes from a diagram)
+ * @param droppedElement
+ * the semantic dropped element
+ * @param semanticContainer
+ * the semantic drop container target
+ * @param tool
+ * the drop tool
+ */
+ public DropinForContainerTaskCommand(DragAndDropTarget target, ContainerMapping mapping, DDiagramElement droppedDiagramElement, EObject droppedElement, EObject semanticContainer,
+ ContainerDropDescription tool) {
+ this.target = target;
+ this.mapping = mapping;
+ this.droppedDiagramElement = droppedDiagramElement;
+ this.droppedElement = droppedElement;
+ this.semanticContainer = semanticContainer;
+ this.tool = tool;
+ }
+
+ @Override
+ public String getLabel() {
+ return "DropIn task for container";
+ }
+
+ @Override
+ public void execute() throws MetaClassNotFoundException, FeatureNotFoundException {
+ final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
+ DDiagramElementContainer newDiagramElementContainer = null;
+ if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping()) && droppedDiagramElement instanceof DDiagramElementContainer) {
+ // The mapping is the same so we don't create a new
+ // DDiagramElementContainer
+ newDiagramElementContainer = (DDiagramElementContainer) droppedDiagramElement;
+ } else if (mapping instanceof IContainerMappingExt) {
+ IInterpreter interpreter = SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(semanticContainer);
+ newDiagramElementContainer = new ContainerMappingHelper(interpreter).createContainer((IContainerMappingExt) mapping, droppedElement, semanticContainer, parentDiagram);
+ }
+ if (newDiagramElementContainer != null) {
+ if (target instanceof DDiagram) {
+ ((DDiagram) target).getOwnedDiagramElements().add(newDiagramElementContainer);
+ } else if (target instanceof DNodeContainer) {
+ ((DNodeContainer) target).getOwnedDiagramElements().add(newDiagramElementContainer);
+ }
+ // move contains children
+ if (droppedDiagramElement instanceof DNodeContainer && newDiagramElementContainer instanceof DNodeContainer) {
+ DnDTasksOperations.moveSubNodes((DNodeContainer) droppedDiagramElement, droppedElement, tool, (DNodeContainer) newDiagramElementContainer);
+ }
+ // move edges
+ if (!newDiagramElementContainer.equals(droppedDiagramElement)) {
+ if (tool.isMoveEdges()) {
+ DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, newDiagramElementContainer);
+ }
+ DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
+ }
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForNodeTaskCommand.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForNodeTaskCommand.java
new file mode 100644
index 0000000000..62e11ac88b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/DropinForNodeTaskCommand.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2009 THALES GLOBAL SERVICES.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.diagram.business.internal.helper.task;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
+import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.diagram.AbstractDNode;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.DDiagramElement;
+import org.eclipse.sirius.diagram.DNode;
+import org.eclipse.sirius.diagram.DNodeContainer;
+import org.eclipse.sirius.diagram.DNodeList;
+import org.eclipse.sirius.diagram.DNodeListElement;
+import org.eclipse.sirius.diagram.DragAndDropTarget;
+import org.eclipse.sirius.diagram.business.internal.metamodel.helper.NodeMappingHelper;
+import org.eclipse.sirius.diagram.description.AbstractNodeMapping;
+import org.eclipse.sirius.diagram.description.NodeMapping;
+import org.eclipse.sirius.viewpoint.SiriusPlugin;
+
+/**
+ * Default command for dropin node.
+ *
+ * @author lredor
+ */
+public class DropinForNodeTaskCommand extends AbstractCommandTask {
+
+ private DragAndDropTarget target;
+
+ private NodeMapping mapping;
+
+ private DDiagramElement droppedDiagramElement;
+
+ private EObject droppedElement;
+
+ private EObject semanticContainer;
+
+ private boolean moveEdges;
+
+ /**
+ * Constructor.
+ *
+ * @param target
+ * the drop container target.
+ * @param mapping
+ * the mapping.
+ * @param droppedDiagramElement
+ * the dropped diagram element.
+ * @param droppedElement
+ * the semantic dropped element.
+ * @param semanticContainer
+ * the semantic drop container.
+ * @param moveEdges
+ * tell whether edges should be moved after dnd.
+ */
+ public DropinForNodeTaskCommand(DragAndDropTarget target, NodeMapping mapping, DDiagramElement droppedDiagramElement, EObject droppedElement, EObject semanticContainer, boolean moveEdges) {
+ this.target = target;
+ this.mapping = mapping;
+ this.droppedDiagramElement = droppedDiagramElement;
+ this.droppedElement = droppedElement;
+ this.semanticContainer = semanticContainer;
+ this.moveEdges = moveEdges;
+ }
+
+ /**
+ * (non-Javadoc).
+ *
+ * @see org.eclipse.sirius.business.api.helper.task.ICommandTask#execute()
+ */
+ public void execute() {
+ final DDiagram parentDiagram = DnDTasksOperations.getParentDiagram(target);
+ if (target instanceof DNodeList) {
+ handleDNodeListCase(parentDiagram);
+ } else if (target instanceof DNodeContainer) {
+ handleDNodeContainerCase(parentDiagram);
+ } else if (target instanceof DNode) {
+ handleDNodeCase(parentDiagram);
+ } else if (target instanceof DDiagram) {
+ handleDDiagramCase(parentDiagram);
+ }
+ }
+
+ private void handleDNodeListCase(DDiagram parentDiagram) {
+ AbstractDNode abstractDNode = null;
+ boolean isBorderNode = isBorderNodeMapping(mapping, ((DNodeList) target).getActualMapping());
+ if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping())) {
+ if ((isBorderNode && droppedDiagramElement instanceof DNode) || (!isBorderNode && droppedDiagramElement instanceof DNodeListElement)) {
+ // The mapping is a border node mapping and the
+ // current dragged element is a DNode so we don't need
+ // to
+ // create a new one.
+ abstractDNode = (AbstractDNode) droppedDiagramElement;
+ }
+
+ } else if (abstractDNode == null) {
+ IInterpreter interpreter = SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(droppedElement);
+ if (isBorderNode) {
+ abstractDNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
+ } else {
+ abstractDNode = new NodeMappingHelper(interpreter).createListElement(mapping, droppedElement, parentDiagram);
+ }
+ }
+ if (abstractDNode instanceof DNodeListElement) {
+ ((DNodeList) target).getOwnedElements().add((DNodeListElement) abstractDNode);
+ } else if (abstractDNode instanceof DNode) {
+ ((DNodeList) target).getOwnedBorderedNodes().add((DNode) abstractDNode);
+ }
+ if (!abstractDNode.equals(droppedDiagramElement)) {
+ if (moveEdges) {
+ DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, abstractDNode);
+ }
+
+ DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
+ }
+ }
+
+ /**
+ * Returns whether the given node mapping is used to define a border node.
+ *
+ * @param nodeMapping
+ * the node mapping
+ * @param abstractNodeMapping
+ * the abstract node mapping for which the given node mapping is
+ * a sub-node.
+ * @return true if the given mapping is a border node for the given abstract
+ * node mapping, otherwise false.
+ */
+ private static boolean isBorderNodeMapping(NodeMapping nodeMapping, AbstractNodeMapping abstractNodeMapping) {
+ return abstractNodeMapping.getAllBorderedNodeMappings().contains(nodeMapping);
+ }
+
+ private void handleDNodeContainerCase(DDiagram parentDiagram) {
+ DNode dNode;
+ if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping()) && droppedDiagramElement instanceof DNode) {
+ // The mapping is the same and the droppedDiagramElement
+ // is a DNode (could be a DNodeListElement for instance)
+ // so we don't create a new DNode
+ dNode = (DNode) droppedDiagramElement;
+ } else {
+ dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
+ }
+
+ final DNodeContainer dNodeContainer = (DNodeContainer) target;
+ if (isBorderNodeMapping(mapping, dNodeContainer.getActualMapping())) {
+ dNodeContainer.getOwnedBorderedNodes().add(dNode);
+ } else {
+ dNodeContainer.getOwnedDiagramElements().add(dNode);
+ }
+ if (!dNode.equals(droppedDiagramElement)) {
+ if (moveEdges) {
+ DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
+ }
+
+ DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
+ }
+
+ }
+
+ private void handleDNodeCase(DDiagram parentDiagram) {
+ DNode dNode;
+ if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping()) && droppedDiagramElement instanceof DNode) {
+ // The mapping is the same so we don't create a new
+ // DNode
+ dNode = (DNode) droppedDiagramElement;
+ } else {
+ dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
+ }
+ ((DNode) target).getOwnedBorderedNodes().add(dNode);
+ if (!dNode.equals(droppedDiagramElement)) {
+ if (moveEdges) {
+ DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
+ }
+
+ DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
+ }
+
+ }
+
+ private void handleDDiagramCase(DDiagram parentDiagram) {
+ DNode dNode;
+ if (droppedDiagramElement != null && mapping.equals(droppedDiagramElement.getMapping()) && droppedDiagramElement instanceof DNode) {
+ // The mapping is the same so we don't create a new
+ // DNode
+ dNode = (DNode) droppedDiagramElement;
+ } else {
+ dNode = mapping.createNode(droppedElement, semanticContainer, parentDiagram);
+ }
+ parentDiagram.getOwnedDiagramElements().add(dNode);
+ if (!dNode.equals(droppedDiagramElement)) {
+ if (moveEdges) {
+ DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, dNode);
+ }
+
+ DnDTasksOperations.deletePreviousEdges(target, droppedDiagramElement);
+ }
+ }
+
+ public String getLabel() {
+ return "DropIn task for node";
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.aird
new file mode 100644
index 0000000000..16343de47f
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.aird
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_x0nwEIHbEeSiCbgybe9sTQ" selectedViews="_yWEQQIHbEeSiCbgybe9sTQ" version="8.1.1">
+ <models xmi:type="ecore:EPackage" href="bug428079.ecore#/"/>
+ <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_yWEQQIHbEeSiCbgybe9sTQ" initialized="true">
+ <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_kdlR8IHlEeSiCbgybe9sTQ" name="new bug428079">
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_kdnuMIHlEeSiCbgybe9sTQ" source="GMF_DIAGRAMS">
+ <data xmi:type="notation:Diagram" xmi:id="_kdnuMYHlEeSiCbgybe9sTQ" type="Sirius" element="_kdlR8IHlEeSiCbgybe9sTQ" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="_kdnuM4HlEeSiCbgybe9sTQ" type="2001" element="_kdlR8YHlEeSiCbgybe9sTQ">
+ <children xmi:type="notation:Node" xmi:id="_kdoVQIHlEeSiCbgybe9sTQ" type="5002">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_kdoVQYHlEeSiCbgybe9sTQ" x="134"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kdrYk4HlEeSiCbgybe9sTQ" type="3003" element="_kdlR8oHlEeSiCbgybe9sTQ">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdrYlIHlEeSiCbgybe9sTQ" fontName="Cantarell"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdrYlYHlEeSiCbgybe9sTQ"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdnuNIHlEeSiCbgybe9sTQ" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdnuNYHlEeSiCbgybe9sTQ" x="276" y="216" width="133" height="97"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kdo8UIHlEeSiCbgybe9sTQ" type="2003" element="_kdlR9oHlEeSiCbgybe9sTQ">
+ <children xmi:type="notation:Node" xmi:id="_kdr_oIHlEeSiCbgybe9sTQ" type="3012" element="_kdlR94HlEeSiCbgybe9sTQ">
+ <children xmi:type="notation:Node" xmi:id="_kdsmsIHlEeSiCbgybe9sTQ" type="5010">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_kdsmsYHlEeSiCbgybe9sTQ" x="31"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kdtNwIHlEeSiCbgybe9sTQ" type="3003" element="_kdlR-IHlEeSiCbgybe9sTQ">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdtNwYHlEeSiCbgybe9sTQ" fontName="Cantarell"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdtNwoHlEeSiCbgybe9sTQ"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdr_oYHlEeSiCbgybe9sTQ" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdr_ooHlEeSiCbgybe9sTQ" x="-22" y="43" width="30" height="30"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kdpjYIHlEeSiCbgybe9sTQ" type="5007"/>
+ <children xmi:type="notation:Node" xmi:id="_kdqKcIHlEeSiCbgybe9sTQ" type="7004">
+ <children xmi:type="notation:Node" xmi:id="_kdtNw4HlEeSiCbgybe9sTQ" type="3010" element="_kdlSAYHlEeSiCbgybe9sTQ">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_kdtNxIHlEeSiCbgybe9sTQ"/>
+ </children>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_kdqKcYHlEeSiCbgybe9sTQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_kdqKcoHlEeSiCbgybe9sTQ"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdo8UYHlEeSiCbgybe9sTQ" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdo8UoHlEeSiCbgybe9sTQ" x="72" y="24" width="219" height="123"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kdqKc4HlEeSiCbgybe9sTQ" type="2002" element="_kdlSBoHlEeSiCbgybe9sTQ">
+ <children xmi:type="notation:Node" xmi:id="_kdqxgIHlEeSiCbgybe9sTQ" type="5006"/>
+ <children xmi:type="notation:Node" xmi:id="_kdrYkIHlEeSiCbgybe9sTQ" type="7001">
+ <styles xmi:type="notation:SortingStyle" xmi:id="_kdrYkYHlEeSiCbgybe9sTQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_kdrYkoHlEeSiCbgybe9sTQ"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kdqKdIHlEeSiCbgybe9sTQ" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdqKdYHlEeSiCbgybe9sTQ" x="432" y="36" width="315" height="127"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_kdnuMoHlEeSiCbgybe9sTQ"/>
+ </data>
+ </ownedAnnotationEntries>
+ <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_kdlR8YHlEeSiCbgybe9sTQ" name="NewEClass3" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass3"/>
+ <semanticElements xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass3"/>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="_kdlR8oHlEeSiCbgybe9sTQ">
+ <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR84HlEeSiCbgybe9sTQ"/>
+ <description xmi:type="style:SquareDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@nodeMappings[name='NewEClass3']/@style"/>
+ <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR9IHlEeSiCbgybe9sTQ"/>
+ <color xmi:type="viewpoint:RGBValues" xmi:id="_kdlR9YHlEeSiCbgybe9sTQ" red="255" green="245" blue="181"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@nodeMappings[name='NewEClass3']"/>
+ </ownedDiagramElements>
+ <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_kdlR9oHlEeSiCbgybe9sTQ" name="NewEClass1">
+ <target xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass1"/>
+ <semanticElements xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass1"/>
+ <ownedBorderedNodes xmi:type="diagram:DNode" xmi:id="_kdlR94HlEeSiCbgybe9sTQ" name="ref1" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EReference" href="bug428079.ecore#//NewEClass1/ref1"/>
+ <semanticElements xmi:type="ecore:EReference" href="bug428079.ecore#//NewEClass1/ref1"/>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="_kdlR-IHlEeSiCbgybe9sTQ">
+ <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR-YHlEeSiCbgybe9sTQ"/>
+ <description xmi:type="style:SquareDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@borderedNodeMappings[name='borderNodeRef']/@style"/>
+ <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR-oHlEeSiCbgybe9sTQ"/>
+ <color xmi:type="viewpoint:RGBValues" xmi:id="_kdlR-4HlEeSiCbgybe9sTQ" red="136" green="136" blue="136"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@borderedNodeMappings[name='borderNodeRef']"/>
+ </ownedBorderedNodes>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_kdlR_IHlEeSiCbgybe9sTQ">
+ <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR_YHlEeSiCbgybe9sTQ"/>
+ <description xmi:type="style:FlatContainerStyleDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@style"/>
+ <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR_oHlEeSiCbgybe9sTQ"/>
+ <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlR_4HlEeSiCbgybe9sTQ" red="255" green="255" blue="255"/>
+ <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSAIHlEeSiCbgybe9sTQ" red="209" green="209" blue="209"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:ContainerMapping" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']"/>
+ <ownedElements xmi:type="diagram:DNodeListElement" xmi:id="_kdlSAYHlEeSiCbgybe9sTQ" name="a">
+ <target xmi:type="ecore:EAttribute" href="bug428079.ecore#//NewEClass1/a"/>
+ <semanticElements xmi:type="ecore:EAttribute" href="bug428079.ecore#//NewEClass1/a"/>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="_kdlSAoHlEeSiCbgybe9sTQ">
+ <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSA4HlEeSiCbgybe9sTQ"/>
+ <description xmi:type="style:SquareDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@subNodeMappings[name='listElementAtt']/@style"/>
+ <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSBIHlEeSiCbgybe9sTQ"/>
+ <color xmi:type="viewpoint:RGBValues" xmi:id="_kdlSBYHlEeSiCbgybe9sTQ" red="136" green="136" blue="136"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@subNodeMappings[name='listElementAtt']"/>
+ </ownedElements>
+ </ownedDiagramElements>
+ <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_kdlSBoHlEeSiCbgybe9sTQ" name="NewEClass2">
+ <target xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass2"/>
+ <semanticElements xmi:type="ecore:EClass" href="bug428079.ecore#//NewEClass2"/>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_kdlSB4HlEeSiCbgybe9sTQ">
+ <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSCIHlEeSiCbgybe9sTQ"/>
+ <description xmi:type="style:FlatContainerStyleDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass2']/@style"/>
+ <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSCYHlEeSiCbgybe9sTQ"/>
+ <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdlSCoHlEeSiCbgybe9sTQ" red="255" green="255" blue="255"/>
+ <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdl5AIHlEeSiCbgybe9sTQ" red="209" green="209" blue="209"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:ContainerMapping" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass2']"/>
+ </ownedDiagramElements>
+ <description xmi:type="description_1:DiagramDescription" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']"/>
+ <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_kdl5AYHlEeSiCbgybe9sTQ"/>
+ <activatedLayers xmi:type="description_1:Layer" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer"/>
+ <target xmi:type="ecore:EPackage" href="bug428079.ecore#/"/>
+ </ownedRepresentations>
+ <viewpoint xmi:type="description:Viewpoint" href="bug428079.odesign#//@ownedViewpoints[name='bug428079']"/>
+ </ownedViews>
+</viewpoint:DAnalysis>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.ecore
new file mode 100644
index 0000000000..b9364f627c
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.ecore
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="">
+ <eClassifiers xsi:type="ecore:EClass" name="NewEClass1">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="a"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="ref1" eType="#//NewEClass2"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="NewEClass2"/>
+ <eClassifiers xsi:type="ecore:EClass" name="NewEClass3"/>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.odesign
new file mode 100644
index 0000000000..61ca359437
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/bug428079/bug428079.odesign
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="My" version="10.0.0.201411061000">
+ <ownedViewpoints name="bug428079" modelFileExtension="ecore">
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="bug428079" domainClass="EPackage">
+ <defaultLayer name="Default">
+ <nodeMappings name="NewEClass3" semanticCandidatesExpression="[eClassifiers->select(name='NewEClass3')/]" domainClass="EClass" dropDescriptions="//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@toolSections.0/@ownedTools[name='dnd']">
+ <borderedNodeMappings xsi:type="description_1:NodeMappingImport" name="AttBN" semanticCandidatesExpression="feature:eAllAttributes" importedMapping="//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass2']/@subNodeMappings[name='attr']"/>
+ <borderedNodeMappings name="borderNodeRefEClass3" semanticCandidatesExpression="feature:eStructuralFeatures" domainClass="EReference">
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </borderedNodeMappings>
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_yellow']"/>
+ </style>
+ </nodeMappings>
+ <containerMappings name="NewEClass1" semanticCandidatesExpression="[eClassifiers->select(name='NewEClass1')/]" domainClass="EClass" dropDescriptions="//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@toolSections.0/@ownedTools[name='dnd']" childrenPresentation="List">
+ <borderedNodeMappings name="borderNodeRef" semanticCandidatesExpression="feature:eStructuralFeatures" domainClass="EReference">
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </borderedNodeMappings>
+ <subNodeMappings name="listElementAtt" semanticCandidatesExpression="feature:eAllAttributes" domainClass="EAttribute">
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </subNodeMappings>
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="NewEClass2" semanticCandidatesExpression="[eClassifiers->select(name='NewEClass2')/]" domainClass="EClass" dropDescriptions="//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@toolSections.0/@ownedTools[name='dnd']">
+ <borderedNodeMappings name="borderNodeRefEClass2" semanticCandidatesExpression="feature:eStructuralFeatures" domainClass="EReference">
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </borderedNodeMappings>
+ <subNodeMappings name="attr" semanticCandidatesExpression="feature:eAllAttributes" domainClass="EAttribute">
+ <style xsi:type="style:SquareDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </subNodeMappings>
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <toolSections name="def">
+ <ownedTools xsi:type="tool:ContainerDropDescription" name="dnd" mappings="//@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass2']/@borderedNodeMappings[name='borderNodeRefEClass2'] //@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@nodeMappings[name='NewEClass3']/@borderedNodeMappings[name='borderNodeRefEClass3'] //@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@borderedNodeMappings[name='borderNodeRef'] //@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass2']/@subNodeMappings[name='attr'] //@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@nodeMappings[name='NewEClass3']/@borderedNodeMappings[name='AttBN'] //@ownedViewpoints[name='bug428079']/@ownedRepresentations[name='bug428079']/@defaultLayer/@containerMappings[name='NewEClass1']/@subNodeMappings[name='listElementAtt']">
+ <oldContainer name="oldSemanticContainer"/>
+ <newContainer name="newSemanticContainer"/>
+ <element name="element"/>
+ <newViewContainer name="newContainerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:element">
+ <subModelOperations xsi:type="tool_1:MoveElement" newContainerExpression="var:newSemanticContainer" featureName="eStructuralFeatures"/>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ </toolSections>
+ </defaultLayer>
+ </ownedRepresentations>
+ </ownedViewpoints>
+</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragAndDropDifferentElementsTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragAndDropDifferentElementsTest.java
new file mode 100644
index 0000000000..836c0f6a71
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragAndDropDifferentElementsTest.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.swtbot;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.DNode;
+import org.eclipse.sirius.diagram.DNodeContainer;
+import org.eclipse.sirius.diagram.DNodeList;
+import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNameEditPart;
+import org.eclipse.sirius.diagram.ui.edit.api.part.IAbstractDiagramNodeEditPart;
+import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
+import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+
+/**
+ * Tests that drag and drop an element toward an other node with a different
+ * mapping works properly.
+ *
+ * @author Florian Barbin
+ */
+public class DragAndDropDifferentElementsTest extends AbstractSiriusSwtBotGefTestCase {
+
+ private static final String REF1 = "ref1";
+
+ private static final String A = "a";
+
+ private static final String PATH = "/data/unit/dragAndDrop/bug428079/";
+
+ private static final String SEMANTIC_MODEL = "bug428079.ecore";
+
+ private static final String REPRESENTATION_MODEL = "bug428079.aird";
+
+ private static final String MODELER = "bug428079.odesign";
+
+ private static final String REPRESENTATION_DESCRIPTION_NAME = "bug428079";
+
+ private static final String REPRESENTATION_NAME = "new " + REPRESENTATION_DESCRIPTION_NAME;
+
+ @Override
+ protected void onSetUpBeforeClosingWelcomePage() throws Exception {
+ copyFileToTestProject(Activator.PLUGIN_ID, PATH, SEMANTIC_MODEL, REPRESENTATION_MODEL, MODELER);
+ }
+
+ @Override
+ protected void onSetUpAfterOpeningDesignerPerspective() throws Exception {
+ changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false);
+ sessionAirdResource = new UIResource(designerProject, "/", REPRESENTATION_MODEL);
+ localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), REPRESENTATION_DESCRIPTION_NAME, REPRESENTATION_NAME, DDiagram.class);
+ }
+
+ /**
+ * Tests different drag and drop cases.
+ */
+ public void testDragNDropOfDifferentDDiagramElements() {
+ // list element => container sub-node
+ dragNDropToEClass2Container(AbstractDiagramNameEditPart.class, A, false);
+
+ // container sub-node => border node of node
+ dragNDropToEClass3Node(IAbstractDiagramNodeEditPart.class, A);
+
+ // border node of node => list element
+ dragNDropToEClass1List(IAbstractDiagramNodeEditPart.class, A, false);
+
+ // list element => border node of node
+ dragNDropToEClass3Node(AbstractDiagramNameEditPart.class, A);
+
+ // border node of node => container sub-node
+ dragNDropToEClass2Container(IAbstractDiagramNodeEditPart.class, A, false);
+
+ // container sub-node => list element
+ dragNDropToEClass1List(IAbstractDiagramNodeEditPart.class, A, false);
+
+ // container list border-node => container border-node
+ dragNDropToEClass2Container(IAbstractDiagramNodeEditPart.class, REF1, true);
+
+ // container border-node=> node border-node
+ dragNDropToEClass3Node(IAbstractDiagramNodeEditPart.class, REF1);
+
+ // node border-node => list border-node
+ dragNDropToEClass1List(IAbstractDiagramNodeEditPart.class, REF1, true);
+
+ // list border-node => node border-node
+ dragNDropToEClass3Node(IAbstractDiagramNodeEditPart.class, REF1);
+
+ // node border-node => container border-node
+ dragNDropToEClass2Container(IAbstractDiagramNodeEditPart.class, REF1, true);
+
+ // container border-node => list border-node
+ dragNDropToEClass1List(IAbstractDiagramNodeEditPart.class, REF1, true);
+ }
+
+ private void dragNDropToEClass1List(Class<? extends EditPart> editPartType, String name, boolean isBorder) {
+ SWTBotGefEditPart eClassEditPart = editor.getEditPart("NewEClass1", IAbstractDiagramNodeEditPart.class);
+ dragAndDropFromTo(editor.getEditPart(name, editPartType), eClassEditPart);
+ EditPart editPart = eClassEditPart.part();
+ DNodeList dnodeList = (DNodeList) ((Node) editPart.getModel()).getElement();
+ String message = " element should be dropped into NewEClass1 as a ";
+ if (isBorder) {
+ assertEquals("The " + name + message + "border node", 1, dnodeList.getOwnedBorderedNodes().size());
+ } else {
+ assertEquals("The " + name + message + "list element", 1, dnodeList.getOwnedElements().size());
+ }
+ }
+
+ private void dragNDropToEClass3Node(Class<? extends EditPart> editPartType, String name) {
+ SWTBotGefEditPart eClassEditPart = editor.getEditPart("NewEClass3", IAbstractDiagramNodeEditPart.class);
+ dragAndDropFromTo(editor.getEditPart(name, editPartType), eClassEditPart);
+ EditPart editPart = eClassEditPart.part();
+ DNode dnode = (DNode) ((Node) editPart.getModel()).getElement();
+ assertEquals("The " + name + " element should be dropped into NewEClass3 as a border-node", 1, dnode.getOwnedBorderedNodes().size());
+ }
+
+ private void dragNDropToEClass2Container(Class<? extends EditPart> editPartType, String name, boolean isBorder) {
+ SWTBotGefEditPart eClassEditPart = editor.getEditPart("NewEClass2", IAbstractDiagramNodeEditPart.class);
+ dragAndDropFromTo(editor.getEditPart(name, editPartType), eClassEditPart);
+
+ // Check that the container where the list element has been dropped
+ // contains a sub-node.
+ EditPart editPart = eClassEditPart.part();
+ DNodeContainer container = (DNodeContainer) ((Node) editPart.getModel()).getElement();
+ String message = " element should be dropped into NewEClass2 as a ";
+ if (isBorder) {
+ assertEquals("The " + name + message + "border-node", 1, container.getOwnedBorderedNodes().size());
+ } else {
+ assertEquals("The " + name + message + "sub-node", 1, container.getElements().size());
+ }
+ }
+
+ private void dragAndDropFromTo(SWTBotGefEditPart dragged, SWTBotGefEditPart target) {
+ dragged.click();
+
+ Rectangle endBounds = ((GraphicalEditPart) target.part()).getFigure().getBounds();
+ ((GraphicalEditPart) target.part()).getFigure().translateToAbsolute(endBounds);
+ Point endLocation = endBounds.getCenter();
+
+ editor.drag(dragged, endLocation);
+ SWTBotUtils.waitAllUiEvents();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ editor.close();
+ super.tearDown();
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
index 76e2c3dbe7..4244b23f40 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
@@ -127,6 +127,7 @@ public class AllTestSuite extends TestCase {
suite.addTestSuite(KeyboardDeleteFromDiagramTests.class);
suite.addTestSuite(CustomClipboardSupportTest.class);
suite.addTestSuite(KeyboardDeletionFromLabelTests.class);
+ suite.addTestSuite(DragAndDropDifferentElementsTest.class);
}
/**
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DropinForNodeTaskCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DropinForNodeTaskCommand.java
deleted file mode 100644
index fd5ad65410..0000000000
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/DropinForNodeTaskCommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 THALES GLOBAL SERVICES.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.business.internal.helper.task;
-
-import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
-
-/**
- * Default command for dropin node.
- *
- * @author lredor
- */
-public class DropinForNodeTaskCommand extends AbstractCommandTask {
-
- /**
- * (non-Javadoc).
- *
- * @see org.eclipse.sirius.business.api.helper.task.ICommandTask#execute()
- */
- public void execute() {
- // do nothing
- }
-
- public String getLabel() {
- return "DropIn task for node";
- }
-}

Back to the top