Пример #1
0
  /**
   * IMPORTANT: Compile errors in this method might indicate an old version of EMF. Legacy support
   * is only enabled for EMF with fixed bug #247130. These compile errors do not affect native
   * models!
   */
  protected void resolveProxies(EStructuralFeature feature) {
    Object value = getInstanceValue(instance, feature);
    if (value != null) {
      if (feature.isMany()) {
        @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);
          if (element instanceof LegacyProxy) {
            CDOID id = ((LegacyProxy) element).getID();
            InternalCDOObject resolved = (InternalCDOObject) viewAndState.view.getObject(id);
            InternalEObject instance = resolved.cdoInternalInstance();

            // TODO LEGACY
            // // TODO Is InternalEList.basicSet() needed???
            // if (list instanceof
            // org.eclipse.emf.ecore.util.DelegatingInternalEList)
            // {
            // list =
            // ((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 (deliver) {
          instance.eSetDeliver(true);
        }
      } else {
        if (value instanceof LegacyProxy) {
          CDOID id = ((LegacyProxy) value).getID();
          InternalCDOObject resolved = (InternalCDOObject) viewAndState.view.getObject(id);
          InternalEObject instance = resolved.cdoInternalInstance();
          setInstanceValue(instance, feature, instance);
        }
      }
    }
  }
Пример #2
0
  protected void clearEList(InternalEList<?> list) {
    for (int i = list.size() - 1; i >= 0; --i) {
      Object obj = list.get(i);

      // Disable notifications from value during the
      // invalidation in case of
      // eInverseAdd/eInverseRemove
      boolean eDeliver = false;
      if (obj instanceof Notifier) {
        Notifier notifier = (Notifier) obj;
        eDeliver = notifier.eDeliver();
        if (eDeliver) {
          notifier.eSetDeliver(false);
        }
      }

      list.basicRemove(obj, null);

      if (obj instanceof Notifier && eDeliver) {
        Notifier notifier = (Notifier) obj;
        notifier.eSetDeliver(eDeliver);
      }
    }
  }