summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2014-05-26 05:02:47 (EDT)
committermgolubev2014-05-27 11:29:52 (EDT)
commit7fe69f73e5bc462406cc3f3f627cec98f76928c8 (patch)
tree66b4832a4023d395e6082ffd4c0964c645b5e9ce
parenta558e1e89ffcaad4ead52967b18fb7e5c86e6c97 (diff)
downloadorg.eclipse.papyrus-7fe69f73e5bc462406cc3f3f627cec98f76928c8.zip
org.eclipse.papyrus-7fe69f73e5bc462406cc3f3f627cec98f76928c8.tar.gz
org.eclipse.papyrus-7fe69f73e5bc462406cc3f3f627cec98f76928c8.tar.bz2
Diagram Versions: reconcilers framework introduced to allow automaticrefs/changes/77/27277/3
conevertions of diagrams between Papyrus versions + XXXViewProvider updated to setup "current" diagram version for new diagrams + XXXViewProvider generator updated to generate above + 4x Migration of RobotML diagrams using new framework + repackaged to oep.infra.gmfdiag.common with respect to comments at https://git.eclipse.org/r/#/c/26412/ Change-Id: I40f22852cdd988f904a1b926263c5a18e85ee292 Signed-off-by: mgolubev <golubev@montages.com>
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/plugin.xml47
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLArchitecture2CompositeDiagramFactory.java24
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLComponent2CompositeDiagramFactory.java25
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLDatatype2ClassDiagramFactory.java25
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLInterface2ClassDiagramFactory.java24
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/migration/RobotMLReconciler.java171
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/diagramReconciler.exsd123
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java122
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconciler.java137
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconcilersReader.java175
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java158
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/compatibility/DiagramVersioningUtils.java46
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/providers/UMLViewProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/providers/UMLViewProvider.java2
27 files changed, 1073 insertions, 47 deletions
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/plugin.xml b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/plugin.xml
index f1673ab..f851808 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/plugin.xml
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/plugin.xml
@@ -10,6 +10,26 @@
id="robotML"
label="RobotML">
</diagramCategory>
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
+ factoryClass="org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLArchitecture2CompositeDiagramFactory"
+ icon="icons/robotml_16x16.png">
+ </editorDiagram>
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
+ factoryClass="org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLComponent2CompositeDiagramFactory"
+ icon="icons/robotml_16x16.png">
+ </editorDiagram>
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
+ factoryClass="org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLDatatype2ClassDiagramFactory"
+ icon="icons/robotml_16x16.png">
+ </editorDiagram>
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
+ factoryClass="org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLInterface2ClassDiagramFactory"
+ icon="icons/robotml_16x16.png">
+ </editorDiagram>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
@@ -141,4 +161,31 @@
<Priority name="Low"/>
</editpolicyProvider>
</extension>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.diagramReconciler">
+ <diagramReconciler
+ diagramType="componentdef"
+ reconcilerClass="org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler"
+ source="0.9.0"
+ target="1.0.0">
+ </diagramReconciler>
+ <diagramReconciler
+ diagramType="DatatypeDef"
+ reconcilerClass="org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler"
+ source="0.9.0"
+ target="1.0.0">
+ </diagramReconciler>
+ <diagramReconciler
+ diagramType="architecture"
+ reconcilerClass="org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler"
+ source="0.9.0"
+ target="1.0.0">
+ </diagramReconciler>
+ <diagramReconciler
+ diagramType="InterfaceDef"
+ reconcilerClass="org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler"
+ source="0.9.0"
+ target="1.0.0">
+ </diagramReconciler>
+</extension>
</plugin>
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLArchitecture2CompositeDiagramFactory.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLArchitecture2CompositeDiagramFactory.java
new file mode 100644
index 0000000..cad3d55
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLArchitecture2CompositeDiagramFactory.java
@@ -0,0 +1,24 @@
+package org.eclipse.papyrus.robotml.diagram.common.factory;
+
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
+import org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler;
+import org.eclipse.papyrus.uml.diagram.composite.UmlCompositeDiagramForMultiEditor;
+
+/**
+ * This class is part of the migration of the RobotML diagrams, which,
+ * since Papyrus 1.0 should be opened by the corresponding UML diagram editors,
+ * in this particular case, {@link UmlCompositeDiagramForMultiEditor}
+ * <p/>
+ * This class registers the corresponding UML editor to the robot-ML type and allows the migration framework to proceed.
+ * <p/>
+ * The other component of the process is {@link RobotMLReconciler} which actually performs migration.
+ */
+public class RobotMLArchitecture2CompositeDiagramFactory extends GmfEditorFactory {
+
+ public static final String OLD_ROBOT_ML_TYPE = "architecture";
+
+ public RobotMLArchitecture2CompositeDiagramFactory() {
+ super(UmlCompositeDiagramForMultiEditor.class, OLD_ROBOT_ML_TYPE);
+ }
+
+}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLComponent2CompositeDiagramFactory.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLComponent2CompositeDiagramFactory.java
new file mode 100644
index 0000000..2588321
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLComponent2CompositeDiagramFactory.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.robotml.diagram.common.factory;
+
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
+import org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler;
+import org.eclipse.papyrus.uml.diagram.composite.UmlCompositeDiagramForMultiEditor;
+
+
+/**
+ * This class is part of the migration of the RobotML diagrams, which,
+ * since Papyrus 1.0 should be opened by the corresponding UML diagram editors,
+ * in this particular case, {@link UmlCompositeDiagramForMultiEditor}
+ * <p/>
+ * This class registers the corresponding UML editor to the robot-ML type and allows the migration framework to proceed.
+ * <p/>
+ * The other component of the process is {@link RobotMLReconciler} which actually performs migration.
+ */
+public class RobotMLComponent2CompositeDiagramFactory extends GmfEditorFactory {
+
+ public static final String OLD_ROBOT_ML_TYPE = "componentdef";
+
+ public RobotMLComponent2CompositeDiagramFactory() {
+ super(UmlCompositeDiagramForMultiEditor.class, OLD_ROBOT_ML_TYPE);
+ }
+
+}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLDatatype2ClassDiagramFactory.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLDatatype2ClassDiagramFactory.java
new file mode 100644
index 0000000..f34b0b2
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLDatatype2ClassDiagramFactory.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.robotml.diagram.common.factory;
+
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
+import org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler;
+import org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor;
+
+
+/**
+ * This class is part of the migration of the RobotML diagrams, which,
+ * since Papyrus 1.0 should be opened by the corresponding UML diagram editors,
+ * in this particular case, {@link UmlClassDiagramForMultiEditor}
+ * <p/>
+ * This class registers the corresponding UML editor to the robot-ML type and allows the migration framework to proceed.
+ * <p/>
+ * The other component of the process is {@link RobotMLReconciler} which actually performs migration.
+ */
+public class RobotMLDatatype2ClassDiagramFactory extends GmfEditorFactory {
+
+ public static final String OLD_ROBOT_ML_TYPE = "DatatypeDef";
+
+ public RobotMLDatatype2ClassDiagramFactory() {
+ super(UmlClassDiagramForMultiEditor.class, OLD_ROBOT_ML_TYPE);
+ }
+
+}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLInterface2ClassDiagramFactory.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLInterface2ClassDiagramFactory.java
new file mode 100644
index 0000000..47e8a66
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/factory/RobotMLInterface2ClassDiagramFactory.java
@@ -0,0 +1,24 @@
+package org.eclipse.papyrus.robotml.diagram.common.factory;
+
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
+import org.eclipse.papyrus.robotml.diagram.common.migration.RobotMLReconciler;
+import org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor;
+
+/**
+ * This class is part of the migration of the RobotML diagrams, which,
+ * since Papyrus 1.0 should be opened by the corresponding UML diagram editors,
+ * in this particular case, {@link UmlClassDiagramForMultiEditor}
+ * <p/>
+ * This class registers the corresponding UML editor to the robot-ML type and allows the migration framework to proceed.
+ * <p/>
+ * The other component of the process is {@link RobotMLReconciler} which actually performs migration.
+ */
+public class RobotMLInterface2ClassDiagramFactory extends GmfEditorFactory {
+
+ public static final String OLD_ROBOT_ML_TYPE = "InterfaceDef";
+
+ public RobotMLInterface2ClassDiagramFactory() {
+ super(UmlClassDiagramForMultiEditor.class, OLD_ROBOT_ML_TYPE);
+ }
+
+}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/migration/RobotMLReconciler.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/migration/RobotMLReconciler.java
new file mode 100644
index 0000000..08b9424
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/migration/RobotMLReconciler.java
@@ -0,0 +1,171 @@
+package org.eclipse.papyrus.robotml.diagram.common.migration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+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.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
+import org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLArchitecture2CompositeDiagramFactory;
+import org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLComponent2CompositeDiagramFactory;
+import org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLDatatype2ClassDiagramFactory;
+import org.eclipse.papyrus.robotml.diagram.common.factory.RobotMLInterface2ClassDiagramFactory;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
+
+
+public class RobotMLReconciler extends DiagramReconciler {
+
+ private static final String OLD_ARCHITECTURE_TYPE = RobotMLArchitecture2CompositeDiagramFactory.OLD_ROBOT_ML_TYPE;
+
+ private static final String OLD_COMPONENT_TYPE = RobotMLComponent2CompositeDiagramFactory.OLD_ROBOT_ML_TYPE;
+
+ private static final String OLD_INTERFACE_TYPE = RobotMLInterface2ClassDiagramFactory.OLD_ROBOT_ML_TYPE;
+
+ private static final String OLD_DATATYPE_TYPE = RobotMLDatatype2ClassDiagramFactory.OLD_ROBOT_ML_TYPE;
+
+ private static final String NEW_CLASS_DIAGRAM = ModelEditPart.MODEL_ID;
+
+ private static final String NEW_COMPOSITE_DIAGRAM = CompositeStructureDiagramEditPart.MODEL_ID;
+
+ private static final MigrationData ARCHITECTURE = new MigrationData(OLD_ARCHITECTURE_TYPE, NEW_COMPOSITE_DIAGRAM, "RobotML Architecture");
+
+ private static final MigrationData COMPONENT = new MigrationData(OLD_COMPONENT_TYPE, NEW_COMPOSITE_DIAGRAM, "RobotML Component");
+
+ private static final MigrationData INTERFACE = new MigrationData(OLD_INTERFACE_TYPE, NEW_CLASS_DIAGRAM, "RobotML Interface");
+
+ private static final MigrationData DATATYPE = new MigrationData(OLD_DATATYPE_TYPE, NEW_CLASS_DIAGRAM, "RobotML Datatype");
+
+ /**
+ * Original code in {@link MigrateDiagramsHandler} uses {@link String#equalsIgnoreCase(String)}.
+ * <p/>
+ * So the keys in this map are old types toLoserCase.
+ */
+ private static final Map<String, MigrationData> ourMigrations;
+
+ static {
+ ourMigrations = new HashMap<String, MigrationData>();
+ for(MigrationData next : new MigrationData[]{ ARCHITECTURE, COMPONENT, INTERFACE, DATATYPE }) {
+ ourMigrations.put(safeToLowerCase(next.getOldType()), next);
+ }
+ }
+
+ @Override
+ public ICommand getReconcileCommand(Diagram diagram) {
+ MigrationData data = findMigration(diagram);
+ return data == null ? null : new RobotMLReconcileCommand(diagram, data);
+ }
+
+ /**
+ * Ignores case
+ */
+ private MigrationData findMigration(Diagram diagram) {
+ return ourMigrations.get(safeToLowerCase(diagram.getType()));
+ }
+
+ private static String safeToLowerCase(String text) {
+ return text == null ? null : text.toLowerCase();
+ }
+
+ private static class RobotMLReconcileCommand extends AbstractCommand {
+
+ private final Diagram myDiagram;
+
+ private final MigrationData myMigrationData;
+
+ public RobotMLReconcileCommand(Diagram diagram, MigrationData data) {
+ super("Migrate old RobotML diagram");
+ myDiagram = diagram;
+ myMigrationData = data;
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ DiagramUtils.setPrototype(myDiagram, myMigrationData.getPrototype());
+ DiagramUtils.setOwner(myDiagram, myDiagram.getElement());
+ myDiagram.setType(myMigrationData.getNewType());
+
+ return CommandResult.newOKCommandResult();
+ }
+
+ @Override
+ public boolean canUndo() {
+ return false;
+ }
+
+ @Override
+ public boolean canRedo() {
+ return false;
+ }
+
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ throw new ExecutionException("Should not be called, canRedo false");
+ }
+
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ throw new ExecutionException("Should not be called, canUndo false");
+ }
+
+ }
+
+ /**
+ * Encapsulates migration scheme from given old RobotML, new UML diagram type and given prototype.
+ * <p/>
+ * Instances of this class are considered invalid if the prototype is not known.
+ */
+ private static class MigrationData {
+
+ private ViewPrototype myCachedPrototype;
+
+ private final String myNewType;
+
+ private final String myOldType;
+
+ private final String myPrototypeLabel;
+
+ public MigrationData(String oldType, String newType, String prototypeLabel) {
+ myOldType = oldType;
+ myNewType = newType;
+ myPrototypeLabel = prototypeLabel;
+ }
+
+ public String getPrototypeLabel() {
+ return myPrototypeLabel;
+ }
+
+ public String getOldType() {
+ return myOldType;
+ }
+
+ public String getNewType() {
+ return myNewType;
+ }
+
+ public ViewPrototype getPrototype() {
+ if(myCachedPrototype == null) {
+ myCachedPrototype = findPrototype(myPrototypeLabel);
+ }
+ return myCachedPrototype;
+ }
+
+ private static ViewPrototype findPrototype(String label) {
+ for(ViewPrototype proto : PolicyChecker.getCurrent().getAllPrototypes()) {
+ if(proto.getLabel().contains(label)) {
+ return proto;
+ }
+ }
+ return null;
+ }
+
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
index 17d0e54..689b508 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
@@ -238,6 +238,7 @@ import xpt.editor.VisualIDRegistry
@SuppressWarnings("unchecked")
public org.eclipse.gmf.runtime.notation.Diagram createDiagram(org.eclipse.core.runtime.IAdaptable semanticAdapter, String diagramKind, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagram();«/* FIXME instantiate diagramRunTimeClass instead */»
+ org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils.stampCurrentVersion(diagram);«/* Papyrus specific diagram versioning */»
diagram.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
«xptViewStyles.addCustomStyles(it, 'diagram.getStyles()')»
diagram.setType(«VisualIDRegistry::modelID(it)»);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index 704850f..98e8720 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.common,
org.eclipse.papyrus.infra.gmfdiag.common.model,
org.eclipse.papyrus.infra.gmfdiag.common.preferences,
org.eclipse.papyrus.infra.gmfdiag.common.providers,
+ org.eclipse.papyrus.infra.gmfdiag.common.reconciler,
org.eclipse.papyrus.infra.gmfdiag.common.service.shape,
org.eclipse.papyrus.infra.gmfdiag.common.snap,
org.eclipse.papyrus.infra.gmfdiag.common.strategy,
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index 05125a5..e63fe12 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -10,6 +10,7 @@
<extension-point id="pasteCommandProvider" name="pasteCommandProvider" schema="schema/pasteCommandProvider.exsd"/>
<extension-point id="pasteStrategy" name="pasteStrategy" schema="schema/pasteStrategy.exsd"/>
<extension-point id="copyStrategy" name="copyStrategy" schema="schema/copyStrategy.exsd"/>
+ <extension-point id="diagramReconciler" name="diagramReconciler" schema="schema/diagramReconciler.exsd"/>
<extension
point="org.eclipse.ui.handlers">
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/diagramReconciler.exsd b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/diagramReconciler.exsd
new file mode 100644
index 0000000..6595e6d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/diagramReconciler.exsd
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.common" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.common" id="diagramReconciler" name="diagramReconciler"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="diagramReconciler"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="diagramReconciler">
+ <complexType>
+ <attribute name="diagramType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="reconcilerClass" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="source" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="target" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
index 72508ad..f1a007a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
@@ -17,10 +17,17 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
@@ -35,7 +42,11 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.commands.CheckedDiagramCommandStack;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconcilersReader;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.CommandIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils;
import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
@@ -46,7 +57,9 @@ import org.eclipse.ui.commands.ICommandService;
/**
*
* This GMF editor contains a methods in order to reveal visual element from a list of semantic element.
- *
+ * <p/>
+ * It also provides subclasses with common capability to automatically migrate (reconcile) input
+ * diagrams between papurus versions.
*/
@SuppressWarnings("restriction")
@@ -237,6 +250,113 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
localStore.setValue(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, gridLineStyle);
}
+
+ /**
+ * Encapsulates the reconciling, that is diagram migration between version of Papyrus.
+ */
+ protected static class ReconcileHelper {
+ private final TransactionalEditingDomain domain;
+
+ /**
+ * Instantiates helper that will work with given {@link TransactionalEditingDomain}.
+ * Note that reconcile operations are performed outside the diagram command stack using {@link GMFUnsafe}.
+ */
+ public ReconcileHelper(TransactionalEditingDomain domain) {
+ this.domain = domain;
+ }
+
+ /**
+ * Process diagram reconcilers to migrate models. Does nothing if the diagram is already of the current Papyrus version based on
+ * {@link DiagramVersioningUtils#isOfCurrentPapyrusVersion(Diagram)} check.
+ * <p/>
+ * This method needs configured {@link DiagramEditDomain} to execute collected {@link ICommand} when needed, so it can't be called from
+ * constructor
+ *
+ * @param diagram
+ * the diagram to reconcile
+ * @throws CoreException
+ * subclass may throw wrapping any problem thrown from execution of reconcile using {@link GMFUnsafe}. Default implementation does not
+ * throw it however
+ */
+ public void reconcileDiagram(Diagram diagram) throws CoreException {
+ CompositeCommand migration = buildReconcileCommand(diagram);
+ if (migration == null) {
+ return;
+ }
+ migration.add(DiagramVersioningUtils.createStampCurrentVersionCommand(diagram));
+ try {
+ GMFUnsafe.write(domain, migration);
+ } catch (ExecutionException e) {
+ handleReconcileException(diagram, e);
+ } catch (InterruptedException e) {
+ handleReconcileException(diagram, e);
+ } catch (RollbackException e) {
+ handleReconcileException(diagram, e);
+ }
+ }
+
+ /**
+ * Process diagram reconcilers to migrate models.
+ *
+ * Returns <code>null</code> if the diagram is already of the current Papyrus version based on
+ * {@link DiagramVersioningUtils#isOfCurrentPapyrusVersion(Diagram)} check.
+ * <p/>
+ * If one of the reconcilers returns un-executable command, this method logs the problem and returns <code>null</code>
+ *
+ * @param diagram
+ * the diagram to reconcile
+ */
+ protected CompositeCommand buildReconcileCommand(Diagram diagram) {
+ if(DiagramVersioningUtils.isOfCurrentPapyrusVersion(diagram)) {
+ return null;
+ }
+ String sourceVersion = DiagramVersioningUtils.getCompatibilityVersion(diagram);
+ Map<String, Collection<DiagramReconciler>> diagramReconcilers = DiagramReconcilersReader.getInstance().load();
+ String diagramType = diagram.getType();
+ if(!diagramReconcilers.containsKey(diagramType)) {
+ return null;
+ }
+ Collection<DiagramReconciler> reconcilers = diagramReconcilers.get(diagram.getType());
+
+ boolean someFailed = false;
+ CompositeCommand whole = new CompositeCommand("Reconciling");
+ for(DiagramReconciler next : reconcilers) {
+ if(!next.canReconcileFrom(diagram, sourceVersion)) {
+ //asked for ignore it for this instance, all fine
+ continue;
+ }
+ ICommand nextCommand = next.getReconcileCommand(diagram);
+ if(nextCommand == null) {
+ //legitimate no-op response, all fine
+ continue;
+ }
+ if(nextCommand.canExecute()) {
+ whole.add(nextCommand);
+ } else {
+ Activator.log.error("Diagram reconciler " + next + " failed to reconcile diagram : " + diagram, null); //$NON-NLS-1$ //$NON-NLS-2$
+ someFailed = true;
+ }
+ }
+ if(someFailed) {
+ //probably better to fail the whole reconicle process as user will have a chance to reconcile later when we fix the problem with one of the reconcilers
+ //executing partial reconciliation will leave the diagram in the state with partially current and partially outdated versions
+ return null;
+ }
+
+ return whole;
+ }
+
+ /**
+ * Handles exception from running the diagram reconciler under {@link GMFUnsafe}.
+ * At the time method is called the diagram is probably broken, but default implementation just logs error.
+ * <p/>
+ * This is to allow subclass to decide whether it is worth opening the problem diagram.
+ */
+ protected void handleReconcileException(Diagram diagram, Exception e) throws CoreException {
+ Activator.getInstance().logError("Reconciling the diagram: " + diagram, e);
+ }
+ }
+
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconciler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconciler.java
new file mode 100644
index 0000000..9c2553f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconciler.java
@@ -0,0 +1,137 @@
+package org.eclipse.papyrus.infra.gmfdiag.common.reconciler;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
+
+/**
+ * Instances of this base class are provided via "org.eclipse.papyrus.uml.diagram.common.diagramReconciler" extension point and provide migration of
+ * the diagram instances from "previous" version to the "current" Papyrus version. The version is stored as a {@link StringValueStyle} with name
+ * {@link DiagramVersioningUtils#COMPATIBILITY_VERSION}.
+ * <p/>
+ * Every {@link DiagramReconciler} subclass provides statical descriptor of its capabilities (that is, the supported diagram type, outdated "previous"
+ * version and the expected "current" version). For some possible advanced cases it also gets a chance to decline the reconciliation for some
+ * particular instance based on runtime data, via {@link DiagramReconciler#canReconcileFrom(Diagram, String)}.
+ * <p/>
+ * If the suitable reconcilers are found, all of them are asked to update diagram instance before the first diagram opening. Planned modifications are
+ * provided as an {@link ICommand} instance that allows user to roll-back them all at once.
+ * <p/>
+ */
+public abstract class DiagramReconciler implements IExecutableExtension {
+
+ /**
+ * Extension point attribute passed to {@link IConfigurationElement#createExecutableExtension(String)}, so value should be FQN of reconciler to
+ * instantiate.
+ * <p/>
+ * Note that the value of this class will be used to search the instance to un-register, so it should be unique among all the reconcilers for
+ * given diagram type. It is however safe to define same reconciler class for different diagram types.
+ * <p/>
+ * Value of this constant is "reconcilerClass"
+ */
+ public static final String ATTR_RECONCILER_CLASS = "reconcilerClass"; //$NON-NLS-1$
+
+ /**
+ * Mandatory extension attribute to define applicable diagram type for reconciler
+ * <p/>
+ * Value of this constant is "diagramType"
+ */
+ public static final String ATTR_DIAGRAM_TYPE = "diagramType"; //$NON-NLS-1$
+
+ /**
+ * Mandatory extension attribute to define applicable outdated diagram version this reconciler can handle.
+ * Reconciler's that wants to update diagrams created before the Papyrus 1.0.0 release may be registered to "undefined" source version.
+ * <p/>
+ * Value of this constant is "source"
+ */
+ public static final String ATTR_SOURCE_VERSION = "source"; //$NON-NLS-1$
+
+ /**
+ * Mandatory extension attribute to define applicable "current" diagram version this reconciler will update the instance to.
+ * <p/>
+ * This value should pass the {@link DiagramVersioningUtils#isCurrentPapyrusVersion(String)} check for reconciler to be considered.
+ * <p/>
+ * Value of this constant is "target"
+ */
+ public static final String ATTR_TARGET_VERSION = "target"; //$NON-NLS-1$
+
+ private String myDiagramType;
+
+ private String mySourceVersion;
+
+ private String myTargetVersion;
+
+ /**
+ * The value of this to be used when searching
+ */
+ private String myClassFqn;
+
+ /**
+ * Instance of reconciler gets a chance to deny reconciliation based on some custom run-time properties.
+ * The <code>false</code> value returned from this method means that the diagram is unsuitable for this reconciler, and does not assume any error.
+ * <p>
+ * Subclass can override tgis method, default implementation always return true, because all the dfeault filtering is done based on static
+ * extension declarations.
+ *
+ * @param diagram
+ * the runtime instance to reconcile
+ * @param currentDiagramVersion
+ * @return <code>false</code> if this reconciler wants to be ignored for some particular diagram instance
+ */
+ public boolean canReconcileFrom(Diagram diagram, String currentDiagramVersion) {
+ return true;
+ }
+
+ /**
+ * Creates command that will fix the given diagram and update it to the statically known "current" version.
+ * It is considered an error to return the command with {@link ICommand#canExecute()} of <code>false</code>, and editor implementation will log an
+ * erroneous reconcile attempt.
+ * <p/>
+ * If the reconciler wants to ignore the instance it can either return <code>false</code> from
+ * {@link DiagramReconciler#canReconcileFrom(Diagram, String)} or return <code>null</code> from this method
+ *
+ * @param diagram
+ * @return the command or <code>null</code> if nothing to do with this instance
+ */
+ public abstract ICommand getReconcileCommand(Diagram diagram);
+
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ myDiagramType = config.getAttribute(ATTR_DIAGRAM_TYPE);
+ mySourceVersion = config.getAttribute(ATTR_SOURCE_VERSION);
+ myTargetVersion = config.getAttribute(ATTR_TARGET_VERSION);
+ myClassFqn = config.getAttribute(propertyName);
+ }
+
+ public String getDiagramVisualID() {
+ return myDiagramType;
+ }
+
+ public String getSourceVersion() {
+ return mySourceVersion;
+ }
+
+ public String getTargetVersion() {
+ return myTargetVersion;
+ }
+
+ public String getClassFqn() {
+ return myClassFqn;
+ }
+
+ protected static boolean safeEquals(String s1, String s2) {
+ if(s1 == s2) {
+ return true;
+ }
+ return s1 != null && s1.equals(s2);
+ }
+
+ /**
+ * For debug purpose only
+ */
+ @Override
+ public String toString() {
+ return "DiagramReconciler:" + myClassFqn + "[" + myDiagramType + ": " + mySourceVersion + " -> " + myTargetVersion + "]";
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconcilersReader.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconcilersReader.java
new file mode 100644
index 0000000..9124d72
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramReconcilersReader.java
@@ -0,0 +1,175 @@
+package org.eclipse.papyrus.infra.gmfdiag.common.reconciler;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.plugin.RegistryReader;
+import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
+
+public class DiagramReconcilersReader extends RegistryReader {
+
+ private static volatile DiagramReconcilersReader ourInstance = null;
+
+ private static final String EXT_PT = "diagramReconciler"; //$NON-NLS-1$
+
+ private static final String TAG_DIAGRAM_RECONCILER = "diagramReconciler"; //$NON-NLS-1$
+
+ private Map<String, Collection<DiagramReconciler>> myReconcilers;
+
+ /**
+ * Read-only view on the myReconcilers bag. Only available when myReconcilers != null
+ */
+ private Map<String, Collection<DiagramReconciler>> myReconcilersRO;
+
+ public final static DiagramReconcilersReader getInstance() {
+ if(ourInstance == null) {
+ synchronized(DiagramReconcilersReader.class) {
+ if(ourInstance == null) {
+ ourInstance = new DiagramReconcilersReader();
+ }
+ }
+ }
+ return ourInstance;
+ }
+
+ DiagramReconcilersReader() {
+ super(Platform.getExtensionRegistry(), Activator.ID, EXT_PT);
+ }
+
+ /**
+ * @return unmodifiable map of loaded reconcilers
+ */
+ public synchronized Map<String, Collection<DiagramReconciler>> load() {
+ if(myReconcilers == null) {
+ myReconcilers = new HashMap<String, Collection<DiagramReconciler>>();
+ myReconcilersRO = Collections.unmodifiableMap(myReconcilers);
+ readRegistry();
+ }
+ return myReconcilersRO;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.ecore.plugin.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement, boolean)
+ */
+ @Override
+ protected boolean readElement(IConfigurationElement element, boolean add) {
+ if(!TAG_DIAGRAM_RECONCILER.equals(element.getName())) {
+ return false;
+ }
+
+ String className = element.getAttribute(DiagramReconciler.ATTR_RECONCILER_CLASS);
+ String diagramTypeString = element.getAttribute(DiagramReconciler.ATTR_DIAGRAM_TYPE);
+ String sourceVersion = element.getAttribute(DiagramReconciler.ATTR_SOURCE_VERSION);
+ String targetVersion = element.getAttribute(DiagramReconciler.ATTR_TARGET_VERSION);
+
+ if(!checkNotEmpty(className)) {
+ logMissingAttribute(element, DiagramReconciler.ATTR_RECONCILER_CLASS);
+ return false;
+ }
+ if(!checkNotEmpty(diagramTypeString)) {
+ logMissingAttribute(element, DiagramReconciler.ATTR_DIAGRAM_TYPE);
+ return false;
+ }
+ if(!checkNotEmpty(sourceVersion)) {
+ logMissingAttribute(element, DiagramReconciler.ATTR_SOURCE_VERSION);
+ return false;
+ }
+
+ if(!checkNotEmpty(targetVersion)) {
+ logMissingAttribute(element, DiagramReconciler.ATTR_TARGET_VERSION);
+ return false;
+ }
+ if(!DiagramVersioningUtils.isCurrentPapyrusVersion(targetVersion)) {
+ Activator.log.debug("Reconciler for outdated version is still registered but will never be executed: " + className); //$NON-NLS-1$
+ return false;
+ }
+
+
+ if(add) {
+ addDiagramReconciler(element);
+ } else {
+ removeDiagramReconciler(element);
+ }
+
+ return true;
+ }
+
+ private static boolean checkNotEmpty(String attr) {
+ return (attr != null) && (attr.length() != 0);
+ }
+
+ protected void addDiagramReconciler(IConfigurationElement element) {
+ DiagramReconciler reconciler = createReconciler(element);
+ if(reconciler != null) {
+ synchronized(myReconcilers) {
+ String diagramType = reconciler.getDiagramVisualID();
+ Collection<DiagramReconciler> listForType = myReconcilers.get(diagramType);
+ if(listForType == null) {
+ listForType = new LinkedList<DiagramReconciler>();
+ myReconcilers.put(diagramType, listForType);
+ }
+ listForType.add(reconciler);
+ }
+ }
+ }
+
+ /**
+ * Unregisters reconciler defined by given extension element.
+ * <p/>
+ * Only diagram type and fully qualified class name will be used to find the one instance to remove.
+ */
+ protected void removeDiagramReconciler(IConfigurationElement element) {
+ String diagramTypeString = element.getAttribute(DiagramReconciler.ATTR_DIAGRAM_TYPE);
+ String fqn = element.getAttribute(DiagramReconciler.ATTR_RECONCILER_CLASS);
+ if(diagramTypeString == null || fqn == null) {
+ //we already have skipped this config at the time of addition
+ return;
+ }
+
+ synchronized(myReconcilers) {
+ Collection<DiagramReconciler> reconcilers = myReconcilers.get(diagramTypeString);
+ if(reconcilers != null) {
+ for(Iterator<DiagramReconciler> it = reconcilers.iterator(); it.hasNext();) {
+ DiagramReconciler next = it.next();
+ if(fqn.equals(next.getClassFqn())) {
+ it.remove();
+ break;
+ }
+ }
+ if(reconcilers.size() == 0) {
+ myReconcilers.remove(diagramTypeString);
+ }
+ }
+ }
+ }
+
+ /**
+ * Instantiates the reconciler defined by given extension
+ *
+ * @param element
+ * @return configured reconciler instance or <code>null</code> if something bad happens (error is logged in this case)
+ */
+ private DiagramReconciler createReconciler(IConfigurationElement element) {
+ try {
+ Object diagramReconcilerObject = element.createExecutableExtension(DiagramReconciler.ATTR_RECONCILER_CLASS);
+ if(diagramReconcilerObject instanceof DiagramReconciler) {
+ return (DiagramReconciler)diagramReconcilerObject;
+ } else {
+ Activator.log.error("Diagram reconciler extension does not extend mandatory DiagramReconciler base class: " + element.getAttribute(DiagramReconciler.ATTR_RECONCILER_CLASS), null); //$NON-NLS-1$
+ }
+ } catch (CoreException e) {
+ Activator.getInstance().getLog().log(e.getStatus());
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java
new file mode 100644
index 0000000..0bea637
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java
@@ -0,0 +1,158 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * 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.infra.gmfdiag.common.reconciler;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * This class provide several convenience methods to tag a diagram with a version number
+ * in a notation style, or retrieve this version number.
+ */
+public class DiagramVersioningUtils {
+
+ /**
+ * Returns the "current" diagram version. Diagrams with this version don't require the reconciliation until the Papyrus version updates in such a
+ * way that some diagram needs reconciliation.
+ * <p/>
+ * The current value returned by this method is "1.0.0".
+ * <p/>
+ * The value itself, howewer, should NOT be used outside of this package to avoid weird dependency issues. Instead, external code should use
+ * {@link DiagramVersioningUtils#stampCurrentVersion(Diagram)} and {@link DiagramVersioningUtils#createStampCurrentVersionCommand(Diagram)}.
+ * <p/>
+ * This method is intentinally NOT a constant but indeed the method. This method is intentionally private and should NOT be made public.
+ */
+ private static String CURRENT_DIAGRAM_VERSION() {
+ return "1.0.0";
+ }
+
+ /**
+ * Directly marks the given diagram as either created with "current" Papyrus version or already reconciled to the "current" Papyrus version.
+ * <p/>
+ * It is guaranteed that {@link DiagramVersioningUtils#isOfCurrentPapyrusVersion(Diagram)} returns true immediately after the call to this method.
+ *
+ * @param diagram
+ * diagram to stamp as "current"
+ */
+ public static void stampCurrentVersion(Diagram diagram) {
+ setCompatibilityVersion(diagram, CURRENT_DIAGRAM_VERSION());
+ }
+
+ /**
+ * Returns the command that will mark the given diagram as either created with "current" Papyrus version or already reconciled to the "current"
+ * Papyrus version.
+ * <p/>
+ * It is guaranteed that {@link DiagramVersioningUtils#isOfCurrentPapyrusVersion(Diagram)} will returns true immediately after the execution of
+ * the command.
+ *
+ * @param diagram
+ * @return the command that is guaranteed to be not null and executable
+ */
+ public static ICommand createStampCurrentVersionCommand(Diagram diagram) {
+ StringValueStyle style = findOrCreateCompatibilityStyle(diagram);
+ if(style.eContainer() == null) {
+ style.setStringValue(CURRENT_DIAGRAM_VERSION());
+ return new SetValueCommand(new SetRequest(diagram, NotationPackage.eINSTANCE.getView_Styles(), style));
+ } else {
+ return new SetValueCommand(new SetRequest(style, NotationPackage.eINSTANCE.getStringValueStyle_StringValue(), CURRENT_DIAGRAM_VERSION()));
+ }
+ }
+
+ /**
+ * The name of the {@link StringValueStyle} that defines actual diagram version.
+ * <p/>
+ * The value for this constant is "diagram_compatibility_version", it is intentionally the same as been used for SysML diagrams versioning.
+ */
+ public static final String COMPATIBILITY_VERSION = "diagram_compatibility_version";
+
+ /**
+ * The version constant for the diagrams that does not have a {@link DiagramVersioningUtils#COMPATIBILITY_VERSION} style.
+ * It may be assumed that these diagrams had been created before Papyrus 1.0.
+ */
+ public static final String UNDEFINED_VERSION = "undefined";
+
+ /**
+ * Get the diagram compatibility version.
+ *
+ * @param view
+ * the diagram
+ * @return the compatibility version or {@link DiagramVersioningUtils#UNDEFINED_VERSION} if none stored. Never returns <code>null</code>.
+ */
+ public static String getCompatibilityVersion(View view) {
+ StringValueStyle semanticStyle = (StringValueStyle)view.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), COMPATIBILITY_VERSION);
+ return semanticStyle == null ? UNDEFINED_VERSION : semanticStyle.getStringValue();
+ }
+
+ /**
+ * Set the diagram compatibility version.
+ *
+ * @param diagram
+ * the diagram
+ * @param version
+ * the compatibility version
+ */
+ @SuppressWarnings("unchecked")
+ public static void setCompatibilityVersion(View view, String version) {
+ StringValueStyle style = findOrCreateCompatibilityStyle(view);
+ style.setStringValue(version);
+ if(style.eContainer() == null) {
+ view.getStyles().add(style);
+ }
+ }
+
+ /**
+ * Finds the existing style with {@link DiagramVersioningUtils#COMPATIBILITY_VERSION} name or creates a new one if none existing found.
+ * Does NOT attach the new style to the instance, it is left as a caller responsibility.
+ *
+ * @param view
+ * @return the existing or a new not-attached style with {@link DiagramVersioningUtils#COMPATIBILITY_VERSION} name. Called can determine the case
+ * by checking {@link EObject#eContainer()} which is guaranteed to be null in case if new object had been created
+ */
+ private static StringValueStyle findOrCreateCompatibilityStyle(View view) {
+ StringValueStyle style = (StringValueStyle)view.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), COMPATIBILITY_VERSION);
+ if(style == null) {
+ style = NotationFactory.eINSTANCE.createStringValueStyle();
+ style.setName(COMPATIBILITY_VERSION);
+ }
+ return style;
+ }
+
+ /**
+ * Checks whether the diagram is of "current", last released type.
+ */
+ public static boolean isOfCurrentPapyrusVersion(Diagram diagram) {
+ return isCurrentPapyrusVersion(getCompatibilityVersion(diagram));
+ }
+
+ /**
+ * Checks whether the given string represent the current papyrus version without telling explicitly what the current version is.
+ *
+ * @param version
+ * version to check
+ * @return
+ */
+ public static boolean isCurrentPapyrusVersion(String version) {
+ return CURRENT_DIAGRAM_VERSION().equals(version);
+ }
+
+
+
+}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/compatibility/DiagramVersioningUtils.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/compatibility/DiagramVersioningUtils.java
index 906c4ba..6182658 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/compatibility/DiagramVersioningUtils.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/compatibility/DiagramVersioningUtils.java
@@ -13,50 +13,12 @@
*****************************************************************************/
package org.eclipse.papyrus.gmf.diagram.common.compatibility;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.StringValueStyle;
/**
- * This class provide several convenience methods to tag a diagram with a version number
- * in a notation style, or retrieve this version number.
+ * @deprecated This class is repackaged as {@link org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils}, this old version is
+ * deprecated and left for binary compatibility only
*/
-public class DiagramVersioningUtils {
+@Deprecated
+public class DiagramVersioningUtils extends org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils {
- /**
- * The ID for the diagram internal version number stored in Notation model.
- */
- private static final String DIAGRAM_COMPATIBILITY_VERSION = "diagram_compatibility_version";
-
- /**
- * The ID for the diagram internal version number stored in Notation model.
- */
- public static final String UNDEFINED_VERSION = "undefined";
-
- /**
- * Get the diagram compatibility version.
- * @param diagram the diagram
- * @return the compatibility version.
- */
- public static String getCompatibilityVersion(Diagram diagram) {
- StringValueStyle semanticStyle = (StringValueStyle)diagram.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), DIAGRAM_COMPATIBILITY_VERSION);
- return semanticStyle == null ? UNDEFINED_VERSION : semanticStyle.getStringValue();
- }
-
- /**
- * Set the diagram compatibility version.
- * @param diagram the diagram
- * @param version the compatibility version
- */
- @SuppressWarnings("unchecked")
- public static void setCompatibilityVersion(Diagram diagram, String version) {
- StringValueStyle style = (StringValueStyle)diagram.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), DIAGRAM_COMPATIBILITY_VERSION);
- if (style == null) {
- style = NotationFactory.eINSTANCE.createStringValueStyle();
- style.setName(DIAGRAM_COMPATIBILITY_VERSION);
- diagram.getStyles().add(style);
- }
- style.setStringValue(version);
- }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/providers/UMLViewProvider.java
index d744396..9f3b9b7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/providers/UMLViewProvider.java
@@ -56,6 +56,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.*;
import org.eclipse.papyrus.uml.diagram.activity.locator.PinPositionLocator;
@@ -322,6 +323,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
*/
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(ActivityDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/providers/UMLViewProvider.java
index 0fec21c..03e73fe 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.*;
import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
@@ -296,6 +297,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(ModelEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
index d643571..80a03c6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
@@ -4,6 +4,7 @@
package org.eclipse.papyrus.uml.diagram.common.part;
import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
@@ -15,6 +16,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.gmfdiag.common.SynchronizableGmfDiagramEditor;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.contexts.IContextService;
/**
@@ -64,6 +66,14 @@ public class UmlGmfDiagramEditor extends SynchronizableGmfDiagramEditor {
saveAndDirtyService.registerIsaveablePart(this);
}
+ @Override
+ public void doSetInput(IEditorInput input, boolean releaseEditorContents) throws CoreException {
+ super.doSetInput(input, releaseEditorContents);
+ if(getDiagram() != null) {
+ new ReconcileHelper(getEditingDomain()).reconcileDiagram(getDiagram());
+ }
+ }
+
/**
* Dispose services used in this part.
*
@@ -82,8 +92,8 @@ public class UmlGmfDiagramEditor extends SynchronizableGmfDiagramEditor {
return false;
}
- }); //Avoid disposing the shared UndoContext when this nestedEditor is dispose
- //Super.dispose() will try to dispose the IUndoContext
+ }); // Avoid disposing the shared UndoContext when this nestedEditor is dispose
+ // Super.dispose() will try to dispose the IUndoContext
super.dispose();
@@ -222,8 +232,8 @@ public class UmlGmfDiagramEditor extends SynchronizableGmfDiagramEditor {
@Override
public void createPartControl(Composite parent) {
IContextService contextService = (IContextService)getSite().getService(IContextService.class);
- //FIXME : before Eclipse Juno, this line was not necessary
- //see bug 367816 and bug 382218
+ // FIXME : before Eclipse Juno, this line was not necessary
+ // see bug 367816 and bug 382218
contextService.activateContext("org.eclipse.gmf.runtime.diagram.ui.diagramContext"); //$NON-NLS-1$
super.createPartControl(parent);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java
index 0fa2ecf..8274b97 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.communication.edit.parts.AppliedStereotypeMessageEditPart;
@@ -254,6 +255,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(ModelEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/providers/UMLViewProvider.java
index 0583ac0..2ee91c1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.component.edit.parts.AbstractionAppliedStereotypeEditPart;
@@ -326,6 +327,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(ComponentDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/providers/UMLViewProvider.java
index 6746224..e995fdc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/providers/UMLViewProvider.java
@@ -55,6 +55,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.*;
@@ -310,6 +311,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(CompositeStructureDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/providers/UMLViewProvider.java
index 4383e9f..4be4c7c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactCompositeCompartmentEditPart;
@@ -326,6 +327,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(DeploymentDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
index 866b20a..3f30d90 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.profile.edit.parts.*;
@@ -252,6 +253,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(ProfileDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java
index d3bb203..2104559 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java
@@ -55,6 +55,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
@@ -308,6 +309,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
*/
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(PackageEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java
index 388ce2a..c5d1960 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.CommentAnnotatedElementEditPart;
@@ -307,6 +308,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(PackageEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/providers/UMLViewProvider.java
index 6bdad4c..36e4bf0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.timing.edit.parts.CompactLifelineCompartmentEditPartCN;
@@ -315,6 +316,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(TimingDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/providers/UMLViewProvider.java
index 9cc3271..39b59f3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/providers/UMLViewProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.usecase.edit.parts.AbstractionEditPart;
@@ -333,6 +334,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider {
@SuppressWarnings("unchecked")
public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
diagram.setType(UseCaseDiagramEditPart.MODEL_ID);
diagram.setElement(getSemanticElement(semanticAdapter));