diff options
| author | Laurent Redor | 2015-06-25 16:25:56 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-07-06 06:50:37 +0000 |
| commit | ee6df4de0f805a88a73d05362b75343aebf406cf (patch) | |
| tree | b8de1fe79e9b2d8411a0daffc4f8b74431e84e92 | |
| parent | 99616c78590a6f6d5f8eec8bd9249decce63b586 (diff) | |
| download | org.eclipse.sirius-ee6df4de0f805a88a73d05362b75343aebf406cf.tar.gz org.eclipse.sirius-ee6df4de0f805a88a73d05362b75343aebf406cf.tar.xz org.eclipse.sirius-ee6df4de0f805a88a73d05362b75343aebf406cf.zip | |
[463485] Add a snap to all shapes mode for Note and Text
This needs to create to new EditPart for Text and Note to override the
dragTracker used.
Bug: 463485
Change-Id: I1cfcf9ba3aaa5b7cefe3c0e34b39016d6d162ed1
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
7 files changed, 274 insertions, 92 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java index 1a339189da..93cebe0228 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES. * 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 @@ -18,6 +18,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gmf.runtime.diagram.core.util.ViewType; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; import org.eclipse.gmf.runtime.gef.ui.internal.parts.WrapTextCellEditor; @@ -37,6 +38,7 @@ public class SiriusEditPartFactory implements EditPartFactory { /** * @was-generated NOT */ + @Override public EditPart createEditPart(EditPart context, Object model) { if (model instanceof View) { final View view = (View) model; @@ -143,6 +145,13 @@ public class SiriusEditPartFactory implements EditPartFactory { case BracketEdgeEditPart.VISUAL_ID: return new BracketEdgeEditPart(view); + + case -1: + if (ViewType.NOTE.equals(view.getType())) { + return new SiriusNoteEditPart(view); + } else if (ViewType.TEXT.equals(view.getType())) { + return new SiriusTextEditPart(view); + } } } return createUnrecognizedEditPart(context, model); @@ -206,6 +215,7 @@ public class SiriusEditPartFactory implements EditPartFactory { * @not-generated add 1 in the width so that the text is not getting * truncated. */ + @Override public void relocate(CellEditor celleditor) { final Text text = (Text) celleditor.getControl(); final Rectangle rect = new Rectangle(getWrapLabel().getTextBounds()); @@ -249,6 +259,7 @@ public class SiriusEditPartFactory implements EditPartFactory { /** * @was-generated */ + @Override public void relocate(CellEditor celleditor) { final Text text = (Text) celleditor.getControl(); final Rectangle rect = new Rectangle(getLabel().getTextBounds()); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java new file mode 100644 index 0000000000..1a9e21ba6c --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.internal.edit.parts; + +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.sirius.diagram.ui.tools.internal.ui.SnapToAllDragEditPartsTracker; + +/** + * A specific NoteEditPart to handle the snapToAllShapes. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class SiriusNoteEditPart extends NoteEditPart { + + /** + * Default constructor. + * + * @param view + * the view controlled by this edit part + */ + public SiriusNoteEditPart(View view) { + super(view); + } + + @Override + public DragTracker getDragTracker(Request request) { + return new SnapToAllDragEditPartsTracker(this); + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java new file mode 100644 index 0000000000..95bb3a50c1 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.internal.edit.parts; + +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.TextEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.sirius.diagram.ui.tools.internal.ui.SnapToAllDragEditPartsTracker; + +/** + * A specific TextEditPart to handle the snapToAllShapes. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class SiriusTextEditPart extends TextEditPart { + + /** + * Default constructor. + * + * @param view + * the view controlled by this edit part + */ + public SiriusTextEditPart(View view) { + super(view); + } + + @Override + public DragTracker getDragTracker(Request request) { + return new SnapToAllDragEditPartsTracker(this); + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java index 84cdfc0a84..00ac476d94 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java @@ -11,53 +11,19 @@ package org.eclipse.sirius.diagram.ui.tools.internal.ui; import org.eclipse.gef.EditPart; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; /** * A specific dragEditPartTracket that disable the clone feature. Indeed, in * Sirius it's not natural to clone a graphical element that will be removed on * the next refresh. * - * This tracker also allows to change the behavior of SnapToShape (capability to - * snap to all shapes and not only brothers one). - * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> * */ -public class NoCopyDragEditPartsTrackerEx extends DragEditPartsTrackerEx { - - /** - * Constant passed to extended data of the request to keep the chosen mode - * (with KEY {@link #SNAP_TO_ALL}. - */ - public static final String SNAP_TO_ALL_SHAPE_KEY = "snapToAllShape"; - - /** - * The default mode for {@link #snapToAllShape}. - */ - public static final boolean DEFAULT_SNAP_TO_SHAPE_MODE = false; - - /** - * The key shortcut used to change the default behavior of snap to shape. - */ - public static final int SNAP_TO_ALL = SWT.F4; - - /** - * The mode of this tracker concerning the snap to shape: - * <UL> - * <LI>true to snap to all shapes and not only brothers ones,</LI> - * <LI>false otherwise.</LI> - * </UL> - * This variable is used when the request is updated to add an extended data - * to the request. - */ - boolean snapToAllShape = NoCopyDragEditPartsTrackerEx.DEFAULT_SNAP_TO_SHAPE_MODE; +public class NoCopyDragEditPartsTrackerEx extends SnapToAllDragEditPartsTracker { /** - * Defaul constructor. + * Default constructor. * * @param sourceEditPart * the source edit part @@ -95,46 +61,4 @@ public class NoCopyDragEditPartsTrackerEx extends DragEditPartsTrackerEx { super.reveal(editpart); } } - - /** - * Overridden to update the {@link ChangeBoundsRequest} with information - * about snapToAll mode. - * - * {@inheritDoc} - */ - @Override - protected void snapPoint(ChangeBoundsRequest request) { - if (snapToAllShape) { - getTargetRequest().getExtendedData().put(NoCopyDragEditPartsTrackerEx.SNAP_TO_ALL_SHAPE_KEY, Boolean.TRUE); - } else { - getTargetRequest().getExtendedData().put(NoCopyDragEditPartsTrackerEx.SNAP_TO_ALL_SHAPE_KEY, Boolean.FALSE); - } - super.snapPoint(request); - } - - @Override - protected boolean handleKeyDown(KeyEvent event) { - if (NoCopyDragEditPartsTrackerEx.SNAP_TO_ALL == event.keyCode) { - snapToAllShape = !NoCopyDragEditPartsTrackerEx.DEFAULT_SNAP_TO_SHAPE_MODE; - return true; - } - return super.handleKeyDown(event); - } - - @Override - protected boolean handleKeyUp(KeyEvent event) { - if (NoCopyDragEditPartsTrackerEx.SNAP_TO_ALL == event.keyCode) { - snapToAllShape = NoCopyDragEditPartsTrackerEx.DEFAULT_SNAP_TO_SHAPE_MODE; - return true; - } - return super.handleKeyUp(event); - } - - @Override - protected boolean handleButtonUp(int button) { - boolean result = super.handleButtonUp(button); - // Clean up the mode to original state. - snapToAllShape = NoCopyDragEditPartsTrackerEx.DEFAULT_SNAP_TO_SHAPE_MODE; - return result; - } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java new file mode 100644 index 0000000000..b700363c3d --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.tools.internal.ui; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; + +/** + * A specific dragEditPartTracket that allows to change the behavior of + * SnapToShape (capability to snap to all shapes and not only brothers one). + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + * + */ +public class SnapToAllDragEditPartsTracker extends DragEditPartsTrackerEx { + + /** + * Constant passed to extended data of the request to keep the chosen mode + * (with KEY {@link #SNAP_TO_ALL}. + */ + public static final String SNAP_TO_ALL_SHAPE_KEY = "snapToAllShape"; + + /** + * The default mode for {@link #snapToAllShape}. + */ + public static final boolean DEFAULT_SNAP_TO_SHAPE_MODE = false; + + /** + * The key shortcut used to change the default behavior of snap to shape. + */ + public static final int SNAP_TO_ALL = SWT.F4; + + /** + * The mode of this tracker concerning the snap to shape: + * <UL> + * <LI>true to snap to all shapes and not only brothers ones,</LI> + * <LI>false otherwise.</LI> + * </UL> + * This variable is used when the request is updated to add an extended data + * to the request. + */ + boolean snapToAllShape = SnapToAllDragEditPartsTracker.DEFAULT_SNAP_TO_SHAPE_MODE; + + /** + * Default constructor. + * + * @param sourceEditPart + * the source edit part + */ + public SnapToAllDragEditPartsTracker(EditPart sourceEditPart) { + super(sourceEditPart); + } + + /** + * Overridden to update the {@link ChangeBoundsRequest} with information + * about snapToAll mode. + * + * {@inheritDoc} + */ + @Override + protected void snapPoint(ChangeBoundsRequest request) { + if (snapToAllShape) { + getTargetRequest().getExtendedData().put(SnapToAllDragEditPartsTracker.SNAP_TO_ALL_SHAPE_KEY, Boolean.TRUE); + } else { + getTargetRequest().getExtendedData().put(SnapToAllDragEditPartsTracker.SNAP_TO_ALL_SHAPE_KEY, Boolean.FALSE); + } + super.snapPoint(request); + } + + @Override + protected boolean handleKeyDown(KeyEvent event) { + if (SnapToAllDragEditPartsTracker.SNAP_TO_ALL == event.keyCode) { + snapToAllShape = !SnapToAllDragEditPartsTracker.DEFAULT_SNAP_TO_SHAPE_MODE; + return true; + } + return super.handleKeyDown(event); + } + + @Override + protected boolean handleKeyUp(KeyEvent event) { + if (SnapToAllDragEditPartsTracker.SNAP_TO_ALL == event.keyCode) { + snapToAllShape = SnapToAllDragEditPartsTracker.DEFAULT_SNAP_TO_SHAPE_MODE; + return true; + } + return super.handleKeyUp(event); + } + + @Override + protected boolean handleButtonUp(int button) { + boolean result = super.handleButtonUp(button); + // Clean up the mode to original state. + snapToAllShape = SnapToAllDragEditPartsTracker.DEFAULT_SNAP_TO_SHAPE_MODE; + return result; + } +} diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/snap/representations.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/snap/representations.aird index 50565baacd..42a6c2fe7c 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/snap/representations.aird +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/snap/representations.aird @@ -211,6 +211,28 @@ <styles xmi:type="notation:ShapeStyle" xmi:id="_OrQNsRaIEeWQ3O79R6E3Ug" fontName="Ubuntu" fontHeight="8"/> <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OrQNshaIEeWQ3O79R6E3Ug" x="1024" y="112" width="458" height="578"/> </children> + <children xmi:type="notation:Shape" xmi:id="_GxWhgBvTEeWBdP4r18ZtPw" type="Note" fontName="Ubuntu" description="Note" fillColor="13369343" transparency="0" lineColor="6737151" lineWidth="1"> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_GxcBEBvTEeWBdP4r18ZtPw" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_GxdPMBvTEeWBdP4r18ZtPw" type="Description"> + <element xsi:nil="true"/> + </children> + <styles xmi:type="notation:TextStyle" xmi:id="_GxWhgRvTEeWBdP4r18ZtPw"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="_GxWhghvTEeWBdP4r18ZtPw"/> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_GxWhgxvTEeWBdP4r18ZtPw" x="842" y="100" width="67" height="43"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_LMXUQBvTEeWBdP4r18ZtPw" type="Text" fontName="Ubuntu" description="Text"> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_LMX7UBvTEeWBdP4r18ZtPw" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_LMX7URvTEeWBdP4r18ZtPw" type="Description"> + <element xsi:nil="true"/> + </children> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LMXUQRvTEeWBdP4r18ZtPw" x="925" y="100" width="76" height="43"/> + </children> <styles xmi:type="notation:DiagramStyle" xmi:id="_M0bgwRWdEeW7GcqVYwuCiQ"/> <edges xmi:type="notation:Edge" xmi:id="_UTFY4BaIEeWQ3O79R6E3Ug" type="4001" element="_US1hQBaIEeWQ3O79R6E3Ug" source="_OroBIBaIEeWQ3O79R6E3Ug" target="_Or4f0BaIEeWQ3O79R6E3Ug"> <children xmi:type="notation:Node" xmi:id="_UTF_8BaIEeWQ3O79R6E3Ug" type="6001"> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java index ce5be1532a..e3132d49be 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java @@ -19,6 +19,8 @@ import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.EditPart; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart; +import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.TextEditPart; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart; @@ -92,7 +94,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move a container a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Move a container a second time with F4 and check the location is the * expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram. @@ -103,7 +105,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move a node a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Move a node a second time with F4 and check the location is the expected * one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram. @@ -114,7 +116,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move a node in container a first time without F4 and check the location - * is the expected one.<BR> + * is the expected one (ie the mouse location).<BR> * Move a node in container a second time with F4 and check the location is * the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram and in @@ -127,7 +129,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move a node in container a first time without F4 and check the location - * is the expected one.<BR> + * is the expected one (ie the mouse location).<BR> * Move a node in container a second time with F4 and check the location is * the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram and in container @@ -138,8 +140,19 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { } /** + * Move a Note a first time without F4 and check the location is the + * expected one (ie the mouse location).<BR> + * Move a Note a second time with F4 and check the location is the expected + * one (snap to another figure).<BR> + * This test also handles the case of scroll bar in diagram. + */ + public void testMoveNote() { + moveTopOfElementNearBottomOfAnother("Note", NoteEditPart.class, "BNNC_att1", AbstractDiagramBorderNodeEditPart.class); + } + + /** * Resize a container a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Resize a container a second time with F4 and check the location is the * expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram. @@ -150,7 +163,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Resize a node a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Resize a node a second time with F4 and check the location is the * expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram. @@ -161,7 +174,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Resize a node in container a first time without F4 and check the location - * is the expected one.<BR> + * is the expected one (ie the mouse location).<BR> * Resize a node in container a second time with F4 and check the location * is the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram and in @@ -174,7 +187,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Resize a node in container a first time without F4 and check the location - * is the expected one.<BR> + * is the expected one (ie the mouse location).<BR> * Resize a node in container a second time with F4 and check the location * is the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram and in container @@ -185,8 +198,30 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { } /** + * Resize a Note a first time without F4 and check the location is the + * expected one (ie the mouse location).<BR> + * Resize a Note a second time with F4 and check the location is the + * expected one (snap to another figure).<BR> + * This test also handles the case of scroll bar in diagram. + */ + public void testResizeNote() { + resizeTopOfElementNearBottomOfAnother("Note", NoteEditPart.class, "BNNC_att1", AbstractDiagramBorderNodeEditPart.class); + } + + /** + * Resize a Text a first time without F4 and check the location is the + * expected one (ie the mouse location).<BR> + * Resize a Text a second time with F4 and check the location is the + * expected one (snap to another figure).<BR> + * This test also handles the case of scroll bar in diagram. + */ + public void testResizeText() { + resizeTopOfElementNearBottomOfAnother("Text", TextEditPart.class, "BNNC_att1", AbstractDiagramBorderNodeEditPart.class); + } + + /** * Move a bendpoint of an edge a first time without F4 and check the - * location is the expected one.<BR> + * location is the expected one (ie the mouse location).<BR> * Move a bendpoint of an edge a second time with F4 and check the location * is the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram. @@ -197,7 +232,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move a bendpoint of an edge a first time without F4 and check the - * location is the expected one.<BR> + * location is the expected one (ie the mouse location).<BR> * Move a bendpoint of an edge a second time with F4 and check the location * is the expected one (snap to another figure).<BR> * This test also handles the case of scroll bar in diagram and zoom @@ -255,7 +290,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Move element a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Move element a second time with F4 and check the location is the expected * one (snap to another figure).<BR> */ @@ -271,7 +306,11 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { // Get the top center coordinates, just a little below, of the element // to move final Rectangle originalBounds = GraphicalHelper.getAbsoluteBoundsIn100Percent((GraphicalEditPart) elementToMove.part()); - final Point pointToDrag = originalBounds.getTop().getTranslated(0, 3); + Point pointToDrag = originalBounds.getTop().getTranslated(0, 3); + if (TextEditPart.class.equals(expectedEditPartTypeOfMovedElement)) { + pointToDrag = originalBounds.getTop().getTranslated(0, 5); + } + Point scaledPointToDrag = new PrecisionPoint(pointToDrag); GraphicalHelper.logical2screen(scaledPointToDrag, (IGraphicalEditPart) elementToMove.part()); // Compute the drop destination (at 4 pixels of the bottom of another @@ -313,7 +352,7 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase { /** * Resize element a first time without F4 and check the location is the - * expected one.<BR> + * expected one (ie the mouse location).<BR> * Resize element a second time with F4 and check the location is the * expected one (snap to another figure).<BR> */ |
