diff options
| author | Laurent Redor | 2017-10-20 15:10:04 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-11-24 17:11:21 +0000 |
| commit | 1e2ba503d022495457834ae5f76f8de853e89b98 (patch) | |
| tree | c71c90b5908f195f011a2552a7cc302986b7d729 | |
| parent | 3834eb6fc3514f4b5c23353c18c10f1bc29f4923 (diff) | |
| download | org.eclipse.sirius-1e2ba503d022495457834ae5f76f8de853e89b98.tar.gz org.eclipse.sirius-1e2ba503d022495457834ae5f76f8de853e89b98.tar.xz org.eclipse.sirius-1e2ba503d022495457834ae5f76f8de853e89b98.zip | |
[526369] Disable reveal on border node selection
* The code of sirius tracker super classes in handleButtonUp(int) is
copied in SiriusDragEditPartsTrackerEx class and changed to disable
reveal at selection (like it was done before in
NoCopyDragEditPartsTrackerEx).
* Add a specific test in existing ones
* And refactor existing ones to be more reliable
Bug: 526369
Bug: 520110
Change-Id: I2c81f4d7845f1431d346a65968edcea96fc13392
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
4 files changed, 287 insertions, 29 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SiriusDragEditPartsTrackerEx.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SiriusDragEditPartsTrackerEx.java index 7241b8702a..132e0e61fd 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SiriusDragEditPartsTrackerEx.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SiriusDragEditPartsTrackerEx.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 THALES GLOBAL SERVICES. + * Copyright (c) 2009, 2017 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 @@ -202,6 +202,33 @@ public class SiriusDragEditPartsTrackerEx extends SnapToAllDragEditPartsTracker } @Override + protected boolean handleButtonUp(int button) { + // The above code is copied from the super classes (SnapToAllDragEditPartsTracker, DragEditPartsTracker and + // SelectEditPartTracker) to disable the reveal. + boolean result = false; + if (stateTransition(STATE_DRAG_IN_PROGRESS, STATE_TERMINAL)) { + eraseSourceFeedback(); + eraseTargetFeedback(); + performDrag(); + result = true; + } else if (isInState(STATE_DRAG)) { + performSelection(); + if (getFlag(org.eclipse.gef.tools.SelectEditPartTracker.MAX_FLAG)) + // SelectEditPartTracker.MAX_FLAG is a protected constant equals to + // SelectEditPartTracker.FLAG_ENABLE_DIRECT_EDIT (that must be originally used here). + performDirectEdit(); + // The SelectEditPartTracker behavior is overridden here to never reveal the selected element. + // if (button == 1 && getSourceEditPart().getSelected() != EditPart.SELECTED_NONE) + // getCurrentViewer().reveal(getSourceEditPart()); + setState(STATE_TERMINAL); + result = true; + } + // Clean up the mode to original state. + snapToAllShape = SnapToAllDragEditPartsTracker.DEFAULT_SNAP_TO_SHAPE_MODE; + return result; + } + + @Override public void mouseDrag(MouseEvent me, EditPartViewer viewer) { previousMouseLocation = getCurrentInput().getMouseLocation().getCopy(); super.mouseDrag(me, viewer); diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/My.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/My.odesign new file mode 100644 index 0000000000..9f82f79551 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/My.odesign @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" name="My" version="12.0.0.2017041100"> + <ownedViewpoints name="VPwithBorderNode" modelFileExtension="ecore"> + <ownedRepresentations xsi:type="description_1:DiagramDescription" name="MyDiagram" domainClass="ecore::EPackage" enablePopupBars="true"> + <metamodel href="http://www.eclipse.org/emf/2002/Ecore#/"/> + <defaultLayer name="Default"> + <nodeMappings name="classes" semanticCandidatesExpression="feature:eClassifiers" domainClass="ecore::EClass"> + <borderedNodeMappings name="self" semanticCandidatesExpression="var:self" domainClass="ecore::EClass"> + <style xsi:type="style:SquareDescription" labelExpression="aql:self.name + 'Border'" sizeComputationExpression="5" labelPosition="node" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/> + </style> + </borderedNodeMappings> + <style xsi:type="style:SquareDescription" sizeComputationExpression="10" labelPosition="node" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/> + </style> + </nodeMappings> + </defaultLayer> + </ownedRepresentations> + </ownedViewpoints> +</description:Group> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/TestSelection.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/TestSelection.aird index a44dcfcea3..20c03db6e9 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/TestSelection.aird +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/selection/TestSelection.aird @@ -1,16 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style"> - <viewpoint:DAnalysis xmi:id="_RmyMUMHCEeCenq6NHvggaA" selectedViews="_8e1WcHETEee5ZpCMxpRpSA" version="12.1.0.201706291600"> + <viewpoint:DAnalysis xmi:id="_RmyMUMHCEeCenq6NHvggaA" selectedViews="_8e1WcHETEee5ZpCMxpRpSA _pesd0LWlEeeb3fJFsFSJjw" version="12.1.0.201708031200"> <semanticResources>TestSelection.ecore</semanticResources> <ownedViews xmi:type="viewpoint:DView" xmi:id="_8e1WcHETEee5ZpCMxpRpSA"> <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> - <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_8u39kHETEee5ZpCMxpRpSA" name="diagram" repPath="#_8uzFEHETEee5ZpCMxpRpSA"> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_8u39kHETEee5ZpCMxpRpSA" name="diagram" repPath="#_FIlAYLWlEeeb3fJFsFSJjw"> <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> <target xmi:type="ecore:EPackage" href="TestSelection.ecore#/"/> </ownedRepresentationDescriptors> </ownedViews> + <ownedViews xmi:type="viewpoint:DView" xmi:id="_pesd0LWlEeeb3fJFsFSJjw"> + <viewpoint xmi:type="description:Viewpoint" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']"/> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_r6z68LWlEeeb3fJFsFSJjw" name="diagram2" repPath="#_r6QhULWlEeeb3fJFsFSJjw"> + <description xmi:type="description_1:DiagramDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']"/> + <target xmi:type="ecore:EPackage" href="TestSelection.ecore#/"/> + </ownedRepresentationDescriptors> + </ownedViews> </viewpoint:DAnalysis> - <diagram:DSemanticDiagram xmi:id="_8uzFEHETEee5ZpCMxpRpSA" name="diagram"> + <diagram:DSemanticDiagram xmi:id="_8uzFEHETEee5ZpCMxpRpSA" name="diagram" uid="_FIlAYLWlEeeb3fJFsFSJjw"> <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_8uzFEXETEee5ZpCMxpRpSA" source="DANNOTATION_CUSTOMIZATION_KEY"> <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_8uzFEnETEee5ZpCMxpRpSA"/> </ownedAnnotationEntries> @@ -23,7 +30,7 @@ <styles xmi:type="notation:FilteringStyle" xmi:id="_8viE4nETEee5ZpCMxpRpSA"/> </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_8vgPsXETEee5ZpCMxpRpSA" fontName="Segoe UI" fontHeight="8"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vgPsnETEee5ZpCMxpRpSA" x="-78" y="186" width="75" height="63"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vgPsnETEee5ZpCMxpRpSA" x="320" y="40" width="75" height="63"/> </children> <children xmi:type="notation:Node" xmi:id="_8vir8HETEee5ZpCMxpRpSA" type="2003" element="_8uzFGHETEee5ZpCMxpRpSA"> <children xmi:type="notation:Node" xmi:id="_8vjTAHETEee5ZpCMxpRpSA" type="5007"/> @@ -36,7 +43,7 @@ <styles xmi:type="notation:FilteringStyle" xmi:id="_8vjTA3ETEee5ZpCMxpRpSA"/> </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_8vir8XETEee5ZpCMxpRpSA" fontName="Segoe UI" fontHeight="8"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vir8nETEee5ZpCMxpRpSA" x="-69" y="-6"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vir8nETEee5ZpCMxpRpSA" x="40" y="40" width="123" height="163"/> </children> <children xmi:type="notation:Node" xmi:id="_8vj6EHETEee5ZpCMxpRpSA" type="2003" element="_8uzFHHETEee5ZpCMxpRpSA"> <children xmi:type="notation:Node" xmi:id="_8vkhIHETEee5ZpCMxpRpSA" type="5007"/> @@ -54,34 +61,33 @@ <styles xmi:type="notation:DiagramStyle" xmi:id="_8vCVonETEee5ZpCMxpRpSA"/> <edges xmi:type="notation:Edge" xmi:id="_8vrO0HETEee5ZpCMxpRpSA" type="4001" element="_8uzFIHETEee5ZpCMxpRpSA" source="_8vj6EHETEee5ZpCMxpRpSA" target="_8vir8HETEee5ZpCMxpRpSA"> <children xmi:type="notation:Node" xmi:id="_8vtrEHETEee5ZpCMxpRpSA" type="6001"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vtrEXETEee5ZpCMxpRpSA" x="33" y="-1"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vtrEXETEee5ZpCMxpRpSA" x="27" y="3"/> </children> <children xmi:type="notation:Node" xmi:id="_8vu5MHETEee5ZpCMxpRpSA" type="6002"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vu5MXETEee5ZpCMxpRpSA" x="10" y="3"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vu5MXETEee5ZpCMxpRpSA" x="10" y="8"/> </children> <children xmi:type="notation:Node" xmi:id="_8vwuYHETEee5ZpCMxpRpSA" type="6003"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vwuYXETEee5ZpCMxpRpSA" x="12" y="1"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8vwuYXETEee5ZpCMxpRpSA" x="13" y="2"/> </children> <styles xmi:type="notation:ConnectorStyle" xmi:id="_8vrO0XETEee5ZpCMxpRpSA"/> <styles xmi:type="notation:FontStyle" xmi:id="_8vrO0nETEee5ZpCMxpRpSA" fontName="Segoe UI" fontHeight="8"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_8vrO03ETEee5ZpCMxpRpSA" points="[-22, -3, 1281, 181]$[-1303, -184, 0, 0]"/> - <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_8v7GcHETEee5ZpCMxpRpSA" id="(0.9811097992916175,0.0079155672823219)"/> - <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_8v7tgHETEee5ZpCMxpRpSA" id="(0.5178571428571429,1.0)"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_8vrO03ETEee5ZpCMxpRpSA" points="[-61, -8, 774, 102]$[-774, -102, 61, 8]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_8v7GcHETEee5ZpCMxpRpSA" id="(0.5938606847697757,0.021108179419525065)"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_8v7tgXETEee5ZpCMxpRpSA" type="4001" element="_8uzFI3ETEee5ZpCMxpRpSA" source="_8vir8HETEee5ZpCMxpRpSA" target="_8vgPsHETEee5ZpCMxpRpSA"> <children xmi:type="notation:Node" xmi:id="_8v8UknETEee5ZpCMxpRpSA" type="6001"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v8Uk3ETEee5ZpCMxpRpSA" x="7" y="2"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v8Uk3ETEee5ZpCMxpRpSA" x="1" y="-1"/> </children> <children xmi:type="notation:Node" xmi:id="_8v87oHETEee5ZpCMxpRpSA" type="6002"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v87oXETEee5ZpCMxpRpSA" x="-14" y="3"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v87oXETEee5ZpCMxpRpSA" x="1" y="10"/> </children> <children xmi:type="notation:Node" xmi:id="_8v87onETEee5ZpCMxpRpSA" type="6003"> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v87o3ETEee5ZpCMxpRpSA" x="-13" y="4"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8v87o3ETEee5ZpCMxpRpSA" x="-34"/> </children> <styles xmi:type="notation:ConnectorStyle" xmi:id="_8v7tgnETEee5ZpCMxpRpSA"/> <styles xmi:type="notation:FontStyle" xmi:id="_8v8UkHETEee5ZpCMxpRpSA" fontName="Segoe UI" fontHeight="8"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_8v8UkXETEee5ZpCMxpRpSA" points="[27, 3, -186, -27]$[1, 192, -212, 162]"/> - <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_8v-JwHETEee5ZpCMxpRpSA" id="(0.5178571428571429,0.0)"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_8v8UkXETEee5ZpCMxpRpSA" points="[26, -9, -479, 175]$[254, 6, -251, 190]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_E8zKALWsEeewG5AVDxE00g" id="(0.21487603305785125,0.13975155279503104)"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_8v-JwXETEee5ZpCMxpRpSA" id="(3.4383561643835616,-2.6557377049180326)"/> </edges> </data> @@ -159,4 +165,150 @@ <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']"/> <target xmi:type="ecore:EPackage" href="TestSelection.ecore#/"/> </diagram:DSemanticDiagram> + <diagram:DSemanticDiagram xmi:id="_r6ys0LWlEeeb3fJFsFSJjw" name="diagram2" uid="_r6QhULWlEeeb3fJFsFSJjw"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_r6ys0bWlEeeb3fJFsFSJjw" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_r6ys0rWlEeeb3fJFsFSJjw"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_r8puALWlEeeb3fJFsFSJjw" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_r8puAbWlEeeb3fJFsFSJjw" type="Sirius" element="_r6ys0LWlEeeb3fJFsFSJjw" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_r80tILWlEeeb3fJFsFSJjw" type="2001" element="_r6ys1LWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r84-kLWlEeeb3fJFsFSJjw" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r84-kbWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r89QALWlEeeb3fJFsFSJjw" type="3001" element="_r6ys1bWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r89QA7WlEeeb3fJFsFSJjw" type="5001"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r89QBLWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9CIgLWlEeeb3fJFsFSJjw" type="3003" element="_r6ys1rWlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9CIgbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9CIgrWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r89QAbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r89QArWlEeeb3fJFsFSJjw" x="92" y="20" width="50" height="50"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9BhcLWlEeeb3fJFsFSJjw" type="3003" element="_r6ys17WlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9BhcbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9BhcrWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r81UMLWlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r81UMbWlEeeb3fJFsFSJjw" x="280" y="40" width="100" height="100"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r86zwLWlEeeb3fJFsFSJjw" type="2001" element="_r6ys2LWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r87a0LWlEeeb3fJFsFSJjw" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r87a0bWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9CvkLWlEeeb3fJFsFSJjw" type="3001" element="_r6ys2bWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r9Cvk7WlEeeb3fJFsFSJjw" type="5001"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r9CvlLWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9DWo7WlEeeb3fJFsFSJjw" type="3003" element="_r6ys2rWlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9DWpLWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9DWpbWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9CvkbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9CvkrWlEeeb3fJFsFSJjw" x="92" y="18" width="50" height="50"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9DWoLWlEeeb3fJFsFSJjw" type="3003" element="_r6ys27WlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9DWobWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9DWorWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r86zwbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r86zwrWlEeeb3fJFsFSJjw" x="40" y="40" width="100" height="100"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r87a0rWlEeeb3fJFsFSJjw" type="2001" element="_r6ys3LWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r88B4LWlEeeb3fJFsFSJjw" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r88B4bWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9D9sLWlEeeb3fJFsFSJjw" type="3001" element="_r6ys3bWlEeeb3fJFsFSJjw"> + <children xmi:type="notation:Node" xmi:id="_r9D9s7WlEeeb3fJFsFSJjw" type="5001"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_r9D9tLWlEeeb3fJFsFSJjw" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9Ekw7WlEeeb3fJFsFSJjw" type="3003" element="_r6ys3rWlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9EkxLWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9EkxbWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9D9sbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9D9srWlEeeb3fJFsFSJjw" x="-1849" y="18" width="1857" height="50"/> + </children> + <children xmi:type="notation:Node" xmi:id="_r9EkwLWlEeeb3fJFsFSJjw" type="3003" element="_r6ys37WlEeeb3fJFsFSJjw"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r9EkwbWlEeeb3fJFsFSJjw" fontName="Comic Sans MS"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r9EkwrWlEeeb3fJFsFSJjw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_r87a07WlEeeb3fJFsFSJjw" fontName="Comic Sans MS" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_r87a1LWlEeeb3fJFsFSJjw" x="432" y="222" width="849" height="381"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_r8puArWlEeeb3fJFsFSJjw"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_r6ys1LWlEeeb3fJFsFSJjw" name="SC1" width="10" height="10" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//SC1"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//SC1"/> + <ownedBorderedNodes xmi:type="diagram:DNode" xmi:id="_r6ys1bWlEeeb3fJFsFSJjw" name="SC1Border" width="5" height="5" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//SC1"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//SC1"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys1rWlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']"/> + </ownedBorderedNodes> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys17WlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_r6ys2LWlEeeb3fJFsFSJjw" name="C1" width="10" height="10" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//C1"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//C1"/> + <ownedBorderedNodes xmi:type="diagram:DNode" xmi:id="_r6ys2bWlEeeb3fJFsFSJjw" name="C1Border" width="5" height="5" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//C1"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//C1"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys2rWlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']"/> + </ownedBorderedNodes> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys27WlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_r6ys3LWlEeeb3fJFsFSJjw" name="C2" width="10" height="10" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//C2"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//C2"/> + <ownedBorderedNodes xmi:type="diagram:DNode" xmi:id="_r6ys3bWlEeeb3fJFsFSJjw" name="C2Border" width="5" height="5" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestSelection.ecore#//C2"/> + <semanticElements xmi:type="ecore:EClass" href="TestSelection.ecore#//C2"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys3rWlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@borderedNodeMappings[name='self']"/> + </ownedBorderedNodes> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_r6ys37WlEeeb3fJFsFSJjw" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer/@nodeMappings[name='classes']"/> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_r6ys4LWlEeeb3fJFsFSJjw"/> + <activatedLayers xmi:type="description_1:Layer" href="My.odesign#//@ownedViewpoints[name='VPwithBorderNode']/@ownedRepresentations[name='MyDiagram']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="TestSelection.ecore#/"/> + </diagram:DSemanticDiagram> </xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EditPartSelectionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EditPartSelectionTest.java index ceac6886b7..5db9953447 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EditPartSelectionTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EditPartSelectionTest.java @@ -10,15 +10,20 @@ *******************************************************************************/ package org.eclipse.sirius.tests.swtbot; +import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart; import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; +import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckSelectedCondition; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; @@ -36,6 +41,8 @@ public class EditPartSelectionTest extends AbstractSiriusSwtBotGefTestCase { private static final String SESSION_FILE = "TestSelection.aird"; + private static final String VSM_FILE = "My.odesign"; + private static final String REPRESENTATION_DECRIPTION_NAME = "Entities"; private static final String REPRESENTATION_NAME = "diagram"; @@ -46,7 +53,7 @@ public class EditPartSelectionTest extends AbstractSiriusSwtBotGefTestCase { @Override protected void onSetUpBeforeClosingWelcomePage() throws Exception { - copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE); + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE, VSM_FILE); } @Override @@ -64,16 +71,21 @@ public class EditPartSelectionTest extends AbstractSiriusSwtBotGefTestCase { * editor that is not move the scroll bars. */ public void testEditorContentPositionAfterEdgeSelection() { - // check the initial position + // Select an element on the top left to always have the same initial + // scroll + editor.scrollTo(0, 0); + editor.getEditPart("C1", AbstractBorderedShapeEditPart.class).click(); + + // check the initial position of node C2 checkBottomRightCornerNodeAbsolutePosition("Bad diagram test data"); // Select the edge SWTBotGefEditPart edgeEditPart = editor.getEditPart("[0..1] ref", ConnectionEditPart.class); - edgeEditPart.click(); - SWTBotUtils.waitAllUiEvents(); + edgeEditPart.click(getBounds(edgeEditPart).getTopLeft().getTranslated(2, 2)); + bot.waitUntil(new CheckSelectedCondition(editor, edgeEditPart.part()), 2000); - // Check that the node has not moved - checkBottomRightCornerNodeAbsolutePosition("The selection of an edge moved the editor content. Bad node position"); + // Check that the node C2 has not moved + checkBottomRightCornerNodeAbsolutePosition("The selection of an edge moves the editor content. Bad node position"); } /** @@ -81,22 +93,65 @@ public class EditPartSelectionTest extends AbstractSiriusSwtBotGefTestCase { * editor that is not move the scroll bars. */ public void testEditorContentPositionAfterNodeSelection() { - // check the initial position - SWTBotGefEditPart swtNodeEditPart = editor.getEditPart("C2", AbstractBorderedShapeEditPart.class); + // Select an element on the top left to always have the same initial + // scroll + editor.scrollTo(0, 0); + editor.getEditPart("C1", AbstractBorderedShapeEditPart.class).click(); + + // check the initial position of node C2 checkBottomRightCornerNodeAbsolutePosition("Bad diagram test data"); + // Select the node C2 + SWTBotGefEditPart swtNodeEditPart = editor.getEditPart("C2", AbstractBorderedShapeEditPart.class); swtNodeEditPart.click(); - SWTBotUtils.waitAllUiEvents(); + bot.waitUntil(new CheckSelectedCondition(editor, swtNodeEditPart.part()), 2000); - // Check that the node has not moved - checkBottomRightCornerNodeAbsolutePosition("The selection of an Node moved the editor content. Bad node position"); + // Check that the node C2 has not moved + checkBottomRightCornerNodeAbsolutePosition("The selection of an Node moves the editor content. Bad node position"); } + /** + * Check that the selection of a border node that is not fully displayed in + * the editor will not move the content of the editor that is not move the + * scroll bars. + */ + public void testEditorContentPositionAfterBorderNodeSelection() { + editor.close(); + SWTBotUtils.waitAllUiEvents(); + + editor = (SWTBotSiriusDiagramEditor) openRepresentation(session, "MyDiagram", "diagram2", DDiagram.class, true); + // Select an element on the top left to always have the same initial + // scroll + editor.scrollTo(0, 0); + editor.getEditPart("C1", AbstractBorderedShapeEditPart.class).click(); + + // check the initial position of node C2 + checkBottomRightCornerNodeAbsolutePosition("Bad diagram test data"); + + // Select the border node C2Border + SWTBotGefEditPart swtNodeEditPart = editor.getEditPart("C2Border", AbstractDiagramBorderNodeEditPart.class); + swtNodeEditPart.click(getBounds(swtNodeEditPart).getRight().getTranslated(-10, 0)); + bot.waitUntil(new CheckSelectedCondition(editor, swtNodeEditPart.part()), 2000); + + // Check that the node C2 has not moved + checkBottomRightCornerNodeAbsolutePosition("The selection of a BorderNode moves the editor content. Bad node position"); + } + void checkBottomRightCornerNodeAbsolutePosition(String message) { IGraphicalEditPart nodeEditPart = (IGraphicalEditPart) editor.getEditPart("C2", AbstractBorderedShapeEditPart.class).part(); Rectangle bounds = nodeEditPart.getFigure().getBounds().getCopy(); nodeEditPart.getFigure().translateToAbsolute(bounds); - assertEquals("The selection of an edge moved the editor content. Bad node position", INITIAL_NODE_CENTER_POSITION, bounds.getCenter()); + assertEquals(message, INITIAL_NODE_CENTER_POSITION, bounds.getCenter()); + } + + private Rectangle getBounds(SWTBotGefEditPart swtBotGefEditPart) { + final IFigure figure = ((GraphicalEditPart) swtBotGefEditPart.part()).getFigure(); + Rectangle bounds = figure.getBounds().getCopy(); + if (figure instanceof PolylineConnectionEx) { + bounds = ((PolylineConnectionEx) figure).getSimpleBounds(); + } + figure.translateToAbsolute(bounds); + return bounds; } } |
