diff options
| author | Mélanie Bats | 2015-01-18 14:29:51 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-05-18 15:38:11 +0000 |
| commit | 7e48d91962f6f4eff3599469bb6b1ee2f7228def (patch) | |
| tree | 1a61e466c4907357b59c8441427b733e6a318b17 | |
| parent | ecdfe17e35aa9e6c802adfbca9767a0959266950 (diff) | |
| download | org.eclipse.sirius-7e48d91962f6f4eff3599469bb6b1ee2f7228def.tar.gz org.eclipse.sirius-7e48d91962f6f4eff3599469bb6b1ee2f7228def.tar.xz org.eclipse.sirius-7e48d91962f6f4eff3599469bb6b1ee2f7228def.zip | |
[424422] Migration to support multi valued label format attribute
Define a new migration participant which removes the bold_italic
attribute value and replaces it by a mutli valued attribute [bold,
italic].
Bug: 424422
Change-Id: Ib0dfc7f41e1013d3c8aebd7c6df20e7f7b1351d6
Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
5 files changed, 176 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius.table/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.table/META-INF/MANIFEST.MF index ceee7e01d7..64e13db2b6 100644 --- a/plugins/org.eclipse.sirius.table/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.sirius.table/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Export-Package: org.eclipse.sirius.table.business.api.helper;version="3.0.0", org.eclipse.sirius.table.business.internal.metamodel.description.spec.util;x-internal:=true;version="2.0.4", org.eclipse.sirius.table.business.internal.metamodel.operations;x-internal:=true;version="2.0.4", org.eclipse.sirius.table.business.internal.metamodel.spec;x-internal:=true;version="3.0.0", + org.eclipse.sirius.table.business.internal.migration;x-internal:=true;version="3.0.0", org.eclipse.sirius.table.business.internal.refresh;x-internal:=true;version="3.0.0", org.eclipse.sirius.table.metamodel.table;version="3.0.0", org.eclipse.sirius.table.metamodel.table.description;version="2.0.4", diff --git a/plugins/org.eclipse.sirius.table/plugin.xml b/plugins/org.eclipse.sirius.table/plugin.xml index 87b136a553..76a3ad3989 100644 --- a/plugins/org.eclipse.sirius.table/plugin.xml +++ b/plugins/org.eclipse.sirius.table/plugin.xml @@ -39,5 +39,12 @@ 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 new file mode 100644 index 0000000000..a57c4e1937 --- /dev/null +++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/migration/FontFormatMigrationParticipant.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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/plugin.xml b/plugins/org.eclipse.sirius/plugin.xml index bf0480091d..d0a30a7b01 100644 --- a/plugins/org.eclipse.sirius/plugin.xml +++ b/plugins/org.eclipse.sirius/plugin.xml @@ -355,8 +355,16 @@ kind="VSM"> </participant> <participant - class="org.eclipse.sirius.business.internal.migration.RGBValuesToDataTypeMigrationParticipant" - kind="RepresentationsFile"> + class="org.eclipse.sirius.business.internal.migration.RGBValuesToDataTypeMigrationParticipant" + kind="RepresentationsFile"> + </participant> + <participant + class="org.eclipse.sirius.business.internal.migration.FontFormatMigrationParticipant" + kind="VSM"> + </participant> + <participant + class="org.eclipse.sirius.business.internal.migration.FontFormatMigrationParticipant" + kind="RepresentationsFile"> </participant> <participant class="org.eclipse.sirius.business.internal.migration.Sirius3CleanUpParticipant" 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 new file mode 100644 index 0000000000..eeceab8346 --- /dev/null +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/migration/FontFormatMigrationParticipant.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.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("]", ""); + } +} |
