|
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 356-366
Link Here
|
| 356 |
TRACER.format("State of Object is : " + state); |
355 |
TRACER.format("State of Object is : " + state); |
| 357 |
} |
356 |
} |
| 358 |
|
357 |
|
| 359 |
// if (state != CDOState.CONFLICT) // do not do anything with the |
358 |
if (state == CDOState.CLEAN || state == CDOState.PROXY) |
| 360 |
if (state == CDOState.CLEAN || state == CDOState.PROXY) // do not do anything with the |
|
|
| 361 |
// list if state is conflict |
| 362 |
{ |
359 |
{ |
| 363 |
// int size = view.getStore().size(instance, feature); |
|
|
| 364 |
int size = revision.size(feature); |
360 |
int size = revision.size(feature); |
| 365 |
|
361 |
|
| 366 |
@SuppressWarnings("unchecked") |
362 |
@SuppressWarnings("unchecked") |
|
Lines 376-389
Link Here
|
| 376 |
TRACER.format(("Adding " + object + " to feature " + feature + "in instance " + instance)); |
372 |
TRACER.format(("Adding " + object + " to feature " + feature + "in instance " + instance)); |
| 377 |
} |
373 |
} |
| 378 |
|
374 |
|
| 379 |
// instance.eInverseAdd((InternalEObject)object, instance.eClass().getFeatureID(feature), object.getClass(), |
|
|
| 380 |
// null); |
| 381 |
list.basicAdd(object, null); |
375 |
list.basicAdd(object, null); |
| 382 |
} |
376 |
} |
| 383 |
} |
377 |
} |
| 384 |
} |
378 |
} |
| 385 |
else |
379 |
else |
| 386 |
{ // ! isMany() |
380 |
{ |
|
|
381 |
// !feature.isMany() |
| 387 |
Object object = getValueFromRevision(feature, 0); |
382 |
Object object = getValueFromRevision(feature, 0); |
| 388 |
if (feature instanceof EAttribute) |
383 |
if (feature instanceof EAttribute) |
| 389 |
{ |
384 |
{ |
|
Lines 395-401
Link Here
|
| 395 |
eSet(feature, object); |
390 |
eSet(feature, object); |
| 396 |
} |
391 |
} |
| 397 |
else |
392 |
else |
| 398 |
{ // EReferences |
393 |
{ |
|
|
394 |
// EReferences |
| 399 |
if (TRACER.isEnabled()) |
395 |
if (TRACER.isEnabled()) |
| 400 |
{ |
396 |
{ |
| 401 |
TRACER.format(("Adding object " + object + " to feature " + feature + " in instance " + instance)); |
397 |
TRACER.format(("Adding object " + object + " to feature " + feature + " in instance " + instance)); |
|
Lines 403-409
Link Here
|
| 403 |
|
399 |
|
| 404 |
int featureID = instance.eClass().getFeatureID(feature); |
400 |
int featureID = instance.eClass().getFeatureID(feature); |
| 405 |
Class<? extends Object> baseClass = object == null ? null : object.getClass(); |
401 |
Class<? extends Object> baseClass = object == null ? null : object.getClass(); |
| 406 |
instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); |
402 |
|
|
|
403 |
try |
| 404 |
{ |
| 405 |
instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); |
| 406 |
} |
| 407 |
catch (NullPointerException e) |
| 408 |
{ |
| 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-427
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 |
|
| 442 |
try |
| 443 |
{ |
| 444 |
if (oppositeReference.isMany()) |
| 445 |
{ |
| 446 |
// TODO Martin: Is this enough?? |
| 447 |
@SuppressWarnings("unchecked") |
| 448 |
InternalEList<Object> list = (InternalEList<Object>)object.eGet(oppositeReference); |
| 449 |
list.basicAdd(instance, null); |
| 450 |
} |
| 451 |
else |
| 452 |
{ |
| 453 |
// TODO Martin: This only increases performance if getter is cheaper than setter. Should discuss this. |
| 454 |
if (object.eGet(oppositeReference) != instance) |
| 455 |
{ |
| 456 |
object.eInverseAdd(instance, oppositeReference.getFeatureID(), ((EObject)instance).getClass(), null); |
| 457 |
} |
| 458 |
} |
| 459 |
} |
| 460 |
finally |
| 461 |
{ |
| 462 |
if (deliver) |
| 463 |
{ |
| 464 |
object.eSetDeliver(true); |
| 465 |
} |
| 466 |
} |
| 467 |
} |
| 468 |
|
| 416 |
private void clearList(EStructuralFeature feature, InternalEList<Object> list) |
469 |
private void clearList(EStructuralFeature feature, InternalEList<Object> list) |
| 417 |
{ |
470 |
{ |
| 418 |
// attempt 2 |
|
|
| 419 |
int featureID = feature.getFeatureID(); |
| 420 |
for (int i = list.size() - 1; i >= 0; --i) |
471 |
for (int i = list.size() - 1; i >= 0; --i) |
| 421 |
{ |
472 |
{ |
| 422 |
InternalEObject obj = (InternalEObject)list.get(i); |
473 |
InternalEObject obj = (InternalEObject)list.get(i); |
| 423 |
// TODO clarify obj.getClass()/baseclass |
474 |
|
| 424 |
instance.eInverseRemove(obj, featureID, obj.getClass(), null); |
475 |
// TODO Clarify obj.getClass()/baseclass |
|
|
476 |
((InternalEList<?>)list).basicRemove(obj, null); |
| 477 |
|
| 478 |
// TODO Martin: baseicRemove seems to be better than eInverseremove |
| 479 |
// instance.eInverseRemove(obj, featureID, obj.getClass(), null); |
| 425 |
} |
480 |
} |
| 426 |
} |
481 |
} |
| 427 |
|
482 |
|
|
Lines 438-444
Link Here
|
| 438 |
private Object getValueFromRevision(EStructuralFeature feature, int index) |
493 |
private Object getValueFromRevision(EStructuralFeature feature, int index) |
| 439 |
{ |
494 |
{ |
| 440 |
Object object = revision.get(feature, index); |
495 |
Object object = revision.get(feature, index); |
| 441 |
|
|
|
| 442 |
if (object == null) |
496 |
if (object == null) |
| 443 |
{ |
497 |
{ |
| 444 |
return null; |
498 |
return null; |
|
Lines 456-471
Link Here
|
| 456 |
} |
510 |
} |
| 457 |
|
511 |
|
| 458 |
object = getPreRegisteredObjects().get(id); |
512 |
object = getPreRegisteredObjects().get(id); |
| 459 |
|
|
|
| 460 |
if (object != null) |
513 |
if (object != null) |
| 461 |
{ |
514 |
{ |
| 462 |
System.out.println(((CDOLegacyWrapper)object).cdoInternalInstance()); |
515 |
System.out.println(((CDOLegacyWrapper)object).cdoInternalInstance()); |
| 463 |
return ((CDOLegacyWrapper)object).cdoInternalInstance(); |
516 |
return ((CDOLegacyWrapper)object).cdoInternalInstance(); |
| 464 |
} |
517 |
} |
| 465 |
|
518 |
|
| 466 |
// return view.getStore().get(instance, feature, index); |
|
|
| 467 |
object = view.getObject(id); |
519 |
object = view.getObject(id); |
| 468 |
|
|
|
| 469 |
if (object instanceof CDOObjectWrapper) |
520 |
if (object instanceof CDOObjectWrapper) |
| 470 |
{ |
521 |
{ |
| 471 |
return ((CDOObjectWrapper)object).cdoInternalInstance(); |
522 |
return ((CDOObjectWrapper)object).cdoInternalInstance(); |
|
Lines 504-510
Link Here
|
| 504 |
|
555 |
|
| 505 |
protected void setInstanceContainer(InternalEObject container, int containerFeatureID) |
556 |
protected void setInstanceContainer(InternalEObject container, int containerFeatureID) |
| 506 |
{ |
557 |
{ |
| 507 |
// TODO change to direct call of eBasicSetContainer |
558 |
// TODO Change to direct call of eBasicSetContainer |
| 508 |
Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$ |
559 |
Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$ |
| 509 |
ReflectUtil.invokeMethod(method, instance, container, containerFeatureID); |
560 |
ReflectUtil.invokeMethod(method, instance, container, containerFeatureID); |
| 510 |
} |
561 |
} |
|
Lines 586-592
Link Here
|
| 586 |
} |
637 |
} |
| 587 |
|
638 |
|
| 588 |
/** |
639 |
/** |
| 589 |
* TODO Ed: Fix whole mess ;-) |
640 |
* TODO Martin: Can this be optimized? |
| 590 |
*/ |
641 |
*/ |
| 591 |
protected void clearEList(InternalEList<Object> list) |
642 |
protected void clearEList(InternalEList<Object> list) |
| 592 |
{ |
643 |
{ |
|
Lines 602-620
Link Here
|
| 602 |
*/ |
653 |
*/ |
| 603 |
protected void resolveAllProxies() |
654 |
protected void resolveAllProxies() |
| 604 |
{ |
655 |
{ |
| 605 |
// if (!allProxiesResolved) |
656 |
CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry(); |
|
|
657 |
EClass eClass = revision.getEClass(); |
| 658 |
for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass)) |
| 606 |
{ |
659 |
{ |
| 607 |
CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry(); |
660 |
if (feature instanceof EReference) |
| 608 |
EClass eClass = revision.getEClass(); |
|
|
| 609 |
for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass)) |
| 610 |
{ |
661 |
{ |
| 611 |
if (feature instanceof EReference) |
662 |
resolveProxies(feature, packageRegistry); |
| 612 |
{ |
|
|
| 613 |
resolveProxies(feature, packageRegistry); |
| 614 |
} |
| 615 |
} |
663 |
} |
| 616 |
|
|
|
| 617 |
// allProxiesResolved = true; |
| 618 |
} |
664 |
} |
| 619 |
} |
665 |
} |
| 620 |
|
666 |
|
|
Lines 632-637
Link Here
|
| 632 |
@SuppressWarnings("unchecked") |
678 |
@SuppressWarnings("unchecked") |
| 633 |
InternalEList<Object> list = (InternalEList<Object>)value; |
679 |
InternalEList<Object> list = (InternalEList<Object>)value; |
| 634 |
int size = list.size(); |
680 |
int size = list.size(); |
|
|
681 |
|
| 682 |
boolean deliver = instance.eDeliver(); |
| 683 |
if (deliver) |
| 684 |
{ |
| 685 |
instance.eSetDeliver(false); |
| 686 |
} |
| 687 |
|
| 635 |
for (int i = 0; i < size; i++) |
688 |
for (int i = 0; i < size; i++) |
| 636 |
{ |
689 |
{ |
| 637 |
Object element = list.get(i); |
690 |
Object element = list.get(i); |
|
Lines 650-665
Link Here
|
| 650 |
// ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList(); |
703 |
// ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList(); |
| 651 |
// } |
704 |
// } |
| 652 |
|
705 |
|
| 653 |
if (list instanceof NotifyingListImpl<?>) |
706 |
// if (list instanceof NotifyingListImpl<?>) |
| 654 |
{ |
707 |
// { |
| 655 |
((NotifyingListImpl<Object>)list).basicSet(i, instance, null); |
708 |
// ((NotifyingListImpl<Object>)list).basicSet(i, instance, null); |
| 656 |
} |
709 |
// } |
| 657 |
else |
710 |
// else |
| 658 |
{ |
711 |
// { |
| 659 |
list.set(i, instance); |
712 |
list.set(i, instance); |
| 660 |
} |
713 |
// } |
| 661 |
} |
714 |
} |
| 662 |
} |
715 |
} |
|
|
716 |
|
| 717 |
if (deliver) |
| 718 |
{ |
| 719 |
instance.eSetDeliver(true); |
| 720 |
} |
| 663 |
} |
721 |
} |
| 664 |
else |
722 |
else |
| 665 |
{ |
723 |
{ |
|
Lines 794-821
Link Here
|
| 794 |
} |
852 |
} |
| 795 |
|
853 |
|
| 796 |
/** |
854 |
/** |
| 797 |
* @since 3.0 |
|
|
| 798 |
*/ |
| 799 |
public void setUnderConstruction(boolean underConstruction) |
| 800 |
{ |
| 801 |
this.underConstruction = underConstruction; |
| 802 |
} |
| 803 |
|
| 804 |
/** |
| 805 |
* @since 3.0 |
| 806 |
*/ |
| 807 |
public boolean isUnderConstruction() |
| 808 |
{ |
| 809 |
return underConstruction; |
| 810 |
} |
| 811 |
|
| 812 |
/** |
| 813 |
* @author Martin Fluegge |
855 |
* @author Martin Fluegge |
| 814 |
*/ |
856 |
*/ |
| 815 |
private static final class Counter |
857 |
private static final class Counter |
| 816 |
{ |
858 |
{ |
| 817 |
private int value; |
859 |
private int value; |
| 818 |
|
860 |
|
|
|
861 |
public Counter() |
| 862 |
{ |
| 863 |
} |
| 864 |
|
| 819 |
public void increment() |
865 |
public void increment() |
| 820 |
{ |
866 |
{ |
| 821 |
++value; |
867 |
++value; |