Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-05-22 15:42:59 +0000
committerMaxime Porhel2015-05-22 15:57:32 +0000
commit0777e16daa1cd2735caccfc773e2612aafc9aa05 (patch)
tree517c28ab304eda9817070b29e49074650e743ad0
parent236dee680dfb43ce4324295003281f7882bc1217 (diff)
downloadorg.eclipse.sirius-0777e16daa1cd2735caccfc773e2612aafc9aa05.tar.gz
org.eclipse.sirius-0777e16daa1cd2735caccfc773e2612aafc9aa05.tar.xz
org.eclipse.sirius-0777e16daa1cd2735caccfc773e2612aafc9aa05.zip
[424422] Correct migration to handle all FontFormat typed features
All features typed by FontFormat have been modified, in all dialects. A single migration participant is sufficient. The previous Table specific participant has been deleted as it never migrated the TableElementStyle nor the ForegroundStyleDescription which are now covered by the core participant. Bug: 424422 Change-Id: Icb53328389d7abb2e5feff1571a311f7e34d3007 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.table/plugin.xml7
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/migration/FontFormatMigrationParticipant.java79
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java45
3 files changed, 17 insertions, 114 deletions
diff --git a/plugins/org.eclipse.sirius.table/plugin.xml b/plugins/org.eclipse.sirius.table/plugin.xml
index 76a3ad3989..87b136a553 100644
--- a/plugins/org.eclipse.sirius.table/plugin.xml
+++ b/plugins/org.eclipse.sirius.table/plugin.xml
@@ -39,12 +39,5 @@
class="org.eclipse.sirius.table.business.internal.dialect.TableMetamodelsProvider">
</descriptorprovider>
</extension>
- <extension
- point="org.eclipse.sirius.migrationParticipant">
- <participant
- class="org.eclipse.sirius.table.business.internal.migration.FontFormatMigrationParticipant"
- kind="VSM">
- </participant>
- </extension>
</plugin>
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/migration/FontFormatMigrationParticipant.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/migration/FontFormatMigrationParticipant.java
deleted file mode 100644
index a57c4e1937..0000000000
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/migration/FontFormatMigrationParticipant.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 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.table.business.internal.migration;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
-import org.eclipse.sirius.business.api.migration.AbstractMigrationParticipant;
-import org.eclipse.sirius.viewpoint.BasicLabelStyle;
-import org.eclipse.sirius.viewpoint.FontFormat;
-import org.eclipse.sirius.viewpoint.ViewpointPackage;
-import org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription;
-import org.osgi.framework.Version;
-
-import com.google.common.collect.Lists;
-
-/**
- * Remove the old font format attribute values used before the multi valued
- * label font format attribute.
- *
- * @author mbats
- */
-public class FontFormatMigrationParticipant extends AbstractMigrationParticipant {
- private static final String ITALIC = "italic";
-
- private static final String BOLD = "bold";
-
- private static final Version MIGRATION_VERSION = new Version("10.0.0.201505181740");
-
- @Override
- public Version getMigrationVersion() {
- return MIGRATION_VERSION;
- }
-
- @Override
- public Object getValue(EObject object, EStructuralFeature feature, Object value, String loadedVersion) {
- List<FontFormat> labelFormat = Lists.newArrayList();
- if (object instanceof BasicLabelStyleDescription) {
- if (feature.getEType() == ViewpointPackage.Literals.FONT_FORMAT) {
- if (value instanceof String) {
- String oldFontFormat = (String) value;
- if (oldFontFormat.contains(ITALIC)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.ITALIC_LITERAL);
- }
- if (oldFontFormat.contains(BOLD)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.BOLD_LITERAL);
- }
- }
- }
- }
- if (object instanceof BasicLabelStyle) {
- if (feature.getEType() == ViewpointPackage.Literals.FONT_FORMAT) {
- if (value instanceof String) {
- String oldFontFormat = (String) value;
- if (oldFontFormat.contains(ITALIC)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.ITALIC_LITERAL);
- }
- if (oldFontFormat.contains(BOLD)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.BOLD_LITERAL);
- }
- }
- }
- }
- if (labelFormat.size() == 0) {
- return null;
- }
- return labelFormat.toString().replaceAll(",", "").replace("[", "").replace("]", "");
- }
-}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java
index eeceab8346..8ac2f3d8ca 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java
@@ -16,10 +16,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.business.api.migration.AbstractMigrationParticipant;
-import org.eclipse.sirius.viewpoint.BasicLabelStyle;
import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
-import org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription;
import org.osgi.framework.Version;
import com.google.common.collect.Lists;
@@ -31,12 +29,13 @@ import com.google.common.collect.Lists;
* @author mbats
*/
public class FontFormatMigrationParticipant extends AbstractMigrationParticipant {
+
+ private static final Version MIGRATION_VERSION = new Version("10.0.0.201505222000");
+
private static final String ITALIC = "italic";
private static final String BOLD = "bold";
- private static final Version MIGRATION_VERSION = new Version("10.0.0.201505181740");
-
@Override
public Version getMigrationVersion() {
return MIGRATION_VERSION;
@@ -45,33 +44,23 @@ public class FontFormatMigrationParticipant extends AbstractMigrationParticipant
@Override
public Object getValue(EObject object, EStructuralFeature feature, Object value, String loadedVersion) {
List<FontFormat> labelFormat = Lists.newArrayList();
- if (object instanceof BasicLabelStyleDescription) {
- if (feature.getEType() == ViewpointPackage.Literals.FONT_FORMAT) {
- if (value instanceof String) {
- String oldFontFormat = (String) value;
- if (oldFontFormat.contains(ITALIC)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.ITALIC_LITERAL);
- }
- if (oldFontFormat.contains(BOLD)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.BOLD_LITERAL);
- }
- }
+ // All features typed by FontFormat have been modified: the cardinality
+ // has been changed from [0..1] to [0..n], the value, which was a
+ // FontFormat, now has to be a list of FontFormat.
+ // The previous "normal" value correspond to an empty list.
+ if (feature.getEType() == ViewpointPackage.Literals.FONT_FORMAT && value instanceof String) {
+ String oldFontFormat = (String) value;
+ if (oldFontFormat.contains(ITALIC)) {
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.ITALIC_LITERAL);
}
- }
- if (object instanceof BasicLabelStyle) {
- if (feature.getEType() == ViewpointPackage.Literals.FONT_FORMAT) {
- if (value instanceof String) {
- String oldFontFormat = (String) value;
- if (oldFontFormat.contains(ITALIC)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.ITALIC_LITERAL);
- }
- if (oldFontFormat.contains(BOLD)) {
- FontFormatHelper.setFontFormat(labelFormat, FontFormat.BOLD_LITERAL);
- }
- }
+ // The previous "bold_italic" value is treated by the two
+ // "if contains" blocks.
+ if (oldFontFormat.contains(BOLD)) {
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.BOLD_LITERAL);
}
}
- if (labelFormat.size() == 0) {
+
+ if (labelFormat.isEmpty()) {
return null;
}
return labelFormat.toString().replaceAll(",", "").replace("[", "").replace("]", "");

Back to the top