Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-02-24 07:54:58 +0000
committerEike Stepper2012-02-24 07:54:58 +0000
commit646b5fba42b96d6157102c0811c129e6640b9a40 (patch)
treee85ebcb15695f46cd99f6d8e4e7cea4765b93df2 /plugins/org.eclipse.emf.cdo
parentac288aab2f62782dec79a51617d3629f40649433 (diff)
downloadcdo-646b5fba42b96d6157102c0811c129e6640b9a40.tar.gz
cdo-646b5fba42b96d6157102c0811c129e6640b9a40.tar.xz
cdo-646b5fba42b96d6157102c0811c129e6640b9a40.zip
372311: [Legacy] eContainer changes not properly propagated
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372311
Diffstat (limited to 'plugins/org.eclipse.emf.cdo')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java215
1 files changed, 121 insertions, 94 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
index 1719a506a7..cbeaf33fd0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
@@ -88,7 +88,6 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
return;
}
- CDOStore store = view.getStore();
if (EMFUtil.isPersistent(feature))
{
int eventType = msg.getEventType();
@@ -99,130 +98,158 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
switch (eventType)
{
case Notification.SET:
- {
- store.set(instance, feature, position, newValue);
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- if (oldValue != null)
- {
- InternalEObject oldChild = (InternalEObject)oldValue;
- setContainer(store, oldChild, null, 0);
- }
-
- if (newValue != null)
- {
- InternalEObject newChild = (InternalEObject)newValue;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
- }
-
+ notifySet(feature, position, oldValue, newValue);
break;
- }
case Notification.UNSET:
- {
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- @SuppressWarnings("unchecked")
- List<Object> list = (List<Object>)oldValue;
- for (Object child : list)
- {
- if (child != null)
- {
- setContainer(store, (InternalEObject)child, null, 0);
- }
- }
- }
- }
-
- store.unset(instance, feature);
+ notifyUnset(feature, oldValue);
break;
- }
case Notification.MOVE:
- store.move(instance, feature, position, (Integer)oldValue);
+ notifyMove(feature, position, oldValue);
break;
case Notification.ADD:
- store.add(instance, feature, position, newValue);
- if (newValue != null && feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- InternalEObject newChild = (InternalEObject)newValue;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
-
+ notifyAdd(feature, position, newValue);
break;
case Notification.ADD_MANY:
- {
- int pos = position;
- @SuppressWarnings("unchecked")
- List<Object> list = (List<Object>)newValue;
- for (Object object : list)
- {
- store.add(instance, feature, pos++, object);
- if (object != null && feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- InternalEObject newChild = (InternalEObject)object;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
- }
+ notifyAddMany(feature, position, newValue);
+ break;
+
+ case Notification.REMOVE:
+ notifyRemove(feature, position);
+ break;
+ case Notification.REMOVE_MANY:
+ notifyRemoveMany(feature, oldValue);
break;
}
- case Notification.REMOVE:
+ // Align Container for bidirectional references because this is not set in the store. See Bugzilla_246622_Test
+ instanceToRevisionContainment();
+ }
+ }
+
+ protected void notifySet(EStructuralFeature feature, int position, Object oldValue, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ store.set(instance, feature, position, newValue);
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
{
- InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, position);
- if (oldChild != null && feature instanceof EReference)
+ if (oldValue != null)
{
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- setContainer(store, oldChild, null, 0);
- }
+ InternalEObject oldChild = (InternalEObject)oldValue;
+ setContainer(store, oldChild, null, 0);
+ }
+
+ if (newValue != null)
+ {
+ InternalEObject newChild = (InternalEObject)newValue;
+ setContainer(store, newChild, this, reference.getFeatureID());
}
- break;
}
+ }
+ }
- case Notification.REMOVE_MANY:
+ protected void notifyUnset(EStructuralFeature feature, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
{
@SuppressWarnings("unchecked")
List<Object> list = (List<Object>)oldValue;
- for (int i = list.size() - 1; i >= 0; --i)
+ for (Object child : list)
{
- InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, i);
- if (oldChild != null && feature instanceof EReference)
+ if (child != null)
{
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- setContainer(store, oldChild, null, 0);
- }
+ setContainer(store, (InternalEObject)child, null, 0);
}
}
+ }
+ }
- break;
+ store.unset(instance, feature);
+ }
+
+ protected void notifyMove(EStructuralFeature feature, int position, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ store.move(instance, feature, position, (Integer)oldValue);
+ }
+
+ protected void notifyAdd(EStructuralFeature feature, int position, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ store.add(instance, feature, position, newValue);
+ if (newValue != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ InternalEObject newChild = (InternalEObject)newValue;
+ setContainer(store, newChild, this, reference.getFeatureID());
+ }
+ }
+ }
+
+ protected void notifyAddMany(EStructuralFeature feature, int position, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ int pos = position;
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>)newValue;
+ for (Object object : list)
+ {
+ store.add(instance, feature, pos++, object);
+ if (object != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ InternalEObject newChild = (InternalEObject)object;
+ setContainer(store, newChild, this, reference.getFeatureID());
+ }
}
+ }
+ }
+
+ protected void notifyRemove(EStructuralFeature feature, int position)
+ {
+ CDOStore store = view.getStore();
+ InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, position);
+ if (oldChild != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ setContainer(store, oldChild, null, 0);
}
+ }
+ }
- // Align Container for bidirectional references because this is not set in the store. See Bugzilla_246622_Test
- instanceToRevisionContainment();
+ protected void notifyRemoveMany(EStructuralFeature feature, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>)oldValue;
+ for (int i = list.size() - 1; i >= 0; --i)
+ {
+ InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, i);
+ if (oldChild != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ setContainer(store, oldChild, null, 0);
+ }
+ }
}
}
@@ -240,7 +267,7 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
return;
}
- store.setContainer(object, null, container, containingFeatureID);
+ store.setContainer(object, null, container, InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureID);
}
/**

Back to the top