diff options
| author | Laurent Redor | 2016-06-24 14:37:45 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-07-06 14:00:16 +0000 |
| commit | 9809db17095bc93475f818679ff2d632ca914293 (patch) | |
| tree | 65b9990a19afc289228ccc049d7a414ac816fb47 | |
| parent | a625f9ca427957268a733f479c43379f243ef92d (diff) | |
| download | org.eclipse.sirius-9809db17095bc93475f818679ff2d632ca914293.tar.gz org.eclipse.sirius-9809db17095bc93475f818679ff2d632ca914293.tar.xz org.eclipse.sirius-9809db17095bc93475f818679ff2d632ca914293.zip | |
[496744] Fix wrong GMF size after region insertion
The result with this fix is not really correct, but it is better than
the current dimension computed from the location of the next region (for
wrong reason).
Bug: 496744
Change-Id: Id33cba6263ed9438c907a42f249e19a6f703944b
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/internal/refresh/GMFHelper.java | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java index f63325bb02..30023caa1e 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java @@ -555,24 +555,30 @@ public final class GMFHelper { DDiagramElementContainerExperimentalQuery query = new DDiagramElementContainerExperimentalQuery(ddec); boolean isRegion = query.isRegion(); EList children = ((Node) node.eContainer()).getChildren(); - int nextIndex = children.indexOf(node) + 1; - if (isRegion && nextIndex != 0 && nextIndex < children.size() && children.get(nextIndex) instanceof Node) { - Node nextNode = (Node) children.get(nextIndex); - int visualID = SiriusVisualIDRegistry.getVisualID(nextNode.getType()); - if (DNodeContainer2EditPart.VISUAL_ID == visualID || DNodeListEditPart.VISUAL_ID == visualID || DNodeList2EditPart.VISUAL_ID == visualID) { - // DNodeContainerEditPart.VISUAL_ID == visualID is not - // checked as a region cannot be a DNodeContainerEditPart as - // it is directly contained by the diagram part. - LayoutConstraint layoutConstraint = nextNode.getLayoutConstraint(); - if (layoutConstraint instanceof Location) { - Location nextLocation = (Location) layoutConstraint; - // Update only the parent stack direction if some layout - // has already been done. - if (bounds.width == -1 && query.isRegionInHorizontalStack() && nextLocation.getX() != 0) { - bounds.width = nextLocation.getX() - bounds.x; - } - if (bounds.height == -1 && query.isRegionInVerticalStack() && nextLocation.getY() != 0) { - bounds.height = nextLocation.getY() - bounds.y; + int currentIndex = children.indexOf(node); + if (!(currentIndex != 0 && bounds.equals(new Rectangle(0, 0, -1, -1)))) { + // We are not in the case of a new region insertion (in this + // case, we use the default size) + int nextIndex = currentIndex + 1; + if (isRegion && nextIndex != 0 && nextIndex < children.size() && children.get(nextIndex) instanceof Node) { + Node nextNode = (Node) children.get(nextIndex); + int visualID = SiriusVisualIDRegistry.getVisualID(nextNode.getType()); + if (DNodeContainer2EditPart.VISUAL_ID == visualID || DNodeListEditPart.VISUAL_ID == visualID || DNodeList2EditPart.VISUAL_ID == visualID) { + // DNodeContainerEditPart.VISUAL_ID == visualID is not + // checked as a region cannot be a + // DNodeContainerEditPart as it is directly contained by + // the diagram part. + LayoutConstraint layoutConstraint = nextNode.getLayoutConstraint(); + if (layoutConstraint instanceof Location) { + Location nextLocation = (Location) layoutConstraint; + // Update only the parent stack direction if some + // layout has already been done. + if (bounds.width == -1 && query.isRegionInHorizontalStack() && nextLocation.getX() != 0) { + bounds.width = nextLocation.getX() - bounds.x; + } + if (bounds.height == -1 && query.isRegionInVerticalStack() && nextLocation.getY() != 0) { + bounds.height = nextLocation.getY() - bounds.y; + } } } } @@ -648,9 +654,9 @@ public final class GMFHelper { } } } - return Options.<GraphicalEditPart>newNone(); + return Options.<GraphicalEditPart> newNone(); } - + private static boolean isEditorFor(IEditorPart editor, Diagram diagram) { return editor instanceof DiagramEditor && ((DiagramEditor) editor).getDiagram() == diagram; } |
