diff options
| author | Laurent Redor | 2021-06-10 09:00:55 +0000 |
|---|---|---|
| committer | Laurent Redor | 2021-06-11 10:17:43 +0000 |
| commit | 5121d26952bcfc3417c0b97575445fd69ba52aec (patch) | |
| tree | 688968186d78592a23fdcd484ef11c6dd1618619 | |
| parent | 7cd119a004745c9fa0109c6ae074246591816564 (diff) | |
| download | org.eclipse.sirius-5121d26952bcfc3417c0b97575445fd69ba52aec.tar.gz org.eclipse.sirius-5121d26952bcfc3417c0b97575445fd69ba52aec.tar.xz org.eclipse.sirius-5121d26952bcfc3417c0b97575445fd69ba52aec.zip | |
When a Note is created in a Sirius diagram in a collaborative context
(Obeo Designer Team Edition or Team for Capella), the text is centered
vertically (instead of being aligned at the top).
Indeed, the implementation of ESTRING_TO_STRING_MAP_ENTRY is not
obligatorily a org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl.
So this commit adapts the code of
org.eclipse.sirius.diagram.ui.internal.view.factories.SiriusNoteViewFactory.createDefaultVerticalAlignmentEAnnotation()
to handle this case.
This commit also adds a migration participant to fix the notes created
before this version.
Tests:
* org.eclipse.sirius.tests.unit.diagram.migration.NoteShapeDefaultLabelAlignmentMigrationTest
always checks the migration of initial problem (bugzilla 515044).
* org.eclipse.sirius.tests.unit.diagram.migration.NoteShapeDefaultLabelAlignmentMigrationTest2
checks the migration of the new problem corresponding to this bugzilla.
* org.eclipse.sirius.tests.swtbot.NoteCreationTest has been updated to
also check that the GMF styles concerning note text alignment.
Bug: 574133
Change-Id: I2acff0a2f69d9623e1576d46759b521b01c0bec9
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
11 files changed, 188 insertions, 48 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java index f4f11f0e80..33093684cd 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 THALES GLOBAL SERVICES. + * Copyright (c) 2017, 2021 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 @@ -37,21 +37,24 @@ import com.google.common.collect.Iterables; /** * Default label alignment of Note's shapes have been updated in GMF runtime 1.8.0 (see * https://bugs.eclipse.org/bugs/show_bug.cgi?id=432387). This migration participant restores the old default alignment - * value. + * value.<BR> + * + * @since 6.5.1 In a collaborative environment, there is a regression in Sirius 6.3.2. So this migration has been + * modified to also cover the new case. The migration version has been updated. * * @see org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusDescriptionCompartmentEditPart * @see org.eclipse.sirius.diagram.ui.internal.providers.SiriusNoteViewProvider * @see org.eclipse.sirius.diagram.ui.internal.view.factories.SiriusNoteViewFactory * * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a> - * + * @author Laurent Redor */ public class NoteShapeDefaultLabelAlignmentMigrationParticipant extends AbstractRepresentationsFileMigrationParticipant { /** * The Sirius version for which this migration is added. */ - private static final Version MIGRATION_VERSION = new Version("12.0.0.201704070000"); //$NON-NLS-1$ + private static final Version MIGRATION_VERSION = new Version("14.5.1.202106111100"); //$NON-NLS-1$ @Override public Version getMigrationVersion() { @@ -71,8 +74,11 @@ public class NoteShapeDefaultLabelAlignmentMigrationParticipant extends Abstract textStyle.setTextAlignment(TextAlignment.CENTER_LITERAL); } } + // Check that this specific style has the vertical alignment defined (potential regression since + // Sirius 6.3.2). + } else if (!SiriusNoteViewFactory.hasDefaultVerticalAlignment(specificStyles)) { + SiriusNoteViewFactory.addDefaultVerticalAlignment(specificStyles); } - } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java index 253cb62564..93687a6df1 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 THALES GLOBAL SERVICES. + * Copyright (c) 2017, 2021 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 @@ -15,6 +15,7 @@ package org.eclipse.sirius.diagram.ui.internal.view.factories; import java.util.Collection; import java.util.List; +import java.util.Map; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.draw2d.PositionConstants; @@ -22,7 +23,6 @@ import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl; import org.eclipse.gmf.runtime.diagram.ui.view.factories.NoteViewFactory; import org.eclipse.gmf.runtime.notation.Style; import org.eclipse.gmf.runtime.notation.TextAlignment; @@ -53,13 +53,23 @@ public class SiriusNoteViewFactory extends NoteViewFactory { public static EAnnotation createDefaultVerticalAlignmentEAnnotation() { EAnnotation specificStyles = EcoreFactory.eINSTANCE.createEAnnotation(); specificStyles.setSource(ViewQuery.SPECIFIC_STYLES); + addDefaultVerticalAlignment(specificStyles); + return specificStyles; + } + + public static boolean hasDefaultVerticalAlignment(EAnnotation specificStyles) { + return !specificStyles.getDetails().isEmpty() && specificStyles.getDetails().stream().anyMatch(entry -> entry.getKey().equals(ViewQuery.VERTICAL_ALIGNMENT)); + } + + public static void addDefaultVerticalAlignment(EAnnotation specificStyles) { EObject defaultVerticalAlignment = EcoreFactory.eINSTANCE.create(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY); - if (defaultVerticalAlignment instanceof EStringToStringMapEntryImpl) { - ((EStringToStringMapEntryImpl) defaultVerticalAlignment).setKey(ViewQuery.VERTICAL_ALIGNMENT); - ((EStringToStringMapEntryImpl) defaultVerticalAlignment).setValue(String.valueOf(PositionConstants.TOP)); - specificStyles.getDetails().add((EStringToStringMapEntryImpl) defaultVerticalAlignment); + if (defaultVerticalAlignment instanceof Map.Entry<?, ?> + && defaultVerticalAlignment.eClass().getEAttributes().stream().allMatch(att -> String.class.getName().equals(att.getEAttributeType().getInstanceTypeName())) + && EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY.equals(defaultVerticalAlignment.eClass())) { + defaultVerticalAlignment.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__KEY, ViewQuery.VERTICAL_ALIGNMENT); + defaultVerticalAlignment.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__VALUE, String.valueOf(PositionConstants.TOP)); + specificStyles.getDetails().add((Map.Entry<String, String>) defaultVerticalAlignment); } - return specificStyles; } /** diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index dfcb6694ad..857820e281 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -14,6 +14,11 @@ <ol style="list-style: disc;"> <li> <a href="#sirius6.5.1">Changes in Sirius 6.5.1</a> + <ol style="list-style: disc;"> + <li> + <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a> + </li> + </ol> </li> <li> <a href="#sirius6.5.0">Changes in Sirius 6.5.0</a> @@ -25,7 +30,7 @@ <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> </li> </ol> </li> @@ -42,7 +47,7 @@ <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> </li> </ol> </li> @@ -53,7 +58,7 @@ <a href="#UserVisibleChanges3">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> </li> </ol> </li> @@ -64,7 +69,7 @@ <a href="#UserVisibleChanges4">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> </li> </ol> </li> @@ -78,7 +83,7 @@ <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> </li> </ol> </li> @@ -89,7 +94,7 @@ <a href="#sirius6.2.1">Changes in Sirius 6.2.1</a> <ol style="list-style: disc;"> <li> - <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> </li> </ol> </li> @@ -103,7 +108,7 @@ <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a> </li> </ol> </li> @@ -114,7 +119,7 @@ <a href="#UserVisibleChanges7">User-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges9">Developer-Visible Changes</a> </li> </ol> </li> @@ -136,7 +141,7 @@ <a href="#SpecifierVisibleChanges5">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges9">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges10">Developer-Visible Changes</a> </li> </ol> </li> @@ -150,7 +155,7 @@ <a href="#SpecifierVisibleChanges6">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges10">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges11">Developer-Visible Changes</a> </li> </ol> </li> @@ -161,6 +166,14 @@ <a href="Release_Notes_Previous.html">the release notes from previous versions</a> for details about older releases. </p> <h2 id="sirius6.5.1">Changes in Sirius 6.5.1</h2> + <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <h4 id="Migrations">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 + <em>14.5.1.202106111100</em>. + </li> + </ul> <h2 id="sirius6.5.0">Changes in Sirius 6.5.0</h2> <h3 id="UserVisibleChanges">User-Visible Changes</h3> <ul> @@ -198,7 +211,7 @@ </ul> </li> </ul> - <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> It is now possible to keep semantic element traceability during the representation export. For now, this option is only supported for diagram SVG export. In this case, a new attribute <code>diagram:targetSemanticId</code> is added on SVG elements to reference the target semantic id on which the graphical element is based on. This option can be activated programmatically or by setting a preference. See the details below: @@ -294,7 +307,7 @@ <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="Migrations">Migrations</h4> + <h4 id="Migrations2">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>. @@ -345,7 +358,7 @@ <p>Several improvements have been done concerning ELK integration. This feature is always considered as experimental (because several bugs remain). Additional documentation is available <a href="specifier/diagrams/Diagrams.html#useElk">here</a> . </p> - <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.ui.tools.api.dialogs.AnalysisSelectorFilteredItemsSelectionDialog</code> has been created in order to have custom analysis selector provider able to modify the analysis selector dialog. @@ -467,7 +480,7 @@ </ul> <img border="0" src="images/combined_fragment_label_before.png"/> With Sirius 6.3.2, the label is now on the top of execution: <img border="0" src="images/combined_fragment_label_after.png"/> - <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius.common2">Changes in <code>org.eclipse.sirius.common</code> </h4> @@ -524,7 +537,7 @@ <ul> <li><span class="label label-danger">Removed</span> The feature concerning the capability to move labels on border of node, or border node, all around the node, added in 6.3.0, has been reverted. There are unexpected side effects (wrong location after a rename of a label for example).</li> </ul> - <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> <ul> <li><span class="label label-info">Modified</span> Upgraded ELK version from 0.5.0 to 0.6.1, see the <a href="https://projects.eclipse.org/projects/modeling.elk/releases/0.6.1">ELK documentation</a> for the list of changes in that version (and previous). @@ -572,7 +585,7 @@ </ul> </li> </ul> - <h4 id="Migrations2">Migrations</h4> + <h4 id="Migrations3">Migrations</h4> <ul> <li><span class="label label-success">Added</span> A migration participant has been added only to change the version of the model. Indeed, if the new value “Tunnel” of GMF jump link type is used, see “User-Visible Changes” in <a href="Release_Notes.html#sirius6.3.1">Sirius 6.1.3</a>, the model will be invalid for an older version of Sirius. The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is @@ -605,7 +618,7 @@ <code>Type</code>. </li> </ul> - <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> <ul> <li><span class="label label-info">Modified</span> Upgraded ELK version from 0.4.1 to 0.5.0, see the <a href="https://projects.eclipse.org/projects/modeling.elk/releases/0.5.0" target="_blank">ELK documentation</a> for the list of changes in that version.</li> <li><span class="label label-info">Modified</span> Upgraded EEF version from 2.1.2 to 2.1.3 (which contains a single bugfix, for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=550436" target="_blank">#550436</a>).</li> @@ -721,7 +734,7 @@ <code>org.eclipse.sirius.diagram.elk.IELKLayoutExtension</code> interface for more details. </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 move the name and documentation from the representations to their descriptors (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=548631">bugzilla #548631</a> for more details). The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is @@ -743,7 +756,7 @@ <h2 id="sirius6.2.2">Changes in Sirius 6.2.2</h2> <p>There are no user-visible changes in Sirius 6.2.2 compared to 6.2.1. The only changes are internal and related either to the build process or to the automated tests.</p> <h2 id="sirius6.2.1">Changes in Sirius 6.2.1</h2> - <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges7">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius4">Changes in <code>org.eclipse.sirius</code> </h4> @@ -818,7 +831,7 @@ <a href="specifier/diagrams/Diagrams.html#group">corresponding documentation</a> . </li> </ul> - <h3 id="DeveloperVisibleChanges7">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges8">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius.common4">Changes in <code>org.eclipse.sirius.common</code> </h4> @@ -1195,7 +1208,7 @@ <em>Delete</em>. It was previously the case only for representations which semantic target does not exist anymore. </li> </ul> - <h3 id="DeveloperVisibleChanges8">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges9">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> If the <code>org.eclipse.sirius.diagam.ui.hidePrintingOfPermissionAuthorityDecoration</code> system property is set to true and if there is no other printable decoration provided at the same location (South-West), the permission authority decorations displayed on diagrams are not printed nor exported in images (export as image actions). @@ -1346,7 +1359,7 @@ <a href="specifier/tables/Tables.html#edition_tables">the documentation</a> for details. </li> </ul> - <h3 id="DeveloperVisibleChanges9">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges10">Developer-Visible Changes</h3> <p><span class="label label-info">IMPORTANT</span> Note that all plug-ins in the <em>Sirius Server</em> feature ( <code>org.eclipse.sirius.server.*</code> and @@ -1588,7 +1601,7 @@ <code>oes.common</code> plugin. </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 convert the serialized xmi:id to the technical id (uid attribut) for Sirius model elements of the .aird files (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=525261">bugzilla #525261</a> for more details). The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is @@ -1663,7 +1676,7 @@ <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=531487">bugzilla 531487</a> for more details. </li> </ul> - <h3 id="DeveloperVisibleChanges10">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges11">Developer-Visible Changes</h3> <ul> <li><span class="label label-info">Modified</span> The SWTBot test framework version has been upgraded toward SWTBot 2.6. The main impacts are described below: <ul> @@ -1860,7 +1873,7 @@ <code>org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.dragAndDrop(AbstractSWTBot<? extends Widget>)</code> method instead. </li> </ul> - <h4 id="Migrations5">Migrations</h4> + <h4 id="Migrations6">Migrations</h4> <ul> <li><span class="label label-success">Added</span> A migration participant has been added to fix diagram with note attachment corrupted (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=533177">bugzilla #533177</a> for more details). The corresponding version, stored in attribute version of viewpoint:DAnalysis of the aird file, is diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index 5f3481a4d1..8828d1ae6c 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -6,6 +6,12 @@ This document contains the release notes for recent major releases of Sirius. Se h2(#sirius6.5.1). Changes in Sirius 6.5.1 +h3. Developer-Visible Changes + +h4. Migrations + +* <span class="label label-info">Modified</span> The migration participant @org.eclipse.sirius.diagram.ui.business.internal.migration.NoteShapeDefaultLabelAlignmentMigrationParticipant@ 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 _14.5.1.202106111100_. + h2(#sirius6.5.0). Changes in Sirius 6.5.0 h3. User-Visible Changes diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.aird new file mode 100644 index 0000000000..5feb246274 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.aird @@ -0,0 +1,40 @@ +<?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.3/notation" 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"> + <viewpoint:DAnalysis uid="_k7WwEebREeaOa_5yitWewA" selectedViews="_jkvtAObSEeaOa_5yitWewA" version="14.5.0.202104161500"> + <semanticResources>noteAttachmentAlignment.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DView" uid="_jkvtAObSEeaOa_5yitWewA"> + <viewpoint xmi:type="description:Viewpoint" href="noteAttachmentAlignment.odesign#//@ownedViewpoints[name='MyViewpoint']"/> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" uid="_1md08BVUEeeX-9J1yKditQ" name="new ClassDiag" repPath="#_1mecABVUEeeX-9J1yKditQ" changeId="75e78830-111e-46dd-8319-059c93cb2e3c"> + <description xmi:type="description_1:DiagramDescription" href="noteAttachmentAlignment.odesign#//@ownedViewpoints[name='MyViewpoint']/@ownedRepresentations[name='ClassDiag']"/> + <target xmi:type="ecore:EPackage" href="noteAttachmentAlignment.ecore#/"/> + </ownedRepresentationDescriptors> + </ownedViews> + </viewpoint:DAnalysis> + <diagram:DSemanticDiagram uid="_1mecABVUEeeX-9J1yKditQ"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" uid="_1mecARVUEeeX-9J1yKditQ" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" uid="_1mecAhVUEeeX-9J1yKditQ"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" uid="_1mmX0BVUEeeX-9J1yKditQ" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_1mmX0RVUEeeX-9J1yKditQ" type="Sirius" element="_1mecABVUEeeX-9J1yKditQ" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_2SWDgBVUEeeX-9J1yKditQ" type="Note" fontName="Segoe UI" description="Text2" fillColor="13369343" transparency="0" lineColor="6737151" lineWidth="1"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_dnXWYMqEEeuH8KT3tnBg5g" source="specificStyles"/> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_2SXRoBVUEeeX-9J1yKditQ" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_2SXRoRVUEeeX-9J1yKditQ" type="Description"> + <element xsi:nil="true"/> + </children> + <styles xmi:type="notation:TextStyle" xmi:id="_2SWDgRVUEeeX-9J1yKditQ" textAlignment="Center"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="_2SWDghVUEeeX-9J1yKditQ"/> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_2SWDgxVUEeeX-9J1yKditQ" x="160" y="80" width="261" height="196"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_1mmX0hVUEeeX-9J1yKditQ"/> + </data> + </ownedAnnotationEntries> + <description xmi:type="description_1:DiagramDescription" href="noteAttachmentAlignment.odesign#//@ownedViewpoints[name='MyViewpoint']/@ownedRepresentations[name='ClassDiag']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" uid="_1mecAxVUEeeX-9J1yKditQ"/> + <activatedLayers xmi:type="description_1:Layer" href="noteAttachmentAlignment.odesign#//@ownedViewpoints[name='MyViewpoint']/@ownedRepresentations[name='ClassDiag']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="noteAttachmentAlignment.ecore#/"/> + </diagram:DSemanticDiagram> +</xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.ecore new file mode 100644 index 0000000000..73475d5100 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.ecore @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + name="Root"/> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.odesign new file mode 100644 index 0000000000..162b6853ef --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment2/noteAttachmentAlignment.odesign @@ -0,0 +1,9 @@ +<?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" name="My" version="11.1.1.201610211630"> + <ownedViewpoints name="MyViewpoint" modelFileExtension="*.ecore"> + <ownedRepresentations xsi:type="description_1:DiagramDescription" name="ClassDiag" domainClass="ecore.EPackage" enablePopupBars="true"> + <metamodel href="http://www.eclipse.org/emf/2002/Ecore#/"/> + <defaultLayer name="Default"/> + </ownedRepresentations> + </ownedViewpoints> +</description:Group> 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 b516c9fe5d..8a1ad02957 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 @@ -142,6 +142,7 @@ import org.eclipse.sirius.tests.unit.diagram.migration.MigrationOfHideLabelFilte import org.eclipse.sirius.tests.unit.diagram.migration.MigrationRoutingStyleEndUserOverrideTest; import org.eclipse.sirius.tests.unit.diagram.migration.NoteAttachmentMigrationTest; import org.eclipse.sirius.tests.unit.diagram.migration.NoteShapeDefaultLabelAlignmentMigrationTest; +import org.eclipse.sirius.tests.unit.diagram.migration.NoteShapeDefaultLabelAlignmentMigrationTest2; 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; @@ -239,6 +240,7 @@ public class AllCommonPluginTests extends TestCase { suite.addTestSuite(ChangeIdAPIForMigrationTest.class); suite.addTestSuite(RgbValuesEDataTypeMigrationTest.class); suite.addTestSuite(NoteShapeDefaultLabelAlignmentMigrationTest.class); + suite.addTestSuite(NoteShapeDefaultLabelAlignmentMigrationTest2.class); suite.addTestSuite(SnapBackDistantLabelsMigrationTest.class); suite.addTestSuite(ConvertViewpointModelingProjectToSiriusModelingProjectTest.class); suite.addTestSuite(FontFormatMigrationTest.class); diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java index 2570ee477c..bdc5d40dd2 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 THALES GLOBAL SERVICES. + * Copyright (c) 2017, 2021 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 @@ -46,14 +46,16 @@ import com.google.common.collect.UnmodifiableIterator; */ public class NoteShapeDefaultLabelAlignmentMigrationTest extends SiriusTestCase { - private static final String PATH = "data/unit/migration/do_not_migrate/noteAttachmentAlignment/"; - private static final String SESSION_RESOURCE_NAME = "noteAttachmentAlignment.aird"; private static final String SEMANTIC_RESOURCE_NAME = "noteAttachmentAlignment.ecore"; private static final String VSM_RESOURCE_NAME = "noteAttachmentAlignment.odesign"; + protected String dataPath = "data/unit/migration/do_not_migrate/noteAttachmentAlignment/"; + + protected String errorMessage = "One note should be found in this session to check the migration of a Note with the problem of bugzilla 515044."; + private Resource sessionResource; @Override @@ -65,7 +67,7 @@ public class NoteShapeDefaultLabelAlignmentMigrationTest extends SiriusTestCase protected void setUp() throws Exception { super.setUp(); genericSetUp(); - copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, PATH, SESSION_RESOURCE_NAME, SEMANTIC_RESOURCE_NAME, VSM_RESOURCE_NAME); + copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, dataPath, 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); @@ -90,7 +92,9 @@ public class NoteShapeDefaultLabelAlignmentMigrationTest extends SiriusTestCase public void testNoteShapeAlignmentAfterMigration() { TreeIterator<EObject> allContents = sessionResource.getAllContents(); UnmodifiableIterator<EObject> shapes = Iterators.filter(allContents, input -> input instanceof Shape && ViewType.NOTE.equals(((Shape) input).getType())); - if (shapes.hasNext()) { + int nbTestedShapes = 0; + while (shapes.hasNext()) { + nbTestedShapes++; Shape note = (Shape) shapes.next(); Iterable<TextStyle> textStyles = Iterables.filter(note.getStyles(), TextStyle.class); assertEquals("The text style must be defined on the view for the note", 1, Iterables.size(textStyles)); @@ -102,9 +106,7 @@ public class NoteShapeDefaultLabelAlignmentMigrationTest extends SiriusTestCase Entry<String, String> entry = details.iterator().next(); assertSame("The eAnnotation detail for the vertical alignment is missing", ViewQuery.VERTICAL_ALIGNMENT, entry.getKey()); assertEquals("The vertical alignment of the note should be set to TOP", String.valueOf(PositionConstants.TOP), entry.getValue()); - assertFalse("Only one Note should be found in this session", shapes.hasNext()); - } else { - assertTrue("A Note should be found in this session", false); } + assertEquals(errorMessage, 1, nbTestedShapes); } } diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest2.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest2.java new file mode 100644 index 0000000000..64ba421f57 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest2.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2017, 2021 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.unit.diagram.migration; + +import org.eclipse.sirius.diagram.ui.business.internal.migration.NoteShapeDefaultLabelAlignmentMigrationParticipant; + +/** + * Test for {@link NoteShapeDefaultLabelAlignmentMigrationParticipant} updated in Sirius 6.5.1. Same test than + * {@link NoteShapeDefaultLabelAlignmentMigrationTest} but with the new use case data corresponding to bugzilla 574133. + * The use case can not exist in pure Sirius environment. It has been created in collaborative environment. + * + * @author Laurent Redor + */ +public class NoteShapeDefaultLabelAlignmentMigrationTest2 extends NoteShapeDefaultLabelAlignmentMigrationTest { + + public NoteShapeDefaultLabelAlignmentMigrationTest2() { + dataPath = "data/unit/migration/do_not_migrate/noteAttachmentAlignment2/"; + errorMessage = "One note should be found in this session to check the migration of a Note with the problem of bugzilla 574133."; + } + +} diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteCreationTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteCreationTest.java index 1ff61340f8..72050472b9 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteCreationTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteCreationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2020 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2021 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 @@ -18,10 +18,12 @@ import java.util.List; import org.eclipse.draw2d.Border; import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.text.FlowPage; +import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.emf.edit.provider.IItemLabelProvider; @@ -31,10 +33,14 @@ import org.eclipse.gef.EditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart; import org.eclipse.gmf.runtime.diagram.ui.figures.NoteFigure; import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.notation.Shape; +import org.eclipse.gmf.runtime.notation.TextAlignment; +import org.eclipse.gmf.runtime.notation.TextStyle; import org.eclipse.sirius.business.api.dialect.DialectManager; import org.eclipse.sirius.business.api.dialect.command.DeleteRepresentationCommand; import org.eclipse.sirius.business.api.dialect.command.RenameRepresentationCommand; import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeContainerEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeList2EditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusDescriptionCompartmentEditPart; @@ -63,6 +69,8 @@ import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; import org.eclipse.ui.PartInitException; +import com.google.common.collect.Iterables; + /** * Test class for double click tool and navigation operation. * @@ -596,9 +604,19 @@ public class NoteCreationTest extends AbstractSiriusSwtBotGefTestCase { assertTrue(editor.selectedEditParts().size() == 1); - if (link != null) { + SWTBotGefEditPart note = editor.selectedEditParts().get(0); + // Check alignment stored in GMF model + Shape gefNoteShape = (Shape) note.part().getModel(); + Iterable<TextStyle> textStyles = Iterables.filter(gefNoteShape.getStyles(), TextStyle.class); + assertEquals("The text style must be defined on the view for the gefNoteShape", 1, Iterables.size(textStyles)); + assertSame("The text style must be center aligned for the note", TextAlignment.CENTER_LITERAL, textStyles.iterator().next().getTextAlignment()); + EAnnotation specificStyles = gefNoteShape.getEAnnotation(ViewQuery.SPECIFIC_STYLES); + assertNotNull("The note should have an eAnnotation for the vertical alignment", specificStyles); + specificStyles.getDetails().stream().anyMatch(entry -> entry.getKey().equals(ViewQuery.VERTICAL_ALIGNMENT)); + assertTrue("The eAnnotation detail for the vertical alignment is missing", + specificStyles.getDetails().stream().anyMatch(entry -> ViewQuery.VERTICAL_ALIGNMENT.equals(entry.getKey()) && String.valueOf(PositionConstants.TOP).equals(entry.getValue()))); - SWTBotGefEditPart note = editor.selectedEditParts().get(0); + if (link != null) { validateDiagramNameCompartment(note, link.getName(), getIcon(link)); |
