Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2014-11-17 16:57:43 +0000
committerEsteban DUGUEPEROUX2015-08-20 14:13:41 +0000
commit541a8f8fc415b26c562df2a9bfc6778bd761be6b (patch)
treec76b1a9f0e1b4d8f300719699aeb45f6dae1d519
parentc98a37bf98ef99a883f140881808e0795983f8b3 (diff)
downloadorg.eclipse.sirius-541a8f8fc415b26c562df2a9bfc6778bd761be6b.tar.gz
org.eclipse.sirius-541a8f8fc415b26c562df2a9bfc6778bd761be6b.tar.xz
org.eclipse.sirius-541a8f8fc415b26c562df2a9bfc6778bd761be6b.zip
[475380] Consider parent border bounds instead of global bounds
In case of container there is a delta of 2 pixels between the global bounds and the border bounds (the 2 pixels of shadow). Bug: 475380 Change-Id: I7652d4d3b334f71803f285c77ba9b0c06f0ec357 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
index 7f052486ab..b3a9e8df60 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/BorderItemAwareLayoutProvider.java
@@ -59,6 +59,7 @@ import org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNodeOperation;
import org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
@@ -1318,6 +1319,7 @@ public class BorderItemAwareLayoutProvider extends AbstractLayoutProvider {
Rectangle bounds = null;
boolean isPinned = false;
+ Dimension parentBorderSize = getBorder(graphicalEditPart).getSize();
if (graphicalEditPart.resolveSemanticElement() instanceof DDiagramElement) {
DDiagramElement dDiagramElement = (DDiagramElement) graphicalEditPart.resolveSemanticElement();
isPinned = new PinHelper().isPinned(dDiagramElement);
@@ -1354,6 +1356,8 @@ public class BorderItemAwareLayoutProvider extends AbstractLayoutProvider {
}
}
graphicalEditPart.getFigure().translateToAbsolute(bounds);
+ // The interesting size is the parent border one here.
+ bounds.setSize(parentBorderSize);
if (!isPinned && launchNormalArrange) {
// Compute size after arrange (with auto-size)
@@ -1365,6 +1369,26 @@ public class BorderItemAwareLayoutProvider extends AbstractLayoutProvider {
}
/**
+ * Utility to calculate the bounds with consideration for the handle bounds
+ * inset. Copied from
+ * org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator
+ * .getParentBorder().
+ *
+ * @param graphicalEditPart
+ * The concerned edit part
+ *
+ * @return <code>Rectangle</code> that is the bounds of the edit part.
+ */
+ protected Rectangle getBorder(IGraphicalEditPart graphicalEditPart) {
+ IFigure figure = graphicalEditPart.getFigure();
+ Rectangle bounds = figure.getBounds().getCopy();
+ if (figure instanceof NodeFigure) {
+ bounds = ((NodeFigure) figure).getHandleBounds().getCopy();
+ }
+ return bounds;
+ }
+
+ /**
* Compute the delta between the actual location of the <code>part</code>
* and the target bounds.
*

Back to the top