Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2018-03-09 16:44:46 +0000
committerPierre-Charles David2018-04-12 09:01:55 +0000
commit4cd1686e522a91d0a1ab206ea23331bd45e38a05 (patch)
tree9884bbf8d60ee5376df5d3a8fe08c603e7b98b70
parent053f159251ceacaf19318b7adc64da2e3de5c4c4 (diff)
downloadorg.eclipse.sirius-4cd1686e522a91d0a1ab206ea23331bd45e38a05.tar.gz
org.eclipse.sirius-4cd1686e522a91d0a1ab206ea23331bd45e38a05.tar.xz
org.eclipse.sirius-4cd1686e522a91d0a1ab206ea23331bd45e38a05.zip
[509070] Do not override Node size with move request.
* Move and Resize requests are treated in the same way in AirdXYLayoutEditPolicy. getMoveChildrenCommand delegates to getResizeChildrenCommand. If the request is a move (there is no size modification) the current figure size is applied. That makes problem in the case where the GMF bounds have been modify by a previous command. Bug: 509070 Change-Id: I40b0b45f37ab07f6bf54c3a627badeb2ba4af0ae 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/AirXYLayoutEditPolicy.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/AirXYLayoutEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/AirXYLayoutEditPolicy.java
index 4fdacf8fe7..deeb24ac42 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/AirXYLayoutEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/AirXYLayoutEditPolicy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2018 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
@@ -11,6 +11,7 @@
package org.eclipse.sirius.diagram.ui.graphical.edit.policies;
import java.util.List;
+import java.util.Optional;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.draw2d.FigureCanvas;
@@ -41,6 +42,8 @@ import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.Size;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DNodeContainer;
@@ -330,6 +333,25 @@ public class AirXYLayoutEditPolicy extends XYLayoutEditPolicy {
return layoutHelper;
}
+ @Override
+ protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
+ Rectangle constraint = (Rectangle) super.getConstraintFor(request, child);
+
+ // If the request is a move request, there is no reason to override the size of the GMF Node with the current
+ // figure size. In some cases, the GMF Bounds may have been updated but the figure has not been refreshed yet.
+ if (REQ_MOVE_CHILDREN.equals(request.getType())) {
+ // We retrieve the Size of the GMF Node attached to the edit part.
+ Optional<Size> optionalSize = Optional.ofNullable(child.getModel()).filter(Node.class::isInstance).map(model -> ((Node) model).getLayoutConstraint()).filter(Size.class::isInstance)
+ .map(Size.class::cast);
+ if (optionalSize.isPresent()) {
+ Dimension dimension = new Dimension(optionalSize.get().getWidth(), optionalSize.get().getHeight());
+ constraint.setSize(dimension);
+ }
+
+ }
+ return constraint;
+ }
+
/**
* {@inheritDoc}
*

Back to the top