Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime PORHEL2013-12-04 17:23:52 +0000
committerMaxime PORHEL2013-12-11 13:12:19 +0000
commit48693804124fa95627e94fe445d9abe904864600 (patch)
treeba58a2aff93ce69c63bbab8816fa50393f5e9d39
parentd422f15b48f2eb95e06dca8ff0fca62c896ffed7 (diff)
downloadorg.eclipse.sirius-48693804124fa95627e94fe445d9abe904864600.tar.gz
org.eclipse.sirius-48693804124fa95627e94fe445d9abe904864600.tar.xz
org.eclipse.sirius-48693804124fa95627e94fe445d9abe904864600.zip
[423576] Add version tags during preSave
This should be done on Group and DAnalysis to remember the creation version. Otherwise, the next loads will trigger the migration (until the next save). This is done in resource handlers during preSave. eDeliver has been deactivated during the version modification to avoid to trigger notification while save is performed. Correctly launch the indirectly collapsed node migration. It has been introduced in 6.5.3 et 6.7.0 versions. The migration application condition must trigger the migration for version < 6.5.3 or version between 6.6.0 and 6.7. The sequence migration part has also been modified. Cherry-picked from 9c2c27d1896b53c20069f92ebd1af0d59325bb7c Signed-off-by: Maxime PORHEL <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/internal/migration/SequenceDiagramRepresentationsFileMigrationParticipant.java42
-rw-r--r--plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipant.java20
-rw-r--r--plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipantV670.java20
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.html2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.textile2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.textile2
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/wizards/DescriptionModelWizardSpec.java18
-rw-r--r--plugins/org.eclipse.sirius/plugin.xml8
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/AbstractSiriusMigrationService.java12
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/DefaultRepresentationsFileMigrationParticipant.java47
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/RepresentationsFileResourceHandler.java27
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/DefaultVSMMigrationParticipant.java46
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/VSMResourceHandler.java32
14 files changed, 118 insertions, 162 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/internal/migration/SequenceDiagramRepresentationsFileMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/internal/migration/SequenceDiagramRepresentationsFileMigrationParticipant.java
index 5fd1fee5c2..3fa40a4311 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/internal/migration/SequenceDiagramRepresentationsFileMigrationParticipant.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/internal/migration/SequenceDiagramRepresentationsFileMigrationParticipant.java
@@ -18,16 +18,8 @@ import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Node;
-import org.osgi.framework.Version;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-
-import org.eclipse.sirius.common.tools.api.util.Option;
import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant;
+import org.eclipse.sirius.common.tools.api.util.Option;
import org.eclipse.sirius.diagram.business.api.query.DDiagramGraphicalQuery;
import org.eclipse.sirius.diagram.business.api.query.NodeQuery;
import org.eclipse.sirius.diagram.internal.edit.parts.DNode2EditPart;
@@ -53,6 +45,13 @@ import org.eclipse.sirius.viewpoint.DView;
import org.eclipse.sirius.viewpoint.GraphicalFilter;
import org.eclipse.sirius.viewpoint.IndirectlyCollapseFilter;
import org.eclipse.sirius.viewpoint.ViewpointFactory;
+import org.osgi.framework.Version;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
/**
* Migration contribution for sequence diagram part of representations file.
@@ -63,7 +62,11 @@ public class SequenceDiagramRepresentationsFileMigrationParticipant extends Abst
/**
* The latest VP version for this participant.
*/
- private static final Version MIGRATION_VERSION = new Version("6.5.3.201301221200");
+ private static final Version MIGRATION_VERSION = new Version("6.7.0.201302181200");
+
+ private static final Version ALREADY_MIGRATED_VERSION = new Version("6.5.3");
+
+ private static final Version NOT_MIGRATED_VERSION = new Version("6.6.0");
private Predicate<Node> isNode = new IsNode();
@@ -86,9 +89,16 @@ public class SequenceDiagramRepresentationsFileMigrationParticipant extends Abst
public void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
super.postLoad(dAnalysis, loadedVersion);
- List<Diagram> sequenceDiagrams = getGMFSequenceDiagrams(dAnalysis);
- if (!sequenceDiagrams.isEmpty()) {
- migrateGMFBoundsOfCollapsedBorderedNode(sequenceDiagrams);
+ if (loadedVersion.compareTo(MIGRATION_VERSION) < 0) {
+ // The 6.5.3 maintenance version already contains the migration,
+ // migration should be done for versions in
+ // [0.0.0, 6.5.3[ U [6.6.0, 6.7.0[.
+ if (loadedVersion.compareTo(ALREADY_MIGRATED_VERSION) < 0 || loadedVersion.compareTo(NOT_MIGRATED_VERSION) >= 0) {
+ List<Diagram> sequenceDiagrams = getGMFSequenceDiagrams(dAnalysis);
+ if (!sequenceDiagrams.isEmpty()) {
+ migrateGMFBoundsOfCollapsedBorderedNode(sequenceDiagrams);
+ }
+ }
}
}
@@ -173,8 +183,10 @@ public class SequenceDiagramRepresentationsFileMigrationParticipant extends Abst
}
}
for (DDiagramElement indirectlyCollaspedDDE : indirectlyCollaspedDDEs) {
- IndirectlyCollapseFilter indirectlyCollapseFilter = ViewpointFactory.eINSTANCE.createIndirectlyCollapseFilter();
- indirectlyCollaspedDDE.getGraphicalFilters().add(indirectlyCollapseFilter);
+ if (!Iterables.any(indirectlyCollaspedDDE.getGraphicalFilters(), Predicates.instanceOf(IndirectlyCollapseFilter.class))) {
+ IndirectlyCollapseFilter indirectlyCollapseFilter = ViewpointFactory.eINSTANCE.createIndirectlyCollapseFilter();
+ indirectlyCollaspedDDE.getGraphicalFilters().add(indirectlyCollapseFilter);
+ }
}
}
diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipant.java
index 16ffaddd2c..33a7d07d7a 100644
--- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipant.java
+++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipant.java
@@ -40,6 +40,8 @@ public class DiagramRepresentationsFileMigrationParticipant extends AbstractRepr
private static final Version ALREADY_MIGRATED_VERSION = new Version("6.5.3");
+ private static final Version NOT_MIGRATED_VERSION = new Version("6.6.0");
+
/**
* {@inheritDoc}
*/
@@ -54,12 +56,18 @@ public class DiagramRepresentationsFileMigrationParticipant extends AbstractRepr
new DiagramRepresentationsFileMigrationParticipantV650().moveGMFDiagramsFromRoot(dAnalysis, diagramsToMove);
}
}
- if (loadedVersion.compareTo(ALREADY_MIGRATED_VERSION) < 0) {
- List<Diagram> diagrams = getGMFDiagrams(dAnalysis);
- if (!diagrams.isEmpty()) {
- DiagramRepresentationsFileMigrationParticipantV670 diagramRepresentationsFileMigrationParticipantV670 = new DiagramRepresentationsFileMigrationParticipantV670();
- diagramRepresentationsFileMigrationParticipantV670.migrateLabelConstraintFromBoundsToLocation(diagrams);
- diagramRepresentationsFileMigrationParticipantV670.migrateGMFBoundsOfBorderedNodes(diagrams);
+
+ if (loadedVersion.compareTo(DiagramRepresentationsFileMigrationParticipantV670.MIGRATION_VERSION) < 0) {
+ // The 6.5.3 maintenance version already contains the migration,
+ // migration should be done for versions in
+ // [0.0.0, 6.5.3[ U [6.6.0, 6.7.0[.
+ if (loadedVersion.compareTo(ALREADY_MIGRATED_VERSION) < 0 || loadedVersion.compareTo(NOT_MIGRATED_VERSION) >= 0) {
+ List<Diagram> diagrams = getGMFDiagrams(dAnalysis);
+ if (!diagrams.isEmpty()) {
+ DiagramRepresentationsFileMigrationParticipantV670 diagramRepresentationsFileMigrationParticipantV670 = new DiagramRepresentationsFileMigrationParticipantV670();
+ diagramRepresentationsFileMigrationParticipantV670.migrateLabelConstraintFromBoundsToLocation(diagrams);
+ diagramRepresentationsFileMigrationParticipantV670.migrateGMFBoundsOfBorderedNodes(diagrams);
+ }
}
}
if (loadedVersion.compareTo(DiagramRepresentationsFileMigrationParticipantV680.MIGRATION_VERSION) < 0) {
diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipantV670.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipantV670.java
index 587efb16b7..ff8ad895a7 100644
--- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipantV670.java
+++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/DiagramRepresentationsFileMigrationParticipantV670.java
@@ -25,13 +25,6 @@ import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.osgi.framework.Version;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-
import org.eclipse.sirius.business.api.query.DDiagramElementQuery;
import org.eclipse.sirius.diagram.business.api.query.NodeQuery;
import org.eclipse.sirius.diagram.edit.internal.part.PortLayoutHelper;
@@ -60,6 +53,13 @@ import org.eclipse.sirius.viewpoint.IndirectlyCollapseFilter;
import org.eclipse.sirius.viewpoint.ViewpointFactory;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
+import org.osgi.framework.Version;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
/**
* The migration code of Sirius 6.7.0.
@@ -268,8 +268,10 @@ public class DiagramRepresentationsFileMigrationParticipantV670 {
}
}
for (DDiagramElement indirectlyCollaspedDDE : indirectlyCollaspedDDEs) {
- IndirectlyCollapseFilter indirectlyCollapseFilter = ViewpointFactory.eINSTANCE.createIndirectlyCollapseFilter();
- indirectlyCollaspedDDE.getGraphicalFilters().add(indirectlyCollapseFilter);
+ if (!Iterables.any(indirectlyCollaspedDDE.getGraphicalFilters(), Predicates.instanceOf(IndirectlyCollapseFilter.class))) {
+ IndirectlyCollapseFilter indirectlyCollapseFilter = ViewpointFactory.eINSTANCE.createIndirectlyCollapseFilter();
+ indirectlyCollaspedDDE.getGraphicalFilters().add(indirectlyCollapseFilter);
+ }
}
}
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.html b/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.html
index 6e7f471c48..c3138c793b 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.html
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.html
@@ -360,7 +360,7 @@
<p>Note that Sirius does its best to take into account any change in the VSM, even for existing and opened representations. Sometimes, if the changes are too complex or in some corner cases not yet supported, you may need to close and reopen your representation, or in extreme case delete it and create a new one, in order to take the VSM changes into account properly.</p>
<h3 id="migration">Migration from Previous Versions</h3>
<p>The
- <em>Viewpoint Specification Model</em> can evolve between two versions of Sirius. The migration process is done automatically. That means all VSM are migrated at loading time without any action from the user.
+ <em>Viewpoint Specification Model</em> can evolve between two versions of Sirius. The migration process is done automatically. That means all VSM are migrated at loading time without any action from the user. While a VSM is not saved, the automatic migration will be replayed at the next opening.
</p>
</body>
</html> \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.textile b/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.textile
index f716e23678..3d76a0a75e 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/Specifying_Viewpoints.textile
@@ -138,4 +138,4 @@ Note that Sirius does its best to take into account any change in the VSM, even
h3(#migration). Migration from Previous Versions
-The _Viewpoint Specification Model_ can evolve between two versions of Sirius. The migration process is done automatically. That means all VSM are migrated at loading time without any action from the user.
+The _Viewpoint Specification Model_ can evolve between two versions of Sirius. The migration process is done automatically. That means all VSM are migrated at loading time without any action from the user. While a VSM is not saved, the automatic migration will be replayed at the next opening.
diff --git a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html
index 3c20a0f38c..5f79ecd8af 100644
--- a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html
+++ b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html
@@ -158,7 +158,7 @@
<a href="../../Release%20Notes.html">release notes</a> for more details.
</p>
<h3 id="Migration">Migration of Existing Representation Files</h3>
- <p>Representation files are now automatically migrated when opened. This migration is transparent for the end-user.</p>
+ <p>Representation files are now automatically migrated when opened. This migration is transparent for the end-user. While a representation file is not saved, the automatic migration will be replayed at the next opening.</p>
<h3 id="UICHanges">User Interface Changes</h3>
<p>You will notice some radical changes in the user interface. The most important change is the disappearance of the
<em>Model Content</em> view. It has been replaced with a streamlined UI which integrates directly into the Eclipse explorer view. The notion of &#171;Local Session&#187; has disappeared from the user interface; its management has been made as transparent as possible so you do not have to deal with it except in some very specific circumstances.
diff --git a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.textile b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.textile
index af67e34fc1..821c75e83f 100644
--- a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.textile
@@ -31,7 +31,7 @@ New users can skip this section safely. For users of previous version who have e
h3(#Migration). Migration of Existing Representation Files
-Representation files are now automatically migrated when opened. This migration is transparent for the end-user.
+Representation files are now automatically migrated when opened. This migration is transparent for the end-user. While a representation file is not saved, the automatic migration will be replayed at the next opening.
h3(#UICHanges). User Interface Changes
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/wizards/DescriptionModelWizardSpec.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/wizards/DescriptionModelWizardSpec.java
index dec2fc03dc..d066a29b86 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/wizards/DescriptionModelWizardSpec.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/wizards/DescriptionModelWizardSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008, 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2013 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.sirius.editor.wizards;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.sirius.editor.editorPlugin.SiriusEditorPlugin;
@@ -30,17 +29,4 @@ public class DescriptionModelWizardSpec extends DescriptionModelWizard {
setWindowTitle(SiriusEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(SiriusEditorPlugin.INSTANCE.getImage("full/wizban/banner_odesign")));
}
-
- /**
- * Create a new model.
- */
- @Override
- protected EObject createInitialModel() {
- // super should create the group and name it.
- EObject rootObject = super.createInitialModel();
- // if (rootObject instanceof Group) {
- // addNecessaryMigrationTags((Group) rootObject);
- // }
- return rootObject;
- }
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius/plugin.xml b/plugins/org.eclipse.sirius/plugin.xml
index 379b697009..08f4ce146b 100644
--- a/plugins/org.eclipse.sirius/plugin.xml
+++ b/plugins/org.eclipse.sirius/plugin.xml
@@ -530,10 +530,6 @@
<extension
point="org.eclipse.sirius.migrationParticipant">
<participant
- class="org.eclipse.sirius.business.internal.migration.DefaultRepresentationsFileMigrationParticipant"
- kind="RepresentationsFile">
- </participant>
- <participant
class="org.eclipse.sirius.business.internal.migration.RemoveOldMigrationAnnotations"
kind="RepresentationsFile">
</participant>
@@ -542,10 +538,6 @@
kind="RepresentationsFile">
</participant>
<participant
- class="org.eclipse.sirius.business.internal.migration.description.DefaultVSMMigrationParticipant"
- kind="VSM">
- </participant>
- <participant
class="org.eclipse.sirius.business.internal.migration.description.RemoveOldMigrationAnnotations"
kind="VSM">
</participant>
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/AbstractSiriusMigrationService.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/AbstractSiriusMigrationService.java
index 9dbf31d941..4e767aa501 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/AbstractSiriusMigrationService.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/AbstractSiriusMigrationService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2012, 2013 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,6 +43,10 @@ import org.osgi.framework.Version;
*/
public abstract class AbstractSiriusMigrationService {
+ // This migration way was introduced with 6.5.0.201208161001 version
+ // for both VSM and representations files.
+ private static final Version FIRST_VERSION = new Version("6.5.0.201208161001");
+
/**
* loaded delegates contributions.
*/
@@ -229,10 +233,10 @@ public abstract class AbstractSiriusMigrationService {
*/
public Version getLastMigrationVersion() {
if (lastMigrationVersion == null) {
+ // Initialized here to do the initialization only once.
+ lastMigrationVersion = FIRST_VERSION;
for (IMigrationParticipant contribution : delegatesParticipants) {
- if (lastMigrationVersion == null) {
- lastMigrationVersion = contribution.getMigrationVersion();
- } else if (lastMigrationVersion.compareTo(contribution.getMigrationVersion()) < 0) {
+ if (lastMigrationVersion.compareTo(contribution.getMigrationVersion()) < 0) {
lastMigrationVersion = contribution.getMigrationVersion();
}
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/DefaultRepresentationsFileMigrationParticipant.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/DefaultRepresentationsFileMigrationParticipant.java
deleted file mode 100644
index 2a6d479677..0000000000
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/DefaultRepresentationsFileMigrationParticipant.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 THALES GLOBAL SERVICES.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.business.internal.migration;
-
-import org.osgi.framework.Version;
-import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant;
-import org.eclipse.sirius.viewpoint.DAnalysis;
-
-/**
- * This migration participant updates the version attribute to the last
- * migration version.
- *
- * @author fbarbin
- *
- */
-public class DefaultRepresentationsFileMigrationParticipant extends AbstractRepresentationsFileMigrationParticipant {
- /**
- * The VP version for which this migration is added.
- */
- private static final Version MIGRATION_VERSION = new Version("6.5.0.201208161001");
-
- /**
- * {@inheritDoc}
- */
- public void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
- super.postLoad(dAnalysis, loadedVersion);
- // Set version according to current bundle version
- dAnalysis.setVersion(RepresentationsFileMigrationService.getInstance().getLastMigrationVersion().toString());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.business.api.migration.IMigrationParticipant#getMigrationVersion()
- */
- public Version getMigrationVersion() {
- return MIGRATION_VERSION;
- }
-}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/RepresentationsFileResourceHandler.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/RepresentationsFileResourceHandler.java
index 7939618b8f..2d16a6d2ff 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/RepresentationsFileResourceHandler.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/RepresentationsFileResourceHandler.java
@@ -11,10 +11,13 @@
package org.eclipse.sirius.business.internal.migration;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Map;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler;
+import org.eclipse.sirius.viewpoint.DAnalysis;
+import org.osgi.framework.Version;
/**
* Implementation for viewpoint migration post-treatment. Delegates to
@@ -37,10 +40,32 @@ public class RepresentationsFileResourceHandler extends BasicResourceHandler {
this.loadedVersion = loadedVersion;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void postLoad(XMLResource resource, InputStream inputStream, Map<?, ?> options) {
RepresentationsFileMigrationService.getInstance().postLoad(resource, loadedVersion);
super.postLoad(resource, inputStream, options);
}
-}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void preSave(XMLResource resource, OutputStream outputStream, Map<?, ?> options) {
+ super.preSave(resource, outputStream, options);
+
+ if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof DAnalysis) {
+ DAnalysis analysis = (DAnalysis) resource.getContents().get(0);
+ Version lastMigrationVersion = RepresentationsFileMigrationService.getInstance().getLastMigrationVersion();
+
+ boolean previousDeliver = analysis.eDeliver();
+ analysis.eSetDeliver(false);
+
+ analysis.setVersion(lastMigrationVersion.toString());
+
+ analysis.eSetDeliver(previousDeliver);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/DefaultVSMMigrationParticipant.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/DefaultVSMMigrationParticipant.java
deleted file mode 100644
index 50dce6d789..0000000000
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/DefaultVSMMigrationParticipant.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 THALES GLOBAL SERVICES.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.business.internal.migration.description;
-
-import org.osgi.framework.Version;
-import org.eclipse.sirius.business.api.migration.AbstractVSMMigrationParticipant;
-import org.eclipse.sirius.viewpoint.description.Group;
-
-/**
- * The default participant for VSM migration rules. Updates the version
- * attribute to the last migration version.
- *
- * @author fbarbin
- *
- */
-public class DefaultVSMMigrationParticipant extends AbstractVSMMigrationParticipant {
- /**
- * The VP version for which this migration is added.
- */
- private static final Version MIGRATION_VERSION = new Version("6.5.0.201208161001");
-
- /**
- * {@inheritDoc}
- */
- public void postLoad(Group group, Version loadedVersion) {
- super.postLoad(group, loadedVersion);
- group.setVersion(VSMMigrationService.getInstance().getLastMigrationVersion().toString());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.business.api.migration.IMigrationParticipant#getMigrationVersion()
- */
- public Version getMigrationVersion() {
- return MIGRATION_VERSION;
- }
-}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/VSMResourceHandler.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/VSMResourceHandler.java
index 46bedba7df..13f3d64e73 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/VSMResourceHandler.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/description/VSMResourceHandler.java
@@ -11,10 +11,14 @@
package org.eclipse.sirius.business.internal.migration.description;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Map;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler;
+import org.osgi.framework.Version;
+
+import org.eclipse.sirius.viewpoint.description.Group;
/**
* VSM resource handler implementation.
@@ -24,22 +28,38 @@ import org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler;
*/
public class VSMResourceHandler extends BasicResourceHandler {
- private String version;
+ private String loadedVersion;
/**
* Constructor.
*
- * @param version
+ * @param loadedVersion
* the current version of the meta-model to migrate.
*/
- public VSMResourceHandler(String version) {
- this.version = version;
+ public VSMResourceHandler(String loadedVersion) {
+ this.loadedVersion = loadedVersion;
}
@Override
public void postLoad(XMLResource resource, InputStream inputStream, Map<?, ?> options) {
- VSMMigrationService.getInstance().postLoad(resource, version);
+ VSMMigrationService.getInstance().postLoad(resource, loadedVersion);
super.postLoad(resource, inputStream, options);
}
-}
+ @Override
+ public void preSave(XMLResource resource, OutputStream outputStream, Map<?, ?> options) {
+ super.preSave(resource, outputStream, options);
+
+ if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof Group) {
+ Group group = (Group) resource.getContents().get(0);
+ Version lastMigrationVersion = VSMMigrationService.getInstance().getLastMigrationVersion();
+
+ boolean previousDeliver = group.eDeliver();
+ group.eSetDeliver(false);
+
+ group.setVersion(lastMigrationVersion.toString());
+
+ group.eSetDeliver(previousDeliver);
+ }
+ }
+} \ No newline at end of file

Back to the top