diff options
| author | jmallet | 2017-08-03 16:13:39 +0000 |
|---|---|---|
| committer | Florian Barbin | 2017-08-04 09:03:53 +0000 |
| commit | f14ec1fcce397ee670f045c06fa89d91ba1bb663 (patch) | |
| tree | 16b7203f96e74a7cb38f5981208b801c114cd53c | |
| parent | a5e634fe1f011a08bd9c33448b6849087611c249 (diff) | |
| download | org.eclipse.sirius-f14ec1fcce397ee670f045c06fa89d91ba1bb663.tar.gz org.eclipse.sirius-f14ec1fcce397ee670f045c06fa89d91ba1bb663.tar.xz org.eclipse.sirius-f14ec1fcce397ee670f045c06fa89d91ba1bb663.zip | |
[519044] Add impact log on bend-points migration participant.
When diagram has been modified because there was some edge with wrong
GMF coordinates, migration impacts are now logged.
Bug: 519044
Change-Id: Ied19561445d1c002c2838f34af350c6d09569dfd
Signed-off-by: jmallet <jessy.mallet@obeo.fr>
3 files changed, 33 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties index 5194e51573..15f2f8eace 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties @@ -1039,6 +1039,8 @@ RegionContainerUpdateLayoutOperation_name = Layout Regions Operations RegionResizableEditPolicy_regionAutoSizeCommandLabel = Region Auto Size Composite Command RemoveBendpointsHandler_cmdLabel = Remove Bend-points RemoveInvalidViewsCommand_label = Remove invalid views +RepairGMFbendpointsMigrationParticipant_edgesModified = \n\t* In diagram "{0}", bend-points of some edges have been repaired because their GMF coordinates was not correct. +RepairGMFbendpointsMigrationParticipant_title = Migration done for "Wrong edge bend-points" (the result of this migration will be saved on the next session save): ResetOriginChangeModelOperation_name = Reset Origin ResetOriginChangeModelOperation_nameOnContainer = Reset Container Origin ResetOriginChangeModelOperation_nameOnDiagram = Reset Diagram Origin 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 index 64254277ee..234d0f258e 100644 --- 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 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.business.internal.migration; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -29,9 +30,11 @@ 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.DiagramPlugin; 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.provider.Messages; 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; @@ -63,17 +66,26 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat @Override protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { if (loadedVersion.compareTo(MIGRATION_VERSION) < 0) { + boolean isModified = false; + StringBuilder sb = new StringBuilder(Messages.RepairGMFbendpointsMigrationParticipant_title); 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); + boolean isEdgeModified = false; for (Edge edge : edgeList) { - checkAndRepairBendpointsOfEdge(edge); + isEdgeModified = checkAndRepairBendpointsOfEdge(edge); + } + if (isEdgeModified) { + isModified = true; + sb.append(MessageFormat.format(Messages.RepairGMFbendpointsMigrationParticipant_edgesModified, dDiagram.getName())); } } } } - + if (isModified) { + DiagramPlugin.getDefault().logInfo(sb.toString()); + } } } @@ -82,8 +94,10 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat * * @param edge * the edge which contains bend-points to check + * @return true if bend-points of the given edge have been modified, false otherwise */ - private void checkAndRepairBendpointsOfEdge(Edge edge) { + private boolean checkAndRepairBendpointsOfEdge(Edge edge) { + boolean isEdgeModified = false; // compute Source and Target Reference point View source = edge.getSource(); IdentityAnchor srcAnchor = (IdentityAnchor) edge.getSourceAnchor(); @@ -110,13 +124,14 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat 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); + isEdgeModified = 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); + isEdgeModified = repairBendpointsOfEdge(edge, srcBounds, srcRef, tgtBounds, tgtRef); } } + return isEdgeModified; } /** @@ -132,8 +147,10 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat * bounds of the figure of target edge * @param tgtRef * target point used as reference to compute bend-points + * @return true if bend-points of the given edge have been modified, false otherwise */ - private void repairBendpointsOfEdge(Edge edge, Rectangle srcBounds, Point srcRef, Rectangle tgtBounds, Point tgtRef) { + private boolean repairBendpointsOfEdge(Edge edge, Rectangle srcBounds, Point srcRef, Rectangle tgtBounds, Point tgtRef) { + boolean isEdgeModified = false; PointList newPointList = new PointList(); // compute intersection of anchors line with bounds @@ -141,6 +158,7 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat Option<Point> tgtConnectionBendpoint = GraphicalHelper.getIntersection(srcRef, tgtRef, tgtBounds, false); if (srcConnectionBendpoint.some() && tgtConnectionBendpoint.some()) { + isEdgeModified = true; EdgeQuery edgeQuery = new EdgeQuery(edge); Routing routingStyle = edgeQuery.getRoutingStyle(); // Compute anchor logical coordinates @@ -154,6 +172,7 @@ public class RepairGMFbendpointsMigrationParticipant extends AbstractRepresentat setNewBendPoints(edge, srcRef, tgtRef, newPointList); } + return isEdgeModified; } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java index b14270620c..d5094dd8af 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java @@ -894,6 +894,12 @@ public final class Messages { public static String RemoveInvalidViewsCommand_label; @TranslatableMessage + public static String RepairGMFbendpointsMigrationParticipant_edgesModified; + + @TranslatableMessage + public static String RepairGMFbendpointsMigrationParticipant_title; + + @TranslatableMessage public static String ResetOriginChangeModelOperation_name; @TranslatableMessage |
