|
Lines 30-36
Link Here
|
| 30 |
import org.eclipse.net4j.util.om.trace.ContextTracer; |
30 |
import org.eclipse.net4j.util.om.trace.ContextTracer; |
| 31 |
|
31 |
|
| 32 |
import org.eclipse.emf.common.notify.Adapter; |
32 |
import org.eclipse.emf.common.notify.Adapter; |
| 33 |
import org.eclipse.emf.common.notify.impl.NotifyingListImpl; |
|
|
| 34 |
import org.eclipse.emf.common.util.URI; |
33 |
import org.eclipse.emf.common.util.URI; |
| 35 |
import org.eclipse.emf.ecore.EAttribute; |
34 |
import org.eclipse.emf.ecore.EAttribute; |
| 36 |
import org.eclipse.emf.ecore.EClass; |
35 |
import org.eclipse.emf.ecore.EClass; |
|
Lines 358-364
Link Here
|
| 358 |
|
357 |
|
| 359 |
// if (state != CDOState.CONFLICT) // do not do anything with the |
358 |
// if (state != CDOState.CONFLICT) // do not do anything with the |
| 360 |
if (state == CDOState.CLEAN || state == CDOState.PROXY) // do not do anything with the |
359 |
if (state == CDOState.CLEAN || state == CDOState.PROXY) // do not do anything with the |
| 361 |
// list if state is conflict |
|
|
| 362 |
{ |
360 |
{ |
| 363 |
// int size = view.getStore().size(instance, feature); |
361 |
// int size = view.getStore().size(instance, feature); |
| 364 |
int size = revision.size(feature); |
362 |
int size = revision.size(feature); |
|
Lines 403-409
Link Here
|
| 403 |
|
401 |
|
| 404 |
int featureID = instance.eClass().getFeatureID(feature); |
402 |
int featureID = instance.eClass().getFeatureID(feature); |
| 405 |
Class<? extends Object> baseClass = object == null ? null : object.getClass(); |
403 |
Class<? extends Object> baseClass = object == null ? null : object.getClass(); |
| 406 |
instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); |
404 |
try |
|
|
405 |
{ |
| 406 |
instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); |
| 407 |
} |
| 408 |
catch (NullPointerException e) |
| 409 |
{// TODO: Martin:quick hack, because there is still a problem with the feature id. Should investigate this soon |
| 410 |
System.out.println("Feature: " + feature); |
| 411 |
|
| 412 |
instance.eSet(feature, object); |
| 413 |
} |
| 414 |
|
| 415 |
// adjust opposite for transient opposite features |
| 416 |
EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature; |
| 417 |
EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite(); |
| 418 |
if (oppositeReference != null && object != null) |
| 419 |
{ |
| 420 |
adjustOppositeReference(instance, (InternalEObject)object, oppositeReference); |
| 421 |
} |
| 407 |
|
422 |
|
| 408 |
if (TRACER.isEnabled()) |
423 |
if (TRACER.isEnabled()) |
| 409 |
{ |
424 |
{ |
|
Lines 413-418
Link Here
|
| 413 |
} |
428 |
} |
| 414 |
} |
429 |
} |
| 415 |
|
430 |
|
|
|
431 |
private void adjustOppositeReference(InternalEObject instance, InternalEObject object, EReference oppositeReference) |
| 432 |
{ |
| 433 |
System.out.println("Adjusting opposite for : instance: " + instance + " object:" + object + " reference: " |
| 434 |
+ oppositeReference); |
| 435 |
|
| 436 |
boolean deliver = object.eDeliver(); // disable notifications |
| 437 |
if (deliver) |
| 438 |
{ |
| 439 |
object.eSetDeliver(false); |
| 440 |
} |
| 441 |
try |
| 442 |
{ |
| 443 |
if (oppositeReference.isMany()) |
| 444 |
{ |
| 445 |
// TODO Martin: is this enough?? |
| 446 |
((InternalEList<Object>)object.eGet(oppositeReference)).basicAdd(instance, null); |
| 447 |
} |
| 448 |
else |
| 449 |
{ |
| 450 |
// TODO Martin: this only increases performance if getter is cheaper than setter. Should discuss this. |
| 451 |
if (object.eGet(oppositeReference) != instance) |
| 452 |
{ |
| 453 |
object.eInverseAdd(instance, oppositeReference.getFeatureID(), ((EObject)instance).getClass(), null); |
| 454 |
} |
| 455 |
} |
| 456 |
} |
| 457 |
finally |
| 458 |
{ |
| 459 |
if (deliver) |
| 460 |
{ |
| 461 |
object.eSetDeliver(true); |
| 462 |
} |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 416 |
private void clearList(EStructuralFeature feature, InternalEList<Object> list) |
466 |
private void clearList(EStructuralFeature feature, InternalEList<Object> list) |
| 417 |
{ |
467 |
{ |
| 418 |
// attempt 2 |
468 |
// attempt 2 |
|
Lines 421-427
Link Here
|
| 421 |
{ |
471 |
{ |
| 422 |
InternalEObject obj = (InternalEObject)list.get(i); |
472 |
InternalEObject obj = (InternalEObject)list.get(i); |
| 423 |
// TODO clarify obj.getClass()/baseclass |
473 |
// TODO clarify obj.getClass()/baseclass |
| 424 |
instance.eInverseRemove(obj, featureID, obj.getClass(), null); |
474 |
((InternalEList<?>)list).basicRemove(obj, null); |
|
|
475 |
//TODO Martin: baseicRemove seems to be better than eInverseremove |
| 476 |
|
| 477 |
// instance.eInverseRemove(obj, featureID, obj.getClass(), null); |
| 478 |
|
| 425 |
} |
479 |
} |
| 426 |
} |
480 |
} |
| 427 |
|
481 |
|
|
Lines 572-579
Link Here
|
| 572 |
* at runtime. Note also that the proxy object might even not be cast to the concrete type of the target object. The |
626 |
* at runtime. Note also that the proxy object might even not be cast to the concrete type of the target object. The |
| 573 |
* proxy can only guaranteed to be of <em>any</em> concrete subtype of the declared type of the given feature. |
627 |
* proxy can only guaranteed to be of <em>any</em> concrete subtype of the declared type of the given feature. |
| 574 |
* <p> |
628 |
* <p> |
| 575 |
* TODO {@link InternalEObject#eResolveProxy(InternalEObject) |
629 |
* TODO {@link InternalEObject#eResolveProxy(InternalEObject)
*/ |
| 576 |
*/ |
|
|
| 577 |
protected InternalEObject createProxy(InternalCDOView view, EStructuralFeature feature, CDOID id) |
630 |
protected InternalEObject createProxy(InternalCDOView view, EStructuralFeature feature, CDOID id) |
| 578 |
{ |
631 |
{ |
| 579 |
EClassifier eType = feature.getEType(); |
632 |
EClassifier eType = feature.getEType(); |
|
Lines 632-637
Link Here
|
| 632 |
@SuppressWarnings("unchecked") |
685 |
@SuppressWarnings("unchecked") |
| 633 |
InternalEList<Object> list = (InternalEList<Object>)value; |
686 |
InternalEList<Object> list = (InternalEList<Object>)value; |
| 634 |
int size = list.size(); |
687 |
int size = list.size(); |
|
|
688 |
|
| 689 |
boolean deliver = instance.eDeliver(); |
| 690 |
if (deliver) |
| 691 |
{ |
| 692 |
instance.eSetDeliver(false); |
| 693 |
} |
| 694 |
|
| 635 |
for (int i = 0; i < size; i++) |
695 |
for (int i = 0; i < size; i++) |
| 636 |
{ |
696 |
{ |
| 637 |
Object element = list.get(i); |
697 |
Object element = list.get(i); |
|
Lines 650-665
Link Here
|
| 650 |
// ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList(); |
710 |
// ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList(); |
| 651 |
// } |
711 |
// } |
| 652 |
|
712 |
|
| 653 |
if (list instanceof NotifyingListImpl<?>) |
713 |
// if (list instanceof NotifyingListImpl<?>) |
| 654 |
{ |
714 |
// { |
| 655 |
((NotifyingListImpl<Object>)list).basicSet(i, instance, null); |
715 |
// ((NotifyingListImpl<Object>)list).basicSet(i, instance, null); |
| 656 |
} |
716 |
// } |
| 657 |
else |
717 |
// else |
| 658 |
{ |
718 |
// { |
| 659 |
list.set(i, instance); |
719 |
list.set(i, instance); |
| 660 |
} |
720 |
// } |
| 661 |
} |
721 |
} |
| 662 |
} |
722 |
} |
|
|
723 |
if (deliver) |
| 724 |
{ |
| 725 |
instance.eSetDeliver(true); |
| 726 |
} |
| 727 |
|
| 663 |
} |
728 |
} |
| 664 |
else |
729 |
else |
| 665 |
{ |
730 |
{ |