Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2007-05-18 16:39:15 -0400
committeratikhomirov2007-05-18 16:39:15 -0400
commit0e38bdb9a91570c5609bc2ffdd1c9dbdfefccb22 (patch)
tree9bdd9a84da428f46f0704728032ebb71fbe51fde
parent1d73ed034b480a094fe271beee418cc5b7f250e8 (diff)
downloadorg.eclipse.gmf-tooling-0e38bdb9a91570c5609bc2ffdd1c9dbdfefccb22.tar.gz
org.eclipse.gmf-tooling-0e38bdb9a91570c5609bc2ffdd1c9dbdfefccb22.tar.xz
org.eclipse.gmf-tooling-0e38bdb9a91570c5609bc2ffdd1c9dbdfefccb22.zip
[187811] akarjakina - Migration support refactored
-rw-r--r--plugins/org.eclipse.gmf.map/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.gmf.map/plugin.xml2
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/GMFMapResource.java59
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/MigrationDelegate.java63
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java44
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapMigration.java76
6 files changed, 125 insertions, 122 deletions
diff --git a/plugins/org.eclipse.gmf.map/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.map/META-INF/MANIFEST.MF
index bfcdd4f34..b95082ed0 100644
--- a/plugins/org.eclipse.gmf.map/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.map/META-INF/MANIFEST.MF
@@ -4,7 +4,8 @@ Bundle-Name: GMF Mapping Model
Bundle-SymbolicName: org.eclipse.gmf.map; singleton:=true
Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: Eclipse.org
-Export-Package: org.eclipse.gmf.mappings,
+Export-Package: org.eclipse.gmf.internal.map.util;x-internal:=true,
+ org.eclipse.gmf.mappings,
org.eclipse.gmf.mappings.impl,
org.eclipse.gmf.mappings.util
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
diff --git a/plugins/org.eclipse.gmf.map/plugin.xml b/plugins/org.eclipse.gmf.map/plugin.xml
index e1492bf18..dbb375156 100644
--- a/plugins/org.eclipse.gmf.map/plugin.xml
+++ b/plugins/org.eclipse.gmf.map/plugin.xml
@@ -14,7 +14,7 @@
</extension>
<extension point="org.eclipse.emf.ecore.extension_parser">
- <parser type="gmfmap" class="org.eclipse.gmf.internal.common.migrate.CompatibleToolResourceFactory$MigrateOnLoad" />
+ <parser type="gmfmap" class="org.eclipse.gmf.internal.map.util.GMFMapResource$Factory" />
</extension>
<extension point="org.eclipse.team.core.fileTypes">
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/GMFMapResource.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/GMFMapResource.java
new file mode 100644
index 000000000..20c16b695
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/GMFMapResource.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * 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: Borland - initial API and implementation
+ */
+package org.eclipse.gmf.internal.map.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.internal.common.ToolingResourceFactory;
+import org.eclipse.gmf.internal.common.migrate.MigrationHelperDelegate;
+import org.eclipse.gmf.internal.common.migrate.MigrationResource;
+import org.eclipse.gmf.mappings.GMFMapPackage;
+
+public class GMFMapResource extends MigrationResource {
+ private Collection<String> myBackwardSupportedURIs;
+
+ public static class Factory extends ToolingResourceFactory {
+ @Override
+ public Resource createResource(URI uri) {
+ return new GMFMapResource(uri);
+ }
+ }
+
+ private GMFMapResource(URI uri) {
+ super(uri);
+ }
+
+ @Override
+ protected MigrationHelperDelegate createDelegate() {
+ MigrationDelegate migrationHelper = new MigrationDelegate();
+ migrationHelper.init();
+ return migrationHelper;
+ }
+
+ @Override
+ protected Collection<String> getBackwardSupportedURIs() {
+ if (myBackwardSupportedURIs == null) {
+ myBackwardSupportedURIs = Arrays.asList(new String[] {
+ "http://www.eclipse.org/gmf/2005/mappings", //$NON-NLS-1$
+ });
+ }
+ return myBackwardSupportedURIs;
+ }
+
+ @Override
+ protected String getMetamodelNsURI() {
+ return GMFMapPackage.eNS_URI;
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/MigrationDelegate.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/MigrationDelegate.java
new file mode 100644
index 000000000..d39b8096c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/internal/map/util/MigrationDelegate.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * 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: Borland - initial API and implementation
+ */
+package org.eclipse.gmf.internal.map.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.internal.common.migrate.MigrationHelper;
+import org.eclipse.gmf.mappings.FeatureLabelMapping;
+import org.eclipse.gmf.mappings.GMFMapPackage;
+import org.eclipse.gmf.mappings.LabelMapping;
+import org.eclipse.gmf.mappings.MappingEntry;
+
+class MigrationDelegate extends MigrationHelper.MigrationHelperDelegateImpl {
+ private Collection<FeatureLabelMapping> myFeatureLabelMappings;
+
+ MigrationDelegate() {
+ }
+
+ void init() {
+ registerNarrowReferenceType(GMFMapPackage.eINSTANCE.getFeatureSeqInitializer_Initializers(), GMFMapPackage.eINSTANCE.getFeatureValueSpec());
+ registerNarrowReferenceType(GMFMapPackage.eINSTANCE.getMappingEntry_LabelMappings(), GMFMapPackage.eINSTANCE.getFeatureLabelMapping());
+ }
+
+ @Override
+ public void postProcess() {
+ for (FeatureLabelMapping mapping : getSavedFeatureLabelMappings()) {
+ if (mapping.getFeatures().isEmpty()) {
+ MappingEntry entry = mapping.getMapEntry();
+ entry.getLabelMappings().remove(mapping);
+ LabelMapping newMapping = GMFMapPackage.eINSTANCE.getGMFMapFactory().createLabelMapping();
+ newMapping.setDiagramLabel(mapping.getDiagramLabel());
+ if (mapping.isReadOnly()) {
+ newMapping.setReadOnly(true);
+ }
+ entry.getLabelMappings().add(newMapping);
+ }
+ }
+ }
+
+ @Override
+ public void processObject(EObject result) {
+ if (result instanceof FeatureLabelMapping) {
+ getSavedFeatureLabelMappings().add((FeatureLabelMapping) result);
+ }
+ }
+
+ private Collection<FeatureLabelMapping> getSavedFeatureLabelMappings() {
+ if (myFeatureLabelMappings == null) {
+ myFeatureLabelMappings = new ArrayList<FeatureLabelMapping>();
+ }
+ return myFeatureLabelMappings;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
index 3ea39280b..57126e26c 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
@@ -14,50 +14,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
-import org.eclipse.gmf.mappings.AppearanceSteward;
-import org.eclipse.gmf.mappings.AuditContainer;
-import org.eclipse.gmf.mappings.AuditRule;
-import org.eclipse.gmf.mappings.Auditable;
-import org.eclipse.gmf.mappings.AuditedMetricTarget;
-import org.eclipse.gmf.mappings.CanvasMapping;
-import org.eclipse.gmf.mappings.ChildReference;
-import org.eclipse.gmf.mappings.CompartmentMapping;
-import org.eclipse.gmf.mappings.Constraint;
-import org.eclipse.gmf.mappings.DesignLabelMapping;
-import org.eclipse.gmf.mappings.DiagramElementTarget;
-import org.eclipse.gmf.mappings.DomainAttributeTarget;
-import org.eclipse.gmf.mappings.DomainElementTarget;
-import org.eclipse.gmf.mappings.ElementInitializer;
-import org.eclipse.gmf.mappings.FeatureInitializer;
-import org.eclipse.gmf.mappings.FeatureLabelMapping;
-import org.eclipse.gmf.mappings.FeatureSeqInitializer;
-import org.eclipse.gmf.mappings.FeatureValueSpec;
-import org.eclipse.gmf.mappings.GMFMapFactory;
-import org.eclipse.gmf.mappings.GMFMapPackage;
-import org.eclipse.gmf.mappings.LabelMapping;
-import org.eclipse.gmf.mappings.LabelTextAccessMethod;
-import org.eclipse.gmf.mappings.Language;
-import org.eclipse.gmf.mappings.LinkConstraints;
-import org.eclipse.gmf.mappings.LinkMapping;
-import org.eclipse.gmf.mappings.Mapping;
-import org.eclipse.gmf.mappings.MappingEntry;
-import org.eclipse.gmf.mappings.Measurable;
-import org.eclipse.gmf.mappings.MenuOwner;
-import org.eclipse.gmf.mappings.MetricContainer;
-import org.eclipse.gmf.mappings.MetricRule;
-import org.eclipse.gmf.mappings.NeedsContainment;
-import org.eclipse.gmf.mappings.NodeMapping;
-import org.eclipse.gmf.mappings.NodeReference;
-import org.eclipse.gmf.mappings.NotationElementTarget;
-import org.eclipse.gmf.mappings.ReferenceNewElementSpec;
-import org.eclipse.gmf.mappings.RuleBase;
-import org.eclipse.gmf.mappings.Severity;
-import org.eclipse.gmf.mappings.ToolOwner;
-import org.eclipse.gmf.mappings.TopNodeReference;
-import org.eclipse.gmf.mappings.ValueExpression;
-import org.eclipse.gmf.internal.common.migrate.MigrationConfig;
import org.eclipse.gmf.mappings.*;
-import org.eclipse.gmf.mappings.util.GMFMapMigration;
import org.eclipse.gmf.tooldef.GMFToolPackage;
import org.eclipse.gmf.validate.GMFValidator;
@@ -417,7 +374,6 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
initializePackageContentsGen();
// Can't use GMFMapPackage.eINSTANCE here
EValidator.Registry.INSTANCE.put(this, GMFValidator.INSTANCE);
- MigrationConfig.Registry.INSTANCE.register(GMFMapMigration.CONFIG);
}
/**
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapMigration.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapMigration.java
deleted file mode 100644
index e493ae90a..000000000
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapMigration.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2006 Eclipse.org
- *
- * 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: dvorak - initial API and implementation
- */
-package org.eclipse.gmf.mappings.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.internal.common.migrate.MigrationConfig;
-import org.eclipse.gmf.mappings.FeatureLabelMapping;
-import org.eclipse.gmf.mappings.GMFMapPackage;
-import org.eclipse.gmf.mappings.LabelMapping;
-import org.eclipse.gmf.mappings.MappingEntry;
-
-public class GMFMapMigration {
-
- private static final String GMFMAP_FILE_EXT = "gmfmap"; //$NON-NLS-1$
-
- private static final String eNS_URI_1_0 = "http://www.eclipse.org/gmf/2005/mappings"; //$NON-NLS-1$
-
- public static final MigrationConfig.Descriptor CONFIG = new MigrationConfig.Descriptor() {
-
- public String getExtension() {
- return GMFMAP_FILE_EXT;
- }
-
- public MigrationConfig getConfig() {
- MigrationConfig config = new MigrationConfig(GMFMapPackage.eNS_URI, new String[] { eNS_URI_1_0 }) {
-
- @Override
- protected void handleResourceLoaded(Resource resource, Map<EObject, Map<String, String>> ignoredAttributes) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=161380
- // replace FeatureLabelMappings without features by LabelMappings
- for (Iterator<EObject> it = resource.getAllContents(); it.hasNext();) {
- EObject object = it.next();
- if (object instanceof MappingEntry) {
- MappingEntry entry = (MappingEntry) object;
- Collection<LabelMapping> mappings = new ArrayList<LabelMapping>(entry.getLabelMappings());
- for (LabelMapping mapping : mappings) {
- if (mapping instanceof FeatureLabelMapping && ((FeatureLabelMapping) mapping).getFeatures().isEmpty()) {
- entry.getLabelMappings().remove(mapping);
- LabelMapping newMapping = GMFMapPackage.eINSTANCE.getGMFMapFactory().createLabelMapping();
- newMapping.setDiagramLabel(mapping.getDiagramLabel());
- if (mapping.isReadOnly()) {
- newMapping.setReadOnly(true);
- }
- entry.getLabelMappings().add(newMapping);
- }
- }
- }
- }
- }
- };
- initialize(config);
- return config;
- }
- };
-
- static void initialize(MigrationConfig config) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=138440
- config.addNarrowReferenceType(GMFMapPackage.eINSTANCE.getFeatureSeqInitializer_Initializers(), GMFMapPackage.eINSTANCE.getFeatureValueSpec());
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=161380
- config.addNarrowReferenceType(GMFMapPackage.eINSTANCE.getMappingEntry_LabelMappings(), GMFMapPackage.eINSTANCE.getFeatureLabelMapping());
- }
-}

Back to the top