diff options
| author | Laurent Redor | 2017-08-29 09:18:12 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-08-30 07:34:52 +0000 |
| commit | e1ae600bf4fffac27293e8c038528231b1ec734f (patch) | |
| tree | 24f2bd3ba3c512dc170b0df4dfa47ccde60b65b7 | |
| parent | 403562c75de2576efaff7565e8f667d5261f13e5 (diff) | |
| download | org.eclipse.sirius-e1ae600bf4fffac27293e8c038528231b1ec734f.tar.gz org.eclipse.sirius-e1ae600bf4fffac27293e8c038528231b1ec734f.tar.xz org.eclipse.sirius-e1ae600bf4fffac27293e8c038528231b1ec734f.zip | |
[520881] Fix bug in CopyPasteFormat action for border nodes
Since the fix of NodeQuery in commit 69c1fb1fb [1] concerning insets,
some conversions done in AbstractSiriusFormatDataManager are no
longer needed (the tests from BorderedNodeCopyPasteFormatTest reveal
this problem).
The same fix has been done in deprecated
AbstractSiriusLayoutDataManager.
[1]
http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=69c1fb1fbcd980be8282cc8ac84ce8b3f4996202
Bug: 520881
Change-Id: I8d15f8d788c0782df70c77537e113a22719b42c3
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
2 files changed, 5 insertions, 45 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java index fb3663f9a6..fea828c5ac 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java @@ -666,18 +666,12 @@ public abstract class AbstractSiriusFormatDataManager implements SiriusFormatDat locator.setBorderItemOffset(IBorderItemOffsets.DEFAULT_OFFSET); } - // CanonicalDBorderItemLocator works with absolute GMF parent - // location so we need to translate BorderedNode absolute - // location - // from Draw2D to GMF. - - Point delta = getGMFDraw2DDelta(parentNode, (IGraphicalEditPart) parentGraphicalEditPart); - final Rectangle rect = new Rectangle(locationToApply.getX() - delta.getX(), locationToApply.getY() - delta.getY(), formatData.getWidth(), formatData.getHeight()); + final Rectangle rect = new Rectangle(locationToApply.getX(), locationToApply.getY(), formatData.getWidth(), formatData.getHeight()); final org.eclipse.draw2d.geometry.Point realLocation = locator.getValidLocation(rect, toRestoreView, portsNodesToIgnore); // Compute the new relative position to the parent - final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode).getTopLeft(); + final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode, true).getTopLeft(); locationToApply.setX(realLocation.x); locationToApply.setY(realLocation.y); locationToApply = FormatDataHelper.INSTANCE.getTranslated(locationToApply, parentAbsoluteLocation.negate()); @@ -727,20 +721,6 @@ public abstract class AbstractSiriusFormatDataManager implements SiriusFormatDat } } - private Point getGMFDraw2DDelta(Node parentNode, IGraphicalEditPart parentEditPart) { - - Point delta = FormatdataFactory.eINSTANCE.createPoint(); - - org.eclipse.draw2d.geometry.Point parentDraw2DAbsoluteLocation = parentEditPart.getFigure().getBounds().getTopLeft().getCopy(); - FigureUtilities.translateToAbsoluteByIgnoringScrollbar(parentEditPart.getFigure(), parentDraw2DAbsoluteLocation); - - org.eclipse.draw2d.geometry.Point parentGMFAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode); - delta.setX(parentDraw2DAbsoluteLocation.x - parentGMFAbsoluteLocation.x); - delta.setY(parentDraw2DAbsoluteLocation.y - parentGMFAbsoluteLocation.y); - - return delta; - } - /** * Try to apply a format to the children of the {@link DNodeList}. * diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java index 481641e62d..185b656d5e 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 THALES GLOBAL SERVICES and others. + * Copyright (c) 2009, 2017 THALES GLOBAL SERVICES and others. * 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 @@ -667,18 +667,12 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat locator.setBorderItemOffset(IBorderItemOffsets.DEFAULT_OFFSET); } - // CanonicalDBorderItemLocator works with absolute GMF parent - // location so we need to translate BorderedNode absolute - // location - // from Draw2D to GMF. - - Point delta = getGMFDraw2DDelta(parentNode, (IGraphicalEditPart) parentGraphicalEditPart); - final Rectangle rect = new Rectangle(locationToApply.getX() - delta.getX(), locationToApply.getY() - delta.getY(), layoutData.getWidth(), layoutData.getHeight()); + final Rectangle rect = new Rectangle(locationToApply.getX(), locationToApply.getY(), layoutData.getWidth(), layoutData.getHeight()); final org.eclipse.draw2d.geometry.Point realLocation = locator.getValidLocation(rect, toRestoreView, portsNodesToIgnore); // Compute the new relative position to the parent - final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode).getTopLeft(); + final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode, true).getTopLeft(); locationToApply.setX(realLocation.x); locationToApply.setY(realLocation.y); locationToApply = LayoutDataHelper.INSTANCE.getTranslated(locationToApply, parentAbsoluteLocation.negate()); @@ -728,20 +722,6 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat } } - private Point getGMFDraw2DDelta(Node parentNode, IGraphicalEditPart parentEditPart) { - - Point delta = LayoutdataFactory.eINSTANCE.createPoint(); - - org.eclipse.draw2d.geometry.Point parentDraw2DAbsoluteLocation = parentEditPart.getFigure().getBounds().getTopLeft().getCopy(); - FigureUtilities.translateToAbsoluteByIgnoringScrollbar(parentEditPart.getFigure(), parentDraw2DAbsoluteLocation); - - org.eclipse.draw2d.geometry.Point parentGMFAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode); - delta.setX(parentDraw2DAbsoluteLocation.x - parentGMFAbsoluteLocation.x); - delta.setY(parentDraw2DAbsoluteLocation.y - parentGMFAbsoluteLocation.y); - - return delta; - } - /** * Try to apply a layout to the children of the {@link DNodeList}. * |
