Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2018-12-17 16:29:00 +0000
committerPierre-Charles David2019-01-03 14:56:18 +0000
commit7b9b602e5ca30f9b21ba6dec4f1c17fb589259be (patch)
treeee3b3f4a85f3d0fdaf8f41a79ee592722f4088d4
parentd99342f0cb63ae672414ba3140f685205c831157 (diff)
downloadorg.eclipse.sirius-7b9b602e5ca30f9b21ba6dec4f1c17fb589259be.tar.gz
org.eclipse.sirius-7b9b602e5ca30f9b21ba6dec4f1c17fb589259be.tar.xz
org.eclipse.sirius-7b9b602e5ca30f9b21ba6dec4f1c17fb589259be.zip
[521937] Fixes DnD wrong location on diagram blank.
* With a figure having negative coordinates or with zoom activated, the drop location on the diagram was wrong. * Reactivate tests with zoom. Bug: 521937 Change-Id: If5a67b5a76fbacf35d5fd0e4ef0641067972a3cf Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerDropPolicy.java26
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragNDropTest.java7
2 files changed, 18 insertions, 15 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerDropPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerDropPolicy.java
index ac173d30f8..5826bfa7ca 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerDropPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerDropPolicy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,7 @@ import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
@@ -441,18 +442,23 @@ public class SiriusContainerDropPolicy extends DragDropEditPolicy {
private Point computeRelativeLocation(final Point absolutePointerLocation, boolean isBorderNode, boolean isConcernedBorderedNode) {
if (absolutePointerLocation != null && getHost() instanceof IGraphicalEditPart) {
final IFigure hostFigure = ((IGraphicalEditPart) getHost()).getFigure();
+ Dimension difference;
+ // If the host edit part is the diagram itself, there is no need to proceed a translation since the
+ // absolutePointerLocation value is already a logical absolute coordinate.
+ if (getHost() instanceof DiagramEditPart) {
+ difference = new Dimension(absolutePointerLocation.x, absolutePointerLocation.y);
+ } else {
+ Point topLeftHostLocation = hostFigure.getBounds().getTopLeft().getCopy();
+ // To avoid the -1 bounds of BorderItemsAwareFreeFormLayer
+ if (topLeftHostLocation.x == -1) {
+ topLeftHostLocation.x = 0;
+ }
+ hostFigure.translateToAbsolute(topLeftHostLocation);
+ GraphicalHelper.screen2logical(topLeftHostLocation, (IGraphicalEditPart) getHost());
- Point topLeftHostLocation = hostFigure.getBounds().getTopLeft().getCopy();
- // To avoid the -1 bounds of BorderItemsAwareFreeFormLayer
- if (topLeftHostLocation.x == -1) {
- topLeftHostLocation.x = 0;
+ difference = absolutePointerLocation.getDifference(topLeftHostLocation);
}
- hostFigure.translateToAbsolute(topLeftHostLocation);
- GraphicalHelper.screen2logical(topLeftHostLocation, (IGraphicalEditPart) getHost());
-
- Dimension difference = absolutePointerLocation.getDifference(topLeftHostLocation);
Point locationHint = new Point(difference.width, difference.height);
-
// if the node is place in a CompartmentEditPart and is
// not a border node, we must take the shifts of compartments in
// account
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragNDropTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragNDropTest.java
index 9123e767b0..29704f3b5a 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragNDropTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DragNDropTest.java
@@ -301,9 +301,7 @@ public class DragNDropTest extends AbstractSiriusSwtBotGefTestCase {
test_DnDPackageFromMC2DiagramBlank2();
try {
-
- // TODO Reactivate once #521937 is fixed.
- // editor.zoom(ZoomLevel.ZOOM_200);
+ editor.zoom(ZoomLevel.ZOOM_200);
openErrorLogViewByAPI();
SWTBot errorLogBot = bot.viewByPartName("Error Log").bot();
@@ -481,8 +479,7 @@ public class DragNDropTest extends AbstractSiriusSwtBotGefTestCase {
try {
editor.click(10, 10);
- // TODO Reactivate once #521937 is fixed.
- // editor.zoom(ZoomLevel.ZOOM_200);
+ editor.zoom(ZoomLevel.ZOOM_200);
openErrorLogViewByAPI();
SWTBot errorLogBot = bot.viewByPartName("Error Log").bot();
int rowCount = errorLogBot.tree().rowCount();

Back to the top