Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2016-05-27 08:06:56 -0400
committerGerrit Code Review @ Eclipse.org2016-05-31 10:28:58 -0400
commit78884f12fcdc10c36624896677378a2448a2ec32 (patch)
tree2ff4cb70cfe916db0b39f305e8dfb6fabe34e56c
parent29c537c3c5327e2dcb8ed1c763bcb3b60acb2adb (diff)
downloadorg.eclipse.papyrus-78884f12fcdc10c36624896677378a2448a2ec32.tar.gz
org.eclipse.papyrus-78884f12fcdc10c36624896677378a2448a2ec32.tar.xz
org.eclipse.papyrus-78884f12fcdc10c36624896677378a2448a2ec32.zip
Bug 493420: StereotypeEAnnotationMigrationEditPolicy should be
replaced/subsumed by a proper DiagramReconcilier https://bugs.eclipse.org/bugs/show_bug.cgi?id=493420 Cherry Pick Mars to Neon. Change-Id: Id9ba0ff917690282ee928ff972b97956314d1b05 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net> Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayDiagramReconciler.java41
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayMigrationConstant.java126
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationLabelMigration.java61
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationMigration.java98
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationNestedMigration.java60
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationPropertiesMigration.java84
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeMigrationHelper.java835
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeCommentPropertiesMigrationCommand.java241
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeLabelMigrationCommand.java496
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeNestedPropertiesMigrationCommand.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypePropertiesMigrationCommand.java625
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesAppliedCommand.java387
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesMigrationCommand.java175
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationLabelMigrationEditPolicy.java170
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationMigrationEditPolicy.java362
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationNestedMigrationEditPolicy.java160
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationPropertiesMigrationEditPolicy.java196
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml78
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypeDisplayMigrationEditPolicyProvider.java220
20 files changed, 2763 insertions, 1783 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
index db854aac9a2..78761f57646 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
@@ -603,4 +603,13 @@
label="Rich Text Renderer">
</contributor>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.diagramReconciler">
+ <diagramReconciler
+ diagramType="AllDiagrams"
+ reconcilerClass="org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler"
+ source="Undefined"
+ target="1.2.0">
+ </diagramReconciler>
+ </extension>
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayDiagramReconciler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayDiagramReconciler.java
new file mode 100644
index 00000000000..07a4b0f863f
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayDiagramReconciler.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypesAppliedCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypesMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ *
+ */
+public class StereotypeDisplayDiagramReconciler extends DiagramReconciler {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getReconcileCommand(final Diagram diagram) {
+ CompositeCommand cc = new CompositeCommand("Migrate diagram from 1.1.0 to 1.2.0"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(diagram);
+ cc.add(new StereotypesAppliedCommand(domain, diagram));
+ cc.add(new StereotypesMigrationCommand(domain, diagram));
+ return cc;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayMigrationConstant.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayMigrationConstant.java
index f7c40fc46d9..57e4f86ff4c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayMigrationConstant.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeDisplayMigrationConstant.java
@@ -1,61 +1,65 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
-
-/**
- * This class regroups all the constant required for the Migration of the Stereotype Display User Preferences.
- *
- * @author Céline JANSSENS
- *
- */
-public final class StereotypeDisplayMigrationConstant {
- /**
- * Stereotype EAnnotation (Old Structure to migrate to the new one)
- */
- public static final String STEREOTYPE_ANNOTATION = "Stereotype_Annotation";//$NON-NLS-1$
- /**
- * the list of stereotype to display
- */
- public static final String STEREOTYPE_LIST = "StereotypeList";//$NON-NLS-1$
-
- /**
- * the list of stereotype to display
- */
- public static final String STEREOTYPE_WITHQN_LIST = "StereotypeWithQualifiedNameList";//$NON-NLS-1$
-
- /**
- * Property location Key
- */
- public static final String STEREOTYPE_PROPERTY_LOCATION = "StereotypePropertyLocation";//$NON-NLS-1$
-
- /**
- * Property display Key
- *
- */
- public static final String PROPERTY_STEREOTYPE_DISPLAY = "PropStereoDisplay";//$NON-NLS-1$
-
- /**
- * the kind of presentation for stereotype
- */
- public static final String STEREOTYPE_PRESENTATION_KIND = "Stereotype_Presentation_Kind";//$NON-NLS-1$
-
- /**
- * Old Type of Views
- */
- public static final String OLD_COMMENT_TYPE = "AppliedStereotypesComment";//$NON-NLS-1$
- public static final Object OLD_COMMENT_LINK_TYPE = "AppliedStereotypesCommentLink";//$NON-NLS-1$
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+/**
+ * This class regroups all the constant required for the Migration of the Stereotype Display User Preferences.
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public final class StereotypeDisplayMigrationConstant {
+ /**
+ * Stereotype EAnnotation (Old Structure to migrate to the new one)
+ */
+ public static final String STEREOTYPE_ANNOTATION = "Stereotype_Annotation";//$NON-NLS-1$
+ /**
+ * the list of stereotype to display
+ */
+ public static final String STEREOTYPE_LIST = "StereotypeList";//$NON-NLS-1$
+
+ /**
+ * the list of stereotype to display
+ */
+ public static final String STEREOTYPE_WITHQN_LIST = "StereotypeWithQualifiedNameList";//$NON-NLS-1$
+
+ /**
+ * Property location Key
+ */
+ public static final String STEREOTYPE_PROPERTY_LOCATION = "StereotypePropertyLocation";//$NON-NLS-1$
+
+ /**
+ * Property display Key
+ *
+ */
+ public static final String PROPERTY_STEREOTYPE_DISPLAY = "PropStereoDisplay";//$NON-NLS-1$
+
+ /**
+ * the kind of presentation for stereotype
+ */
+ public static final String STEREOTYPE_PRESENTATION_KIND = "Stereotype_Presentation_Kind";//$NON-NLS-1$
+
+ /**
+ * Old Type of Views
+ */
+ public static final String OLD_COMMENT_TYPE = "AppliedStereotypesComment";//$NON-NLS-1$
+ public static final Object OLD_COMMENT_LINK_TYPE = "AppliedStereotypesCommentLink";//$NON-NLS-1$
+
+ /**
+ * Separator Constants
+ */
+ public final static String EANNOTATION_LIST_SEPARATOR = ","; //$NON-NLS-1$
+ public final static String EANNOTATION_PROPERTY_SEPARATOR = "."; //$NON-NLS-1$
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationLabelMigration.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationLabelMigration.java
new file mode 100644
index 00000000000..54e8af1dad3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationLabelMigration.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeLabelMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * Class for the Stereotype Label user preferences migration.
+ *
+ */
+public class StereotypeEAnnotationLabelMigration extends StereotypeEAnnotationMigration {
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public StereotypeEAnnotationLabelMigration(final View view) {
+ super(view);
+ }
+
+ public static final String LABEL = "Migration of Stereotype Label";//$NON-NLS-1$
+
+ @Override
+ public void cleanEAnnotationDetails(final View view) {
+ TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(view);
+
+ RemoveEAnnotationDetailCommand deleteStereotype = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_LIST);
+ CommandUtil.executeUnsafeCommand(deleteStereotype, view);
+
+ RemoveEAnnotationDetailCommand deleteQNList = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST);
+ CommandUtil.executeUnsafeCommand(deleteQNList, view);
+ }
+
+ @Override
+ public boolean hasEAnnotationDetails(final View view) {
+ return migrationHelper.getStereotypesToDisplay(hostView) != null;
+ }
+
+ @Override
+ public ICommand getStereotypeMigrationCommand(final View view) {
+ return new StereotypeLabelMigrationCommand(LABEL, view);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationMigration.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationMigration.java
new file mode 100644
index 00000000000..cb8e3915a02
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationMigration.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * This Edit Policy is in charge to migrate user preferences from old stereotype display structure
+ * (which were using EAnnotation) to the new structure using NamedStyle and additional notation Views
+ */
+public abstract class StereotypeEAnnotationMigration {
+ protected StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+ protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ protected View hostView = null;
+ protected EAnnotation eAnnotation = null;
+
+ /**
+ * Set the attributes and launch the migration.
+ *
+ * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate()
+ *
+ */
+ public StereotypeEAnnotationMigration(final View view) {
+ this.hostView = view;
+ }
+
+ public void activate() {
+ // set EAnnotation and start the migration process
+ if (null != hostView) {
+ this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
+ if (null != eAnnotation && !eAnnotation.getDetails().isEmpty()) {
+ migrateStereotype();
+ }
+ }
+
+ }
+
+ /**
+ * Migrate all the Stereotype User preferences
+ *
+ * @throws ExecutionException
+ *
+ */
+ protected void migrateStereotype() {
+ if (eAnnotation != null) {
+ if (hasEAnnotationDetails(hostView)) {
+ // Retrieve the migration Command and execute it.
+ ICommand command = getStereotypeMigrationCommand(hostView);
+ CommandUtil.executeUnsafeCommand(command, hostView);
+
+ }
+ // Clean the details associated to each sub edit policies;
+ cleanEAnnotationDetails(hostView);
+ }
+ }
+
+ /**
+ * Clean EAnnotation Details in the model depending of what has been treated.
+ *
+ * @param hostView
+ * The view on which the Stereotype has been applied
+ */
+ public abstract void cleanEAnnotationDetails(final View view);
+
+ /**
+ * Define if the Edit Policy detail for the specific EANnotation Detail is not Empty.
+ *
+ * @param view
+ * The view on which the Stereotype has been applied
+ */
+ public abstract boolean hasEAnnotationDetails(final View view);
+
+ /**
+ * Get the command to update the Node visibility related to the EAnnotation.
+ *
+ * @param hostView
+ * The view on which the Stereotype has been applied
+ */
+ public abstract ICommand getStereotypeMigrationCommand(final View view);
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationNestedMigration.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationNestedMigration.java
new file mode 100644
index 00000000000..14c3c8ff71e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationNestedMigration.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeNestedPropertiesMigrationCommand;
+
+/**
+ * Class to manage the migration of the object into Compartment :
+ * <ul>
+ * <li>Operations</li>
+ * <li>Properties</li>
+ * <li>Nested Element</li>
+ * <li>Enumeration</li>
+ * <li>....</li>
+ * </ul>
+ */
+public class StereotypeEAnnotationNestedMigration extends StereotypeEAnnotationPropertiesMigration {
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public StereotypeEAnnotationNestedMigration(final View view) {
+ super(view);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void activate() {
+ if (null != hostView) {
+ this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
+ migrateStereotype();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getStereotypeMigrationCommand(final View view) {
+ return new StereotypeNestedPropertiesMigrationCommand(LABEL, view);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationPropertiesMigration.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationPropertiesMigration.java
new file mode 100644
index 00000000000..05cbe32080b
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeEAnnotationPropertiesMigration.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeCommentPropertiesMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * Class for the Stereotype Properties user preferences migration.
+ *
+ */
+public class StereotypeEAnnotationPropertiesMigration extends StereotypeEAnnotationMigration {
+
+ public static final String LABEL = "Migration Stereotype Properties"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public StereotypeEAnnotationPropertiesMigration(final View view) {
+ super(view);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void cleanEAnnotationDetails(final View view) {
+ TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(view);
+
+ if (domain != null) {
+ RemoveEAnnotationDetailCommand deleteLocation = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PROPERTY_LOCATION);
+ CommandUtil.executeUnsafeCommand(deleteLocation, domain);
+ RemoveEAnnotationDetailCommand deleteProperties = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY);
+ CommandUtil.executeUnsafeCommand(deleteProperties, domain);
+ RemoveEAnnotationDetailCommand deleteKind = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PRESENTATION_KIND);
+ CommandUtil.executeUnsafeCommand(deleteKind, domain);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasEAnnotationDetails(final View view) {
+ return migrationHelper.getAppliedStereotypesPropertiesToDisplay(hostView) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getStereotypeMigrationCommand(final View view) {
+ ICommand migrationCommand = null;
+ if (migrationHelper.getAppliedStereotypesPropertiesLocalization(view).equals(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION)) {
+ // In case of properties in Comment, a dedicated Command is required.
+ migrationCommand = new StereotypeCommentPropertiesMigrationCommand(LABEL, view, false);
+ } else {
+ migrationCommand = new StereotypePropertiesMigrationCommand(LABEL, view);
+ }
+
+ return migrationCommand;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeMigrationHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeMigrationHelper.java
index a0516ed6c64..97dd29dfa41 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeMigrationHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/StereotypeMigrationHelper.java
@@ -1,416 +1,419 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This class regroups the methods required to create the new Stereotype Structure based on the Old Structure.
- *
- * @author Céline JANSSENS
- *
- */
-public final class StereotypeMigrationHelper {
-
-
- public static final String EMPTY_STRING = "";//$NON-NLS-1$
-
- /**
- * singleton instance
- */
- private static StereotypeMigrationHelper migrationHelper;
-
- /** Other Helper */
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
-
- /** Singleton constructor */
- private StereotypeMigrationHelper() {
- }
-
- /**
- * Returns the singleton instance of this class
- *
- * @return the singleton instance.
- */
- public static StereotypeMigrationHelper getInstance() {
- if (migrationHelper == null) {
- migrationHelper = new StereotypeMigrationHelper();
- }
- return migrationHelper;
- }
-
-
- /**
- * Get the Semantic Element of the Comment View.
- * The Comment View is not attached to its semantic element through the method {@link View#getElement()}.
- * To retrieve the semantic element, it has been added as a namedStyle with the name {@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_RELATION_NAME}
- *
- * @param view
- * The Stereotype Comment View (of type "StereotypeComment")
- * @return The Base Element of the Comment
- */
- public Element getOldCommentSemanticElement(View view) {
-
- Element elementSemantic = null;
- if (isOldComment(view)) {
- // Retrieve the Base Element of the Comment as the Semantic element
- EObject baseElement = NotationUtils.getEObjectValue(view, StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME, null);
-
- if (baseElement instanceof Element) {
- elementSemantic = (Element) baseElement;
-
- }
- }
- return elementSemantic;
- }
-
-
-
- /**
- * Get a Stereotype from its StereotypeName
- *
- * @param view
- * View on which we try to retrieve the Stereotype
- * @param stereotypeName
- * Stereotype Name
- * @return Stereotype Associated to the stereotype Name for the View.
- */
- public Stereotype getStereotypeFromString(View view, String stereotypeName) {
-
- Stereotype stereotype = null;
-
- Element element = helper.getSemanticElement(view);
- stereotype = element.getAppliedStereotype(stereotypeName);
-
- return stereotype;
- }
-
- /**
- * Get a Property from its Name and its Stereotype
- *
- * @param view
- * The View Containing the Property Compartment (i.e : ClassImpl)
- * @param propertyName
- * The Property Name
- * @return The Property related to the View and to the Stereotype.
- */
- public Property getPropertyFromString(View view, Stereotype stereotype, String propertyName) {
- Property property = null;
- if (view != null && !propertyName.isEmpty()) {
-
- Iterator<Property> propertyIterator = stereotype.getAttributes().iterator();
- while (propertyIterator.hasNext() && property == null) {
- Property propertyTest = propertyIterator.next();
- if (propertyTest.getName().equals(propertyName)) {
- property = propertyTest;
- }
- }
- }
-
- return property;
- }
-
-
-
- /**
- * Check is the node is persistent and make it persistent if not
- * Check if the visibility should be modified, and do it accordingly
- *
- * @param view
- * The View to modify
- * @param diagram
- * The Diagram that is migrated
- * @param visible
- * true if the view has to be visible.
- */
- public void updateVisibilityAndPersistence(View view, EObject object, boolean visible) {
- if (view != null) {
- if (view.eContainer() instanceof View && !((View) view.eContainer()).getPersistedChildren().contains(view)) {
- commandHelper.setPersistency(migrationHelper.getDomain(object), view, false);
- }
-
- if (visible != view.isVisible()) {
- commandHelper.setVisibility(migrationHelper.getDomain(object), view, visible, false);
- }
- }
-
-
- }
-
- /**
- * Get the Editing domain from Eobject
- *
- * @param object
- * Object used to retrieve the Transactional Editing Domain
- * @see {@link CommandUtil#resolveEditingDomain(Object)}
- *
- * @return Transactional Domain
- */
- public TransactionalEditingDomain getDomain(EObject object) {
- return CommandUtil.resolveEditingDomain(object);
- }
-
- /**
- * Get the EAnnotation, dedicated to the Stereotype Display User preferences (Old structure to be replaced by the new one)
- *
- * @param view
- * The View of which the EAnnotation is necessary.
- * @return The EAnnotation of the view . Null if does not exist.
- */
- public EAnnotation getStereotypeEAnnotation(EModelElement view) {
- EAnnotation annotation = null;
- if (view != null) {
- annotation = view.getEAnnotation(StereotypeDisplayMigrationConstant.STEREOTYPE_ANNOTATION);
- }
- return annotation;
-
- }
-
- /**
- *
- * Define if a view has an Stereotype EAnnotation
- *
- * @param content
- * The view
- * @return true if the Stereotype is not null.
- */
- public boolean hasStereotypeEAnnotation(View content) {
-
- return getStereotypeEAnnotation(content) != null;
- }
-
- /**
- * Retrieve the list of the appliedStereotypes from a View
- *
- * @param view
- * The view for which the List of Stereotypes is asked
- * @return The appliedStereotype List. Null if no UML element related to the View.
- */
- public EList<Stereotype> getAppliedStereotypesFromView(View view) {
- EList<Stereotype> list = null;
-
- Element element = helper.getSemanticElement(view);
- list = element.getAppliedStereotypes();
-
- return list;
- }
-
-
- /* ******************* Old EAnnotation Method *************************/
-
- /**
- * get lhe list of stereotype to display with the qulifiedName.
- *
- * @param view
- * the view of the uml element
- *
- * @return the list of applied stereotype to display with their qualified name
- */
- public String getStereotypesQNToDisplay(EModelElement view) {
- EAnnotation eannotation = getStereotypeEAnnotation(view);
- if (eannotation != null) {
- EMap<String, String> entries = eannotation.getDetails();
-
- String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST);
- if (stereotypesToDisplay != null) {
- return stereotypesToDisplay;
- }
- }
- return EMPTY_STRING;
- }
-
- /**
- * get the list of stereotype to display from the eannotation.
- *
- * @param view
- * the view
- *
- * @return the list of stereotypes to display separated by a comma. the applied stereotype to
- * display is represented by the qualified name of the stereotype
- * Empty String by default.
- */
- public String getStereotypesToDisplay(EModelElement view) {
- EAnnotation eannotation = getStereotypeEAnnotation(view);
- if (eannotation != null) {
- EMap<String, String> entries = eannotation.getDetails();
-
- String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.STEREOTYPE_LIST);
- if (stereotypesToDisplay != null) {
- return stereotypesToDisplay;
- }
- }
- return EMPTY_STRING;
- }
-
- /**
- * Gets the applied stereotypes properties localization.
- *
- * @param view
- * the view
- *
- * @return the applied stereotypes properties localization
- */
- public String getAppliedStereotypesPropertiesLocalization(EModelElement view) {
- EAnnotation eannotation = getStereotypeEAnnotation(view);
- if (eannotation != null) {
- EMap<String, String> entries = eannotation.getDetails();
-
- String displayLocalization = entries.get(StereotypeDisplayConstant.STEREOTYPE_PROPERTY_LOCATION);
- if (displayLocalization != null && !displayLocalization.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
- return displayLocalization;
- }
- }
-
-
- return StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION;
- }
-
-
- /**
- * Gets the applied stereotypes properties to display.
- *
- * @param view
- * the view the view that displays the stereotyped element
- *
- * @return the applied stereotypes properties to display
- */
- public String getAppliedStereotypesPropertiesToDisplay(EModelElement view) {
- EAnnotation eannotation = getStereotypeEAnnotation(view);
- if (eannotation != null) {
- EMap<String, String> entries = eannotation.getDetails();
-
- String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY);
- if (stereotypesToDisplay != null) {
- return stereotypesToDisplay;
- }
- }
- return EMPTY_STRING;
- }
-
- /**
- * Define if the passed object is the Old Comment View
- *
- * @param object
- * The object to be tested
- * @return true if the object is a view of type {@link StereotypeDisplayMigrationConstant#OLD_COMMENT_TYPE}
- */
- public boolean isOldComment(Object object) {
-
- if (object instanceof View) {
- View view = (View) object;
- return (view.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_TYPE));
-
- }
-
- return false;
- }
-
-
-
- /**
- * Retrieve the old Comment from a hostView
- *
- * @param hostView
- * The view of which the old comment is retrieve
- * @return The OldComment View or Null if not found.
- */
- public View getOldStereotypeComment(View semanticView) {
- Node node = null;
- if (semanticView != null && semanticView.getSourceEdges() != null) {
- // look for all links with the id AppliedStereotypesCommentLinkEditPart.ID
- Iterator<Edge> edgeIterator = semanticView.getSourceEdges().iterator();
- Edge appliedStereotypeLink = null;
- while (edgeIterator.hasNext() && appliedStereotypeLink == null) {
- Edge edge = edgeIterator.next();
- if (edge.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_LINK_TYPE)) {
- appliedStereotypeLink = edge;
- }
- }
- if (appliedStereotypeLink == null) {
- return null;
- }
- node = (Node) appliedStereotypeLink.getTarget();
- }
- return node;
- }
-
- /**
- * Retrieve the Old Link of the HostView
- *
- * @param hostView
- * The view of which the old link is retrieve
- * @return The Old Link View or Null if not found.
- */
- public Edge getOldStereotypeLinkComment(View semanticView) {
- Edge appliedStereotypeLink = null;
- if (semanticView != null && semanticView.getSourceEdges() != null) {
- // look for all links with the id AppliedStereotypesCommentLinkEditPart.ID
- Iterator<Edge> edgeIterator = semanticView.getSourceEdges().iterator();
-
- while (edgeIterator.hasNext() && appliedStereotypeLink == null) {
- Edge edge = edgeIterator.next();
- if (edge.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_LINK_TYPE)) {
- appliedStereotypeLink = edge;
- }
- }
- }
- return appliedStereotypeLink;
- }
-
- /**
- * Define if an Old Comment is Orphan
- *
- * @param view
- * The View of the Old Comment
- * @return True if the Comment is not related to another Element or if no stereotype is applied to this Element.
- */
- public boolean isOrphanComment(View view) {
- boolean orphanComment = false;
-
- if (isOldComment(view)) {
- // if no stereotypes applied on the Base element, the comment is considered as Orphan
- Element element = getOldCommentSemanticElement(view);
- if (element == null || element.getAppliedStereotypes().size() == 0) {
- orphanComment = true;
- }
-
- }
- return orphanComment;
- }
-
-
-
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * This class regroups the methods required to create the new Stereotype Structure based on the Old Structure.
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public final class StereotypeMigrationHelper {
+ public static final String EMPTY_STRING = "";//$NON-NLS-1$
+
+ /**
+ * singleton instance
+ */
+ private static StereotypeMigrationHelper migrationHelper;
+
+ /** Other Helper */
+ private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
+ private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ /** Singleton constructor */
+ private StereotypeMigrationHelper() {
+ }
+
+ /**
+ * Returns the singleton instance of this class
+ *
+ * @return the singleton instance.
+ */
+ public static StereotypeMigrationHelper getInstance() {
+ if (migrationHelper == null) {
+ migrationHelper = new StereotypeMigrationHelper();
+ }
+ return migrationHelper;
+ }
+
+
+ /**
+ * Get the Semantic Element of the Comment View.
+ * The Comment View is not attached to its semantic element through the method {@link View#getElement()}.
+ * To retrieve the semantic element, it has been added as a namedStyle with the name {@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_RELATION_NAME}
+ *
+ * @param view
+ * The Stereotype Comment View (of type "StereotypeComment")
+ * @return The Base Element of the Comment
+ */
+ public Element getOldCommentSemanticElement(final View view) {
+
+ Element elementSemantic = null;
+ if (isOldComment(view)) {
+ // Retrieve the Base Element of the Comment as the Semantic element
+ EObject baseElement = NotationUtils.getEObjectValue(view, StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME, null);
+
+ if (baseElement instanceof Element) {
+ elementSemantic = (Element) baseElement;
+
+ }
+ }
+ return elementSemantic;
+ }
+
+
+
+ /**
+ * Get a Stereotype from its StereotypeName
+ *
+ * @param view
+ * View on which we try to retrieve the Stereotype
+ * @param stereotypeName
+ * Stereotype Name
+ * @return Stereotype Associated to the stereotype Name for the View.
+ */
+ public Stereotype getStereotypeFromString(final View view, final String stereotypeName) {
+ Stereotype stereotype = null;
+
+ Element element = helper.getSemanticElement(view);
+ if (null != element) {
+ stereotype = element.getAppliedStereotype(stereotypeName);
+ }
+
+ return stereotype;
+ }
+
+ /**
+ * Get a Property from its Name and its Stereotype
+ *
+ * @param view
+ * The View Containing the Property Compartment (i.e : ClassImpl)
+ * @param propertyName
+ * The Property Name
+ * @return The Property related to the View and to the Stereotype.
+ */
+ public Property getPropertyFromString(final View view, final Stereotype stereotype, final String propertyName) {
+ Property property = null;
+ if (view != null && !propertyName.isEmpty()) {
+
+ Iterator<Property> propertyIterator = stereotype.getAttributes().iterator();
+ while (propertyIterator.hasNext() && property == null) {
+ Property propertyTest = propertyIterator.next();
+ if (propertyTest.getName().equals(propertyName)) {
+ property = propertyTest;
+ }
+ }
+ }
+
+ return property;
+ }
+
+
+
+ /**
+ * Check is the node is persistent and make it persistent if not
+ * Check if the visibility should be modified, and do it accordingly
+ *
+ * @param view
+ * The View to modify
+ * @param diagram
+ * The Diagram that is migrated
+ * @param visible
+ * true if the view has to be visible.
+ */
+ public void updateVisibilityAndPersistence(final View view, final EObject object, final boolean visible) {
+ if (view != null) {
+ if (view.eContainer() instanceof View && !((View) view.eContainer()).getPersistedChildren().contains(view)) {
+ commandHelper.setPersistency(migrationHelper.getDomain(object), view, false);
+ }
+
+ if (visible != view.isVisible()) {
+ commandHelper.setVisibility(migrationHelper.getDomain(object), view, visible, false);
+ }
+ }
+
+
+ }
+
+ /**
+ * Get the Editing domain from Eobject
+ *
+ * @param object
+ * Object used to retrieve the Transactional Editing Domain
+ * @see {@link CommandUtil#resolveEditingDomain(Object)}
+ *
+ * @return Transactional Domain
+ */
+ public TransactionalEditingDomain getDomain(final EObject object) {
+ return CommandUtil.resolveEditingDomain(object);
+ }
+
+ /**
+ * Get the EAnnotation, dedicated to the Stereotype Display User preferences (Old structure to be replaced by the new one)
+ *
+ * @param view
+ * The View of which the EAnnotation is necessary.
+ * @return The EAnnotation of the view . Null if does not exist.
+ */
+ public EAnnotation getStereotypeEAnnotation(final EModelElement view) {
+ EAnnotation annotation = null;
+ if (view != null) {
+ annotation = view.getEAnnotation(StereotypeDisplayMigrationConstant.STEREOTYPE_ANNOTATION);
+ }
+ return annotation;
+
+ }
+
+ /**
+ *
+ * Define if a view has an Stereotype EAnnotation
+ *
+ * @param content
+ * The view
+ * @return true if the Stereotype is not null.
+ */
+ public boolean hasStereotypeEAnnotation(final View content) {
+
+ return getStereotypeEAnnotation(content) != null;
+ }
+
+ /**
+ * Retrieve the list of the appliedStereotypes from a View
+ *
+ * @param view
+ * The view for which the List of Stereotypes is asked
+ * @return The appliedStereotype List. Null if no UML element related to the View.
+ */
+ public EList<Stereotype> getAppliedStereotypesFromView(final View view) {
+ EList<Stereotype> list = null;
+
+ Element element = helper.getSemanticElement(view);
+
+ if (null != element) {
+ list = element.getAppliedStereotypes();
+ }
+
+ return list;
+ }
+
+
+ /* ******************* Old EAnnotation Method *************************/
+
+ /**
+ * get lhe list of stereotype to display with the qulifiedName.
+ *
+ * @param view
+ * the view of the uml element
+ *
+ * @return the list of applied stereotype to display with their qualified name
+ */
+ public String getStereotypesQNToDisplay(final EModelElement view) {
+ EAnnotation eannotation = getStereotypeEAnnotation(view);
+ if (eannotation != null) {
+ EMap<String, String> entries = eannotation.getDetails();
+
+ String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST);
+ if (stereotypesToDisplay != null) {
+ return stereotypesToDisplay;
+ }
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * get the list of stereotype to display from the eannotation.
+ *
+ * @param view
+ * the view
+ *
+ * @return the list of stereotypes to display separated by a comma. the applied stereotype to
+ * display is represented by the qualified name of the stereotype
+ * Empty String by default.
+ */
+ public String getStereotypesToDisplay(final EModelElement view) {
+ EAnnotation eannotation = getStereotypeEAnnotation(view);
+ if (eannotation != null) {
+ EMap<String, String> entries = eannotation.getDetails();
+
+ String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.STEREOTYPE_LIST);
+ if (stereotypesToDisplay != null) {
+ return stereotypesToDisplay;
+ }
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * Gets the applied stereotypes properties localization.
+ *
+ * @param view
+ * the view
+ *
+ * @return the applied stereotypes properties localization
+ */
+ public String getAppliedStereotypesPropertiesLocalization(final EModelElement view) {
+ EAnnotation eannotation = getStereotypeEAnnotation(view);
+ if (eannotation != null) {
+ EMap<String, String> entries = eannotation.getDetails();
+
+ String displayLocalization = entries.get(StereotypeDisplayConstant.STEREOTYPE_PROPERTY_LOCATION);
+ if (displayLocalization != null && !displayLocalization.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
+ return displayLocalization;
+ }
+ }
+
+
+ return StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION;
+ }
+
+
+ /**
+ * Gets the applied stereotypes properties to display.
+ *
+ * @param view
+ * the view the view that displays the stereotyped element
+ *
+ * @return the applied stereotypes properties to display
+ */
+ public String getAppliedStereotypesPropertiesToDisplay(final EModelElement view) {
+ EAnnotation eannotation = getStereotypeEAnnotation(view);
+ if (eannotation != null) {
+ EMap<String, String> entries = eannotation.getDetails();
+
+ String stereotypesToDisplay = entries.get(StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY);
+ if (stereotypesToDisplay != null) {
+ return stereotypesToDisplay;
+ }
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * Define if the passed object is the Old Comment View
+ *
+ * @param object
+ * The object to be tested
+ * @return true if the object is a view of type {@link StereotypeDisplayMigrationConstant#OLD_COMMENT_TYPE}
+ */
+ public boolean isOldComment(final Object object) {
+
+ if (object instanceof View) {
+ View view = (View) object;
+ return (view.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_TYPE));
+
+ }
+
+ return false;
+ }
+
+
+
+ /**
+ * Retrieve the old Comment from a hostView
+ *
+ * @param hostView
+ * The view of which the old comment is retrieve
+ * @return The OldComment View or Null if not found.
+ */
+ public View getOldStereotypeComment(final View semanticView) {
+ Node node = null;
+ if (semanticView != null && semanticView.getSourceEdges() != null) {
+ // look for all links with the id AppliedStereotypesCommentLinkEditPart.ID
+ Iterator<Edge> edgeIterator = semanticView.getSourceEdges().iterator();
+ Edge appliedStereotypeLink = null;
+ while (edgeIterator.hasNext() && appliedStereotypeLink == null) {
+ Edge edge = edgeIterator.next();
+ if (edge.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_LINK_TYPE)) {
+ appliedStereotypeLink = edge;
+ }
+ }
+ if (appliedStereotypeLink == null) {
+ return null;
+ }
+ node = (Node) appliedStereotypeLink.getTarget();
+ }
+ return node;
+ }
+
+ /**
+ * Retrieve the Old Link of the HostView
+ *
+ * @param hostView
+ * The view of which the old link is retrieve
+ * @return The Old Link View or Null if not found.
+ */
+ public Edge getOldStereotypeLinkComment(final View semanticView) {
+ Edge appliedStereotypeLink = null;
+ if (semanticView != null && semanticView.getSourceEdges() != null) {
+ // look for all links with the id AppliedStereotypesCommentLinkEditPart.ID
+ Iterator<Edge> edgeIterator = semanticView.getSourceEdges().iterator();
+
+ while (edgeIterator.hasNext() && appliedStereotypeLink == null) {
+ Edge edge = edgeIterator.next();
+ if (edge.getType().equals(StereotypeDisplayMigrationConstant.OLD_COMMENT_LINK_TYPE)) {
+ appliedStereotypeLink = edge;
+ }
+ }
+ }
+ return appliedStereotypeLink;
+ }
+
+ /**
+ * Define if an Old Comment is Orphan
+ *
+ * @param view
+ * The View of the Old Comment
+ * @return True if the Comment is not related to another Element or if no stereotype is applied to this Element.
+ */
+ public boolean isOrphanComment(final View view) {
+ boolean orphanComment = false;
+
+ if (isOldComment(view)) {
+ // if no stereotypes applied on the Base element, the comment is considered as Orphan
+ Element element = getOldCommentSemanticElement(view);
+ if (element == null || element.getAppliedStereotypes().size() == 0) {
+ orphanComment = true;
+ }
+
+ }
+ return orphanComment;
+ }
+
+
+
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeCommentPropertiesMigrationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeCommentPropertiesMigrationCommand.java
index d2f0183e815..5442d385390 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeCommentPropertiesMigrationCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeCommentPropertiesMigrationCommand.java
@@ -1,103 +1,138 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
-
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-
-/**
- *
- * Command to Migrate the StereotypeComment from old Structure (with EAnnotation) to the Structure with NamedStyle.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeCommentPropertiesMigrationCommand extends StereotypePropertiesMigrationCommand {
-
- /**
- * Constructor.
- *
- * @param label
- * Label of the Command
- * @param content
- * Main view on which the Stereotype is applied
- */
- public StereotypeCommentPropertiesMigrationCommand(String label, View content) {
- super(label, content);
-
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand#updateStereotypePropertyDisplay(org.eclipse.gmf.runtime.notation.View, java.lang.String, java.lang.Enum)
- *
- */
- @Override
- protected void updateStereotypePropertyDisplay(View view, String propertyList, Enum<?> location) {
- // In case of the Comment, the view will be the comment itself instead of the main View.
- if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
-
- View newComment = helper.getStereotypeComment(view);
- if (newComment != null) {
- super.updateStereotypePropertyDisplay(newComment, propertyList, location);
- setConstraint(view, newComment);
-
- }
- deleteOldComment(view);
- }
- }
-
- /**
- * @param view
- * @param newComment
- */
- private void setConstraint(final View view, final View newComment) {
- if (newComment instanceof Node) {
- View oldComment = migrationHelper.getOldStereotypeComment(view);
- if (oldComment instanceof Node) {
- ((Node) newComment).setLayoutConstraint(((Node) oldComment).getLayoutConstraint());
- }
- }
- }
-
- /**
- * @param view
- */
- private void deleteOldComment(final View hostView) {
- // Delete Comment from the Old Structure
-
- View oldComment = migrationHelper.getOldStereotypeComment(hostView);
- if (oldComment != null) {
- DeleteCommand deleteComment = new DeleteCommand(oldComment);
- CommandUtil.executeUnsafeCommand(deleteComment, hostView);
- }
- Edge oldLink = migrationHelper.getOldStereotypeLinkComment(hostView);
- if (oldLink != null) {
- DeleteCommand deleteLink = new DeleteCommand(oldLink);
- CommandUtil.executeUnsafeCommand(deleteLink, hostView);
- }
-
-
-
-
- }
-
-
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ *
+ * Command to Migrate the StereotypeComment from old Structure (with EAnnotation) to the Structure with NamedStyle.
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public class StereotypeCommentPropertiesMigrationCommand extends StereotypePropertiesMigrationCommand {
+ /**
+ * Boolean to delete the comment or not.
+ */
+ private boolean deleteOldComment;
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * Label of the Command
+ * @param content
+ * Main view on which the Stereotype is applied
+ */
+ public StereotypeCommentPropertiesMigrationCommand(final String label, final View content, final boolean deleteOldComment) {
+ super(label, content);
+ this.deleteOldComment = deleteOldComment;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand#updateStereotypePropertyDisplay(org.eclipse.gmf.runtime.notation.View, java.lang.String, java.lang.Enum)
+ *
+ */
+ @Override
+ protected void updateStereotypePropertyDisplay(final View view, final String propertyList, final Enum<?> location) {
+ // In case of the Comment, the view will be the comment itself instead of the main View.
+ if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
+ Node newComment = helper.getStereotypeComment(view);
+ if (null != newComment) {
+ super.updateStereotypePropertyDisplay(newComment, propertyList, location);
+ setConstraint(view, newComment);
+
+ Edge stereotypeCommentLink = getStereotypeCommentLink(view, newComment);
+ if (null != stereotypeCommentLink) {
+ setBendpointsAnchors(view, stereotypeCommentLink);
+ }
+ }
+ }
+
+ if (deleteOldComment) {
+ deleteOldComment(view);
+ }
+ }
+
+ /**
+ * Get the comment stereotype link related with the comment
+ *
+ * @param view
+ * @param newComment
+ * @return
+ */
+ private Edge getStereotypeCommentLink(final View view, final Node newComment) {
+ EList<Edge> targetEdges = newComment.getTargetEdges();
+ for (Edge edge : targetEdges) {
+ if (helper.isStereotypeCommentLink(edge)) {
+ if (edge.getSource().equals(view)) {
+ return edge;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param view
+ * @param newComment
+ */
+ private void setConstraint(final View view, final Node newComment) {
+ View oldComment = migrationHelper.getOldStereotypeComment(view);
+ if (oldComment instanceof Node) {
+ newComment.setLayoutConstraint(((Node) oldComment).getLayoutConstraint());
+ }
+ }
+
+ /**
+ * To set the Bendpoints and the anchors (source and target) to the created comment link
+ *
+ * @param view
+ * @param edge
+ */
+ private void setBendpointsAnchors(final View view, final Edge edge) {
+ Edge oldStereotypeLinkComment = migrationHelper.getOldStereotypeLinkComment(view);
+ if (null != oldStereotypeLinkComment) {
+ edge.setBendpoints(oldStereotypeLinkComment.getBendpoints());
+ edge.setSourceAnchor(oldStereotypeLinkComment.getSourceAnchor());
+ edge.setTargetAnchor(oldStereotypeLinkComment.getTargetAnchor());
+ }
+ }
+
+ /**
+ * @param view
+ */
+ private void deleteOldComment(final View hostView) {
+ // Delete Comment from the Old Structure
+ View oldComment = migrationHelper.getOldStereotypeComment(hostView);
+ if (oldComment != null) {
+ DeleteCommand deleteComment = new DeleteCommand(oldComment);
+ CommandUtil.executeUnsafeCommand(deleteComment, hostView);
+ }
+ Edge oldLink = migrationHelper.getOldStereotypeLinkComment(hostView);
+ if (oldLink != null) {
+ DeleteCommand deleteLink = new DeleteCommand(oldLink);
+ CommandUtil.executeUnsafeCommand(deleteLink, hostView);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeLabelMigrationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeLabelMigrationCommand.java
index ae9b3fd2193..ad4bf7be336 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeLabelMigrationCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeLabelMigrationCommand.java
@@ -1,249 +1,247 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST, Christian W. Damus, 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Displays
- * Christian W. Damus - bug 466629
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
-
-import java.util.Iterator;
-import java.util.StringTokenizer;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.StereotypeViewProvider;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Command applies the user preferences for the Stereotype Label
- * In charge of check the visibility, depth and persistence based on the Old EAnnotation
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeLabelMigrationCommand implements Runnable {
-
- // String Constant
- private static final String EANNOTATION_LIST_SEPARATOR = ","; //$NON-NLS-1$
- private static final String QUALIFIED_NAME_DEPTH = "full"; //$NON-NLS-1$
-
-
- private View mainView;
-
- // Static Instances of helpers and providers
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
- private IStereotypeViewProvider provider;
-
-
- /**
- * Constructor.
- *
- * @param label
- * The Label of the Command
- * @param content
- * The View of the element that is migrated.
- */
- public StereotypeLabelMigrationCommand(String label, View content) {
-
- this.mainView = content;
-
- }
-
-
- /**
- * Migrate the Stereotype Label from the old Version.
- *
- * @param View
- * The element of the diagram to migrate
- */
- protected void migrateStereotypeLabel(View view) {
- // Create the provider
- setProvider(view);
-
- if (migrationHelper.hasStereotypeEAnnotation(view)) {
-
- // Update Visibility
- String oldStereotype = getOldStereotypeToDisplay(view);
- updateNewStereotypeVisibility(view, oldStereotype);
-
- // Update Depth
- String oldQNStereotype = getOldQNStereotypeToDisplay(view);
- updateNewStereotypeDepth(view, oldQNStereotype);
-
- }
- }
-
- /**
- * From the Stereotype List to display with they Qualified Name, update the Depth to full
- *
- * @param view
- * The view of the object to migrate
- * @param stereotypeList
- * List of Stereotype to display with their Qualified Name
- */
- protected void updateNewStereotypeDepth(View view, String stereotypeList) {
- StringTokenizer tokenizer = new StringTokenizer(stereotypeList, EANNOTATION_LIST_SEPARATOR);
-
- while (tokenizer.hasMoreTokens()) {
- String stereotypeName = tokenizer.nextToken();
- View label = helper.getStereotypeLabel(view, stereotypeName);
- if (label != null) {
- commandHelper.setDepth(migrationHelper.getDomain(view), migrationHelper.getStereotypeFromString(view, stereotypeName), view, QUALIFIED_NAME_DEPTH, false);
- }
- }
- }
-
-
- /**
- * From the Stereotype List to display , update the Visibility to true
- * And hide visible Stereotype Label that should not be shown.
- *
- * @param view
- * The view of the object to migrate
- * @param stereotypeList
- * List of Stereotype to display
- */
- protected void updateNewStereotypeVisibility(View view, String stereotypeList) {
-
- // Hide all the Label displayed but that should not to be shown
- hideStereotypeLabelNotDisplayed(stereotypeList, view);
-
- }
-
-
- /**
- * Show each Stereotype from the Stereotype to display list.
- *
- * @param stereotypeList
- * The list of stereotype to display
- * @param view
- * The view of the object that is migrated
- */
- private void showStereotypeLabelToBeDisplayed(String stereotypeList, View view) {
- StringTokenizer tokenizer = new StringTokenizer(stereotypeList, EANNOTATION_LIST_SEPARATOR);
- while (tokenizer.hasMoreTokens()) {
- String stereotypeName = tokenizer.nextToken();
- showStereotypeLabel(view, stereotypeName);
- }
-
- }
-
- /**
- * Show the Label To display.
- * Updating Visibility and Persistence
- *
- * @param view
- * The view of the object to migrate
- * @param stereotypeList
- * List of Stereotype to display
- */
- protected void showStereotypeLabel(View view, String stereotypeName) {
- View label = provider.getLabel(migrationHelper.getStereotypeFromString(view, stereotypeName));
- if (label != null) {
- migrationHelper.updateVisibilityAndPersistence(label, view, true);
- }
- }
-
-
- /**
- * Hide visible Stereotype Label that should not be shown.
- * List all the applied Stereotypes, if the applied stereotype is not in the Stereotype to Display list,
- * hide the Node.
- *
- * @param view
- * The view of the object to migrate
- * @param stereotypeList
- * List of Stereotype to display
- */
- private void hideStereotypeLabelNotDisplayed(String stereotypeList, View view) {
- EList<Stereotype> appliedStereotypes = migrationHelper.getAppliedStereotypesFromView(view);
- Iterator<Stereotype> stereotypes = appliedStereotypes.iterator();
- while (stereotypes.hasNext()) {
- String stereotypeName = stereotypes.next().getQualifiedName();
- if (stereotypeList.indexOf(stereotypeName) == -1) {
- hideStereotypeLabel(view, stereotypeName);
- }
- }
- }
-
-
-
-
- /**
- * Hide the Stereotype Label
- *
- * @param view
- * The view of the object that is migrated
- * @param stereotypeName
- * Name of the Stereotype of which the Label should be hidden
- */
- private void hideStereotypeLabel(View view, String stereotypeName) {
- View label = provider.getLabel(migrationHelper.getStereotypeFromString(view, stereotypeName));
- migrationHelper.updateVisibilityAndPersistence(label, mainView, false);
-
- }
-
-
- /**
- * Get List of Stereotype to display with their Qualified Name from the EAnnotation.
- *
- * @param view
- * The view of the object to migrate
- * @return The List of Stereotype to display with their Qualified Name
- */
- protected String getOldQNStereotypeToDisplay(View view) {
- return migrationHelper.getStereotypesQNToDisplay(view);
- }
-
-
- /**
- * Get List of Stereotype to display from the EAnnotation.
- *
- * @param view
- * The view of the object to migrate
- * @return The List of Stereotype to display
- */
- protected String getOldStereotypeToDisplay(View view) {
-
- return migrationHelper.getStereotypesToDisplay(view);
- }
-
- /**
- * Create the provider
- *
- * @param view
- * The view on which stereotypes is applied and from which the Stereotype Views will be provided
- */
- private void setProvider(View view) {
- provider = new StereotypeViewProvider(view);
-
- }
-
-
- /**
- * @see java.lang.Runnable#run()
- *
- */
- @Override
- public void run() {
- migrateStereotypeLabel(mainView);
-
- }
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST, Christian W. Damus, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Displays
+ * Christian W. Damus - bug 466629
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.StereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * This Command applies the user preferences for the Stereotype Label
+ * In charge of check the visibility, depth and persistence based on the Old EAnnotation
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public class StereotypeLabelMigrationCommand extends AbstractTransactionalCommand {
+
+ // String Constant
+ private static final String QUALIFIED_NAME_DEPTH = "full"; //$NON-NLS-1$
+
+ private final View mainView;
+
+ // Static Instances of helpers and providers
+ private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+ private static StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+ private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
+ private IStereotypeViewProvider provider;
+
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * The Label of the Command
+ * @param content
+ * The View of the element that is migrated.
+ */
+ public StereotypeLabelMigrationCommand(final String label, final View content) {
+ super(migrationHelper.getDomain(content), label, null);
+ this.mainView = content;
+ }
+
+ /**
+ * Migrate the Stereotype Label from the old Version.
+ *
+ * @param View
+ * The element of the diagram to migrate
+ */
+ protected void migrateStereotypeLabel(final View view) {
+ // Create the provider
+ setProvider(view);
+
+ if (migrationHelper.hasStereotypeEAnnotation(view)) {
+
+ // Update Visibility
+ String oldStereotype = getOldStereotypeToDisplay(view);
+ updateNewStereotypeVisibility(view, oldStereotype);
+
+ // Update Depth
+ String oldQNStereotype = getOldQNStereotypeToDisplay(view);
+ updateNewStereotypeDepth(view, oldQNStereotype);
+
+ }
+ }
+
+ /**
+ * From the Stereotype List to display with they Qualified Name, update the Depth to full
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param stereotypeList
+ * List of Stereotype to display with their Qualified Name
+ */
+ protected void updateNewStereotypeDepth(final View view, final String stereotypeList) {
+ StringTokenizer tokenizer = new StringTokenizer(stereotypeList, StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR);
+
+ while (tokenizer.hasMoreTokens()) {
+ String stereotypeName = tokenizer.nextToken();
+ View label = helper.getStereotypeLabel(view, stereotypeName);
+ if (label != null) {
+ commandHelper.setDepth(migrationHelper.getDomain(view), migrationHelper.getStereotypeFromString(view, stereotypeName), view, QUALIFIED_NAME_DEPTH, false);
+ }
+ }
+ }
+
+
+ /**
+ * From the Stereotype List to display , update the Visibility to true
+ * And hide visible Stereotype Label that should not be shown.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param stereotypeList
+ * List of Stereotype to display
+ */
+ protected void updateNewStereotypeVisibility(final View view, final String stereotypeList) {
+
+ // Hide all the Label displayed but that should not to be shown
+ hideStereotypeLabelNotDisplayed(stereotypeList, view);
+
+ }
+
+
+ /**
+ * Show each Stereotype from the Stereotype to display list.
+ *
+ * @param stereotypeList
+ * The list of stereotype to display
+ * @param view
+ * The view of the object that is migrated
+ */
+ private void showStereotypeLabelToBeDisplayed(final String stereotypeList, final View view) {
+ StringTokenizer tokenizer = new StringTokenizer(stereotypeList, StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR);
+ while (tokenizer.hasMoreTokens()) {
+ String stereotypeName = tokenizer.nextToken();
+ showStereotypeLabel(view, stereotypeName);
+ }
+ }
+
+ /**
+ * Show the Label To display.
+ * Updating Visibility and Persistence
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param stereotypeList
+ * List of Stereotype to display
+ */
+ protected void showStereotypeLabel(final View view, final String stereotypeName) {
+ View label = provider.getLabel(migrationHelper.getStereotypeFromString(view, stereotypeName));
+ if (label != null) {
+ migrationHelper.updateVisibilityAndPersistence(label, view, true);
+ }
+ }
+
+
+ /**
+ * Hide visible Stereotype Label that should not be shown.
+ * List all the applied Stereotypes, if the applied stereotype is not in the Stereotype to Display list,
+ * hide the Node.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param stereotypeList
+ * List of Stereotype to display
+ */
+ private void hideStereotypeLabelNotDisplayed(final String stereotypeList, final View view) {
+ EList<Stereotype> appliedStereotypes = migrationHelper.getAppliedStereotypesFromView(view);
+ Iterator<Stereotype> stereotypes = appliedStereotypes.iterator();
+ while (stereotypes.hasNext()) {
+ String stereotypeName = stereotypes.next().getQualifiedName();
+ if (stereotypeList.indexOf(stereotypeName) == -1) {
+ hideStereotypeLabel(view, stereotypeName);
+ }
+ }
+ }
+
+
+
+
+ /**
+ * Hide the Stereotype Label
+ *
+ * @param view
+ * The view of the object that is migrated
+ * @param stereotypeName
+ * Name of the Stereotype of which the Label should be hidden
+ */
+ private void hideStereotypeLabel(final View view, final String stereotypeName) {
+ View label = provider.getLabel(migrationHelper.getStereotypeFromString(view, stereotypeName));
+ migrationHelper.updateVisibilityAndPersistence(label, mainView, false);
+
+ }
+
+
+ /**
+ * Get List of Stereotype to display with their Qualified Name from the EAnnotation.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @return The List of Stereotype to display with their Qualified Name
+ */
+ protected String getOldQNStereotypeToDisplay(final View view) {
+ return migrationHelper.getStereotypesQNToDisplay(view);
+ }
+
+
+ /**
+ * Get List of Stereotype to display from the EAnnotation.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @return The List of Stereotype to display
+ */
+ protected String getOldStereotypeToDisplay(final View view) {
+
+ return migrationHelper.getStereotypesToDisplay(view);
+ }
+
+ /**
+ * Create the provider
+ *
+ * @param view
+ * The view on which stereotypes is applied and from which the Stereotype Views will be provided
+ */
+ private void setProvider(final View view) {
+ provider = new StereotypeViewProvider(view);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) throws ExecutionException {
+ migrateStereotypeLabel(mainView);
+ return CommandResult.newOKCommandResult();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeNestedPropertiesMigrationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeNestedPropertiesMigrationCommand.java
index 6d85814a7b4..65603b5d181 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeNestedPropertiesMigrationCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypeNestedPropertiesMigrationCommand.java
@@ -1,61 +1,61 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
-
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-
-/**
- * Command in charge of applying user preferences of stereotype display from the old EANnotation structure to the new one.
- * For the Properties EAnnotation details.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeNestedPropertiesMigrationCommand extends StereotypePropertiesMigrationCommand {
-
- /**
- * Constructor.
- *
- * @param label
- * Command Label
- * @param content
- * View on which the Stereotype is applied.
- */
- public StereotypeNestedPropertiesMigrationCommand(String label, View content) {
- super(label, content);
-
- }
-
-
- /**
- *
- * In this case, the Old structure return "Compartment" as in the new one the properties are stored in the "Brace" location.
- *
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand#getLocation(java.lang.String)
- *
- */
- @Override
- public Enum getLocation(String oldProperties) {
- Enum location = StereotypeLocationEnum.IN_BRACE;
- if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
- location = StereotypeLocationEnum.IN_BRACE;
- } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION)) {
- location = StereotypeLocationEnum.IN_BRACE;
- }
- return location;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+
+/**
+ * Command in charge of applying user preferences of stereotype display from the old EANnotation structure to the new one.
+ * For the Properties EAnnotation details.
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public class StereotypeNestedPropertiesMigrationCommand extends StereotypePropertiesMigrationCommand {
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * Command Label
+ * @param content
+ * View on which the Stereotype is applied.
+ */
+ public StereotypeNestedPropertiesMigrationCommand(final String label, final View content) {
+ super(label, content);
+
+ }
+
+
+ /**
+ *
+ * In this case, the Old structure return "Compartment" as in the new one the properties are stored in the "Brace" location.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand#getLocation(java.lang.String)
+ *
+ */
+ @Override
+ public Enum getLocation(final String oldProperties) {
+ Enum location = StereotypeLocationEnum.IN_BRACE;
+ if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
+ location = StereotypeLocationEnum.IN_BRACE;
+ } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION)) {
+ location = StereotypeLocationEnum.IN_BRACE;
+ }
+ return location;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypePropertiesMigrationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypePropertiesMigrationCommand.java
index 58ca41b722b..63dfb99c9b4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypePropertiesMigrationCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypePropertiesMigrationCommand.java
@@ -1,315 +1,310 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST, Christian W. Damus, 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- * Christian W. Damus - bug 466629
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
-
-import java.util.Iterator;
-import java.util.StringTokenizer;
-
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.StereotypeViewProvider;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * In charge of applying user preferences from the old EAnnotation structure to the new one
- * For Stereotypes Properties
- * This means set visibility to the newly created views .
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypePropertiesMigrationCommand implements Runnable {
-
- protected View mainView;
-
- private IStereotypeViewProvider provider;
-
- // Helpers
- protected static final StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
- protected static final StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
-
- // Constant
- protected final static String EANNOTATION_LIST_SEPARATOR = ","; //$NON-NLS-1$
- protected final static String EANNOTATION_PROPERTY_SEPARATOR = "."; //$NON-NLS-1$
- protected final static String EMPTY_STRING = "";//$NON-NLS-1$
-
- /**
- * Constructor.
- *
- * @param label
- * Label of the Command
- * @param content
- * Main view on which the Stereotype is applied
- */
- public StereotypePropertiesMigrationCommand(String label, View content) {
-
- this.mainView = content;
- }
-
-
-
- /**
- * Migrate the Stereotype Properties from the old Version.
- *
- * @param view
- * View of the Editpart on which the STereotype is applied
- */
- protected void migrateStereotypeProperties(View view) {
-
- createProvider(view);
- if (migrationHelper.hasStereotypeEAnnotation(view)) {
- String oldProperties = getOldPropertiesToDisplay(view);
- String oldPropertiesLocation = getOldLocationToDisplay(view);
- Enum<?> location = getLocation(oldPropertiesLocation);
- updateStereotypePropertyDisplay(view, oldProperties, location);
-
- }
- }
-
-
- /**
- * Convert the EAnnotation Location to the Property Location to display.
- * Can be extended.
- */
- public Enum<?> getLocation(String oldProperties) {
- Enum<?> location = StereotypeLocationEnum.IN_BRACE;
- if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
- location = StereotypeLocationEnum.IN_COMPARTMENT;
- } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION)) {
- location = StereotypeLocationEnum.IN_BRACE;
- } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION)) {
- location = StereotypeLocationEnum.IN_COMMENT;
- }
- return location;
- }
-
- /**
- * Create the Provider with the associated View
- *
- * @param view
- * The View of the object that will be taken as Reference to provide the different Stereotype to display View.
- */
- protected void createProvider(View view) {
- provider = new StereotypeViewProvider(view);
-
- }
-
-
- /**
- * From the Stereotype Property List to display , update the Visibility
- * And hide visible Stereotype property that should not be shown.
- *
- * @param view
- * The view of the object to migrate
- * @param propertyList
- * List of property to display
- * @param location
- * The Location of the Properties to be displayed or hidden.
- */
- protected void updateStereotypePropertyDisplay(View view, String propertyList, Enum<?> location) {
-
- // Show all the properties that should be displayed
- showStereotypePropertyToBeDisplayed(propertyList, view, location);
-
- }
-
- /**
- * Show all the Properties from the Properties List and their location
- *
- * @param propertyList
- * List of properties (ie: "SysML::Blocks::Block.isEncapsulated,SysML::Requirement::Requirement.id")
- * @param view
- * The View of the Object migrated (ie: CSSShapeImpl)
- * @param location
- * Place of the the property to be shown: {@link StereotypeLocationEnum}
- */
- private void showStereotypePropertyToBeDisplayed(String propertyList, View view, Enum<?> location) {
- StringTokenizer tokenizer = new StringTokenizer(propertyList, EANNOTATION_LIST_SEPARATOR);
- while (tokenizer.hasMoreTokens()) {
-
- String propertyString = tokenizer.nextToken();
- Stereotype stereoytpe = getStereotypeFromString(view, propertyString);
- if (stereoytpe != null) {
- Property property = getPropertyFromString(view, propertyString, stereoytpe);
- showStereotypeProperty(view, stereoytpe, property, location);
- }
- }
-
- }
-
- /**
- * Show the property and related Location Compartment to display
- *
- * @param view
- * The Main View on which the stereotype is applied.
- * @param location
- * The location of the Property to show (Compartment, Comment, With Brace)
- * @param stereotype
- * The Stereotype of the Property to show
- * @param property
- * UML Property to show
- */
- private void showStereotypeProperty(View view, Stereotype stereotype, Property property, Enum<?> location) {
- // Make The main View visible (Required for the Comment )
- migrationHelper.updateVisibilityAndPersistence(view, view, true);
-
- // Make The compartment owning the property visible
- View compartment = provider.getCompartment(stereotype, location);
- migrationHelper.updateVisibilityAndPersistence(compartment, view, true);
-
- // Make the properties node into the Compartment visible
- View propertyView = provider.getProperty(property, stereotype, location);
- migrationHelper.updateVisibilityAndPersistence(propertyView, view, true);
-
- }
-
-
-
- /**
- * Hide visible Properties that should not be shown.
- * List all the applied Stereotypes and their Properties, if the property is not in the property to Display list,
- * hide the Node.
- *
- * @param view
- * The view of the object to migrate
- * @param stereotypeList
- * List of Stereotype to display
- */
- private void hideStereotypePropertyNotDisplayed(String propertyList, View view, Enum<?> location) {
-
- // If applied Stereotype is not in the Stereotype list to display, set the visibility to false to hide the Label.
- Iterator<Stereotype> stereotypes = migrationHelper.getAppliedStereotypesFromView(view).iterator();
- while (stereotypes.hasNext()) {
- Stereotype stereotype = stereotypes.next();
- hideStereotypeProperties(stereotype, propertyList, location);
-
- }
- }
-
-
- /**
- * Hide the Properties from the properties list, location and Stereotypes
- *
- * @param stereotype
- * The Stereotype of which the Properties should be hidden
- * @param propertyList
- * The list of all the properties to be displayed
- * @param location
- * The location of the Properties to be hidden
- */
- private void hideStereotypeProperties(Stereotype stereotype, String propertyList, Enum<?> location) {
- for (Property property : stereotype.allAttributes()) {
- if (propertyList.indexOf(property.getName()) == -1) {
-
- // Create the Property view if not existing and Make the properties node into the Compartment visible
- hideStereotypeProperty(property, stereotype, location);
- }
- }
-
- }
-
- /**
- * Hide a single property View based on the stereotype and the location.
- *
- * @param property
- * The property to hide
- * @param stereotype
- * The stereotype of the property to hide
- * @param location
- * the location of the property to hide
- */
- private void hideStereotypeProperty(Property property, Stereotype stereotype, Enum<?> location) {
- View compartment = provider.getCompartment(stereotype, location);
- if (compartment != null) {
- View propertyView = provider.getProperty(property, stereotype, location);
- if (propertyView != null) {
- migrationHelper.updateVisibilityAndPersistence(propertyView, mainView, false);
- }
- }
-
- }
-
- /**
- * Get the property from String
- *
- * @param view
- * The Main View on which the stereotype is applied.
- * @param propertyString
- * the substring from the Old Version (I.e: "SysML::Blocks::Block.isEncapsulate")
- * @return The corresponding UML property
- */
- private Property getPropertyFromString(View view, String propertyString, Stereotype stereotype) {
- String propertyName = propertyString.substring(propertyString.indexOf(EANNOTATION_PROPERTY_SEPARATOR) + 1, propertyString.length());
- return migrationHelper.getPropertyFromString(view, stereotype, propertyName);
- }
-
-
- /**
- * Get the stereotype from String
- *
- * @param view
- * The Main View on which the stereotype is applied.
- * @param propertyString
- * the substring from the Old Version (I.e: "SysML::Blocks::Block")
- * @return The corresponding UML Stereotype
- */
- private Stereotype getStereotypeFromString(View view, String propertyString) {
- String qualifiedName = propertyString.substring(0, propertyString.indexOf(EANNOTATION_PROPERTY_SEPARATOR));
- return migrationHelper.getStereotypeFromString(view, qualifiedName);
-
- }
-
-
- /**
- * Get the EAnnotation Detail value for the properties Location.
- *
- * @param view
- * The view on which the stereotype is applied
- * @return Location value
- */
- protected String getOldLocationToDisplay(View view) {
- return migrationHelper.getAppliedStereotypesPropertiesLocalization(view);
- }
-
-
- /**
- * Get the EAnnotation Detail value for the Property list to displayed
- *
- * @param view
- * The view on which the stereotype is applied
- * @return The list of the properties to be displayed
- */
- protected String getOldPropertiesToDisplay(View view) {
- return migrationHelper.getAppliedStereotypesPropertiesToDisplay(view);
- }
-
-
- /**
- * @see java.lang.Runnable#run()
- *
- */
- @Override
- public void run() {
- migrateStereotypeProperties(mainView);
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST, Christian W. Damus, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Christian W. Damus - bug 466629
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.StereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * In charge of applying user preferences from the old EAnnotation structure to the new one
+ * For Stereotypes Properties
+ * This means set visibility to the newly created views .
+ *
+ */
+public class StereotypePropertiesMigrationCommand extends AbstractTransactionalCommand {
+
+ protected View mainView;
+
+ private IStereotypeViewProvider provider;
+
+ // Helpers
+ protected static final StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+ protected static final StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * Label of the Command
+ * @param content
+ * Main view on which the Stereotype is applied
+ */
+ public StereotypePropertiesMigrationCommand(final String label, final View content) {
+ super(migrationHelper.getDomain(content), label, null);
+ this.mainView = content;
+ }
+
+ /**
+ * Migrate the Stereotype Properties from the old Version.
+ *
+ * @param view
+ * View of the Editpart on which the STereotype is applied
+ */
+ protected void migrateStereotypeProperties(final View view) {
+
+ createProvider(view);
+ if (migrationHelper.hasStereotypeEAnnotation(view)) {
+ String oldProperties = getOldPropertiesToDisplay(view);
+ String oldPropertiesLocation = getOldLocationToDisplay(view);
+ Enum<?> location = getLocation(oldPropertiesLocation);
+ updateStereotypePropertyDisplay(view, oldProperties, location);
+
+ }
+ }
+
+
+ /**
+ * Convert the EAnnotation Location to the Property Location to display.
+ * Can be extended.
+ */
+ public Enum<?> getLocation(final String oldProperties) {
+ Enum<?> location = StereotypeLocationEnum.IN_BRACE;
+ if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION)) {
+ location = StereotypeLocationEnum.IN_COMPARTMENT;
+ } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION)) {
+ location = StereotypeLocationEnum.IN_BRACE;
+ } else if (oldProperties.equals(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION)) {
+ location = StereotypeLocationEnum.IN_COMMENT;
+ }
+ return location;
+ }
+
+ /**
+ * Create the Provider with the associated View
+ *
+ * @param view
+ * The View of the object that will be taken as Reference to provide the different Stereotype to display View.
+ */
+ protected void createProvider(final View view) {
+ provider = new StereotypeViewProvider(view);
+
+ }
+
+
+ /**
+ * From the Stereotype Property List to display , update the Visibility
+ * And hide visible Stereotype property that should not be shown.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param propertyList
+ * List of property to display
+ * @param location
+ * The Location of the Properties to be displayed or hidden.
+ */
+ protected void updateStereotypePropertyDisplay(final View view, final String propertyList, final Enum<?> location) {
+ // Show all the properties that should be displayed
+ showStereotypePropertyToBeDisplayed(propertyList, view, location);
+ }
+
+ /**
+ * Show all the Properties from the Properties List and their location
+ *
+ * @param propertyList
+ * List of properties (ie: "SysML::Blocks::Block.isEncapsulated,SysML::Requirement::Requirement.id")
+ * @param view
+ * The View of the Object migrated (ie: CSSShapeImpl)
+ * @param location
+ * Place of the the property to be shown: {@link StereotypeLocationEnum}
+ */
+ private void showStereotypePropertyToBeDisplayed(final String propertyList, final View view, final Enum<?> location) {
+ StringTokenizer tokenizer = new StringTokenizer(propertyList, StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR);
+ while (tokenizer.hasMoreTokens()) {
+
+ String propertyString = tokenizer.nextToken();
+ Stereotype stereoytpe = getStereotypeFromString(view, propertyString);
+ if (stereoytpe != null) {
+ Property property = getPropertyFromString(view, propertyString, stereoytpe);
+ showStereotypeProperty(view, stereoytpe, property, location);
+ }
+ }
+
+ }
+
+ /**
+ * Show the property and related Location Compartment to display
+ *
+ * @param view
+ * The Main View on which the stereotype is applied.
+ * @param location
+ * The location of the Property to show (Compartment, Comment, With Brace)
+ * @param stereotype
+ * The Stereotype of the Property to show
+ * @param property
+ * UML Property to show
+ */
+ private void showStereotypeProperty(final View view, final Stereotype stereotype, final Property property, final Enum<?> location) {
+ // Make The main View visible (Required for the Comment )
+ migrationHelper.updateVisibilityAndPersistence(view, view, true);
+
+ // Make The compartment owning the property visible
+ View compartment = provider.getCompartment(stereotype, location);
+ migrationHelper.updateVisibilityAndPersistence(compartment, view, true);
+
+ // Make the properties node into the Compartment visible
+ View propertyView = provider.getProperty(property, stereotype, location);
+ migrationHelper.updateVisibilityAndPersistence(propertyView, view, true);
+
+ }
+
+
+
+ /**
+ * Hide visible Properties that should not be shown.
+ * List all the applied Stereotypes and their Properties, if the property is not in the property to Display list,
+ * hide the Node.
+ *
+ * @param view
+ * The view of the object to migrate
+ * @param stereotypeList
+ * List of Stereotype to display
+ */
+ private void hideStereotypePropertyNotDisplayed(final String propertyList, final View view, final Enum<?> location) {
+ // If applied Stereotype is not in the Stereotype list to display, set the visibility to false to hide the Label.
+ EList<Stereotype> appliedStereotypesFromView = migrationHelper.getAppliedStereotypesFromView(view);
+ if (null != appliedStereotypesFromView) {
+ Iterator<Stereotype> stereotypes = appliedStereotypesFromView.iterator();
+ while (stereotypes.hasNext()) {
+ Stereotype stereotype = stereotypes.next();
+ hideStereotypeProperties(stereotype, propertyList, location);
+ }
+ }
+ }
+
+
+ /**
+ * Hide the Properties from the properties list, location and Stereotypes
+ *
+ * @param stereotype
+ * The Stereotype of which the Properties should be hidden
+ * @param propertyList
+ * The list of all the properties to be displayed
+ * @param location
+ * The location of the Properties to be hidden
+ */
+ private void hideStereotypeProperties(final Stereotype stereotype, final String propertyList, final Enum<?> location) {
+ for (Property property : stereotype.allAttributes()) {
+ if (propertyList.indexOf(property.getName()) == -1) {
+
+ // Create the Property view if not existing and Make the properties node into the Compartment visible
+ hideStereotypeProperty(property, stereotype, location);
+ }
+ }
+
+ }
+
+ /**
+ * Hide a single property View based on the stereotype and the location.
+ *
+ * @param property
+ * The property to hide
+ * @param stereotype
+ * The stereotype of the property to hide
+ * @param location
+ * the location of the property to hide
+ */
+ private void hideStereotypeProperty(final Property property, final Stereotype stereotype, final Enum<?> location) {
+ View compartment = provider.getCompartment(stereotype, location);
+ if (compartment != null) {
+ View propertyView = provider.getProperty(property, stereotype, location);
+ if (propertyView != null) {
+ migrationHelper.updateVisibilityAndPersistence(propertyView, mainView, false);
+ }
+ }
+
+ }
+
+ /**
+ * Get the property from String
+ *
+ * @param view
+ * The Main View on which the stereotype is applied.
+ * @param propertyString
+ * the substring from the Old Version (I.e: "SysML::Blocks::Block.isEncapsulate")
+ * @return The corresponding UML property
+ */
+ private Property getPropertyFromString(final View view, final String propertyString, final Stereotype stereotype) {
+ String propertyName = propertyString.substring(propertyString.indexOf(StereotypeDisplayMigrationConstant.EANNOTATION_PROPERTY_SEPARATOR) + 1, propertyString.length());
+ return migrationHelper.getPropertyFromString(view, stereotype, propertyName);
+ }
+
+
+ /**
+ * Get the stereotype from String
+ *
+ * @param view
+ * The Main View on which the stereotype is applied.
+ * @param propertyString
+ * the substring from the Old Version (I.e: "SysML::Blocks::Block")
+ * @return The corresponding UML Stereotype
+ */
+ private Stereotype getStereotypeFromString(final View view, final String propertyString) {
+ String qualifiedName = propertyString.substring(0, propertyString.indexOf(StereotypeDisplayMigrationConstant.EANNOTATION_PROPERTY_SEPARATOR));
+ return migrationHelper.getStereotypeFromString(view, qualifiedName);
+
+ }
+
+
+ /**
+ * Get the EAnnotation Detail value for the properties Location.
+ *
+ * @param view
+ * The view on which the stereotype is applied
+ * @return Location value
+ */
+ protected String getOldLocationToDisplay(final View view) {
+ return migrationHelper.getAppliedStereotypesPropertiesLocalization(view);
+ }
+
+
+ /**
+ * Get the EAnnotation Detail value for the Property list to displayed
+ *
+ * @param view
+ * The view on which the stereotype is applied
+ * @return The list of the properties to be displayed
+ */
+ protected String getOldPropertiesToDisplay(final View view) {
+ return migrationHelper.getAppliedStereotypesPropertiesToDisplay(view);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) throws ExecutionException {
+ migrateStereotypeProperties(mainView);
+ return CommandResult.newOKCommandResult();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesAppliedCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesAppliedCommand.java
new file mode 100644
index 00000000000..99f129c550c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesAppliedCommand.java
@@ -0,0 +1,387 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.BasicCompartment;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.StereotypeViewProvider;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypeCommentViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypeCompartmentCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypePropertyViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateStereotypeLabelCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * Command to create the structure of all the application of stereotypes.
+ */
+public class StereotypesAppliedCommand extends AbstractTransactionalCommand {
+ protected Diagram diagram;
+ protected View currentView;
+
+ protected IStereotypeViewProvider provider;
+
+ /*
+ * Helpers
+ */
+ protected StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+ protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ /*
+ * Constants
+ */
+
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * @param diagram
+ */
+ public StereotypesAppliedCommand(final TransactionalEditingDomain domain, final Diagram diagram) {
+ super(domain, "Stereotypes Applied", null); ////$NON-NLS-1$
+ this.diagram = diagram;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) {
+ TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+
+ while (allContentIterator.hasNext()) {
+ EObject eObject = allContentIterator.next();
+ if (eObject instanceof View) {
+ final View view = (View) eObject;
+
+ if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation(view)) {
+ if (null != view.getElement()) {
+ currentView = view;
+ provider = new StereotypeViewProvider(view);
+
+ List<Stereotype> allStereotypes = getAllStereotypes();
+ if (!allStereotypes.isEmpty()) {
+ /*
+ * Label
+ */
+ for (Stereotype stereotype : allStereotypes) {
+ createAppliedLabelStereotype(view, stereotype);
+ }
+
+ /*
+ * StereotypePropertyLocation
+ */
+ String appliedStereotypesPropertiesLocalization = migrationHelper.getAppliedStereotypesPropertiesLocalization(view);
+
+ /*
+ * StereotypePropertyLocation : Compartment
+ */
+ if (StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION.equals(appliedStereotypesPropertiesLocalization)) {
+ for (Stereotype stereotype : allStereotypes) {
+ createAppliedCompartmentStereotype(stereotype);
+ }
+
+ /*
+ * StereotypePropertyLocation : Brace
+ */
+ } else if (StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION.equals(appliedStereotypesPropertiesLocalization)) {
+ for (Stereotype stereotype : allStereotypes) {
+ createAppliedBraceCompartmentStereotype(stereotype);
+ }
+
+ }
+ /*
+ * Always Create Comment and CommentLink but not displayed
+ */
+ createComment(allStereotypes);
+ }
+ }
+ }
+ }
+ }
+
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * To create the comment.
+ *
+ * @param stereotypes
+ */
+ private void createComment(final List<Stereotype> stereotypes) {
+ Node comment = helper.getStereotypeComment(currentView);
+ String appliedStereotypesLocalization = migrationHelper.getAppliedStereotypesPropertiesLocalization(currentView);
+
+ TransactionalEditingDomain currentDomain = getEditingDomain();
+ if (null == comment) {
+ // if Comment doesn't exist => Create it and copy the structure from the host
+ CreateAppliedStereotypeCommentViewCommand command = new CreateAppliedStereotypeCommentViewCommand(currentDomain, currentView, 200, 100, currentView.getElement(), false);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ comment = helper.getStereotypeComment(currentView);
+
+ }
+ if (comment != null) {
+ for (Stereotype stereotype : stereotypes) {
+ BasicCompartment compartmentStructure = helper.getStereotypeCompartment(comment, stereotype);
+ if (compartmentStructure == null) { // No Compartment Exist for this Stereotype
+ if (!helper.isCompartmentExist(comment, stereotype)) {
+ // Create Compartment
+ CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(currentDomain, comment, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+ }
+ compartmentStructure = helper.getStereotypeCompartment(comment, stereotype);
+ if (null != compartmentStructure && null != stereotype) {
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isPropertyExist(compartmentStructure, property)) {
+ // go through each stereotype property
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(currentDomain, compartmentStructure, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+ }
+ }
+ }
+
+ BasicCompartment braceStructure = helper.getStereotypeCompartment(comment, stereotype);
+ if (braceStructure == null) { // No Label Exist for this Stereotype
+ // doesn't exist already
+ if (!helper.isCompartmentExist(comment, stereotype)) {
+ // Create Compartment
+ CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(currentDomain, comment, stereotype, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+
+ }
+ braceStructure = helper.getStereotypeBraceCompartment(comment, stereotype);
+ if (braceStructure != null && stereotype != null) {
+
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isBracePropertyExist(braceStructure, property)) {
+ // go through each stereotype property
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(currentDomain, braceStructure, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_BRACE_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(appliedStereotypesLocalization)) {
+ hideStereotypePropertiesNotDisplayed(StereotypeLocationEnum.IN_COMMENT);
+ }
+ }
+ }
+
+ /**
+ * Get all the stereotypes applied on the view.
+ *
+ * @return The list of stereotypes.
+ */
+ private List<Stereotype> getAllStereotypes() {
+ List<Stereotype> stereotypes = new ArrayList<Stereotype>();
+ // Get the stereotype on the stereotype list
+ String stereotypesToDisplay = migrationHelper.getStereotypesToDisplay(currentView);
+ if (!StereotypeMigrationHelper.EMPTY_STRING.equals(stereotypesToDisplay)) {
+ String[] split = stereotypesToDisplay.split(StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR);
+ for (String stereotypeString : split) {
+ Stereotype stereotypeFromString = migrationHelper.getStereotypeFromString(currentView, stereotypeString);
+ if (null != stereotypeFromString) {
+ stereotypes.add(stereotypeFromString);
+ }
+ }
+ }
+
+ // Get the stereotypes on the PropStereoDisplay details
+ List<String> parsePropStereoDisplay = parsePropStereoDisplay();
+ for (String stereotypeName : parsePropStereoDisplay) {
+ Stereotype stereotypeFromString = migrationHelper.getStereotypeFromString(currentView, stereotypeName);
+ if ((null != stereotypeFromString) && (!stereotypes.contains(stereotypeFromString))) {
+ stereotypes.add(stereotypeFromString);
+ }
+ }
+
+ return stereotypes;
+ }
+
+ /**
+ * Check all the Stereotype on the "PropStereoDisplay" details
+ *
+ * @return
+ */
+ private List<String> parsePropStereoDisplay() {
+ List<String> stringStereotypes = new ArrayList<String>();
+ String appliedStereotypesPropertiesToDisplay = migrationHelper.getAppliedStereotypesPropertiesToDisplay(currentView);
+ if (!StereotypeMigrationHelper.EMPTY_STRING.equals(appliedStereotypesPropertiesToDisplay)) {
+ String[] splitedProperties = appliedStereotypesPropertiesToDisplay.split(StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR);
+ for (String property : splitedProperties) {
+ // SPlit on the property separator to get only the name of the Stereotype
+ int indexOf = property.indexOf(StereotypeDisplayMigrationConstant.EANNOTATION_PROPERTY_SEPARATOR);
+ if (-1 != indexOf) {
+ String substring = property.substring(0, indexOf);
+ if (!stringStereotypes.contains(substring)) {
+ stringStereotypes.add(substring);
+ }
+ }
+ }
+ }
+
+ return stringStereotypes;
+ }
+
+ /**
+ *
+ * @param view
+ * @param stereotype
+ */
+ private void createAppliedLabelStereotype(final View view, final Stereotype stereotype) {
+ TransactionalEditingDomain currentDomain = getEditingDomain();
+ // create only if the Label doesn't exist yet
+ if (!helper.isLabelExist(view, stereotype)) {
+ CreateStereotypeLabelCommand command = new CreateStereotypeLabelCommand(currentDomain, view, stereotype);
+ CommandUtil.executeUnsafeCommand(command, view);
+ }
+ }
+
+ private void createAppliedCompartmentStereotype(final Stereotype stereotype) {
+ TransactionalEditingDomain currentDomain = getEditingDomain();
+ if (!helper.isCompartmentExist(currentView, stereotype)) {
+ CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(currentDomain, currentView, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+
+ BasicCompartment compartment = helper.getStereotypeCompartment(currentView, stereotype);
+ if (null != compartment && null != stereotype) {
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ if (null != property && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isPropertyExist(compartment, property)) {
+ // go through each stereotype property
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(currentDomain, compartment, property,
+ StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE);
+
+ // Record for undo if possible, otherwise unprotected
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+ }
+ }
+
+ hideStereotypePropertiesNotDisplayed(StereotypeLocationEnum.IN_COMPARTMENT);
+ }
+ }
+
+ /**
+ *
+ * @param stereotype
+ */
+ private void createAppliedBraceCompartmentStereotype(final Stereotype stereotype) {
+ TransactionalEditingDomain currentDomain = getEditingDomain();
+ if (!helper.isBraceCompartmentExist(currentView, stereotype)) {
+ // Create Compartment
+ CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(currentDomain, currentView, stereotype, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+
+ BasicCompartment braceCompartment = helper.getStereotypeBraceCompartment(currentView, stereotype);
+ if (null != braceCompartment && null != stereotype) {
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isBracePropertyExist(braceCompartment, property)) {
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(currentDomain, braceCompartment, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_BRACE_TYPE);
+ CommandUtil.executeUnsafeCommand(command, currentView);
+ }
+ }
+ }
+
+ hideStereotypePropertiesNotDisplayed(StereotypeLocationEnum.IN_BRACE);
+ }
+ }
+
+ /**
+ * Hide visible Stereotype Property that should not be shown.
+ * List all the applied Stereotypes, if the applied stereotype is not in the Stereotype to Display list,
+ * hide the Node.
+ *
+ * @param view
+ * The view of the object to migrate
+ */
+ private void hideStereotypePropertiesNotDisplayed(final Enum<?> location) {
+ String propertyList = migrationHelper.getAppliedStereotypesPropertiesToDisplay(currentView);
+ if (!StereotypeMigrationHelper.EMPTY_STRING.equals(propertyList)) {
+ List<String> displayedProperties = new ArrayList<String>(Arrays.asList(propertyList.split(StereotypeDisplayMigrationConstant.EANNOTATION_LIST_SEPARATOR)));
+ // If applied Stereotype is not in the Stereotype list to display, set the visibility to false to hide the Label.
+ EList<Stereotype> appliedStereotypesFromView = migrationHelper.getAppliedStereotypesFromView(currentView);
+ if (null != appliedStereotypesFromView) {
+ Iterator<Stereotype> stereotypes = appliedStereotypesFromView.iterator();
+ while (stereotypes.hasNext()) {
+ Stereotype stereotype = stereotypes.next();
+ for (Property property : stereotype.allAttributes()) {
+ if (!displayedProperties.contains(property.getQualifiedName())) {
+ hideProperty(stereotype, property, location);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Hide a property.
+ *
+ * @param stereotype
+ * @param property
+ * @param location
+ */
+ private void hideProperty(final Stereotype stereotype, final Property property, final Enum<?> location) {
+ // Create the Property view if not existing and Make the properties node into the Compartment visible
+ View compartment = provider.getCompartment(stereotype, location);
+ if (compartment != null) {
+ View propertyView = provider.getProperty(property, stereotype, location);
+ if (propertyView != null) {
+ migrationHelper.updateVisibilityAndPersistence(propertyView, currentView, false);
+ }
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesMigrationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesMigrationCommand.java
new file mode 100644
index 00000000000..a8dd24c7f9d
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/commands/StereotypesMigrationCommand.java
@@ -0,0 +1,175 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.BasicCompartment;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeEAnnotationLabelMigration;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeEAnnotationNestedMigration;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeEAnnotationPropertiesMigration;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * The command used to migration stereotype representation in the diagram
+ */
+public class StereotypesMigrationCommand extends AbstractTransactionalCommand {
+
+ /**
+ * the migrated diagram
+ */
+ private Diagram diagram;
+
+ protected StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+
+ protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ * @param diagram
+ */
+ public StereotypesMigrationCommand(final TransactionalEditingDomain domain, final Diagram diagram) {
+ super(domain, "Stereotypes Migration", null);
+ this.diagram = diagram;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) {
+ TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+ List<View> viewsToClean = new ArrayList<View>();
+ List<View> viewsWithCommentToDelete = new ArrayList<View>();
+ while (allContentIterator.hasNext()) {
+ EObject eObject = allContentIterator.next();
+ if (eObject instanceof View) {
+ final View view = (View) eObject;
+
+ if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation(view)) {
+ if (null != view.getElement()) {
+ String appliedStereotypesPropertiesLocalization = migrationHelper.getAppliedStereotypesPropertiesLocalization(view);
+
+ StereotypeEAnnotationLabelMigration labelMigration = new StereotypeEAnnotationLabelMigration(view);
+ labelMigration.activate();
+
+ if (view instanceof BasicCompartment) {
+ StereotypeEAnnotationNestedMigration nestedMigration = new StereotypeEAnnotationNestedMigration(view);
+ nestedMigration.activate();
+ } else {
+ StereotypeEAnnotationPropertiesMigration propertiesMigration = new StereotypeEAnnotationPropertiesMigration(view);
+ propertiesMigration.activate();
+ }
+
+ // Clean the Ennotation after
+ viewsToClean.add(view);
+ if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(appliedStereotypesPropertiesLocalization)) {
+ // Delete the comment after
+ viewsWithCommentToDelete.add(view);
+ }
+ } else if (view.getType().equals("AppliedStereotypesComment")) { //$NON-NLS-1$
+ StereotypeEAnnotationNestedMigration nestedMigration = new StereotypeEAnnotationNestedMigration(view);
+ nestedMigration.activate();
+ }
+ }
+ }
+ }
+
+ // Delete all the old comment
+ for (View view : viewsWithCommentToDelete) {
+ deleteOldComment(view);
+ }
+
+ // Clean all Ennotation node of each view with an applied stereotype
+ for (View view : viewsToClean) {
+ cleanEAnnotation(view);
+ }
+
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @param view
+ */
+ private void deleteOldComment(final View view) {
+ // Delete Comment from the Old Structure
+ View oldComment = migrationHelper.getOldStereotypeComment(view);
+ if (oldComment != null) {
+ DeleteCommand deleteComment = new DeleteCommand(oldComment);
+ CommandUtil.executeUnsafeCommand(deleteComment, view);
+ }
+ Edge oldLink = migrationHelper.getOldStereotypeLinkComment(view);
+ if (oldLink != null) {
+ DeleteCommand deleteLink = new DeleteCommand(oldLink);
+ CommandUtil.executeUnsafeCommand(deleteLink, view);
+ }
+ }
+
+ /**
+ * Remove the EAnnotation when necessary.
+ */
+ private void cleanEAnnotation(final View view) {
+ final TransactionalEditingDomain resolveEditingDomain = CommandUtil.resolveEditingDomain(view);
+ EAnnotation eAnnotation = migrationHelper.getStereotypeEAnnotation(view);
+
+ // If the EAnnotation is Empty Delete it
+ if ((null != eAnnotation) && (eAnnotation.getDetails().isEmpty())) {
+ final RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(resolveEditingDomain, view, eAnnotation);
+ CommandUtil.executeUnsafeCommand(command, view);
+ }
+
+ // If No Stereotype Structure is Found on the host but EAnnotation is present, delete the EAnnotation
+ if ((null != eAnnotation) && (!helper.hasStereotypeViews(view))) {
+ final RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(resolveEditingDomain, view, eAnnotation);
+ CommandUtil.executeUnsafeCommand(command, view);
+ }
+
+ // Delete orphan Comment Node from OldStructure
+ final Object container = view.eContainer();
+ if (container instanceof View) {
+ final View containerView = (View) container;
+ Iterator<Object> sibilings = containerView.getChildren().iterator();
+ while (sibilings.hasNext()) {
+ Object sibiling = sibilings.next();
+ if (migrationHelper.isOldComment(sibiling)) {
+ if (migrationHelper.isOrphanComment((View) sibiling)) {
+ DeleteCommand deleteComment = new DeleteCommand((View) sibiling);
+ CommandUtil.executeUnsafeCommand(deleteComment, sibiling);
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationLabelMigrationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationLabelMigrationEditPolicy.java
index 8c9cd48ef08..5cc40882dee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationLabelMigrationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationLabelMigrationEditPolicy.java
@@ -1,85 +1,85 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeLabelMigrationCommand;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-
-/**
- * Edit Policy for the Stereotype Label user preferences migration.
- * Should be applied to every graphicalEditPart on which Stereotypes can be applied.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeEAnnotationLabelMigrationEditPolicy extends StereotypeEAnnotationMigrationEditPolicy {
-
- public static final String LABEL = "Migration of Stereotype Label";//$NON-NLS-1$
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#cleanEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
- *
- *
- * Clean the Key of EAnnotation related to the StereotypeLabel:
- * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_LIST}</li>
- * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST}</li>
- *
- *
- * @param view
- * The view owning the EAnnotation to clean
- *
- */
- @Override
- public void cleanEAnnotationDetails(View view) {
-
-
- TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(view);
-
- RemoveEAnnotationDetailCommand deleteStereotype = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_LIST);
- CommandUtil.executeUnsafeCommand(deleteStereotype, view);
-
- RemoveEAnnotationDetailCommand deleteQNList = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST);
- CommandUtil.executeUnsafeCommand(deleteQNList, view);
-
-
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#hasEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public boolean hasEAnnotationDetails(View view) {
-
- return migrationHelper.getStereotypesToDisplay(hostView) != null;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#getStereotypeMigrationCommand(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public Runnable getStereotypeMigrationCommand(View view) {
-
- return new StereotypeLabelMigrationCommand(LABEL, view);
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeLabelMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * Edit Policy for the Stereotype Label user preferences migration.
+ * Should be applied to every graphicalEditPart on which Stereotypes can be applied.
+ *
+ * @author Céline JANSSENS
+ *
+ * @deprecated Replaced by {@link StereotypeDisplayDiagramReconciler}
+ */
+@Deprecated
+public class StereotypeEAnnotationLabelMigrationEditPolicy extends StereotypeEAnnotationMigrationEditPolicy {
+
+ public static final String LABEL = "Migration of Stereotype Label";//$NON-NLS-1$
+
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#cleanEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
+ *
+ *
+ * Clean the Key of EAnnotation related to the StereotypeLabel:
+ * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_LIST}</li>
+ * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST}</li>
+ *
+ *
+ * @param view
+ * The view owning the EAnnotation to clean
+ *
+ */
+ @Override
+ public void cleanEAnnotationDetails(View view) {
+
+
+ TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(view);
+
+ RemoveEAnnotationDetailCommand deleteStereotype = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_LIST);
+ CommandUtil.executeUnsafeCommand(deleteStereotype, view);
+
+ RemoveEAnnotationDetailCommand deleteQNList = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_WITHQN_LIST);
+ CommandUtil.executeUnsafeCommand(deleteQNList, view);
+
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasEAnnotationDetails(View view) {
+
+ return migrationHelper.getStereotypesToDisplay(hostView) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getStereotypeMigrationTransactionalCommand(View view) {
+ return new StereotypeLabelMigrationCommand(LABEL, view);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationMigrationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationMigrationEditPolicy.java
index 4ff6bed855a..3f60438d974 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationMigrationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationMigrationEditPolicy.java
@@ -1,167 +1,195 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.gef.editpolicies.AbstractEditPolicy;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationCommand;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-
-/**
- * This Edit Policy is in charge to migrate user preferences from old stereotype display structure
- * (which were using EAnnotation) to the new structure using NamedStyle and additional notation Views
- *
- * @author Céline JANSSENS
- *
- */
-public abstract class StereotypeEAnnotationMigrationEditPolicy extends AbstractEditPolicy {
-
- public static final Object STEREOTYPE_RECONCILER = "Stereotype Display Reconciler"; //$NON-NLS-1$
-
- protected StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
- protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
-
- protected View hostView = null;
- protected EAnnotation eAnnotation = null;
- protected IGraphicalEditPart editPart = null;
-
-
-
- /**
- * Set the attributes and launch the migration.
- *
- * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate()
- *
- */
- @Override
- public void activate() {
-
- // set editPart
- if (getHost() instanceof GraphicalEditPart) {
- this.editPart = (GraphicalEditPart) getHost();
- }
-
- if (getHost() instanceof ConnectionEditPart) {
- this.editPart = (ConnectionEditPart) getHost();
- }
-
- // set hostView
- if (editPart != null && editPart.getModel() instanceof View) {
- this.hostView = (View) editPart.getModel();
- }
-
- // set EAnnotation and start the migration process
- if (editPart != null && hostView != null) {
- this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
- if (eAnnotation != null && !eAnnotation.getDetails().isEmpty()) {
- migrateStereotype();
- }
- }
-
- }
-
- /**
- * Migrate all the Stereotype User preferences
- *
- */
- protected void migrateStereotype() {
-
- if (eAnnotation != null) {
- if (hasEAnnotationDetails(hostView)) {
- // Retrieve the migration Command and execute it.
- Runnable command = getStereotypeMigrationCommand(hostView);
- CommandUtil.executeUnsafeCommand(command, editPart);
-
- }
- // Clean the details associated to each sub edit policies;
- cleanEAnnotationDetails(hostView);
- }
- // Clean the EAnnotation if Empty
- cleanEAnnotation();
- }
-
-
- /**
- * Remove the EAnnotation when necessary
- */
- private void cleanEAnnotation() {
-
- // If the EAnnotation is Empty Delete it
- if (eAnnotation != null && eAnnotation.getDetails().size() == 0) {
- RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(editPart.getEditingDomain(), hostView, eAnnotation);
- CommandUtil.executeUnsafeCommand(command, editPart);
- }
-
- // If No Stereotype Structure is Found on the host but EAnnotation is present, delete the EAnnotation
- if (eAnnotation != null && !helper.hasStereotypeViews(hostView)) {
- RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(editPart.getEditingDomain(), hostView, eAnnotation);
- CommandUtil.executeUnsafeCommand(command, editPart);
- }
-
- // Delete orphan Comment Node from OldStructure
- Object container = hostView.eContainer();
- if (container instanceof View) {
- View containerView = (View) container;
- Iterator<Object> sibilings = containerView.getChildren().iterator();
- while (sibilings.hasNext()) {
- Object sibiling = sibilings.next();
- if (migrationHelper.isOldComment(sibiling)) {
- if (migrationHelper.isOrphanComment((View) sibiling)) {
- DeleteCommand deleteComment = new DeleteCommand((View) sibiling);
- CommandUtil.executeUnsafeCommand(deleteComment, sibiling);
- }
- }
- }
- }
-
- }
-
- /**
- * Clean EAnnotation Details in the model depending of what has been treated.
- *
- * @param hostView
- * The view on which the Stereotype has been applied
- */
- public abstract void cleanEAnnotationDetails(View view);
-
- /**
- * Define if the Edit Policy detail for the specific EANnotation Detail is not Empty.
- *
- * @param view
- * The view on which the Stereotype has been applied
- */
- public abstract boolean hasEAnnotationDetails(View view);
-
- /**
- * Get the command to update the Node visibility related to the EAnnotation.
- *
- * @param hostView
- * The view on which the Stereotype has been applied
- */
- public abstract Runnable getStereotypeMigrationCommand(View view);
-
-
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.editpolicies.AbstractEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationCommand;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * This Edit Policy is in charge to migrate user preferences from old stereotype display structure
+ * (which were using EAnnotation) to the new structure using NamedStyle and additional notation Views
+ *
+ * @author Céline JANSSENS
+ *
+ * @deprecated Replaced by {@link StereotypeDisplayDiagramReconciler}
+ */
+@Deprecated
+public abstract class StereotypeEAnnotationMigrationEditPolicy extends AbstractEditPolicy {
+
+ public static final Object STEREOTYPE_RECONCILER = "Stereotype Display Reconciler"; //$NON-NLS-1$
+
+ protected StereotypeMigrationHelper migrationHelper = StereotypeMigrationHelper.getInstance();
+ protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
+
+ protected View hostView = null;
+ protected EAnnotation eAnnotation = null;
+ protected IGraphicalEditPart editPart = null;
+
+
+
+ /**
+ * Set the attributes and launch the migration.
+ *
+ * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate()
+ *
+ */
+ @Override
+ public void activate() {
+
+ // set editPart
+ if (getHost() instanceof GraphicalEditPart) {
+ this.editPart = (GraphicalEditPart) getHost();
+ }
+
+ if (getHost() instanceof ConnectionEditPart) {
+ this.editPart = (ConnectionEditPart) getHost();
+ }
+
+ // set hostView
+ if (editPart != null && editPart.getModel() instanceof View) {
+ this.hostView = (View) editPart.getModel();
+ }
+
+ // set EAnnotation and start the migration process
+ if (editPart != null && hostView != null) {
+ this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
+ if (eAnnotation != null && !eAnnotation.getDetails().isEmpty()) {
+ migrateStereotype();
+ }
+ }
+
+ }
+
+ /**
+ * Migrate all the Stereotype User preferences
+ *
+ */
+ protected void migrateStereotype() {
+
+ if (eAnnotation != null) {
+ if (hasEAnnotationDetails(hostView)) {
+ // Retrieve the migration Command and execute it.
+ ICommand command = getStereotypeMigrationTransactionalCommand(hostView);
+ CommandUtil.executeUnsafeCommand(command, editPart);
+
+ }
+ // Clean the details associated to each sub edit policies;
+ cleanEAnnotationDetails(hostView);
+ }
+ // Clean the EAnnotation if Empty
+ cleanEAnnotation();
+ }
+
+
+ /**
+ * Remove the EAnnotation when necessary
+ */
+ private void cleanEAnnotation() {
+
+ // If the EAnnotation is Empty Delete it
+ if (eAnnotation != null && eAnnotation.getDetails().size() == 0) {
+ RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(editPart.getEditingDomain(), hostView, eAnnotation);
+ CommandUtil.executeUnsafeCommand(command, editPart);
+ }
+
+ // If No Stereotype Structure is Found on the host but EAnnotation is present, delete the EAnnotation
+ if (eAnnotation != null && !helper.hasStereotypeViews(hostView)) {
+ RemoveEAnnotationCommand command = new RemoveEAnnotationCommand(editPart.getEditingDomain(), hostView, eAnnotation);
+ CommandUtil.executeUnsafeCommand(command, editPart);
+ }
+
+ // Delete orphan Comment Node from OldStructure
+ Object container = hostView.eContainer();
+ if (container instanceof View) {
+ View containerView = (View) container;
+ Iterator<Object> sibilings = containerView.getChildren().iterator();
+ while (sibilings.hasNext()) {
+ Object sibiling = sibilings.next();
+ if (migrationHelper.isOldComment(sibiling)) {
+ if (migrationHelper.isOrphanComment((View) sibiling)) {
+ DeleteCommand deleteComment = new DeleteCommand((View) sibiling);
+ CommandUtil.executeUnsafeCommand(deleteComment, sibiling);
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Clean EAnnotation Details in the model depending of what has been treated.
+ *
+ * @param hostView
+ * The view on which the Stereotype has been applied
+ */
+ public abstract void cleanEAnnotationDetails(View view);
+
+ /**
+ * Define if the Edit Policy detail for the specific EANnotation Detail is not Empty.
+ *
+ * @param view
+ * The view on which the Stereotype has been applied
+ */
+ public abstract boolean hasEAnnotationDetails(View view);
+
+ /**
+ * Get the command to update the Node visibility related to the EAnnotation.
+ *
+ * @param hostView
+ * The view on which the Stereotype has been applied
+ */
+ public Runnable getStereotypeMigrationCommand(View view) {
+ return null;
+ }
+
+ /**
+ * Get the command to update the Node visibility related to the EAnnotation.
+ *
+ * @param hostView
+ * The view on which the Stereotype has been applied
+ */
+ public ICommand getStereotypeMigrationTransactionalCommand(final View view) {
+ ICommand command = null;
+ if (null != getStereotypeMigrationCommand(view)) {
+ command = new AbstractTransactionalCommand(migrationHelper.getDomain(view), "Migration Stereotype", null) { //$NON-NLS-1$
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ getStereotypeMigrationCommand(view).run();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ }
+ return command;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationNestedMigrationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationNestedMigrationEditPolicy.java
index 044396de925..adf3e0cafd7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationNestedMigrationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationNestedMigrationEditPolicy.java
@@ -1,79 +1,81 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
-
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeNestedPropertiesMigrationCommand;
-
-/**
- * Edit Policy to manage the migration of the object into Compartment :
- * <ul>
- * <li>Operations</li>
- * <li>Properties</li>
- * <li>Nested Element</li>
- * <li>Enumeration</li>
- * <li>....</li>
- * </ul>
- *
- * To be applied on all the instances of {@link UMLCompartmentEditPart}.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeEAnnotationNestedMigrationEditPolicy extends StereotypeEAnnotationPropertiesMigrationEditPolicy {
-
-
- /**
- * Constructor.
- *
- */
- public StereotypeEAnnotationNestedMigrationEditPolicy() {
- super();
- }
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#activate()
- *
- */
- @Override
- public void activate() {
- if (getHost() instanceof GraphicalEditPart) {
- this.editPart = (GraphicalEditPart) getHost();
- }
-
- if (editPart instanceof UMLCompartmentEditPart && editPart.getModel() instanceof View) {
- this.hostView = (View) editPart.getModel();
- }
-
- if (editPart != null && hostView != null) {
- this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
- migrateStereotype();
- }
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationPropertiesMigrationEditPolicy#getStereotypeMigrationCommand(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public Runnable getStereotypeMigrationCommand(View view) {
-
- return new StereotypeNestedPropertiesMigrationCommand(LABEL, view);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeNestedPropertiesMigrationCommand;
+
+/**
+ * Edit Policy to manage the migration of the object into Compartment :
+ * <ul>
+ * <li>Operations</li>
+ * <li>Properties</li>
+ * <li>Nested Element</li>
+ * <li>Enumeration</li>
+ * <li>....</li>
+ * </ul>
+ *
+ * To be applied on all the instances of {@link UMLCompartmentEditPart}.
+ *
+ * @author Céline JANSSENS
+ *
+ * @deprecated Replaced by {@link StereotypeDisplayDiagramReconciler}
+ */
+@Deprecated
+public class StereotypeEAnnotationNestedMigrationEditPolicy extends StereotypeEAnnotationPropertiesMigrationEditPolicy {
+
+
+ /**
+ * Constructor.
+ *
+ */
+ public StereotypeEAnnotationNestedMigrationEditPolicy() {
+ super();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void activate() {
+ if (getHost() instanceof GraphicalEditPart) {
+ this.editPart = (GraphicalEditPart) getHost();
+ }
+
+ if (editPart instanceof UMLCompartmentEditPart && editPart.getModel() instanceof View) {
+ this.hostView = (View) editPart.getModel();
+ }
+
+ if (editPart != null && hostView != null) {
+ this.eAnnotation = migrationHelper.getStereotypeEAnnotation(hostView);
+ migrateStereotype();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getStereotypeMigrationTransactionalCommand(final View view) {
+ return new StereotypeNestedPropertiesMigrationCommand(LABEL, view);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationPropertiesMigrationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationPropertiesMigrationEditPolicy.java
index d00ac6a648b..86fdc7c2c28 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationPropertiesMigrationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/migration/editpolicies/StereotypeEAnnotationPropertiesMigrationEditPolicy.java
@@ -1,97 +1,99 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeCommentPropertiesMigrationCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-
-/**
- * Edit Policy for the Stereotype Properties user preferences migration.
- * Should be applied to every graphicalEditPart on which Stereotypes Properties can be displayed.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeEAnnotationPropertiesMigrationEditPolicy extends StereotypeEAnnotationMigrationEditPolicy {
-
- public static final String LABEL = "Migration Stereotype Properties";//$NON-NLS-1$
-
-
-
- /**
- * Clean the Key of EAnnotation related to the StereotypeLabel:
- * <ul>
- * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_PROPERTY_LOCATION}</li>
- * <li>{@link StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY}</li>
- * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_PRESENTATION_KIND}</li>
- * </ul>
- *
- * @param view
- * The view owning the EAnnotation to clean
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#cleanEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public void cleanEAnnotationDetails(View view) {
-
- TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(editPart);
-
- if (domain != null) {
- RemoveEAnnotationDetailCommand deleteLocation = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PROPERTY_LOCATION);
- CommandUtil.executeUnsafeCommand(deleteLocation, domain);
- RemoveEAnnotationDetailCommand deleteProperties = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY);
- CommandUtil.executeUnsafeCommand(deleteProperties, domain);
- RemoveEAnnotationDetailCommand deleteKind = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PRESENTATION_KIND);
- CommandUtil.executeUnsafeCommand(deleteKind, domain);
- }
-
- }
-
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#hasEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public boolean hasEAnnotationDetails(View view) {
-
- return migrationHelper.getAppliedStereotypesPropertiesToDisplay(hostView) != null;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#getStereotypeMigrationCommand(org.eclipse.gmf.runtime.notation.View)
- *
- */
- @Override
- public Runnable getStereotypeMigrationCommand(View view) {
- Runnable migrationCommand = null;
- if (migrationHelper.getAppliedStereotypesPropertiesLocalization(view).equals(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION)) {
- // In case of properties in Comment, a dedicated Command is required.
- migrationCommand = new StereotypeCommentPropertiesMigrationCommand(LABEL, view);
- } else {
- migrationCommand = new StereotypePropertiesMigrationCommand(LABEL, view);
- }
-
- return migrationCommand;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayMigrationConstant;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypeCommentPropertiesMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.commands.StereotypePropertiesMigrationCommand;
+import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
+
+/**
+ * Edit Policy for the Stereotype Properties user preferences migration.
+ * Should be applied to every graphicalEditPart on which Stereotypes Properties can be displayed.
+ *
+ * @author Céline JANSSENS
+ *
+ * @deprecated Replaced by {@link StereotypeDisplayDiagramReconciler}
+ */
+@Deprecated
+public class StereotypeEAnnotationPropertiesMigrationEditPolicy extends StereotypeEAnnotationMigrationEditPolicy {
+
+ public static final String LABEL = "Migration Stereotype Properties";//$NON-NLS-1$
+
+
+
+ /**
+ * Clean the Key of EAnnotation related to the StereotypeLabel:
+ * <ul>
+ * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_PROPERTY_LOCATION}</li>
+ * <li>{@link StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY}</li>
+ * <li>{@link StereotypeDisplayMigrationConstant.STEREOTYPE_PRESENTATION_KIND}</li>
+ * </ul>
+ *
+ * @param view
+ * The view owning the EAnnotation to clean
+ * @see org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationMigrationEditPolicy#cleanEAnnotationDetails(org.eclipse.gmf.runtime.notation.View)
+ *
+ */
+ @Override
+ public void cleanEAnnotationDetails(final View view) {
+
+ TransactionalEditingDomain domain = CommandUtil.resolveEditingDomain(editPart);
+
+ if (domain != null) {
+ RemoveEAnnotationDetailCommand deleteLocation = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PROPERTY_LOCATION);
+ CommandUtil.executeUnsafeCommand(deleteLocation, domain);
+ RemoveEAnnotationDetailCommand deleteProperties = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.PROPERTY_STEREOTYPE_DISPLAY);
+ CommandUtil.executeUnsafeCommand(deleteProperties, domain);
+ RemoveEAnnotationDetailCommand deleteKind = new RemoveEAnnotationDetailCommand(domain, eAnnotation, StereotypeDisplayMigrationConstant.STEREOTYPE_PRESENTATION_KIND);
+ CommandUtil.executeUnsafeCommand(deleteKind, domain);
+ }
+
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasEAnnotationDetails(final View view) {
+
+ return migrationHelper.getAppliedStereotypesPropertiesToDisplay(hostView) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getStereotypeMigrationTransactionalCommand(final View view) {
+ ICommand migrationCommand = null;
+ if (migrationHelper.getAppliedStereotypesPropertiesLocalization(view).equals(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION)) {
+ // In case of properties in Comment, a dedicated Command is required.
+ migrationCommand = new StereotypeCommentPropertiesMigrationCommand(LABEL, view, true);
+ } else {
+ migrationCommand = new StereotypePropertiesMigrationCommand(LABEL, view);
+ }
+
+ return migrationCommand;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
index 4eeaf1f1345..6230fb968ea 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
@@ -1,42 +1,36 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-<extension
- point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">
- <editpolicyProvider
- class="org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.CustomEditPolicyProvider">
- <Priority
- name="Low">
- </Priority>
- </editpolicyProvider>
- <editpolicyProvider
- class="org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.StereotypeDisplayMigrationEditPolicyProvider">
- <Priority
- name="Medium">
- </Priority>
- </editpolicyProvider>
-</extension>
-<extension
- id="stereotype-ep-provider"
- point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders">
- <editpartProvider
- class="org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.StereotypePropertiesEditPartProvider">
- <Priority name="Medium"/>
-
- <object
- class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)"
- id="StereotypePropertiesEditPartProvider">
- <method name="getType()" value="StereotypePropertyBrace, StereotypeBrace, StereotypeLabel, StereotypeComment,StereotypeCompartment,StereotypeProperty,StereotypeCommentLink"/>
- </object>
- </editpartProvider>
- </extension>
-
- <extension
- point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
- <elementTypeSet
- clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
- path="model/stereotype-edit.elementtypesconfigurations">
- </elementTypeSet>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<extension
+ point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">
+ <editpolicyProvider
+ class="org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.CustomEditPolicyProvider">
+ <Priority
+ name="Low">
+ </Priority>
+ </editpolicyProvider>
+</extension>
+<extension
+ id="stereotype-ep-provider"
+ point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders">
+ <editpartProvider
+ class="org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.StereotypePropertiesEditPartProvider">
+ <Priority name="Medium"/>
+
+ <object
+ class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)"
+ id="StereotypePropertiesEditPartProvider">
+ <method name="getType()" value="StereotypePropertyBrace, StereotypeBrace, StereotypeLabel, StereotypeComment,StereotypeCompartment,StereotypeProperty,StereotypeCommentLink"/>
+ </object>
+ </editpartProvider>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
+ path="model/stereotype-edit.elementtypesconfigurations">
+ </elementTypeSet>
+ </extension>
+
+</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypeDisplayMigrationEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypeDisplayMigrationEditPolicyProvider.java
index fa65009a838..cb8b8aba4fc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypeDisplayMigrationEditPolicyProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypeDisplayMigrationEditPolicyProvider.java
@@ -1,108 +1,112 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.stereotype.edition.provider;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationLabelMigrationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationNestedMigrationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationPropertiesMigrationEditPolicy;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
-
-/**
- * @author Céline JANSSENS
- *
- */
-public class StereotypeDisplayMigrationEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
-
-
-
- /**
- * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
- *
- */
- public boolean provides(IOperation operation) {
- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
- if (!(epOperation.getEditPart() instanceof GraphicalEditPart) && !(epOperation.getEditPart() instanceof ConnectionEditPart)) {
- return false;
- }
-
- EditPart gep = epOperation.getEditPart();
-
- // Only the EditPart with an Stereotype EAnnotation into its View.
- try {
- if (ServiceUtilsForEditPart.getInstance().getServiceRegistry(gep) != null) {
- if (gep.getModel() instanceof View) {
- if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation((View) gep.getModel())) {
- if (UMLUtil.resolveUMLElement(gep) != null) {
- return true;
- }
- }
- }
- }
- } catch (ServiceException e) {
- return false;
- }
-
- return false;
-
-
- }
-
-
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider#createEditPolicies(org.eclipse.gef.EditPart)
- *
- */
- public void createEditPolicies(EditPart editPart) {
-
-
- if (editPart.getModel() instanceof View) {
- if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation((View) editPart.getModel())) {
-
- // Main policy for Stereotype Label Migration
-
- if (UMLUtil.resolveUMLElement(editPart) != null) {
- editPart.installEditPolicy(StereotypeEAnnotationLabelMigrationEditPolicy.LABEL, new StereotypeEAnnotationLabelMigrationEditPolicy());
- if (!(editPart instanceof UMLCompartmentEditPart)) {
- editPart.installEditPolicy(StereotypeEAnnotationPropertiesMigrationEditPolicy.LABEL, new StereotypeEAnnotationPropertiesMigrationEditPolicy());
- }
- }
-
-
- // Policy for Stereotype Property and Label Migration of Element into Compartment (Property, Operation, Nested element, Enumeration Item,...)
- if (editPart instanceof UMLCompartmentEditPart) {
- if (UMLUtil.resolveUMLElement(editPart) != null) {
- editPart.installEditPolicy(StereotypeEAnnotationPropertiesMigrationEditPolicy.LABEL, new StereotypeEAnnotationNestedMigrationEditPolicy());
- }
- }
-
- }
- }
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 493420
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.stereotype.edition.provider;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeMigrationHelper;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationLabelMigrationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationNestedMigrationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies.StereotypeEAnnotationPropertiesMigrationEditPolicy;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+
+/**
+ * @author Céline JANSSENS
+ *
+ * @deprecated Replaced by {@link StereotypeDisplayDiagramReconciler}
+ */
+@Deprecated
+public class StereotypeDisplayMigrationEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
+
+
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
+ *
+ */
+ public boolean provides(IOperation operation) {
+ CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
+ if (!(epOperation.getEditPart() instanceof GraphicalEditPart) && !(epOperation.getEditPart() instanceof ConnectionEditPart)) {
+ return false;
+ }
+
+ EditPart gep = epOperation.getEditPart();
+
+ // Only the EditPart with an Stereotype EAnnotation into its View.
+ try {
+ if (ServiceUtilsForEditPart.getInstance().getServiceRegistry(gep) != null) {
+ if (gep.getModel() instanceof View) {
+ if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation((View) gep.getModel())) {
+ if (UMLUtil.resolveUMLElement(gep) != null) {
+ return true;
+ }
+ }
+ }
+ }
+ } catch (ServiceException e) {
+ return false;
+ }
+
+ return false;
+
+
+ }
+
+
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider#createEditPolicies(org.eclipse.gef.EditPart)
+ *
+ */
+ public void createEditPolicies(EditPart editPart) {
+
+
+ if (editPart.getModel() instanceof View) {
+ if (StereotypeMigrationHelper.getInstance().hasStereotypeEAnnotation((View) editPart.getModel())) {
+
+ // Main policy for Stereotype Label Migration
+
+ if (UMLUtil.resolveUMLElement(editPart) != null) {
+ editPart.installEditPolicy(StereotypeEAnnotationLabelMigrationEditPolicy.LABEL, new StereotypeEAnnotationLabelMigrationEditPolicy());
+ if (!(editPart instanceof UMLCompartmentEditPart)) {
+ editPart.installEditPolicy(StereotypeEAnnotationPropertiesMigrationEditPolicy.LABEL, new StereotypeEAnnotationPropertiesMigrationEditPolicy());
+ }
+ }
+
+
+ // Policy for Stereotype Property and Label Migration of Element into Compartment (Property, Operation, Nested element, Enumeration Item,...)
+ if (editPart instanceof UMLCompartmentEditPart) {
+ if (UMLUtil.resolveUMLElement(editPart) != null) {
+ editPart.installEditPolicy(StereotypeEAnnotationPropertiesMigrationEditPolicy.LABEL, new StereotypeEAnnotationNestedMigrationEditPolicy());
+ }
+ }
+
+ }
+ }
+
+ }
+
+}

Back to the top