diff options
| author | Axel Richard | 2017-03-30 14:36:49 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-04-18 13:44:17 +0000 |
| commit | 7ed80d9bade81f66caf6a22141ad04961ab60780 (patch) | |
| tree | addefcfd83ad2f63b6c7d302cdc3670ceb759a5d | |
| parent | 0f1a2f4511ca1988dd33ce18e1f24323b5097f1e (diff) | |
| download | org.eclipse.sirius-7ed80d9bade81f66caf6a22141ad04961ab60780.tar.gz org.eclipse.sirius-7ed80d9bade81f66caf6a22141ad04961ab60780.tar.xz org.eclipse.sirius-7ed80d9bade81f66caf6a22141ad04961ab60780.zip | |
[515378] Restore old Notes' labels alignment
With versions of Sirius using Juno, the label of new Note (from the
Palette toolbar) was top & center aligned, which is not the case anymore
(middle and left aligned). This fix restores the old behavior for new
notes and old notes (via migration participant).
Bug: 515378
Cherry-picked-from: 515044
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
Change-Id: I0ee98aa4961bb748ca085cd10b1fb3d17cd5a638
13 files changed, 632 insertions, 40 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml index 7b127c1552..6f5b84c83a 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <!-- - Copyright (c) 2014 THALES GLOBAL SERVICES + Copyright (c) 2014, 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 @@ -815,6 +815,13 @@ </viewProvider> </extension> + <extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders"> + <viewProvider class="org.eclipse.sirius.diagram.ui.internal.providers.SiriusNoteViewProvider"> + <Priority name="Low"/> + <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="Note"/> + </viewProvider> + </extension> + <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders"> <?gmfgen generated="true"?> <editpartProvider class="org.eclipse.sirius.diagram.ui.internal.providers.SiriusEditPartProvider"> @@ -1823,6 +1830,10 @@ class="org.eclipse.sirius.diagram.ui.business.internal.migration.BorderSizeRepresentationFileMigrationParticipant" kind="RepresentationsFile"> </participant> + <participant + class="org.eclipse.sirius.diagram.ui.business.internal.migration.NoteShapeDefaultLabelAlignmentMigrationParticipant" + 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/api/query/ViewQuery.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java index f94778a3aa..fbb38e1589 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES and others. + * Copyright (c) 2012, 2017 THALES GLOBAL SERVICES and others. * 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 @@ -54,6 +54,18 @@ import org.eclipse.swt.graphics.RGB; public class ViewQuery { /** + * custom data key for note shapes specific styles. This key should be used combined {@link #VERTICAL_ALIGNMENT} + * key. + */ + public static final String SPECIFIC_STYLES = "specificStyles"; //$NON-NLS-1$ + + /** + * custom data key for note shapes vertical alignment. This key should be used combined {@link #SPECIFIC_STYLES} + * key. + */ + public static final String VERTICAL_ALIGNMENT = "verticalAlignment"; //$NON-NLS-1$ + + /** * The set of GMF style attributes customizable for which not corresponding * Sirius style property exists. */ 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 new file mode 100644 index 0000000000..eb8c001f83 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * 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.Collection; +import java.util.HashSet; + +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.gmf.runtime.diagram.core.util.ViewType; +import org.eclipse.gmf.runtime.notation.Diagram; +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.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.DDiagramGraphicalQuery; +import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; +import org.eclipse.sirius.diagram.ui.internal.view.factories.SiriusNoteViewFactory; +import org.eclipse.sirius.ext.base.Option; +import org.eclipse.sirius.viewpoint.DAnalysis; +import org.eclipse.sirius.viewpoint.DView; +import org.osgi.framework.Version; + +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. + * + * @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> + * + */ +public class NoteShapeDefaultLabelAlignmentMigrationParticipant extends AbstractRepresentationsFileMigrationParticipant { + + /** + * The Sirius version for which this migration is added. + */ + private static final Version MIGRATION_VERSION = new Version("11.1.5.201704181500"); //$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 (Shape noteShape : getNoteShapes(dAnalysis)) { + EAnnotation specificStyles = noteShape.getEAnnotation(ViewQuery.SPECIFIC_STYLES); + if (specificStyles == null) { + specificStyles = SiriusNoteViewFactory.createDefaultVerticalAlignmentEAnnotation(); + noteShape.getEAnnotations().add(specificStyles); + for (TextStyle textStyle : Iterables.filter(noteShape.getStyles(), TextStyle.class)) { + if (TextAlignment.LEFT_LITERAL == textStyle.getTextAlignment()) { + textStyle.setTextAlignment(TextAlignment.CENTER_LITERAL); + } + } + } + + } + } + } + + /** + * Get the {@link DDiagram}s contained in the given resource to migrate. + * + * @param dAnalysis + * The analysis of the resource to migrate. + * @return the {@link DDiagram}s contained in the given resource to migrate. + */ + private Collection<DDiagram> getDiagrams(DAnalysis dAnalysis) { + Collection<DDiagram> diagrams = new HashSet<>(); + for (DView view : dAnalysis.getOwnedViews()) { + Iterables.addAll(diagrams, Iterables.filter(new DViewQuery(view).getLoadedRepresentations(), DDiagram.class)); + } + return diagrams; + } + + /** + * Get the {@link Shape}s with Note types contained in the given resource to + * migrate. + * + * @param dAnalysis + * The analysis of the resource to migrate. + * @return the {@link Shape}s with Note types contained in the given + * resource to migrate. + */ + private Collection<Shape> getNoteShapes(DAnalysis dAnalysis) { + Collection<Shape> shapes = new HashSet<>(); + for (DDiagram dDiagram : getDiagrams(dAnalysis)) { + shapes.addAll(getNoteShapes(dDiagram)); + } + return shapes; + } + + /** + * Get the {@link Shape}s with Note types contained in the given + * {@link DDiagram}. + * + * @param dDiagram + * the given {@link DDiagram}. + * @return the {@link Shape}s with Note types contained in the given + * {@link DDiagram}. + */ + private Collection<Shape> getNoteShapes(DDiagram dDiagram) { + Collection<Shape> shapes = new HashSet<>(); + DDiagramGraphicalQuery query = new DDiagramGraphicalQuery(dDiagram); + Option<Diagram> gmfDiagram = query.getAssociatedGMFDiagram(); + if (gmfDiagram.some()) { + for (Shape shape : Iterables.filter(gmfDiagram.get().getChildren(), Shape.class)) { + if (ViewType.NOTE.equals(shape.getType())) { + shapes.add(shape); + } + } + } + return shapes; + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java index b794ef4b2b..b7d26a5082 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 THALES GLOBAL SERVICES. + * Copyright (c) 2016, 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 @@ -10,15 +10,25 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.internal.edit.parts; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.gef.DragTracker; import org.eclipse.gef.Request; import org.eclipse.gmf.runtime.diagram.ui.editparts.DescriptionCompartmentEditPart; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.TextAlignment; +import org.eclipse.gmf.runtime.notation.TextStyle; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; /** - * A specific DescriptionCompartmentEditPart to continue the selection with its - * parents. This allows to handle the direct edit (slow double click) directly - * on Note and Text.. + * A specific DescriptionCompartmentEditPart to: + * <UL> + * continue the selection with its parents. This allows to handle the + * <LI>direct edit (slow double click) directly on Note and Text,</LI> + * <LI>and to have specific behavior for Sirius Note and Text: capability to change vertical alignment of text through a + * specific EAnnotation.</LI> + * </UL> * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> */ @@ -39,4 +49,56 @@ public class SiriusDescriptionCompartmentEditPart extends DescriptionCompartment public DragTracker getDragTracker(Request request) { return getParent().getDragTracker(request); } + + /* + * (non-Javadoc) Overridden to allow to consider the specific EAnnotation to change vertical alignment. + */ + @Override + protected void refreshTextAlignment() { + int verticalAlignment = PositionConstants.MIDDLE; + View view = getPrimaryView(); + EAnnotation specificStyles = view.getEAnnotation(ViewQuery.SPECIFIC_STYLES); + if (specificStyles != null) { + String stringVerticalAlignment = specificStyles.getDetails().get(ViewQuery.VERTICAL_ALIGNMENT); + if (stringVerticalAlignment != null) { + verticalAlignment = new Integer(stringVerticalAlignment).intValue(); + } + } + TextStyle style = (TextStyle) view.getStyle(NotationPackage.eINSTANCE.getTextStyle()); + if (style != null) { + if (style.getTextAlignment() == TextAlignment.RIGHT_LITERAL) { + if ((getLabelDelegate().getIcon(0) == null)) + if (verticalAlignment != PositionConstants.MIDDLE) { + getLabelDelegate().setAlignment(verticalAlignment | PositionConstants.RIGHT); + } else { + getLabelDelegate().setAlignment(PositionConstants.RIGHT); + } + else + getLabelDelegate().setTextJustification(PositionConstants.RIGHT); + } else if (style.getTextAlignment() == TextAlignment.CENTER_LITERAL) { + if ((getLabelDelegate().getIcon(0) == null)) + if (verticalAlignment == PositionConstants.TOP) { + getLabelDelegate().setAlignment(PositionConstants.TOP); + } else if (verticalAlignment == PositionConstants.BOTTOM) { + getLabelDelegate().setAlignment(PositionConstants.BOTTOM); + } else { + getLabelDelegate().setAlignment(PositionConstants.CENTER); + } + else { + getLabelDelegate().setTextJustification(PositionConstants.CENTER); + } + } else { + // default to TextAlignment.LEFT_LITERAL + if ((getLabelDelegate().getIcon(0) == null)) + if (verticalAlignment != PositionConstants.MIDDLE) { + getLabelDelegate().setAlignment(verticalAlignment | PositionConstants.LEFT); + } else { + getLabelDelegate().setAlignment(PositionConstants.LEFT); + } + else + getLabelDelegate().setTextJustification(PositionConstants.LEFT); + } + } + } + } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusNoteViewProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusNoteViewProvider.java new file mode 100644 index 0000000000..d5135e5866 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusNoteViewProvider.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.internal.providers; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.gmf.runtime.diagram.core.providers.AbstractViewProvider; +import org.eclipse.gmf.runtime.diagram.core.util.ViewType; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.sirius.diagram.ui.internal.view.factories.SiriusNoteViewFactory; + +/** + * Specific view provider for Notes created from the Palette. + * + * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a> + * + */ +public class SiriusNoteViewProvider extends AbstractViewProvider { + + @Override + protected Class<?> getNodeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) { + // Inspired from + // org.eclipse.gmf.runtime.diagram.ui.providers.internal.DiagramViewProvider.getNodeViewClass(IAdaptable, View, + // String) for original GMF NoteViewFactory. + if (ViewType.NOTE.equals(semanticHint)) { + return SiriusNoteViewFactory.class; + } + return null; + } +} 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 new file mode 100644 index 0000000000..83b2a084a4 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.internal.view.factories; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.draw2d.PositionConstants; +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; +import org.eclipse.gmf.runtime.notation.TextStyle; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; + +import com.google.common.collect.Iterables; + +/** + * Specific view factory for Notes created from the Palette. 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 factory creates notes with the + * old default alignment value. + * + * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a> + * + */ +public class SiriusNoteViewFactory extends NoteViewFactory { + + /** + * Create an {@link EAnnotation} that set the default vertical alignment (org.eclipse.draw2d.PositionConstants.TOP). + * + * @return an {@link EAnnotation} with the default vertical alignment set. + */ + public static EAnnotation createDefaultVerticalAlignmentEAnnotation() { + EAnnotation specificStyles = EcoreFactory.eINSTANCE.createEAnnotation(); + specificStyles.setSource(ViewQuery.SPECIFIC_STYLES); + 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); + } + return specificStyles; + } + + /** + * Set the {@link TextStyle} with the default horizontal alignment. + * + * @param styles + * the styles of the Note. + */ + public void setDefaultHorizontalAlignment(Collection<Style> styles) { + for (TextStyle textStyle : Iterables.filter(styles, TextStyle.class)) { + textStyle.setTextAlignment(TextAlignment.CENTER_LITERAL); + return; + } + } + + @Override + protected List<?> createStyles(View view) { + List<Style> styles = super.createStyles(view); + EAnnotation verticalAlignment = createDefaultVerticalAlignmentEAnnotation(); + view.getEAnnotations().add(verticalAlignment); + setDefaultHorizontalAlignment(styles); + return styles; + } +} diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index b4d8a0c1b2..92f131e227 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -13,7 +13,7 @@ <a href="#ReleaseNotesforSirius">Release Notes for Sirius</a> <ol style="list-style: disc;"> <li> - <a href="#sirius4.1.4">Changes in Sirius 4.1.4</a> + <a href="#sirius4.1.5">Changes in Sirius 4.1.5</a> <ol style="list-style: disc;"> <li> <a href="#UserVisibleChanges">User-Visible Changes</a> @@ -24,21 +24,32 @@ </ol> </li> <li> - <a href="#sirius4.1.3">Changes in Sirius 4.1.3</a> + <a href="#sirius4.1.4">Changes in Sirius 4.1.4</a> <ol style="list-style: disc;"> <li> + <a href="#UserVisibleChanges2">User-Visible Changes</a> + </li> + <li> <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a> </li> </ol> </li> <li> + <a href="#sirius4.1.3">Changes in Sirius 4.1.3</a> + <ol style="list-style: disc;"> + <li> + <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a> + </li> + </ol> + </li> + <li> <a href="#sirius4.1.2">Changes in Sirius 4.1.2</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges2">User-Visible Changes</a> + <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> @@ -46,10 +57,10 @@ <a href="#sirius4.1.1">Changes in Sirius 4.1.1</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges3">User-Visible Changes</a> + <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> @@ -57,13 +68,13 @@ <a href="#sirius4.1.0">Changes in Sirius 4.1.0</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges4">User-Visible Changes</a> + <a href="#UserVisibleChanges5">User-Visible Changes</a> </li> <li> <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> </li> </ol> </li> @@ -71,13 +82,13 @@ <a href="#sirius4.0.0">Changes in Sirius 4.0.0</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges5">User-Visible Changes</a> + <a href="#UserVisibleChanges6">User-Visible Changes</a> </li> <li> <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> </li> </ol> </li> @@ -85,13 +96,13 @@ <a href="#sirius3.1.0">Changes in Sirius 3.1.0</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges6">User-Visible Changes</a> + <a href="#UserVisibleChanges7">User-Visible Changes</a> </li> <li> <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a> </li> </ol> </li> @@ -99,13 +110,13 @@ <a href="#sirius3.0.0">Changes in Sirius 3.0.0</a> <ol style="list-style: disc;"> <li> - <a href="#UserVisibleChanges7">User-Visible Changes</a> + <a href="#UserVisibleChanges8">User-Visible Changes</a> </li> <li> <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a> </li> <li> - <a href="#DeveloperVisibleChanges8">Developer-Visible Changes</a> + <a href="#DeveloperVisibleChanges9">Developer-Visible Changes</a> </li> </ol> </li> @@ -115,14 +126,30 @@ <p>This document contains the release notes for recent major releases of Sirius. See also <a href="Release_Notes_Previous.html">the release notes from previous versions</a> for details about older releases. </p> - <h2 id="sirius4.1.4">Changes in Sirius 4.1.4</h2> + <h2 id="sirius4.1.5">Changes in Sirius 4.1.5</h2> <h3 id="UserVisibleChanges">User-Visible Changes</h3> <ul> + <li><span class="label label-info">Modified</span> The label alignment of Notes from the Palette has been modified from Juno to Luna or newer versions of Eclipse. The label alignment changed from TOP & CENTER to MIDDLE & LEFT. The initial alignment (TOP & CENTER) has been restored.</li> + </ul> + <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-success">Added</span> Constants + <code>org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.SPECIFIC_STYLES</code> & + <code>org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.VERTICAL_ALIGNMENT</code> have been added to retrieve the initial label alignment of Notes from the Palette (see + <a href="Release_Notes.html#UserVisibleChanges">user-visible changes</a> ). Currently the vertical alignment can not be changed (potential new feature later). + </li> + </ul> + <h2 id="sirius4.1.4">Changes in Sirius 4.1.4</h2> + <h3 id="UserVisibleChanges2">User-Visible Changes</h3> + <ul> <li><span class="label label-info">Modified</span>The “straighten to” actions previously had a limitation concerning overlap detection. This is no longer the case. The previous known limitation was removed from the documentation ( <i>In case of multi-selection, the overlap check is done in the current context of existing border nodes and not in the context of location of border nodes after each straighten edges.</i>). </li> </ul> - <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius.ui">Changes in <code>org.eclipse.sirius.ui</code> </h4> @@ -132,7 +159,7 @@ </li> </ul> <h2 id="sirius4.1.3">Changes in Sirius 4.1.3</h2> - <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> <h4 id="Changesinorg.eclipse.sirius.tests.junit.support">Changes in <code>org.eclipse.sirius.tests.junit.support</code> </h4> @@ -142,7 +169,7 @@ </li> </ul> <h2 id="sirius4.1.2">Changes in Sirius 4.1.2</h2> - <h3 id="UserVisibleChanges2">User-Visible Changes</h3> + <h3 id="UserVisibleChanges3">User-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> </li> </ul> @@ -151,7 +178,7 @@ <br/> <img border="0" src="./images/PreferencePageMaxTabName.png"/> </p> - <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping</code> class has been added to handle copy/paste format with mapping information when an element target of a format pasting has many source diagram format corresponding to its key. In this case, we use the mapping information to get the more precise data format. And if no result matched, then we return the first found by using the key. @@ -182,18 +209,18 @@ <code>org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping.addFormatData(FormatDataKey, RepresentationElementMapping, AbstractFormatData)</code> to better handle copy/paste format cases. </p> <h2 id="sirius4.1.1">Changes in Sirius 4.1.1</h2> - <h3 id="UserVisibleChanges3">User-Visible Changes</h3> + <h3 id="UserVisibleChanges4">User-Visible Changes</h3> <ul> <li><span class="label label-info">Modified</span>The “straighten to” actions were previously disabled when an edge is connected to border nodes that have several edges. It is now allowed.</li> </ul> - <h3 id="DeveloperVisibleChanges4">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.table.business.api.helper.TableHelper.getEStructuralFeature(DLine, DColumn)</code> method has been added to retrieve the EStructuralFeature associated to a table column. </li> </ul> <h2 id="sirius4.1.0">Changes in Sirius 4.1.0</h2> - <h3 id="UserVisibleChanges4">User-Visible Changes</h3> + <h3 id="UserVisibleChanges5">User-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> Copy/Paste Layout has been completed with Copy/Paste Style and Copy/Paste Format. <em>Paste Format</em> is equivalent to paste @@ -309,7 +336,7 @@ <code>org.eclipse.sirius.diagram.ui.formatDataManager</code>. The deprecated extension point will be removed in the next 5.0 Sirius major release. Several classes associated with this deprecated extension point are also deprecated (see Developer-Visible Changes for details). </li> </ul> - <h3 id="DeveloperVisibleChanges5">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> As the first step to save the DRepresentation in its own resource, <code>org.eclipse.sirius.viewpoint.DView.getOwnedRepresentationDescriptors()</code> has been added as a wrapper of the @@ -509,7 +536,7 @@ <code>allowsCopyPasteLayout(DSemanticDecorator)</code> will be removed in the new major version. </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> @@ -711,7 +738,7 @@ </li> </ul> <h2 id="sirius4.0.0">Changes in Sirius 4.0.0</h2> - <h3 id="UserVisibleChanges5">User-Visible Changes</h3> + <h3 id="UserVisibleChanges6">User-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> The user can now filter elements according to a Typed variable (String, Integer, EEnum or any EDataType). If a user applies a filter containing Typed Variables, a dialog is displayed to allow user entering the Typed Variable values. That values can be used as variables in the Condition Expression of the Variable Filter.</li> <li><span class="label label-success">Added</span> When the diagram is larger than the editor, you can move it in all directions pressing the middle-button and dragging the mouse (keeping the button pressed).</li> @@ -797,7 +824,7 @@ </li> <li><span class="label label-info">Modified</span> The variable under VariableFilter, previously named “Variable”, is renamed to “Select Model Element Variable”. It is functionally equivalent.</li> </ul> - <h3 id="DeveloperVisibleChanges6">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges7">Developer-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> It is now possible to provide a full customized tab-bar by implementing the <code>ITabbarContributor</code> through the @@ -995,7 +1022,7 @@ <code>org.eclipse.sirius.ui.business.api.editor.SpecificSessionManager</code> has been removed. </li> </ul> - <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> @@ -1193,7 +1220,7 @@ </li> </ul> <h2 id="sirius3.1.0">Changes in Sirius 3.1.0</h2> - <h3 id="UserVisibleChanges6">User-Visible Changes</h3> + <h3 id="UserVisibleChanges7">User-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> A new feature allows to snap to all shapes (instead of just to snap to sibling shapes). The <kdb>F4</kdb> shortcut key activates this mode when you resize a node, move a node or move a bendpoint of an edge, see <a href="./user/diagrams/Diagrams.html#snap_to_shapes">the documentation</a> for details. @@ -1279,7 +1306,7 @@ <code>IPermissionAuthority</code>) of the potential to delete objects. This is the reverse order of what was done before, and can have performance impacts if the precondition is slow. The specifier will to take care to ensure a good performance for the precondition expression of the delete tool. </li> </ul> - <h3 id="DeveloperVisibleChanges7">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges8">Developer-Visible Changes</h3> <h4 id="Partialsupportforinternationalization">Partial support for internationalization</h4> <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate “language packs” as OSGi fragments. Note that this does not concern the VSM editor’s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p> <p>Some API changes were required to enable this. While technically breaking changes if interpreting strictly the OSGi versioning rules, the major version number of the impacted bundles was not incremented as the changes only concern classes that should not impact the vast majority of users. Most breaking changes concern the plug-in/activator classes from each bundle. They are:</p> @@ -1581,7 +1608,7 @@ <code>IEditorPart</code> through the navigation history view. </li> </ul> - <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> @@ -1737,7 +1764,7 @@ </li> </ul> <h2 id="sirius3.0.0">Changes in Sirius 3.0.0</h2> - <h3 id="UserVisibleChanges7">User-Visible Changes</h3> + <h3 id="UserVisibleChanges8">User-Visible Changes</h3> <ul> <li><span class="label label-success">Added</span> The ability to print table representations has been re-introduced.</li> <li><span class="label label-success">Added</span> The quick outline feature has been added for tree and table editors, see documentation for details.</li> @@ -1836,7 +1863,7 @@ <em>EStructuralFeature</em> (inherited or with same name). </li> </ul> - <h3 id="DeveloperVisibleChanges8">Developer-Visible Changes</h3> + <h3 id="DeveloperVisibleChanges9">Developer-Visible Changes</h3> <p>The most important and impacting changes in this release are (details below in plug-in specific sections):</p> <ul> <li><span class="label label-success">Added</span> The new extension point @@ -2269,7 +2296,7 @@ <code>ComputedStyleDescriptionRegistry.computedStyleDescriptions</code> list. </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> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index 768ecf87b3..47ad743ff5 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -4,6 +4,18 @@ h1. Release Notes for Sirius This document contains the release notes for recent major releases of Sirius. See also "the release notes from previous versions":Release_Notes_Previous.html for details about older releases. +h2(#sirius4.1.5). Changes in Sirius 4.1.5 + +h3. User-Visible Changes + +* <span class="label label-info">Modified</span> The label alignment of Notes from the Palette has been modified from Juno to Luna or newer versions of Eclipse. The label alignment changed from TOP & CENTER to MIDDLE & LEFT. The initial alignment (TOP & CENTER) has been restored. + +h3. Developer-Visible Changes + +h4. Changes in @org.eclipse.sirius.diagram.ui@ + +* <span class="label label-success">Added</span> Constants @org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.SPECIFIC_STYLES@ & @org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.VERTICAL_ALIGNMENT@ have been added to retrieve the initial label alignment of Notes from the Palette (see "user-visible changes":Release_Notes.html#UserVisibleChanges ). Currently the vertical alignment can not be changed (potential new feature later). + h2(#sirius4.1.4). Changes in Sirius 4.1.4 h3. User-Visible Changes diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.aird new file mode 100644 index 0000000000..856c478a15 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.aird @@ -0,0 +1,39 @@ +<?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: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 xmi:id="_k7WwEebREeaOa_5yitWewA" selectedViews="_jkvtAObSEeaOa_5yitWewA" version="11.1.0.201608251200"> + <semanticResources>noteAttachmentAlignment.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DView" xmi:id="_jkvtAObSEeaOa_5yitWewA"> + <viewpoint xmi:type="description:Viewpoint" href="noteAttachmentAlignment.odesign#//@ownedViewpoints[name='MyViewpoint']"/> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_1md08BVUEeeX-9J1yKditQ" name="new ClassDiag" representation="_1mecABVUEeeX-9J1yKditQ"> + <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 xmi:id="_1mecABVUEeeX-9J1yKditQ" name="new ClassDiag"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_1mecARVUEeeX-9J1yKditQ" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_1mecAhVUEeeX-9J1yKditQ"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_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="Text" fillColor="13369343" transparency="0" lineColor="6737151" lineWidth="1"> + <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"/> + <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" xmi:id="_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/noteAttachmentAlignment/noteAttachmentAlignment.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.ecore new file mode 100644 index 0000000000..73475d5100 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/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/noteAttachmentAlignment/noteAttachmentAlignment.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.odesign new file mode 100644 index 0000000000..162b6853ef --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/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/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java new file mode 100644 index 0000000000..704cfacbc3 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.Map.Entry; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAnnotation; +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.diagram.core.util.ViewType; +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.diagram.ui.business.api.query.ViewQuery; +import org.eclipse.sirius.diagram.ui.business.internal.migration.NoteShapeDefaultLabelAlignmentMigrationParticipant; +import org.eclipse.sirius.tests.SiriusTestsPlugin; +import org.eclipse.sirius.tests.support.api.SiriusTestCase; +import org.eclipse.sirius.tools.api.command.ICommandFactory; +import org.osgi.framework.Version; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; +import com.google.common.collect.UnmodifiableIterator; + +/** + * Test for {@link NoteShapeDefaultLabelAlignmentMigrationParticipant}. + * + * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a> + * + */ +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"; + + 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 NoteShapeDefaultLabelAlignmentMigrationParticipant().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.", loadedVersion == null || migrationVersion.compareTo(loadedVersion) > 0); + } + + /** + * Check note shape with eAnnotation after migration. + */ + public void testNoteShapeAlignmentAfterMigration() { + TreeIterator<EObject> allContents = sessionResource.getAllContents(); + UnmodifiableIterator<Shape> shapes = Iterators.filter(Iterators.filter(allContents, Shape.class), new Predicate<Shape>() { + public boolean apply(Shape input) { + return ViewType.NOTE.equals(input.getType()); + } + });; + if (shapes.hasNext()) { + Shape note = 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)); + assertSame("The text style must be center aligned for the note", TextAlignment.CENTER_LITERAL, textStyles.iterator().next().getTextAlignment()); + EAnnotation specificStyles = note.getEAnnotation(ViewQuery.SPECIFIC_STYLES); + assertNotNull("The note should have an eAnnotation for the vertical alignment", specificStyles); + EMap<String, String> details = specificStyles.getDetails(); + assertEquals("The eAnnotation detail for the vertical alignment is missing", 1, details.size()); + 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); + } + } +} 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 44c4261f6a..10fe9a2e39 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, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 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 @@ -10,11 +10,23 @@ *******************************************************************************/ package org.eclipse.sirius.tests.swtbot; +import java.util.List; + +import org.eclipse.draw2d.Border; +import org.eclipse.draw2d.IFigure; +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.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.sirius.diagram.DDiagram; 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; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart; import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys; import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentation.ZoomLevel; @@ -23,6 +35,7 @@ import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; import org.eclipse.sirius.tests.swtbot.support.api.view.DesignerViews; import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; /** * Test class for double click tool and navigation operation. @@ -265,6 +278,49 @@ public class NoteCreationTest extends AbstractSiriusSwtBotGefTestCase { editor.directEditType(newLabel); // Check the location of the note (with the absolute coordinate) assertNoteAtLocation(newLabel, p2AbsoluteLocation.getTranslated(delta)); + // Check note's label alignment + checkNoteLabelAlignment(editor.getEditPart(newLabel)); + } + + /** + * + */ + private void checkNoteLabelAlignment(SWTBotGefEditPart editPart) { + assertNotNull("The edit part shouldn't be null for the note label", editPart); + EditPart part = editPart.part(); + assertTrue("The edit part of the note label should an instance of SiriusDescriptionCompartmentEditPart", part instanceof SiriusDescriptionCompartmentEditPart); + // Retrieve the bounds of the Note + EditPart parentPart = part.getParent(); + assertTrue("The edit part of the note should an instance of SiriusNoteEditPart", parentPart instanceof SiriusNoteEditPart); + IFigure noteFigure = ((SiriusNoteEditPart) parentPart).getFigure(); + assertTrue("The figure of the note should an instance of NoteFigure", noteFigure instanceof NoteFigure); + Rectangle noteFigureBounds = noteFigure.getBounds(); + Border noteFigureBorder = noteFigure.getBorder(); + Insets noteFigureInsets = noteFigureBorder.getInsets(noteFigure); + // Retrieve the bounds of the label of the Note + IFigure wrapLabelFigure = ((SiriusDescriptionCompartmentEditPart) part).getFigure(); + assertTrue("The figure of the note label should an instance of WrappingLabel", wrapLabelFigure instanceof WrappingLabel); + List<?> childrenFigure = wrapLabelFigure.getChildren(); + assertSame("The figure of the note label should have only one child", 1, childrenFigure.size()); + Object flowPageFigure = childrenFigure.get(0); + assertTrue("The figure of the note label child should be an instance of FlowPage", flowPageFigure instanceof FlowPage); + Rectangle flowPageBounds = ((FlowPage) flowPageFigure).getBounds(); + // The label should be TOP & CENTER aligned. + int middleOfTheNoteX = noteFigureBounds.x + ((noteFigureBounds.width + noteFigureInsets.left - noteFigureInsets.right) / 2); + int middleOfTheLabelX = flowPageBounds.getCenter().x; + assertEquals("The label should be centered in the note", middleOfTheNoteX, middleOfTheLabelX, 2); + int middleOfTheNoteY = noteFigureBounds.getCenter().y; + int beginingOfTheLabelY = flowPageBounds.y; + int endOfTheLabelY = flowPageBounds.y + flowPageBounds.height; + assertTrue("The label should be at the top of the note", beginingOfTheLabelY < middleOfTheNoteY); + assertTrue("The label should be at the top of the note", endOfTheLabelY < middleOfTheNoteY); + // We do all of this because the following commented lines don't works + // assertSame("The note label should be centered", + // PositionConstants.CENTER, ((SiriusDescriptionCompartmentEditPart) + // part).getLabelDelegate().getTextJustification()); + // assertSame("The note label should be on top", PositionConstants.TOP, + // ((SiriusDescriptionCompartmentEditPart) + // part).getLabelDelegate().getAlignment()); } /** |
