Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155030 Details for
Bug 247226
Transparently support legacy models (CDOLegacyAdapter)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
LegacyAdapter Patch v4 - ready to be committed
patch.txt (text/plain), 9.10 KB, created by
Eike Stepper
on 2009-12-25 04:45:20 EST
(
hide
)
Description:
LegacyAdapter Patch v4 - ready to be committed
Filename:
MIME Type:
Creator:
Eike Stepper
Created:
2009-12-25 04:45:20 EST
Size:
9.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo >Index: src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java,v >retrieving revision 1.32 >diff -u -r1.32 CDOLegacyWrapper.java >--- src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java 10 Nov 2009 09:23:28 -0000 1.32 >+++ src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java 25 Dec 2009 09:48:24 -0000 >@@ -30,7 +30,6 @@ > import org.eclipse.net4j.util.om.trace.ContextTracer; > > import org.eclipse.emf.common.notify.Adapter; >-import org.eclipse.emf.common.notify.impl.NotifyingListImpl; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EAttribute; > import org.eclipse.emf.ecore.EClass; >@@ -356,11 +355,8 @@ > TRACER.format("State of Object is : " + state); > } > >- // if (state != CDOState.CONFLICT) // do not do anything with the >- if (state == CDOState.CLEAN || state == CDOState.PROXY) // do not do anything with the >- // list if state is conflict >+ if (state == CDOState.CLEAN || state == CDOState.PROXY) > { >- // int size = view.getStore().size(instance, feature); > int size = revision.size(feature); > > @SuppressWarnings("unchecked") >@@ -376,14 +372,13 @@ > TRACER.format(("Adding " + object + " to feature " + feature + "in instance " + instance)); > } > >- // instance.eInverseAdd((InternalEObject)object, instance.eClass().getFeatureID(feature), object.getClass(), >- // null); > list.basicAdd(object, null); > } > } > } > else >- { // ! isMany() >+ { >+ // !feature.isMany() > Object object = getValueFromRevision(feature, 0); > if (feature instanceof EAttribute) > { >@@ -395,7 +390,8 @@ > eSet(feature, object); > } > else >- { // EReferences >+ { >+ // EReferences > if (TRACER.isEnabled()) > { > TRACER.format(("Adding object " + object + " to feature " + feature + " in instance " + instance)); >@@ -403,7 +399,26 @@ > > int featureID = instance.eClass().getFeatureID(feature); > Class<? extends Object> baseClass = object == null ? null : object.getClass(); >- instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); >+ >+ try >+ { >+ instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); >+ } >+ catch (NullPointerException e) >+ { >+ // TODO: Martin:quick hack, because there is still a problem with the feature id. Should investigate this soon >+ System.out.println("Feature: " + feature); >+ >+ instance.eSet(feature, object); >+ } >+ >+ // Adjust opposite for transient opposite features >+ EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature; >+ EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite(); >+ if (oppositeReference != null && object != null) >+ { >+ adjustOppositeReference(instance, (InternalEObject)object, oppositeReference); >+ } > > if (TRACER.isEnabled()) > { >@@ -413,15 +428,55 @@ > } > } > >+ private void adjustOppositeReference(InternalEObject instance, InternalEObject object, EReference oppositeReference) >+ { >+ System.out.println("Adjusting opposite for : instance: " + instance + " object:" + object + " reference: " >+ + oppositeReference); >+ >+ boolean deliver = object.eDeliver(); // Disable notifications >+ if (deliver) >+ { >+ object.eSetDeliver(false); >+ } >+ >+ try >+ { >+ if (oppositeReference.isMany()) >+ { >+ // TODO Martin: Is this enough?? >+ @SuppressWarnings("unchecked") >+ InternalEList<Object> list = (InternalEList<Object>)object.eGet(oppositeReference); >+ list.basicAdd(instance, null); >+ } >+ else >+ { >+ // TODO Martin: This only increases performance if getter is cheaper than setter. Should discuss this. >+ if (object.eGet(oppositeReference) != instance) >+ { >+ object.eInverseAdd(instance, oppositeReference.getFeatureID(), ((EObject)instance).getClass(), null); >+ } >+ } >+ } >+ finally >+ { >+ if (deliver) >+ { >+ object.eSetDeliver(true); >+ } >+ } >+ } >+ > private void clearList(EStructuralFeature feature, InternalEList<Object> list) > { >- // attempt 2 >- int featureID = feature.getFeatureID(); > for (int i = list.size() - 1; i >= 0; --i) > { > InternalEObject obj = (InternalEObject)list.get(i); >- // TODO clarify obj.getClass()/baseclass >- instance.eInverseRemove(obj, featureID, obj.getClass(), null); >+ >+ // TODO Clarify obj.getClass()/baseclass >+ ((InternalEList<?>)list).basicRemove(obj, null); >+ >+ // TODO Martin: baseicRemove seems to be better than eInverseremove >+ // instance.eInverseRemove(obj, featureID, obj.getClass(), null); > } > } > >@@ -438,7 +493,6 @@ > private Object getValueFromRevision(EStructuralFeature feature, int index) > { > Object object = revision.get(feature, index); >- > if (object == null) > { > return null; >@@ -456,16 +510,13 @@ > } > > object = getPreRegisteredObjects().get(id); >- > if (object != null) > { > System.out.println(((CDOLegacyWrapper)object).cdoInternalInstance()); > return ((CDOLegacyWrapper)object).cdoInternalInstance(); > } > >- // return view.getStore().get(instance, feature, index); > object = view.getObject(id); >- > if (object instanceof CDOObjectWrapper) > { > return ((CDOObjectWrapper)object).cdoInternalInstance(); >@@ -504,7 +555,7 @@ > > protected void setInstanceContainer(InternalEObject container, int containerFeatureID) > { >- // TODO change to direct call of eBasicSetContainer >+ // TODO Change to direct call of eBasicSetContainer > Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$ > ReflectUtil.invokeMethod(method, instance, container, containerFeatureID); > } >@@ -586,7 +637,7 @@ > } > > /** >- * TODO Ed: Fix whole mess ;-) >+ * TODO Martin: Can this be optimized? > */ > protected void clearEList(InternalEList<Object> list) > { >@@ -602,19 +653,14 @@ > */ > protected void resolveAllProxies() > { >- // if (!allProxiesResolved) >+ CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry(); >+ EClass eClass = revision.getEClass(); >+ for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass)) > { >- CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry(); >- EClass eClass = revision.getEClass(); >- for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass)) >+ if (feature instanceof EReference) > { >- if (feature instanceof EReference) >- { >- resolveProxies(feature, packageRegistry); >- } >+ resolveProxies(feature, packageRegistry); > } >- >- // allProxiesResolved = true; > } > } > >@@ -632,6 +678,13 @@ > @SuppressWarnings("unchecked") > InternalEList<Object> list = (InternalEList<Object>)value; > int size = list.size(); >+ >+ boolean deliver = instance.eDeliver(); >+ if (deliver) >+ { >+ instance.eSetDeliver(false); >+ } >+ > for (int i = 0; i < size; i++) > { > Object element = list.get(i); >@@ -650,16 +703,21 @@ > // ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList(); > // } > >- if (list instanceof NotifyingListImpl<?>) >- { >- ((NotifyingListImpl<Object>)list).basicSet(i, instance, null); >- } >- else >- { >- list.set(i, instance); >- } >+ // if (list instanceof NotifyingListImpl<?>) >+ // { >+ // ((NotifyingListImpl<Object>)list).basicSet(i, instance, null); >+ // } >+ // else >+ // { >+ list.set(i, instance); >+ // } > } > } >+ >+ if (deliver) >+ { >+ instance.eSetDeliver(true); >+ } > } > else > { >@@ -794,28 +852,16 @@ > } > > /** >- * @since 3.0 >- */ >- public void setUnderConstruction(boolean underConstruction) >- { >- this.underConstruction = underConstruction; >- } >- >- /** >- * @since 3.0 >- */ >- public boolean isUnderConstruction() >- { >- return underConstruction; >- } >- >- /** > * @author Martin Fluegge > */ > private static final class Counter > { > private int value; > >+ public Counter() >+ { >+ } >+ > public void increment() > { > ++value;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247226
:
112514
|
112894
|
134866
|
151009
|
151634
|
151651
|
152232
|
153867
|
153868
|
155030
|
155031
|
155181
|
155182
|
155400
|
163497
|
163499