Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2017-03-30 14:36:49 +0000
committerLaurent Redor2017-04-18 12:30:51 +0000
commit3b6c5dc93a3c60aacb09c3c00dc3d4f802e2946d (patch)
treeb03a45bb369a86ed5621a3c8a3828026e2ca55ef
parentbf1ec03dbaa87af3008c55f8412792776f507f4b (diff)
downloadorg.eclipse.sirius-3b6c5dc93a3c60aacb09c3c00dc3d4f802e2946d.tar.gz
org.eclipse.sirius-3b6c5dc93a3c60aacb09c3c00dc3d4f802e2946d.tar.xz
org.eclipse.sirius-3b6c5dc93a3c60aacb09c3c00dc3d4f802e2946d.zip
[515044] 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: 515044 Signed-off-by: Axel Richard <axel.richard@obeo.fr> Also-by: Laurent Redor <laurent.redor@obeo.fr> Change-Id: I0ee98aa4961bb748ca085cd10b1fb3d17cd5a638
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/plugin.xml13
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java14
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java128
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java70
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusNoteViewProvider.java37
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/SiriusNoteViewFactory.java79
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html8
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile3
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.aird39
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.ecore3
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/do_not_migrate/noteAttachmentAlignment/noteAttachmentAlignment.odesign9
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java106
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteCreationTest.java58
13 files changed, 560 insertions, 7 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml
index 683105ef06..72d4d12c6e 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">
@@ -1802,6 +1809,10 @@
class="org.eclipse.sirius.diagram.ui.business.internal.migration.description.DecorationImageDescriptionVSMMigrationParticipant"
kind="VSM">
</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..79cae6b5fe
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/NoteShapeDefaultLabelAlignmentMigrationParticipant.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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("12.0.0.201704070000"); //$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 4068a5b3a2..e99cd96785 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -112,12 +112,20 @@
</p>
<h2 id="sirius5.0.0M7">Changes in Sirius 5.0.0M7</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 &amp; CENTER to MIDDLE &amp; LEFT. The initial alignment (TOP &amp; CENTER) has been restored.</li>
+ </ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
<ul>
+ <li><span class="label label-success">Added</span> Constants
+ <code>org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.SPECIFIC_STYLES</code> &amp;
+ <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>
<li><span class="label label-info">Moved</span> The methods of interface
<code>org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping</code> that are
<code>getFormatData(FormatDataKey, RepresentationElementMapping)</code> and
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index e084b50fea..c3bd893648 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -8,12 +8,15 @@ h2(#sirius5.0.0M7). Changes in Sirius 5.0.0M7
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. Specifier-Visible Changes
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).
* <span class="label label-info">Moved</span> The methods of interface @org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping@ that are @getFormatData(FormatDataKey, RepresentationElementMapping)@ and @addFormatData(FormatDataKey, RepresentationElementMapping, AbstractFormatData)@ have been moved into the interface @org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManager@ to reduce interface numbers for less complexity.
* <span class="label label-danger">Removed</span> The methods @getFormatData(FormatDataKey key)@ and @addFormatData(FormatDataKey key, AbstractFormatData formatData)@ have been removed from interface @org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManager@ because they were deprecated.
* <span class="label label-danger">Removed</span> The interface @org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManagerWithMapping@ has been removed because all its methods have been moved into interface @org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManager@
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..23dfe45bff
--- /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>My.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="My.odesign#//@ownedViewpoints[name='MyViewpoint']/@ownedRepresentations[name='ClassDiag']"/>
+ <target xmi:type="ecore:EPackage" href="My.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="My.odesign#//@ownedViewpoints[name='MyViewpoint']/@ownedRepresentations[name='ClassDiag']/@defaultLayer"/>
+ <target xmi:type="ecore:EPackage" href="My.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..625ea0ac02
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/NoteShapeDefaultLabelAlignmentMigrationTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.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 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);
+ URI sessionResourceURI = URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + "/" + PATH + 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.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + "/" + PATH + 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<EObject> shapes = Iterators.filter(allContents, input -> input instanceof Shape && ViewType.NOTE.equals(((Shape) input).getType()));
+ if (shapes.hasNext()) {
+ 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));
+ 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());
}
/**

Back to the top