Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormfeldman2007-05-20 08:54:39 -0400
committermfeldman2007-05-20 08:54:39 -0400
commit676b8b37672a85016e7ace67877a71c8784e3419 (patch)
treed1ae6b59f6d8035672764294cfda74931b2c79b9
parent0094715b074687c5905d32b89ec22493e8888176 (diff)
downloadorg.eclipse.gmf-tooling-676b8b37672a85016e7ace67877a71c8784e3419.tar.gz
org.eclipse.gmf-tooling-676b8b37672a85016e7ace67877a71c8784e3419.tar.xz
org.eclipse.gmf-tooling-676b8b37672a85016e7ace67877a71c8784e3419.zip
Anna Karyakina's migration fix
-rw-r--r--plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/migrate/MigrationHelper.java36
1 files changed, 26 insertions, 10 deletions
diff --git a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/migrate/MigrationHelper.java b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/migrate/MigrationHelper.java
index d15671a8e..484ac326d 100644
--- a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/migrate/MigrationHelper.java
+++ b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/migrate/MigrationHelper.java
@@ -10,21 +10,22 @@
*/
package org.eclipse.gmf.internal.common.migrate;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.impl.EReferenceImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl;
public class MigrationHelper extends XMIHelperImpl {
private final MigrationHelperDelegate myDelegate;
- private EStructuralFeature mySavedFeature;
- private EReferenceImpl myFakeFeatureWithNarrowType;
private boolean myIsDelegateDisabled = true;
+ private Map<EStructuralFeature, EStructuralFeature> myNarrowedFeatureTypes;
public MigrationHelper(XMLResource resource, MigrationHelperDelegate delegate) {
super(resource);
@@ -55,8 +56,9 @@ public class MigrationHelper extends XMIHelperImpl {
super.setValue(object, feature, value, position);
return;
}
- if (feature != null && feature.equals(myFakeFeatureWithNarrowType)) {
- feature = mySavedFeature;
+ EStructuralFeature originalFeature = getOriginalFeature(feature);
+ if (originalFeature != null) {
+ feature = originalFeature;
}
if (!myDelegate.setValue(object, feature, value, position)) {
super.setValue(object, feature, value, position);
@@ -74,11 +76,9 @@ public class MigrationHelper extends XMIHelperImpl {
}
EClass narrow = myDelegate.getStructuralFeatureType(result);
if (narrow != null) {
- mySavedFeature = result;
- myFakeFeatureWithNarrowType = new EReferenceImpl() {};
- myFakeFeatureWithNarrowType.setName(result.getName());
- myFakeFeatureWithNarrowType.setEType(narrow);
- return myFakeFeatureWithNarrowType;
+ EStructuralFeature fake = addNarrowedFeature(result);
+ fake.setEType(narrow);
+ return fake;
}
return result;
}
@@ -103,4 +103,20 @@ public class MigrationHelper extends XMIHelperImpl {
}
myDelegate.postProcess();
}
+
+ protected EStructuralFeature getOriginalFeature(EStructuralFeature feature) {
+ if (myNarrowedFeatureTypes == null) {
+ myNarrowedFeatureTypes = new HashMap<EStructuralFeature, EStructuralFeature>();
+ }
+ return myNarrowedFeatureTypes.get(feature);
+ }
+
+ protected EStructuralFeature addNarrowedFeature(EStructuralFeature originalFeature) {
+ if (myNarrowedFeatureTypes == null) {
+ myNarrowedFeatureTypes = new HashMap<EStructuralFeature, EStructuralFeature>();
+ }
+ EStructuralFeature result = (EStructuralFeature) EcoreUtil.copy(originalFeature);
+ myNarrowedFeatureTypes.put(result, originalFeature);
+ return result;
+ }
}

Back to the top