Skip to content

Commit

Permalink
[331] Complete an existing migration participant
Browse files Browse the repository at this point in the history
The previous version of the migration participant does not handle all
the cases. The case of the image style of nodes contained in a container
(and not directly in diagram) was missed.
The version number of the migration participant has just been bumped as
there is no incidence to call this migration on an aird file already
migrated.

Bug: #331
  • Loading branch information
lredor committed Mar 20, 2024
1 parent 0101c53 commit ceb41b8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 THALES GLOBAL SERVICES.
* Copyright (c) 2022, 2024 THALES GLOBAL SERVICES.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -19,6 +19,8 @@

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Node;
Expand Down Expand Up @@ -59,7 +61,7 @@ public class WorkspaceImageGMFBoundsMigrationParticipant extends AbstractReprese
/**
* Migration version.
*/
public static final Version MIGRATION_VERSION = new Version("15.0.0.202209061200"); //$NON-NLS-1$
public static final Version MIGRATION_VERSION = new Version("15.4.1.202403191723"); //$NON-NLS-1$

/**
* The previous migration version of this participant. This one introduced a wrong size migration for collapsed
Expand Down Expand Up @@ -89,20 +91,10 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
if (descriptor.getRepresentation() instanceof DDiagram) {
DDiagram dDiagram = (DDiagram) descriptor.getRepresentation();
DDiagramGraphicalQuery query = new DDiagramGraphicalQuery(dDiagram);
Option<Diagram> gmfDiagram = query.getAssociatedGMFDiagram();
if (gmfDiagram.some()) {
boolean migrationOccurredInCurrentDiag = false;
String representationName = StringUtil.EMPTY_STRING;
for (Object child : gmfDiagram.get().getChildren()) {
if (resizeWorkspaceImageGMFBounds(child, previousMigrationApplied)) {
migrationOccurred = true;
migrationOccurredInCurrentDiag = true;
representationName = dDiagram.getName();
}
}
if (migrationOccurredInCurrentDiag) {
sb.append(MessageFormat.format(Messages.WorkspaceImageGMFBoundsMigrationParticipant_GMFBoundsResized, representationName));
}
Option<Diagram> optionalGmfDiagram = query.getAssociatedGMFDiagram();
if (optionalGmfDiagram.some()) {
boolean migrationOccurredInCurrentDiag = resizeWorkspaceImageGmfBoundsOfDiagram(previousMigrationApplied, sb, dDiagram, optionalGmfDiagram.get());
migrationOccurred = migrationOccurredInCurrentDiag || migrationOccurred;
}
}
}
Expand All @@ -114,27 +106,41 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}
}

private boolean resizeWorkspaceImageGMFBounds(Object child, boolean previousMigrationApplied) {
boolean resized = false;
if (child instanceof Node && ((Node) child).getLayoutConstraint() instanceof Size) {
Node node = (Node) child;
if (node.getElement() instanceof DNode) {
DNode dnode = (DNode) node.getElement();
if (dnode.getStyle() != null) {
StyleDescription description = dnode.getStyle().getDescription();
resized = resizeGMFNode(previousMigrationApplied, node, description, dnode.getWidth(), dnode.getHeight());
}
} else if (node.getElement() instanceof DDiagramElementContainer) {
DDiagramElementContainer dDiagramElementContainer = (DDiagramElementContainer) node.getElement();
if (dDiagramElementContainer.getStyle() != null) {
StyleDescription description = dDiagramElementContainer.getStyle().getDescription();
resized = resizeGMFNode(previousMigrationApplied, node, description, dDiagramElementContainer.getWidth(), dDiagramElementContainer.getHeight());
for (Object o : node.getChildren()) {
resized = resizeWorkspaceImageGMFBounds(o, previousMigrationApplied);
}
private boolean resizeWorkspaceImageGmfBoundsOfDiagram(boolean previousMigrationApplied, StringBuilder sb, DDiagram dDiagram, Diagram gmfDiagram) {
boolean migrationOccurredInCurrentDiag = false;
String representationName = StringUtil.EMPTY_STRING;
TreeIterator<EObject> childIterator = gmfDiagram.eAllContents();
while (childIterator.hasNext()) {
EObject eObject = childIterator.next();
if (eObject instanceof Node && ((Node) eObject).getLayoutConstraint() instanceof Size) {
Node node = (Node) eObject;
if (resizeWorkspaceImageGMFBounds(node, previousMigrationApplied)) {
migrationOccurredInCurrentDiag = true;
representationName = dDiagram.getName();
}
}
}
if (migrationOccurredInCurrentDiag) {
sb.append(MessageFormat.format(Messages.WorkspaceImageGMFBoundsMigrationParticipant_GMFBoundsResized, representationName));
}
return migrationOccurredInCurrentDiag;
}

private boolean resizeWorkspaceImageGMFBounds(Node node, boolean previousMigrationApplied) {
boolean resized = false;
if (node.getElement() instanceof DNode) {
DNode dnode = (DNode) node.getElement();
if (dnode.getStyle() != null) {
StyleDescription description = dnode.getStyle().getDescription();
resized = resizeGMFNode(previousMigrationApplied, node, description, dnode.getWidth(), dnode.getHeight());
}
} else if (node.getElement() instanceof DDiagramElementContainer) {
DDiagramElementContainer dDiagramElementContainer = (DDiagramElementContainer) node.getElement();
if (dDiagramElementContainer.getStyle() != null) {
StyleDescription description = dDiagramElementContainer.getStyle().getDescription();
resized = resizeGMFNode(previousMigrationApplied, node, description, dDiagramElementContainer.getWidth(), dDiagramElementContainer.getHeight());
}
}
return resized;
}

Expand Down
35 changes: 22 additions & 13 deletions plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,21 @@ <h3 id="UserVisibleChanges">User-Visible Changes</h3>
</ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
<li><span class="label label-info">Modified</span> The method
<code>org.eclipse.sirius.diagram.ui.tools.api.color.ColorManager.collectVsmColors(Session)</code> has replaced
<code>Map&lt;String, RGB&gt; collectVsmAndDefaultColors(Session session)</code>.
</li>
</ul>
<h4 id="Migrations">Migrations</h4>
<ul>
<li><span class="label label-success">Added</span> The migration participant WorkspaceImageGMFBoundsMigrationParticipant has been updated to handle the missed case of the image style of nodes contained in a container (and not directly in diagram). As reminder, this migration participant has been introduced in Sirius 7.0.0. The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is
<em>15.4.1.202403191723</em>.
</li>
</ul>
<h2 id="sirius7.4.0">Changes in Sirius Desktop 7.4.0</h2>
<h3 id="UserVisibleChanges2">User-Visible Changes</h3>
<ul>
Expand Down Expand Up @@ -297,7 +306,7 @@ <h4 id="Changesinorg.eclipse.sirius.table">Changes in
<code>org.eclipse.sirius.table.tools.api.command.ITableCommandFactory.buildCreateColumnCommandFromTool(DTable, EObject, CreateTool)</code> have been deprecated for removal. They have been replaced by methods using applicable DSemanticDecorator in signature.
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui2">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -369,7 +378,7 @@ <h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
</ul>
</li>
</ul>
<h4 id="Migrations">Migrations</h4>
<h4 id="Migrations2">Migrations</h4>
<ul>
<li><span class="label label-success">Added</span> A migration participant has been added to migrate ELK options used in VSM. Some have been renamed and some others have been removed. You should carefully read the information logged during this migration and the
<a href="https://eclipse.dev/elk/downloads/releasenotes/release-0.9.0.html">ELK release notes</a> to check if any manual adjustments need to be made. The corresponding version, stored in attribute version of description:Group of the odesign file, is
Expand All @@ -383,7 +392,7 @@ <h3 id="UserVisibleChanges3">User-Visible Changes</h3>
</ul>
<h3 id="SpecifierVisibleChanges3">Specifier-Visible Changes</h3>
<h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui2">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui3">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -441,7 +450,7 @@ <h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
</li>
</ul>
<h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui3">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui4">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -560,7 +569,7 @@ <h4 id="Changesinorg.eclipse.sirius2">Changes in
<code>org.eclipse.sirius.business.api.session.Session.getSharedMainDAnalysis()</code> is added to get the DAnalysis that holds data and can be shared in some context such as CDO.
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui4">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui5">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -618,7 +627,7 @@ <h4 id="Changesinorg.eclipse.sirius.properties.core">Changes in
<code>org.eclipse.sirius.properties.core.api.SiriusInputDescriptor.getOriginalSelections()</code>.
</li>
</ul>
<h4 id="Migrations2">Migrations</h4>
<h4 id="Migrations3">Migrations</h4>
<ul>
<li><span class="label label-info">Modified</span>The migration participant introduced by
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=576423">Bug 576423 -
Expand Down Expand Up @@ -887,7 +896,7 @@ <h4 id="Changesinorg.eclipse.sirius.diagram.model">Changes in
<code>org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContentHelper.getAllEdgeMappings(diagramDescription, false)</code> alongside with the getAllNodeMappings and getAllContainerMappings methods.
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui5">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui6">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -1021,7 +1030,7 @@ <h4 id="Changesinorg.eclipse.sirius.tests.junit.support">Changes in
<code>org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper.copyDirectory(String, String)</code> have been added to ease to the copy of the test files from the test plugin to the junit workspace.
</li>
</ul>
<h4 id="Migrations3">Migrations</h4>
<h4 id="Migrations4">Migrations</h4>
<ul>
<li><span class="label label-success">Added</span> A migration participant has been added to repair size of GMF nodes with Workspace Image style description. A default size was set for this type of nodes, which resulted in graphical inconsistencies (see
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=576423)">Bug 576423 -
Expand Down Expand Up @@ -1079,15 +1088,15 @@ <h4 id="Changesinorg.eclipse.sirius.diagram3">Changes in
</ul>
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui6">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui7">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
<li>* <span class="label label-info">Modified</span> The method
<code>org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDDiagramEditPart.refreshChildren()</code> has been overridden to redraw the edges figures according to the order of the GMF edges.
</li>
</ul>
<h4 id="Migrations4">Migrations</h4>
<h4 id="Migrations5">Migrations</h4>
<ul>
<li><span class="label label-success">Added</span> A migration participant has been added to set a changeId value for each DRepresentationDescriptor that did not have one. Some old models were missing the changeId attribute, which could lead to technical problems. The migration participant
<code>org.eclipse.sirius.diagram.ui.business.internal.migration.SetChangeIdMigrationParticipant</code> sets a random changeId if it didn&#8217;t already exist. The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is
Expand All @@ -1099,7 +1108,7 @@ <h4 id="Migrations4">Migrations</h4>
</ul>
<h2 id="sirius6.5.1">Changes in Sirius 6.5.1</h2>
<h3 id="DeveloperVisibleChanges12">Developer-Visible Changes</h3>
<h4 id="Migrations5">Migrations</h4>
<h4 id="Migrations6">Migrations</h4>
<ul>
<li><span class="label label-info">Modified</span> The migration participant
<code>org.eclipse.sirius.diagram.ui.business.internal.migration.NoteShapeDefaultLabelAlignmentMigrationParticipant</code> has been updated to repair Notes with a potential wrong vertical label alignment. This problem can occur since Sirius 6.3.2 used in a collaborative environment, Obeo Designer Team Edition or Team For Capella for example. The corresponding version, stored in the attribute version of viewpoint:DAnalysis of the aird file, is
Expand Down Expand Up @@ -1201,7 +1210,7 @@ <h4 id="Changesinorg.eclipse.sirius5">Changes in
<code>new DRepresentationQuery(DRpresentation).isAutoRefresh()</code> instead.
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui7">Changes in
<h4 id="Changesinorg.eclipse.sirius.diagram.ui8">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
Expand Down Expand Up @@ -1239,7 +1248,7 @@ <h4 id="Changesinorg.eclipse.sirius.ext.gmf.runtime">Changes in
<code>org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper.getAbsoluteBoundsWithoutLabelsIn100Percent(GraphicalEditPart)</code> has been added to get the rectangle bounds without taking labels into account. This is used, in particular, to compute the bendpoints of an edge when the source or the target of the edge is an edge.
</li>
</ul>
<h4 id="Migrations6">Migrations</h4>
<h4 id="Migrations7">Migrations</h4>
<ul>
<li><span class="label label-success">Added</span> A migration participant has been added to repair rectilinear edges containing only one bendpoint. Bracket edges are not relevant. The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is
<em>14.5.0.202104070943</em>.
Expand Down
6 changes: 6 additions & 0 deletions plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ h3. Specifier-Visible Changes

h3. Developer-Visible Changes

h4. Changes in @org.eclipse.sirius.diagram.ui@

* <span class="label label-info">Modified</span> The method @org.eclipse.sirius.diagram.ui.tools.api.color.ColorManager.collectVsmColors(Session)@ has replaced @Map<String, RGB> collectVsmAndDefaultColors(Session session)@.

h4. Migrations

* <span class="label label-success">Added</span> The migration participant WorkspaceImageGMFBoundsMigrationParticipant has been updated to handle the missed case of the image style of nodes contained in a container (and not directly in diagram). As reminder, this migration participant has been introduced in Sirius 7.0.0. The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is _15.4.1.202403191723_.


h2(#sirius7.4.0). Changes in Sirius Desktop 7.4.0

Expand Down

0 comments on commit ceb41b8

Please sign in to comment.