diff options
| author | jmallet | 2017-07-07 16:10:27 +0000 |
|---|---|---|
| committer | jmallet | 2017-08-03 09:49:32 +0000 |
| commit | 51684694d9f3d47058bbe56094cbdfffc3256ee5 (patch) | |
| tree | f6c681bce3fe01654caf79ec96b83b318bd79666 | |
| parent | 879dd5c2462ce1293ac61eeb76519b8de2c7c107 (diff) | |
| download | org.eclipse.sirius-51684694d9f3d47058bbe56094cbdfffc3256ee5.tar.gz org.eclipse.sirius-51684694d9f3d47058bbe56094cbdfffc3256ee5.tar.xz org.eclipse.sirius-51684694d9f3d47058bbe56094cbdfffc3256ee5.zip | |
[519044] Add a migration participant for diagram with corrupted edge.
In some case, diagrams containing edge own bend-points with bad value
because at their creation, bend-point computation were not complete. For
example, there was only two bendpoints created with bad coordinates for
rectilinear edge.
The migration participant detects them and reset their coordinates to
correct value.
Bug: 519044
Change-Id: Id98be37218fb88e20c3760eff66225965c1cd634
Signed-off-by: jmallet <jessy.mallet@obeo.fr>
9 files changed, 627 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml index 140aeed344..1709b3b8d8 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml @@ -1817,6 +1817,10 @@ class="org.eclipse.sirius.diagram.ui.business.internal.migration.SnapBackDistantLabelsMigrationParticipant" kind="RepresentationsFile"> </participant> + <participant + class="org.eclipse.sirius.diagram.ui.business.internal.migration.RepairGMFbendpointsMigrationParticipant" + kind="RepresentationsFile"> + </participant> </extension> <extension point="org.eclipse.emf.edit.itemProviderAdapterFactories"> diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java new file mode 100644 index 0000000000..64254277ee --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.business.internal.migration; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.PrecisionPoint; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.IdentityAnchor; +import org.eclipse.gmf.runtime.notation.RelativeBendpoints; +import org.eclipse.gmf.runtime.notation.Routing; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; +import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; +import org.eclipse.sirius.business.api.query.DViewQuery; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.business.api.query.EdgeQuery; +import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper; +import org.eclipse.sirius.diagram.ui.internal.refresh.edge.SlidableAnchor; +import org.eclipse.sirius.diagram.ui.tools.internal.routers.RectilinearEdgeUtil; +import org.eclipse.sirius.ext.base.Option; +import org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper; +import org.eclipse.sirius.viewpoint.DAnalysis; +import org.eclipse.sirius.viewpoint.DView; +import org.osgi.framework.Version; + +import com.google.common.collect.Iterables; + +/** + * A representation file migration to repair GMF bend-points of edge. Source and target connection points must belongs + * to bounds of source and target edge figure. Moreover, if edge is rectilinear and not vertical neither horizontal, + * edge should have at least three bend-points. + * + * @author jmallet + */ +public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentationsFileMigrationParticipant { + + /** + * The Sirius version for which this migration is added. + */ + public static final Version MIGRATION_VERSION = new Version("12.1.0.201708031200"); //$NON-NLS-1$ + + @Override + public Version getMigrationVersion() { + return MIGRATION_VERSION; + } + + @Override + protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { + if (loadedVersion.compareTo(MIGRATION_VERSION) < 0) { + for (DView dView : dAnalysis.getOwnedViews()) { + for (DDiagram dDiagram : Iterables.filter(new DViewQuery(dView).getLoadedRepresentations(), DDiagram.class)) { + if ("DSemanticDiagramSpec".equals(dDiagram.getClass().getSimpleName())) { //$NON-NLS-1$ + List<Edge> edgeList = getEdgeList(dDiagram); + for (Edge edge : edgeList) { + checkAndRepairBendpointsOfEdge(edge); + } + } + } + } + + } + } + + /** + * Check bend-points of a given edge and repair them if necessary. + * + * @param edge + * the edge which contains bend-points to check + */ + private void checkAndRepairBendpointsOfEdge(Edge edge) { + // compute Source and Target Reference point + View source = edge.getSource(); + IdentityAnchor srcAnchor = (IdentityAnchor) edge.getSourceAnchor(); + View target = edge.getTarget(); + IdentityAnchor tgtAnchor = (IdentityAnchor) edge.getTargetAnchor(); + + List<RelativeBendpoint> pointList = ((RelativeBendpoints) edge.getBendpoints()).getPoints(); + if (srcAnchor != null && tgtAnchor != null && pointList.size() == 2) { + Point srcRef = getAnchorPosition(srcAnchor, source); + Point tgtRef = getAnchorPosition(tgtAnchor, target); + + // Retrieve anchor bend-points + RelativeBendpoint firstPoint = pointList.get(0); + PrecisionPoint srcPoint = new PrecisionPoint(firstPoint.getSourceX() + srcRef.x, firstPoint.getSourceY() + srcRef.y); + RelativeBendpoint lastPoint = pointList.get(pointList.size() - 1); + PrecisionPoint tgtPoint = new PrecisionPoint(lastPoint.getTargetX() + tgtRef.x, lastPoint.getTargetY() + tgtRef.y); + + Rectangle srcBounds = GMFHelper.getAbsoluteBounds(source).get(); + Rectangle tgtBounds = GMFHelper.getAbsoluteBounds(target).get(); + + EdgeQuery edgeQuery = new EdgeQuery(edge); + Routing routingStyle = edgeQuery.getRoutingStyle(); + + if (Routing.RECTILINEAR_LITERAL.equals(routingStyle)) { + if (srcPoint.x != tgtPoint.x && srcPoint.y != tgtPoint.y) { + // edge is not horizontal neither vertical + repairBendpointsOfEdge(edge, srcBounds, srcRef, tgtBounds, tgtRef); + } + } else if (!isPointOnBounds(srcPoint, srcBounds) || !isPointOnBounds(tgtPoint, tgtBounds)) { + // source and target connection must belong to bounds + repairBendpointsOfEdge(edge, srcBounds, srcRef, tgtBounds, tgtRef); + } + } + } + + /** + * Compute and set new list of bend-points used to define edge. + * + * @param edge + * the edge which own bend-points to replace + * @param srcBounds + * bounds of the figure of source edge + * @param srcRef + * source point used as reference to compute bend-points + * @param tgtBounds + * bounds of the figure of target edge + * @param tgtRef + * target point used as reference to compute bend-points + */ + private void repairBendpointsOfEdge(Edge edge, Rectangle srcBounds, Point srcRef, Rectangle tgtBounds, Point tgtRef) { + PointList newPointList = new PointList(); + + // compute intersection of anchors line with bounds + Option<Point> srcConnectionBendpoint = GraphicalHelper.getIntersection(srcRef, tgtRef, srcBounds, true); + Option<Point> tgtConnectionBendpoint = GraphicalHelper.getIntersection(srcRef, tgtRef, tgtBounds, false); + + if (srcConnectionBendpoint.some() && tgtConnectionBendpoint.some()) { + EdgeQuery edgeQuery = new EdgeQuery(edge); + Routing routingStyle = edgeQuery.getRoutingStyle(); + // Compute anchor logical coordinates + if (Routing.RECTILINEAR_LITERAL.equals(routingStyle)) { + newPointList = RectilinearEdgeUtil.computeRectilinearBendpoints(srcBounds, tgtBounds, srcConnectionBendpoint.get(), tgtConnectionBendpoint.get()); + } else { + newPointList.addPoint(srcConnectionBendpoint.get()); + newPointList.addPoint(tgtConnectionBendpoint.get()); + } + newPointList = RectilinearEdgeUtil.normalizeToStraightLineTolerance(newPointList, 2); + + setNewBendPoints(edge, srcRef, tgtRef, newPointList); + } + } + + /** + * Set bend-points of edge to a new bend-points list. + * + * @param edge + * the edge which own bend-points to replace + * @param srcRef + * source point used as reference to compute bend-points + * @param tgtRef + * target point used as reference to compute bend-points + * @param newPointList + * the new bend-points list + */ + private void setNewBendPoints(Edge edge, Point srcRef, Point tgtRef, PointList newPointList) { + List<RelativeBendpoint> newBendpoints = new ArrayList<RelativeBendpoint>(); + + int numOfPoints = newPointList.size(); + for (short i = 0; i < numOfPoints; i++) { + Dimension s = newPointList.getPoint(i).getDifference(srcRef); + Dimension t = newPointList.getPoint(i).getDifference(tgtRef); + newBendpoints.add(new RelativeBendpoint(s.width, s.height, t.width, t.height)); + } + + RelativeBendpoints points = (RelativeBendpoints) edge.getBendpoints(); + points.setPoints(newBendpoints); + } + + /** + * Return the relative coordinates of the anchor. + * + * @param anchor + * anchor from which point is extract + * @param view + * <code>View</code> that this anchor is associated with. + * @return relative coordinates of the anchor. + */ + private Point getAnchorPosition(IdentityAnchor anchor, View view) { + String id = anchor.getId(); + PrecisionPoint relativeReference = SlidableAnchor.parseTerminalString(id); + SlidableAnchor slidableAnchor = new SlidableAnchor(view, relativeReference); + return slidableAnchor.getReferencePoint(); + } + + /** + * Check if a given point belongs to bounds of figure. + * + * + * @param point + * the point to check + * @param bounds + * bounds of the figure where point is checked + * @return true if the point belongs to the figure bound, false otherwise. + */ + private boolean isPointOnBounds(PrecisionPoint point, Rectangle bounds) { + boolean isAlignWithBounds = point.x == bounds.x || point.x == bounds.x + bounds.width || point.y == bounds.y || point.y == bounds.y + bounds.height(); + boolean isInsideBounds = point.y >= bounds.y && point.y <= bounds.y + bounds.height() && point.x >= bounds.x && point.x <= bounds.x + bounds.width; + return isInsideBounds && isAlignWithBounds; + } + + /** + * Return a list of the edges contained in a representation. + * + * @param representation + * the representation + * @return a list of edges + */ + protected List<Edge> getEdgeList(DDiagram representation) { + List<Edge> edges = new ArrayList<Edge>(); + TreeIterator<EObject> eAllContents = representation.eAllContents(); + while (eAllContents.hasNext()) { + EObject element = eAllContents.next(); + if (element instanceof Edge) { + edges.add((Edge) element); + // Do not loop inner this edge + eAllContents.prune(); + } + } + return edges; + } + +} diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 36797a09d5..903d10b14b 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -161,6 +161,12 @@ <code>uid</code> as fragment. </li> </ul> + <ul> + <li><span class="label label-success">Added</span> A migration has been added to fix diagram with edge bend-points corrupted (see + <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=519044">bugzilla #519044</a> for more details). The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is + <em>12.1.0.201708031200</em>. + </li> + </ul> <h2 id="sirius5.0.1">Changes in Sirius 5.0.1</h2> <p>Sirius 5.0.1 is a maintenance release with only bugfixes and small tweaks to the UI of <a href="user/general/Aird_Editor.html">the aird editor</a>. diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index b51945f78b..e411c3f424 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -28,6 +28,8 @@ h4. Migrations * <span class="label label-success">Added</span> A new class @org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.SiriusDefaultSizeNodeFigure@ has been added in plugin @org.eclipse.sirius.ext.gmf.runtime@. The goal of the class is to workaround a "GMF bug":https://bugs.eclipse.org/bugs/show_bug.cgi?id=519250. So if you have created class which inherits from @org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure@, you must now use the new @SiriusDefaultSizeNodeFigure@ instead. * <span class="label label-success">Added</span> A migration has been added to add an @uid@ to all instances of type DRepresentation.This @uid@ is used to reference the DRepresentation from the DRepresentationDescriptor. @DRepresentationDescriptor.repPath@ has been changed to have @uid@ as fragment. +* <span class="label label-success">Added</span> A migration has been added to fix diagram with edge bend-points corrupted (see "bugzilla #519044":https://bugs.eclipse.org/bugs/show_bug.cgi?id=519044 for more details). The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is _12.1.0.201708031200_. + h2(#sirius5.0.1). Changes in Sirius 5.0.1 Sirius 5.0.1 is a maintenance release with only bugfixes and small tweaks to the UI of "the aird editor":user/general/Aird_Editor.html. diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.ecore new file mode 100644 index 0000000000..7da0f9e858 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.ecore @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="P1"> + <eClassifiers xsi:type="ecore:EClass" name="C1" eSuperTypes="#//C2"/> + <eClassifiers xsi:type="ecore:EClass" name="C2"/> + <eSubpackages name="P2"> + <eClassifiers xsi:type="ecore:EClass" name="C3" eSuperTypes="#//P2/C4"/> + <eClassifiers xsi:type="ecore:EClass" name="C4"/> + </eSubpackages> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.odesign new file mode 100644 index 0000000000..afee0c1256 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/TestRectilinear.odesign @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="ASCII"?> +<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" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="TestRectilinear" version="12.0.0.2017041100"> + <ownedViewpoints name="TestRectilinear" modelFileExtension="ecore"> + <ownedRepresentations xsi:type="description_1:DiagramDescription" name="TestRectilinear Node" domainClass="EPackage"> + <defaultLayer name="Default"> + <nodeMappings name="NodeEClass" semanticCandidatesExpression="feature:eContents" domainClass="EClass"> + <borderedNodeMappings name="BNodeEClass_Out" preconditionExpression="aql:self.eSuperTypes->size() <> 0" semanticCandidatesExpression="var:self" createElements="false" domainClass="EClass"> + <style xsi:type="style:SquareDescription" hideLabelByDefault="true" sizeComputationExpression="1"> + <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='blue']"/> + </style> + </borderedNodeMappings> + <borderedNodeMappings name="BNodeEClass_In" preconditionExpression="aql:self.eInverse('eSuperTypes')->size() <> 0" semanticCandidatesExpression="var:self" createElements="false" domainClass="EClass"> + <style xsi:type="style:SquareDescription" hideLabelByDefault="true" sizeComputationExpression="1"> + <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='green']"/> + </style> + </borderedNodeMappings> + <style xsi:type="style:SquareDescription" 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> + <edgeMappings name="Node_Supertype" createElements="false" sourceMapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']" targetMapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']" targetFinderExpression="aql:self.eSuperTypes"> + <style sizeComputationExpression="2" routingStyle="manhattan"> + <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/> + </style> + </edgeMappings> + <edgeMappings name="Node_SupertypeBn" createElements="false" sourceMapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@borderedNodeMappings[name='BNodeEClass_Out']" targetMapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@borderedNodeMappings[name='BNodeEClass_In']" targetFinderExpression="aql:self.eSuperTypes"> + <style sizeComputationExpression="2" routingStyle="manhattan"> + <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/> + </style> + </edgeMappings> + <toolSections name="Tools"> + <ownedTools xsi:type="tool:EdgeCreationDescription" name="Super" edgeMappings="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_Supertype']"> + <sourceVariable name="source"/> + <targetVariable name="target"/> + <sourceViewVariable name="sourceView"/> + <targetViewVariable name="targetView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:source"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="eSuperTypes" valueExpression="var:target"/> + </firstModelOperations> + </initialOperation> + </ownedTools> + <ownedTools xsi:type="tool:EdgeCreationDescription" name="SuperWithBorderNode" edgeMappings="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_SupertypeBn']" extraSourceMappings="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']" extraTargetMappings="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']"> + <sourceVariable name="source"/> + <targetVariable name="target"/> + <sourceViewVariable name="sourceView"/> + <targetViewVariable name="targetView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:source"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="eSuperTypes" valueExpression="var:target"/> + <subModelOperations xsi:type="tool:CreateView" mapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@borderedNodeMappings[name='BNodeEClass_Out']" containerViewExpression="var:sourceView" variableName="newSourceView"/> + <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:target"> + <subModelOperations xsi:type="tool:CreateView" mapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@borderedNodeMappings[name='BNodeEClass_In']" containerViewExpression="var:targetView" variableName="newTargetView"/> + <subModelOperations xsi:type="tool:CreateEdgeView" mapping="//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_SupertypeBn']" containerViewExpression="[sourceView.eContainer(diagram::DDiagram)/]" variableName="edgeCreatedView" sourceExpression="var:source" targetExpression="var:target"/> + </subModelOperations> + </firstModelOperations> + </initialOperation> + </ownedTools> + </toolSections> + </defaultLayer> + </ownedRepresentations> + </ownedViewpoints> +</description:Group> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/representations.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/representations.aird new file mode 100644 index 0000000000..5c54ecc54a --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/edgeBendpointsRepair/representations.aird @@ -0,0 +1,181 @@ +<?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="_-aHbgGMqEee3DdaQR_R7SA" selectedViews="_AjlCYGMrEee3DdaQR_R7SA" version="12.0.0.201704271200"> + <semanticResources>TestRectilinear.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DView" xmi:id="_AjlCYGMrEee3DdaQR_R7SA"> + <viewpoint xmi:type="description:Viewpoint" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']"/> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_CPjcAGMrEee3DdaQR_R7SA" name="DiagBadEdge" repPath="#_CPgYsGMrEee3DdaQR_R7SA"> + <description xmi:type="description_1:DiagramDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']"/> + <target xmi:type="ecore:EPackage" href="TestRectilinear.ecore#/"/> + </ownedRepresentationDescriptors> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_DvXB4GMrEee3DdaQR_R7SA" name="DiagGoodEdge" repPath="#_DvVzwGMrEee3DdaQR_R7SA"> + <description xmi:type="description_1:DiagramDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']"/> + <target xmi:type="ecore:EPackage" href="TestRectilinear.ecore#//P2"/> + </ownedRepresentationDescriptors> + </ownedViews> + </viewpoint:DAnalysis> + <diagram:DSemanticDiagram xmi:id="_CPgYsGMrEee3DdaQR_R7SA" name="DiagBadEdge"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_CPgYsWMrEee3DdaQR_R7SA" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_CPgYsmMrEee3DdaQR_R7SA"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_CPr-4GMrEee3DdaQR_R7SA" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_CPr-4WMrEee3DdaQR_R7SA" type="Sirius" element="_CPgYsGMrEee3DdaQR_R7SA" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_CPvpQGMrEee3DdaQR_R7SA" type="2001" element="_CPg_wGMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_CP1I0GMrEee3DdaQR_R7SA" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_CP1I0WMrEee3DdaQR_R7SA" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_CP4MIGMrEee3DdaQR_R7SA" type="3003" element="_CPg_wWMrEee3DdaQR_R7SA"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CP4zMGMrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CP4zMWMrEee3DdaQR_R7SA"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CPvpQWMrEee3DdaQR_R7SA" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CPvpQmMrEee3DdaQR_R7SA" x="120" y="95" width="151" height="206"/> + </children> + <children xmi:type="notation:Node" xmi:id="_CP2-AGMrEee3DdaQR_R7SA" type="2001" element="_CPg_wmMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_CP3lEGMrEee3DdaQR_R7SA" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_CP3lEWMrEee3DdaQR_R7SA" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_CP4zMmMrEee3DdaQR_R7SA" type="3003" element="_CPg_w2MrEee3DdaQR_R7SA"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CP4zM2MrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CP4zNGMrEee3DdaQR_R7SA"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CP2-AWMrEee3DdaQR_R7SA" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CP2-AmMrEee3DdaQR_R7SA" x="400" y="70" width="136" height="166"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_CPr-4mMrEee3DdaQR_R7SA"/> + <edges xmi:type="notation:Edge" xmi:id="_OmF64GMrEee3DdaQR_R7SA" type="4001" element="_OmCQgGMrEee3DdaQR_R7SA" source="_CPvpQGMrEee3DdaQR_R7SA" target="_CP2-AGMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_OmF65GMrEee3DdaQR_R7SA" type="6001"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OmGh8GMrEee3DdaQR_R7SA" y="-10"/> + </children> + <children xmi:type="notation:Node" xmi:id="_OmGh8WMrEee3DdaQR_R7SA" type="6002"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OmGh8mMrEee3DdaQR_R7SA" y="10"/> + </children> + <children xmi:type="notation:Node" xmi:id="_OmGh82MrEee3DdaQR_R7SA" type="6003"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OmGh9GMrEee3DdaQR_R7SA" y="10"/> + </children> + <styles xmi:type="notation:ConnectorStyle" xmi:id="_OmF64WMrEee3DdaQR_R7SA" routing="Rectilinear"/> + <styles xmi:type="notation:FontStyle" xmi:id="_OmF64mMrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_OmF642MrEee3DdaQR_R7SA" points="[25, 16, -139, -90]$[154, 117, -10, 11]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_OmGh9WMrEee3DdaQR_R7SA" id="(0.8344370860927153,0.0970873786407767)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_OmGh9mMrEee3DdaQR_R7SA" id="(0.07352941176470588,0.9096385542168675)"/> + </edges> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_CPg_wGMrEee3DdaQR_R7SA" name="C1" outgoingEdges="_OmCQgGMrEee3DdaQR_R7SA" width="3" height="3" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//C1"/> + <semanticElements xmi:type="ecore:EClass" href="TestRectilinear.ecore#//C1"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_CPg_wWMrEee3DdaQR_R7SA" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_CPg_wmMrEee3DdaQR_R7SA" name="C2" incomingEdges="_OmCQgGMrEee3DdaQR_R7SA" width="3" height="3" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//C2"/> + <semanticElements xmi:type="ecore:EClass" href="TestRectilinear.ecore#//C2"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_CPg_w2MrEee3DdaQR_R7SA" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DEdge" xmi:id="_OmCQgGMrEee3DdaQR_R7SA" sourceNode="_CPg_wGMrEee3DdaQR_R7SA" targetNode="_CPg_wmMrEee3DdaQR_R7SA"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//C1"/> + <ownedStyle xmi:type="diagram:EdgeStyle" xmi:id="_OmCQgWMrEee3DdaQR_R7SA" size="2" routingStyle="manhattan"> + <customFeatures>routingStyle</customFeatures> + <description xmi:type="style:EdgeStyleDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_Supertype']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:EdgeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_Supertype']"/> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_CPg_xGMrEee3DdaQR_R7SA"/> + <activatedLayers xmi:type="description_1:Layer" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="TestRectilinear.ecore#/"/> + </diagram:DSemanticDiagram> + <diagram:DSemanticDiagram xmi:id="_DvVzwGMrEee3DdaQR_R7SA" name="DiagGoodEdge"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_DvVzwWMrEee3DdaQR_R7SA" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_DvVzwmMrEee3DdaQR_R7SA"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_DvXo8GMrEee3DdaQR_R7SA" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_DvXo8WMrEee3DdaQR_R7SA" type="Sirius" element="_DvVzwGMrEee3DdaQR_R7SA" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_DvYQAGMrEee3DdaQR_R7SA" type="2001" element="_DvVzxGMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_DvY3EGMrEee3DdaQR_R7SA" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_DvY3EWMrEee3DdaQR_R7SA" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_DvZeImMrEee3DdaQR_R7SA" type="3003" element="_DvVzxWMrEee3DdaQR_R7SA"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_DvZeI2MrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DvZeJGMrEee3DdaQR_R7SA"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_DvYQAWMrEee3DdaQR_R7SA" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DvYQAmMrEee3DdaQR_R7SA" x="127" y="20" width="107" height="173"/> + </children> + <children xmi:type="notation:Node" xmi:id="_DvY3EmMrEee3DdaQR_R7SA" type="2001" element="_DvVzxmMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_DvZeIGMrEee3DdaQR_R7SA" type="5002"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_DvZeIWMrEee3DdaQR_R7SA" y="5"/> + </children> + <children xmi:type="notation:Node" xmi:id="_DvZeJWMrEee3DdaQR_R7SA" type="3003" element="_DvVzx2MrEee3DdaQR_R7SA"> + <styles xmi:type="notation:ShapeStyle" xmi:id="_DvZeJmMrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DvZeJ2MrEee3DdaQR_R7SA"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_DvY3E2MrEee3DdaQR_R7SA" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DvY3FGMrEee3DdaQR_R7SA" x="365" y="100" width="89" height="162"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_DvXo8mMrEee3DdaQR_R7SA"/> + <edges xmi:type="notation:Edge" xmi:id="_GdqbMGMrEee3DdaQR_R7SA" type="4001" element="_GdifYGMrEee3DdaQR_R7SA" source="_DvYQAGMrEee3DdaQR_R7SA" target="_DvY3EmMrEee3DdaQR_R7SA"> + <children xmi:type="notation:Node" xmi:id="_GdrCQGMrEee3DdaQR_R7SA" type="6001"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_GdrCQWMrEee3DdaQR_R7SA" x="18" y="-10"/> + </children> + <children xmi:type="notation:Node" xmi:id="_GdrpUGMrEee3DdaQR_R7SA" type="6002"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_GdrpUWMrEee3DdaQR_R7SA" y="10"/> + </children> + <children xmi:type="notation:Node" xmi:id="_GdsQYGMrEee3DdaQR_R7SA" type="6003"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_GdsQYWMrEee3DdaQR_R7SA" y="10"/> + </children> + <styles xmi:type="notation:ConnectorStyle" xmi:id="_GdqbMWMrEee3DdaQR_R7SA" routing="Rectilinear"/> + <styles xmi:type="notation:FontStyle" xmi:id="_GdqbMmMrEee3DdaQR_R7SA" fontName="Segoe UI"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_GdqbM2MrEee3DdaQR_R7SA" points="[17, 19, -147, -170]$[100, 19, -64, -170]$[100, 170, -64, -19]$[148, 170, -16, -19]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Gds3cGMrEee3DdaQR_R7SA" id="(0.8411214953271028,0.2023121387283237)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Gds3cWMrEee3DdaQR_R7SA" id="(0.1797752808988764,0.8888888888888888)"/> + </edges> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_DvVzxGMrEee3DdaQR_R7SA" name="C3" outgoingEdges="_GdifYGMrEee3DdaQR_R7SA" width="3" height="3" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//P2/C3"/> + <semanticElements xmi:type="ecore:EClass" href="TestRectilinear.ecore#//P2/C3"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_DvVzxWMrEee3DdaQR_R7SA" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_DvVzxmMrEee3DdaQR_R7SA" name="C4" incomingEdges="_GdifYGMrEee3DdaQR_R7SA" width="3" height="3" resizeKind="NSEW"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//P2/C4"/> + <semanticElements xmi:type="ecore:EClass" href="TestRectilinear.ecore#//P2/C4"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:Square" xmi:id="_DvVzx2MrEee3DdaQR_R7SA" labelPosition="node"> + <description xmi:type="style:SquareDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@nodeMappings[name='NodeEClass']"/> + </ownedDiagramElements> + <ownedDiagramElements xmi:type="diagram:DEdge" xmi:id="_GdifYGMrEee3DdaQR_R7SA" sourceNode="_DvVzxGMrEee3DdaQR_R7SA" targetNode="_DvVzxmMrEee3DdaQR_R7SA"> + <target xmi:type="ecore:EClass" href="TestRectilinear.ecore#//P2/C3"/> + <ownedStyle xmi:type="diagram:EdgeStyle" xmi:id="_GdjtgGMrEee3DdaQR_R7SA" size="2" routingStyle="manhattan"> + <customFeatures>routingStyle</customFeatures> + <description xmi:type="style:EdgeStyleDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_Supertype']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:EdgeMapping" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer/@edgeMappings[name='Node_Supertype']"/> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_DvVzyGMrEee3DdaQR_R7SA"/> + <activatedLayers xmi:type="description_1:Layer" href="TestRectilinear.odesign#//@ownedViewpoints[name='TestRectilinear']/@ownedRepresentations[name='TestRectilinear%20Node']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="TestRectilinear.ecore#//P2"/> + </diagram:DSemanticDiagram> +</xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java index e90de9ba0f..2d766c1f8f 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java @@ -136,6 +136,7 @@ import org.eclipse.sirius.tests.unit.diagram.migration.NoteShapeDefaultLabelAlig import org.eclipse.sirius.tests.unit.diagram.migration.OptionalLayerToAdditionalLayerMigrationTest; import org.eclipse.sirius.tests.unit.diagram.migration.ReferencedModelResourceMigrationTest; import org.eclipse.sirius.tests.unit.diagram.migration.RemoveAcceleoReferencesMigrationTest; +import org.eclipse.sirius.tests.unit.diagram.migration.RepairGMFbendpointsMigrationParticipantTest; import org.eclipse.sirius.tests.unit.diagram.migration.RepairMigrateLostDiagramElementsTC1Test; import org.eclipse.sirius.tests.unit.diagram.migration.RepairMigrateLostDiagramElementsTC2Test; import org.eclipse.sirius.tests.unit.diagram.migration.RepairMigratePinStatusTest; @@ -234,6 +235,7 @@ public class AllCommonPluginTests extends TestCase { suite.addTestSuite(NoteAttachmentMigrationTest.class); suite.addTestSuite(DRepInDViewToRootObjectsAndWithDRepDescRepPathMigrationTest.class); suite.addTestSuite(DecorationDescriptionImageExpressionMigrationTest.class); + suite.addTestSuite(RepairGMFbendpointsMigrationParticipantTest.class); suite.addTest(new JUnit4TestAdapter(CommonPreferencesTest.class)); suite.addTest(new JUnit4TestAdapter(GroupingContentProviderTest.class)); diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairGMFbendpointsMigrationParticipantTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairGMFbendpointsMigrationParticipantTest.java new file mode 100644 index 0000000000..a76207ef66 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairGMFbendpointsMigrationParticipantTest.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.unit.diagram.migration; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.RelativeBendpoints; +import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; +import org.eclipse.sirius.business.api.query.DViewQuery; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.business.internal.migration.RepairGMFbendpointsMigrationParticipant; +import org.eclipse.sirius.tests.SiriusTestsPlugin; +import org.eclipse.sirius.tests.support.api.SiriusTestCase; +import org.eclipse.sirius.tools.api.command.ICommandFactory; +import org.eclipse.sirius.viewpoint.DAnalysis; +import org.eclipse.sirius.viewpoint.DView; +import org.osgi.framework.Version; + +import com.google.common.collect.Iterables; + +/** + * Test for {@link RepairGMFbendpointsMigrationParticipant}. + * + * @author jmallet + */ +public class RepairGMFbendpointsMigrationParticipantTest extends SiriusTestCase { + + private static final String PATH = "data/unit/migration/do_not_migrate/edgeBendpointsRepair/"; + + private static final String SESSION_RESOURCE_NAME = "representations.aird"; + + private static final String SEMANTIC_RESOURCE_NAME = "TestRectilinear.ecore"; + + private static final String VSM_RESOURCE_NAME = "TestRectilinear.odesign"; + + private Resource sessionResource; + + @Override + protected ICommandFactory getCommandFactory() { + return null; + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + genericSetUp(); + copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, PATH, SESSION_RESOURCE_NAME, SEMANTIC_RESOURCE_NAME, + VSM_RESOURCE_NAME); + URI sessionResourceURI = URI + .createPlatformResourceURI(SiriusTestCase.TEMPORARY_PROJECT_NAME + "/" + SESSION_RESOURCE_NAME, true); + ResourceSet resourceSet = new ResourceSetImpl(); + sessionResource = resourceSet.getResource(sessionResourceURI, true); + + } + + /** + * Test that the data were not migrated on the repository. It allows to + * check the effect of the migration in the other test. + */ + public void testMigrationIsNeededOnData() { + Version migrationVersion = new RepairGMFbendpointsMigrationParticipant().getMigrationVersion(); + + // Check that the migration of the session resource is needed. + Version loadedVersion = checkRepresentationFileMigrationStatus(URI.createPlatformResourceURI( + SiriusTestCase.TEMPORARY_PROJECT_NAME + "/" + SESSION_RESOURCE_NAME, true), true); + assertTrue("The migration must be required on test data.", migrationVersion.compareTo(loadedVersion) > 0); + } + + /** + * Test that bend-points of edge on diagram are repaired. + */ + public void testBendpointsHaveBeenRepaired() { + for (DView view : ((DAnalysis) sessionResource.getContents().iterator().next()).getOwnedViews()) { + for (DDiagram dDiagram : Iterables.filter(new DViewQuery(view).getLoadedRepresentations(), + DDiagram.class)) { + checkBendpointsNumber(dDiagram); + } + } + } + + /** + * Check that edge have correct number of bend-point which implies that they have been repaired. + * + * @param diagram + * the migrated diagram to check + */ + private void checkBendpointsNumber(DDiagram diagram) { + Iterator<EObject> iterator = diagram.eAllContents(); + while (iterator.hasNext()) { + EObject element = iterator.next(); + if (element instanceof Edge) { + Edge edge = (Edge) element; + RelativeBendpoints bendpoints = (RelativeBendpoints) edge.getBendpoints(); + List<RelativeBendpoint> pointList = bendpoints.getPoints(); + // Rectilinear edge should have more than 2 bendpoints if source and target are not aligned. + assertTrue("Number of bendpoints on rectilinear edge should be greater than 2.", pointList.size() > 2); + } + } + } +} |
