Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2007-05-18 16:39:19 -0400
committeratikhomirov2007-05-18 16:39:19 -0400
commit5bd389884024b20123aedf56dd01177b14378d88 (patch)
tree02ae565996190b4416478e913b980e44e29700db
parent0e38bdb9a91570c5609bc2ffdd1c9dbdfefccb22 (diff)
downloadorg.eclipse.gmf-tooling-5bd389884024b20123aedf56dd01177b14378d88.tar.gz
org.eclipse.gmf-tooling-5bd389884024b20123aedf56dd01177b14378d88.tar.xz
org.eclipse.gmf-tooling-5bd389884024b20123aedf56dd01177b14378d88.zip
[187811] akarjakina - Migration support refactored
-rw-r--r--plugins/org.eclipse.gmf.codegen/plugin.xml2
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java147
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenMigration.java215
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java59
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/MigrationDelegate.java128
5 files changed, 192 insertions, 359 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/plugin.xml b/plugins/org.eclipse.gmf.codegen/plugin.xml
index 2c4dd2268..bb5d872ea 100644
--- a/plugins/org.eclipse.gmf.codegen/plugin.xml
+++ b/plugins/org.eclipse.gmf.codegen/plugin.xml
@@ -14,7 +14,7 @@
</extension>
<extension point="org.eclipse.emf.ecore.extension_parser">
- <parser type="gmfgen" class="org.eclipse.gmf.internal.common.migrate.CompatibleToolResourceFactory$MigrateOnLoad" />
+ <parser type="gmfgen" class="org.eclipse.gmf.internal.codegen.util.GMFGenResource$Factory" />
</extension>
<extension point="org.eclipse.team.core.fileTypes">
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
index 564c80005..77fe50028 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
@@ -16,145 +16,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.EPackageImpl;
-import org.eclipse.gmf.codegen.gmfgen.AbstractToolEntry;
-import org.eclipse.gmf.codegen.gmfgen.Attributes;
-import org.eclipse.gmf.codegen.gmfgen.BatchValidation;
-import org.eclipse.gmf.codegen.gmfgen.Behaviour;
-import org.eclipse.gmf.codegen.gmfgen.ColorAttributes;
-import org.eclipse.gmf.codegen.gmfgen.CustomBehaviour;
-import org.eclipse.gmf.codegen.gmfgen.CustomTabFilter;
-import org.eclipse.gmf.codegen.gmfgen.DefaultSizeAttributes;
-import org.eclipse.gmf.codegen.gmfgen.DesignLabelModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.DiagramColors;
-import org.eclipse.gmf.codegen.gmfgen.EditPartCandies;
-import org.eclipse.gmf.codegen.gmfgen.EditorCandies;
-import org.eclipse.gmf.codegen.gmfgen.ElementType;
-import org.eclipse.gmf.codegen.gmfgen.EntryBase;
-import org.eclipse.gmf.codegen.gmfgen.FeatureLabelModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.FigureViewmap;
-import org.eclipse.gmf.codegen.gmfgen.FontStyle;
-import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
-import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
-import org.eclipse.gmf.codegen.gmfgen.GenActionFactoryContributionItem;
-import org.eclipse.gmf.codegen.gmfgen.GenApplication;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditable;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditedMetricTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenChildContainer;
-import org.eclipse.gmf.codegen.gmfgen.GenChildLabelNode;
-import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
-import org.eclipse.gmf.codegen.gmfgen.GenChildSideAffixedNode;
-import org.eclipse.gmf.codegen.gmfgen.GenColor;
-import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
-import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
-import org.eclipse.gmf.codegen.gmfgen.GenConstantColor;
-import org.eclipse.gmf.codegen.gmfgen.GenConstraint;
-import org.eclipse.gmf.codegen.gmfgen.GenContainerBase;
-import org.eclipse.gmf.codegen.gmfgen.GenContributionItem;
-import org.eclipse.gmf.codegen.gmfgen.GenContributionManager;
-import org.eclipse.gmf.codegen.gmfgen.GenCustomFont;
-import org.eclipse.gmf.codegen.gmfgen.GenCustomPreferencePage;
-import org.eclipse.gmf.codegen.gmfgen.GenCustomPropertyTab;
-import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
-import org.eclipse.gmf.codegen.gmfgen.GenDiagramElementTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenDiagramPreferences;
-import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater;
-import org.eclipse.gmf.codegen.gmfgen.GenDomainAttributeTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenDomainElementTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenDomainModelNavigator;
-import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
-import org.eclipse.gmf.codegen.gmfgen.GenEditorView;
-import org.eclipse.gmf.codegen.gmfgen.GenElementInitializer;
-import org.eclipse.gmf.codegen.gmfgen.GenExpressionInterpreter;
-import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
-import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderContainer;
-import org.eclipse.gmf.codegen.gmfgen.GenExternalNodeLabel;
-import org.eclipse.gmf.codegen.gmfgen.GenFeatureInitializer;
-import org.eclipse.gmf.codegen.gmfgen.GenFeatureSeqInitializer;
-import org.eclipse.gmf.codegen.gmfgen.GenFeatureValueSpec;
-import org.eclipse.gmf.codegen.gmfgen.GenFont;
-import org.eclipse.gmf.codegen.gmfgen.GenGroupMarker;
-import org.eclipse.gmf.codegen.gmfgen.GenJavaExpressionProvider;
-import org.eclipse.gmf.codegen.gmfgen.GenLabel;
-import org.eclipse.gmf.codegen.gmfgen.GenLanguage;
-import org.eclipse.gmf.codegen.gmfgen.GenLink;
-import org.eclipse.gmf.codegen.gmfgen.GenLinkConstraints;
-import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
-import org.eclipse.gmf.codegen.gmfgen.GenMeasurable;
-import org.eclipse.gmf.codegen.gmfgen.GenMenuManager;
-import org.eclipse.gmf.codegen.gmfgen.GenMetricContainer;
-import org.eclipse.gmf.codegen.gmfgen.GenMetricRule;
-import org.eclipse.gmf.codegen.gmfgen.GenNavigator;
-import org.eclipse.gmf.codegen.gmfgen.GenNavigatorChildReference;
-import org.eclipse.gmf.codegen.gmfgen.GenNavigatorPath;
-import org.eclipse.gmf.codegen.gmfgen.GenNavigatorPathSegment;
-import org.eclipse.gmf.codegen.gmfgen.GenNavigatorReferenceType;
-import org.eclipse.gmf.codegen.gmfgen.GenNode;
-import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
-import org.eclipse.gmf.codegen.gmfgen.GenNotationElementTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenPlugin;
-import org.eclipse.gmf.codegen.gmfgen.GenPreferencePage;
-import org.eclipse.gmf.codegen.gmfgen.GenPropertySheet;
-import org.eclipse.gmf.codegen.gmfgen.GenPropertyTab;
-import org.eclipse.gmf.codegen.gmfgen.GenPropertyTabFilter;
-import org.eclipse.gmf.codegen.gmfgen.GenRGBColor;
-import org.eclipse.gmf.codegen.gmfgen.GenReferenceNewElementSpec;
-import org.eclipse.gmf.codegen.gmfgen.GenRuleBase;
-import org.eclipse.gmf.codegen.gmfgen.GenRuleTarget;
-import org.eclipse.gmf.codegen.gmfgen.GenSeparator;
-import org.eclipse.gmf.codegen.gmfgen.GenSeverity;
-import org.eclipse.gmf.codegen.gmfgen.GenSharedContributionItem;
-import org.eclipse.gmf.codegen.gmfgen.GenStandardFont;
-import org.eclipse.gmf.codegen.gmfgen.GenStandardPreferencePage;
-import org.eclipse.gmf.codegen.gmfgen.GenStandardPropertyTab;
-import org.eclipse.gmf.codegen.gmfgen.GenToolBarManager;
-import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
-import org.eclipse.gmf.codegen.gmfgen.GeneratedType;
-import org.eclipse.gmf.codegen.gmfgen.InnerClassViewmap;
-import org.eclipse.gmf.codegen.gmfgen.JFaceFont;
-import org.eclipse.gmf.codegen.gmfgen.LabelModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.LabelOffsetAttributes;
-import org.eclipse.gmf.codegen.gmfgen.LabelTextAccessMethod;
-import org.eclipse.gmf.codegen.gmfgen.LinkConstraints;
-import org.eclipse.gmf.codegen.gmfgen.LinkLabelAlignment;
-import org.eclipse.gmf.codegen.gmfgen.LinkModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.MeasurementUnit;
-import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
-import org.eclipse.gmf.codegen.gmfgen.ModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.NotationType;
-import org.eclipse.gmf.codegen.gmfgen.OpenDiagramBehaviour;
-import org.eclipse.gmf.codegen.gmfgen.PackageNames;
-import org.eclipse.gmf.codegen.gmfgen.Palette;
-import org.eclipse.gmf.codegen.gmfgen.ParentAssignedViewmap;
-import org.eclipse.gmf.codegen.gmfgen.ProviderClassNames;
-import org.eclipse.gmf.codegen.gmfgen.ProviderPriority;
-import org.eclipse.gmf.codegen.gmfgen.ResizeConstraints;
-import org.eclipse.gmf.codegen.gmfgen.Routing;
-import org.eclipse.gmf.codegen.gmfgen.RulerUnits;
-import org.eclipse.gmf.codegen.gmfgen.Separator;
-import org.eclipse.gmf.codegen.gmfgen.SharedBehaviour;
-import org.eclipse.gmf.codegen.gmfgen.Shortcuts;
-import org.eclipse.gmf.codegen.gmfgen.SnippetViewmap;
-import org.eclipse.gmf.codegen.gmfgen.SpecializationType;
-import org.eclipse.gmf.codegen.gmfgen.StandardEntry;
-import org.eclipse.gmf.codegen.gmfgen.StandardEntryKind;
-import org.eclipse.gmf.codegen.gmfgen.StandardPreferencePages;
-import org.eclipse.gmf.codegen.gmfgen.StyleAttributes;
-import org.eclipse.gmf.codegen.gmfgen.ToolEntry;
-import org.eclipse.gmf.codegen.gmfgen.ToolGroup;
-import org.eclipse.gmf.codegen.gmfgen.ToolGroupItem;
-import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.TypeTabFilter;
-import org.eclipse.gmf.codegen.gmfgen.ValueExpression;
-import org.eclipse.gmf.codegen.gmfgen.Viewmap;
-import org.eclipse.gmf.codegen.gmfgen.ViewmapLayoutType;
import org.eclipse.gmf.codegen.gmfgen.*;
-import org.eclipse.gmf.codegen.gmfgen.util.GMFGenMigration;
-import org.eclipse.gmf.internal.common.migrate.MigrationConfig;
import org.eclipse.gmf.validate.GMFValidator;
/**
@@ -1177,7 +1039,6 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
public void initializePackageContents() {
initializePackageContentsGen();
EValidator.Registry.INSTANCE.put(this, GMFValidator.INSTANCE);
- MigrationConfig.Registry.INSTANCE.register(GMFGenMigration.CONFIG);
}
/**
@@ -7875,7 +7736,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
"constraints", "http://www.eclipse.org/gmf/2005/constraints",
"meta", "http://www.eclipse.org/gmf/2005/constraints/meta",
"deprecated", "http://www.eclipse.org/gmf/2006/deprecated"
- });
+ });
}
/**
@@ -7905,7 +7766,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
new String[] {
"ocl", "styles->forAll(style|style.ecoreClass.eAllSuperTypes->including(style.ecoreClass)->one(ePackage.name = \'notation\' and name = \'Style\'))",
"description", "Each style must be a notation::Style or sub-class"
- });
+ });
addAnnotation
(getGenCommonBase_VisualID(),
source,
@@ -8124,7 +7985,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
source,
new String[] {
"documentation", "LinkCreationConstants should be generated if diagram has any links"
- });
+ });
addAnnotation
(genNavigatorEClass.getEOperations().get(9),
source,
@@ -8140,7 +8001,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
* @generated
*/
protected void createMetaAnnotations() {
- String source = "http://www.eclipse.org/gmf/2005/constraints/meta";
+ String source = "http://www.eclipse.org/gmf/2005/constraints/meta";
addAnnotation
(getTypeModelFacet_ModelElementSelector(),
source,
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenMigration.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenMigration.java
deleted file mode 100644
index af8552dbe..000000000
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenMigration.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2005, 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: Radek Dvorak (Borland) - initial API and implementation
- * Anna Karjakina (Borland) - support GenAuditContainer migration
- */
-package org.eclipse.gmf.codegen.gmfgen.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.codegen.gmfgen.FeatureLabelModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
-import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
-import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
-import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
-import org.eclipse.gmf.internal.common.migrate.MigrationConfig;
-import org.eclipse.gmf.internal.common.migrate.MigrationResource.MigrationHandler;
-
-public class GMFGenMigration {
-
- private static final String eNS_URI_1_0 = "http://www.eclipse.org/gmf/2005/GenModel"; //$NON-NLS-1$
-
- public static final MigrationConfig.Descriptor CONFIG = new MigrationConfig.Descriptor() {
-
- public String getExtension() {
- return "gmfgen"; //$NON-NLS-1$
- }
-
- public MigrationConfig getConfig() {
- MigrationConfig config = new MigrationConfig(GMFGenPackage.eNS_URI, new String[] { eNS_URI_1_0 }) {
- private boolean isDefaultAuditCategoryAdded = false;
- private boolean isAuditMigrationApplied = false;
-
- @Override
- protected void handleResourceLoaded(Resource resource, Map<EObject, Map<String, String>> ignoredAttributes) {
- if (!isAuditMigrationApplied) {
- return;
- }
- List<EObject> initialResourceContents = new ArrayList<EObject>(resource.getContents().size());
- initialResourceContents.addAll(resource.getContents());
- for (Iterator<EObject> it = initialResourceContents.iterator(); it.hasNext();) {
- EObject object = it.next();
- if (object instanceof GenAuditContainer) {
- GenAuditRoot root = GMFGenFactory.eINSTANCE.createGenAuditRoot();
- resource.getContents().add(root);
- GenAuditContainer nextContainer = (GenAuditContainer) object;
- root.getCategories().add(nextContainer);
- moveNestedCategoriesToTheRoot(nextContainer, root);
- nextContainer.getPath().clear();
- }
- if (object instanceof GenEditorGenerator) {
- GenEditorGenerator generator = (GenEditorGenerator) object;
- GenAuditRoot root = generator.getAudits();
- if (root != null && !root.getCategories().isEmpty()) {
- if (isDefaultAuditCategoryAdded) {
- GenAuditContainer defaultCategory = getDefaultAuditContainer(root);
- for (Iterator<GenAuditRule> toplevelRules = root.getRules().iterator(); toplevelRules.hasNext();) {
- GenAuditRule nextFirst = toplevelRules.next();
- nextFirst.setCategory(defaultCategory);
- }
- if (root.getCategories().size() > 1) {
- List<GenAuditContainer> containersList = new ArrayList<GenAuditContainer>(root.getCategories().size());
- containersList.addAll(root.getCategories());
- containersList.remove(defaultCategory);
- for (Iterator<GenAuditContainer> containers = containersList.iterator(); containers.hasNext();) {
- GenAuditContainer nextContainer = containers.next();
- moveNestedCategoriesToTheRoot(nextContainer, root);
- nextContainer.getPath().clear();
- nextContainer.getPath().add(defaultCategory);
- }
- }
- } else {
- List<GenAuditContainer> containersList = new ArrayList<GenAuditContainer>(root.getCategories().size());
- containersList.addAll(root.getCategories());
- for (Iterator<GenAuditContainer> containers = containersList.iterator(); containers.hasNext();) {
- GenAuditContainer nextContainer = containers.next();
- moveNestedCategoriesToTheRoot(nextContainer, root);
- nextContainer.getPath().clear();
- }
- }
- }
- }
- }
- isDefaultAuditCategoryAdded = false;
- isAuditMigrationApplied = false;
- }
-
- private void moveNestedCategoriesToTheRoot(GenAuditContainer nextContainer, GenAuditRoot root) {
- moveNestedAuditsToTheRoot(nextContainer, root);
- for (Iterator<GenAuditContainer> nestedContainers=nextContainer.getPath().iterator(); nestedContainers.hasNext();) {
- GenAuditContainer nextNestedContainer = nestedContainers.next();
- moveNestedCategoriesToTheRoot(nextNestedContainer, root);
- nestedContainers.remove();
- root.getCategories().add(nextNestedContainer);
- nextNestedContainer.getPath().clear();
- nextNestedContainer.getPath().add(nextContainer);
- }
- }
-
- private void moveNestedAuditsToTheRoot(GenAuditContainer nextContainer, GenAuditRoot root) {
- for (Iterator<GenAuditRule> nestedAudits = nextContainer.getAudits().iterator(); nestedAudits.hasNext();) {
- GenAuditRule nextNestedRule = nestedAudits.next();
- nextNestedRule.setCategory(nextContainer);
- root.getRules().add(nextNestedRule);
- }
- }
-
- @Override
- public boolean setAttribValue(MigrationHandler handler, EObject peekObject, String name, String value) {
- if (peekObject instanceof GenAuditRoot) {
- if ("id".equals(name)) { //$NON-NLS-1$
- getDefaultAuditContainer((GenAuditRoot) peekObject).setId(value);
- isAuditMigrationApplied = true;
- return true;
- } else if ("name".equals(name)) { //$NON-NLS-1$
- getDefaultAuditContainer((GenAuditRoot) peekObject).setName(value);
- isAuditMigrationApplied = true;
- return true;
- } else if ("description".equals(name)) { //$NON-NLS-1$
- getDefaultAuditContainer((GenAuditRoot) peekObject).setDescription(value);
- isAuditMigrationApplied = true;
- return true;
- }
- }
- return super.setAttribValue(handler, peekObject, name, value);
- }
-
- private GenAuditContainer getDefaultAuditContainer(GenAuditRoot root) {
- /*
- * As we are mapping first audit category right into audit root,
- * we should create some instance for that default category parameters
- * also
- */
- if (root.getCategories().isEmpty()) {
- root.getCategories().add(0, GMFGenFactory.eINSTANCE.createGenAuditContainer());
- isDefaultAuditCategoryAdded = true;
- }
- return root.getCategories().get(0);
- }
-
- @Override
- protected boolean handleFeature(MigrationHandler handler, String prefix, String name) {
- EObject object = handler.peekEObject();
- if ("metaFeature".equals(name) && object instanceof FeatureLabelModelFacet) { //$NON-NLS-1$
- name = "metaFeatures"; //$NON-NLS-1$
- handler.handleFeatureHook(prefix, name);
- return true;
- }
- if ("audits".equals(name) && object instanceof GenAuditRoot) { //$NON-NLS-1$
- name = "rules"; //$NON-NLS-1$
- handler.handleFeatureHook(prefix, name);
- isAuditMigrationApplied = true;
- return true;
- }
- if ("childContainers".equals(name) && object instanceof GenAuditRoot) { //$NON-NLS-1$
- name = "categories"; //$NON-NLS-1$
- handler.handleFeatureHook(prefix, name);
- isAuditMigrationApplied = true;
- return true;
- }
- if ("childContainers".equals(name) && object instanceof GenAuditContainer) { //$NON-NLS-1$
- name = "path"; //$NON-NLS-1$
- handler.handleFeatureHook(prefix, name);
- isAuditMigrationApplied = true;
- return true;
- }
- return false;
- }
-
- @Override
- protected boolean handleCreateObject(MigrationHandler handler, EObject peekObject, EStructuralFeature feature) {
- if ("gmfgen:CompositeFeatureLabelModelFacet".equals(handler.getXSIType())) { //$NON-NLS-1$
- handler.createObjectFromTypeNameHook(peekObject, "gmfgen:FeatureLabelModelFacet", feature); //$NON-NLS-1$
- return true;
- }
- return false;
- }
-
- };
- initialize(config);
- return config;
- }
- };
-
- static void initialize(MigrationConfig config) {
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getEditorCandies(), "diagramFileCreatorClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getEditorCandies(), "preferenceInitializerClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getFeatureLabelModelFacet(), "metaFeature"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "abstractParserClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "structuralFeatureParserClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "structuralFeaturesParserClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "paletteProviderClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "paletteProviderPriority"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "propertyProviderClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getProviderClassNames(), "propertyProviderPriority"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getEditPartCandies(), "referenceConnectionEditPolicyClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getEditPartCandies(), "externalNodeLabelHostLayoutEditPolicyClassName"); //$NON-NLS-1$
- config.registerDeletedAttribute(GMFGenPackage.eINSTANCE.getTypeLinkModelFacet(), "createCommandClassName"); //$NON-NLS-1$
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=138440
- config.addNarrowReferenceType(GMFGenPackage.eINSTANCE.getGenFeatureSeqInitializer_Initializers(), GMFGenPackage.eINSTANCE.getGenFeatureValueSpec());
- }
-}
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java
new file mode 100644
index 000000000..fc2a58bd9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.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.codegen.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.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.internal.common.ToolingResourceFactory;
+import org.eclipse.gmf.internal.common.migrate.MigrationHelperDelegate;
+import org.eclipse.gmf.internal.common.migrate.MigrationResource;
+
+public class GMFGenResource extends MigrationResource {
+ private Collection<String> myBackwardSupportedURIs;
+
+ public static class Factory extends ToolingResourceFactory {
+ @Override
+ public Resource createResource(URI uri) {
+ return new GMFGenResource(uri);
+ }
+ }
+
+ private GMFGenResource(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/GenModel", //$NON-NLS-1$
+ });
+ }
+ return myBackwardSupportedURIs;
+ }
+
+ @Override
+ protected String getMetamodelNsURI() {
+ return GMFGenPackage.eNS_URI;
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/MigrationDelegate.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/MigrationDelegate.java
new file mode 100644
index 000000000..7694b25db
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/MigrationDelegate.java
@@ -0,0 +1,128 @@
+/*
+ * 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.codegen.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EReferenceImpl;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.internal.common.migrate.MigrationHelper;
+
+class MigrationDelegate extends MigrationHelper.MigrationHelperDelegateImpl {
+ private EReference ourGenEditorGenerator_Audits;
+ private EReference ourGenAuditContainer_ChildContainers;
+ private EReference ourGenAuditContainer_Audits;
+
+ MigrationDelegate() {
+ }
+
+ void init() {
+ registerDeletedAttributes(GMFGenPackage.eINSTANCE.getEditorCandies(),
+ "diagramFileCreatorClassName", //$NON-NLS-1$
+ "preferenceInitializerClassName" //$NON-NLS-1$
+ );
+ registerDeletedAttributes(GMFGenPackage.eINSTANCE.getFeatureLabelModelFacet(), "metaFeature"); //$NON-NLS-1$
+ registerDeletedAttributes(GMFGenPackage.eINSTANCE.getProviderClassNames(),
+ "abstractParserClassName", //$NON-NLS-1$
+ "structuralFeatureParserClassName", //$NON-NLS-1$
+ "structuralFeaturesParserClassName", //$NON-NLS-1$
+ "paletteProviderClassName", //$NON-NLS-1$
+ "paletteProviderPriority", //$NON-NLS-1$
+ "propertyProviderClassName", //$NON-NLS-1$
+ "propertyProviderPriority" //$NON-NLS-1$
+ );
+ registerDeletedAttributes(GMFGenPackage.eINSTANCE.getEditPartCandies(),
+ "referenceConnectionEditPolicyClassName", //$NON-NLS-1$
+ "externalNodeLabelHostLayoutEditPolicyClassName" //$NON-NLS-1$
+ );
+ registerDeletedAttributes(GMFGenPackage.eINSTANCE.getTypeLinkModelFacet(), "createCommandClassName"); //$NON-NLS-1$
+
+ registerNarrowReferenceType(GMFGenPackage.eINSTANCE.getGenFeatureSeqInitializer_Initializers(), GMFGenPackage.eINSTANCE.getGenFeatureValueSpec());
+ {
+ Map<String, EStructuralFeature> renamings = new HashMap<String, EStructuralFeature>();
+ renamings.put("metaFeature", GMFGenPackage.eINSTANCE.getFeatureLabelModelFacet_MetaFeatures()); //$NON-NLS-1$
+ registerRenamedAttributes(GMFGenPackage.eINSTANCE.getFeatureLabelModelFacet(), renamings);
+ }
+ ourGenEditorGenerator_Audits = new EReferenceImpl() {};
+ ourGenEditorGenerator_Audits.setName("audits"); //$NON-NLS-1$
+ ourGenEditorGenerator_Audits.setEType(GMFGenPackage.eINSTANCE.getGenAuditContainer());
+ ourGenEditorGenerator_Audits.setContainment(true);
+ ourGenEditorGenerator_Audits.setLowerBound(0);
+ ourGenEditorGenerator_Audits.setUpperBound(1);
+ ourGenAuditContainer_ChildContainers = new EReferenceImpl() {};
+ ourGenAuditContainer_ChildContainers.setName("childContainers"); //$NON-NLS-1$
+ ourGenAuditContainer_ChildContainers.setEType(GMFGenPackage.eINSTANCE.getGenAuditContainer());
+ ourGenAuditContainer_ChildContainers.setContainment(true);
+ ourGenAuditContainer_ChildContainers.setLowerBound(0);
+ ourGenAuditContainer_ChildContainers.setUpperBound(-1);
+ ourGenAuditContainer_Audits = new EReferenceImpl() {};
+ ourGenAuditContainer_Audits.setName("audits"); //$NON-NLS-1$
+ ourGenAuditContainer_Audits.setEType(GMFGenPackage.eINSTANCE.getGenAuditRule());
+ ourGenAuditContainer_Audits.setContainment(true);
+ ourGenAuditContainer_Audits.setLowerBound(0);
+ ourGenAuditContainer_Audits.setUpperBound(-1);
+ {
+ Map<String, EStructuralFeature> renamings = new HashMap<String, EStructuralFeature>();
+ renamings.put(ourGenEditorGenerator_Audits.getName(), ourGenEditorGenerator_Audits);
+ registerRenamedAttributes(GMFGenPackage.eINSTANCE.getGenEditorGenerator(), renamings);
+ }
+ {
+ Map<String, EStructuralFeature> renamings = new HashMap<String, EStructuralFeature>();
+ renamings.put(ourGenAuditContainer_Audits.getName(), ourGenAuditContainer_Audits);
+ renamings.put(ourGenAuditContainer_ChildContainers.getName(), ourGenAuditContainer_ChildContainers);
+ registerRenamedAttributes(GMFGenPackage.eINSTANCE.getGenAuditContainer(), renamings);
+ }
+ registerRenamedType("CompositeFeatureLabelModelFacet", GMFGenPackage.eINSTANCE.getFeatureLabelModelFacet()); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean setValue(EObject object, EStructuralFeature feature, Object value, int position) {
+ if (ourGenEditorGenerator_Audits.equals(feature)) {
+ GenEditorGenerator generator = (GenEditorGenerator) object;
+ GenAuditContainer rootContainer = (GenAuditContainer) value;
+ generator.setAudits(getOrCreateRoot(rootContainer));
+ } else if (ourGenAuditContainer_ChildContainers.equals(feature)) {
+ GenAuditContainer parent = (GenAuditContainer)object;
+ GenAuditContainer container = (GenAuditContainer)value;
+ container.getPath().addAll(parent.getPath());
+ container.getPath().add(parent);
+ getOrCreateRoot(parent).getCategories().add(container);
+ } else if (ourGenAuditContainer_Audits.equals(feature)) {
+ GenAuditContainer container = (GenAuditContainer)object;
+ GenAuditRule rule = (GenAuditRule)value;
+ rule.setCategory(container);
+ getOrCreateRoot(container).getRules().add(rule);
+ } else {
+ // other cases are would be processed as defaults
+ return super.setValue(object, feature, value, position);
+ }
+ return true;
+ }
+
+ private GenAuditRoot getOrCreateRoot(GenAuditContainer auditContainer) {
+ GenAuditRoot result = auditContainer.getRoot();
+ if (result == null) {
+ result = GMFGenFactory.eINSTANCE.createGenAuditRoot();
+ result.getCategories().add(auditContainer);
+ }
+ return result;
+ }
+
+}

Back to the top