diff options
| author | Laurent Redor | 2015-05-05 15:45:15 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-05-07 06:57:34 +0000 |
| commit | e65687f5d39bea2b79eb413a8f2fb89b6aa11025 (patch) | |
| tree | d1b6a06db68ba73e57ad9ff70998d10b0e72aba8 | |
| parent | 9067bd9865c39b219ef17c43b4452cd0199486d8 (diff) | |
| download | org.eclipse.sirius-e65687f5d39bea2b79eb413a8f2fb89b6aa11025.tar.gz org.eclipse.sirius-e65687f5d39bea2b79eb413a8f2fb89b6aa11025.tar.xz org.eclipse.sirius-e65687f5d39bea2b79eb413a8f2fb89b6aa11025.zip | |
[466456] Ignore resized border node during relocate of brothers
During the conflict detection after a resize, the resized node should be
ignored for other border nodes.
But this reveals another problem (detected with tests of org.eclipse.sirius.tests.swtbot.uml.UmlPortDragAndDropTest). When computing the realExpandedBounds
(SpecificBorderItemSelectionEditPolicy.getRealExpandedBounds()), the
borderItemHasMoved state become wrong. A new API has been added in the
DBIL to reset this state in this case.
Bug: 466456
Change-Id: I94397d579df638b98466ca7b15c25a83d20a35d7
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
5 files changed, 47 insertions, 1 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java index ca6f1bca13..4ac2470d65 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java @@ -579,6 +579,10 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx ((DBorderItemLocator) borderItemLocator).setBorderItemOffset(oldOffset); borderItemLocator.setConstraint(oldConstraint); + // The setConstraint has been reset to old value. The + // borderItemMovedState must be reset to avoid that + // borderItemLocator considers it as a real change. + ((DBorderItemLocator) borderItemLocator).resetBorderItemMovedState(); } return realNewBounds; diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/locator/DBorderItemLocator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/locator/DBorderItemLocator.java index 67218034b9..c994bdc3e8 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/locator/DBorderItemLocator.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/locator/DBorderItemLocator.java @@ -736,7 +736,7 @@ public class DBorderItemLocator extends BorderItemLocator { } } else if (borderItem.getParent().getLayoutManager().getConstraint(borderItem) instanceof DBorderItemLocator) { final DBorderItemLocator airBorderItemLocator = (DBorderItemLocator) borderItem.getParent().getLayoutManager().getConstraint(borderItem); - takeIntoAccount = airBorderItemLocator.located; + takeIntoAccount = airBorderItemLocator.located && !airBorderItemLocator.borderItemHasMoved; } if (borderItem.isVisible() && takeIntoAccount) { final Rectangle rect = new Rectangle(borderItem.getBounds()); @@ -896,4 +896,15 @@ public class DBorderItemLocator extends BorderItemLocator { public void setFiguresToIgnoresDuringNextRelocate(List<IFigure> figuresToIgnore) { this.figuresToIgnoreDuringNextRelocate = figuresToIgnore; } + + /** + * This method set to false the borderItemHasMoved field. It must be used + * carefully only in case where {@link #setConstraint(Rectangle)} is called + * to compute temporary a + * {@link #getValidLocation(Rectangle, IFigure, Collection, List)}, one time + * with a new value and just after with the old value. + */ + public void resetBorderItemMovedState() { + this.borderItemHasMoved = false; + } } diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index c250a09e56..26993c1db8 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -571,6 +571,12 @@ <code>RefreshEditorsPrecommitListener</code>. </li> <li>Extensions in plugin.xml that provides UI functionalities have been moved to org.eclipse.sirius.diagram.ui.ext.</li> + <li>The method + <code>org.eclipse.sirius.diagram.ui.tools.api.figure.locator.DBorderItemLocator.resetBorderItemMovedState()</code> has been added to allow to reset the state of + <code>borderItemHasMoved</code>. This method must be used carefully only in case where + <code>setConstraint(Rectangle)</code> is called to compute temporary a + <code>getValidLocation(Rectangle, IFigure, Collection, List)</code>, one time with a new value and just after with the old value. + </li> </ul> <h4 id="Changesinorg.eclipse.sirius.tests.junit.support">Changes in <code>org.eclipse.sirius.tests.junit.support</code> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index 697218a075..8aa17fbf31 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -164,6 +164,7 @@ h4. Changes in @org.eclipse.sirius.diagram.ui@ * @org.eclipse.sirius.diagram.ui.tools.api.figure.InvisibleResizableCompartmentFigure@ class has been removed, use a @org.eclipse.gmf.runtime.diagram.ui.figures.ShapeCompartmentFigure@ with a @org.eclipse.draw2d.MarginBorder@ or a null border instead. * The method @org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart.getEAdapterSemanticElements()@ has been removed (and all its implementations). For manual refresh, this adapter has been replaced with the @RefreshEditorsPrecommitListener@. * Extensions in plugin.xml that provides UI functionalities have been moved to org.eclipse.sirius.diagram.ui.ext. +* The method @org.eclipse.sirius.diagram.ui.tools.api.figure.locator.DBorderItemLocator.resetBorderItemMovedState()@ has been added to allow to reset the state of @borderItemHasMoved@. This method must be used carefully only in case where @setConstraint(Rectangle)@ is called to compute temporary a @getValidLocation(Rectangle, IFigure, Collection, List)@, one time with a new value and just after with the old value. h4. Changes in @org.eclipse.sirius.tests.junit.support@ diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java index 22930d90df..8e75cf62ee 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java @@ -560,6 +560,30 @@ public class CenteredEdgesTest extends AbstractSiriusSwtBotGefTestCase { } /** + * Test that when resizing a border node over another border node, the + * overlapped border node is not moved. See <a + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=466456">Bug 466456</a>. + */ + public void testResizingTargetBorderNodeOverAnotherNode() { + openDiagram(REPRESENTATION_NAME_RESIZE_BORDER_NODE); + SWTBotGefEditPart border1NodeBotGefEditPart = editor.getEditPart("border1", AbstractDiagramBorderNodeEditPart.class); + Rectangle border1BoundsBefore = ((GraphicalEditPart) border1NodeBotGefEditPart.part()).getFigure().getBounds().getCopy(); + + SWTBotGefEditPart border2NodeBotGefEditPart = editor.getEditPart("border2", AbstractDiagramBorderNodeEditPart.class); + border2NodeBotGefEditPart.select(); + + IFigure figure = ((GraphicalEditPart) border2NodeBotGefEditPart.part()).getFigure(); + Rectangle boundsBefore = figure.getBounds().getCopy(); + // Resize border2 over border1 + border2NodeBotGefEditPart.resize(PositionConstants.SOUTH, 0, 125); + + // we make sure the figure has been resized (and moved) + bot.waitUntil(new WaitFigureResizedCondition(boundsBefore, figure)); + + assertEquals("The overlapped border node should not be moved.", border1BoundsBefore, ((GraphicalEditPart) border1NodeBotGefEditPart.part()).getFigure().getBounds().getCopy()); + } + + /** * Test that when resizing a shape over edge bendpoints, the edge is still * centered. See <a * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=448739#c8">Bug |
