Java Code Examples for org.eclipse.emf.ecore.util.EContentsEList

The following are top voted examples for showing how to use org.eclipse.emf.ecore.util.EContentsEList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: xtext-core   File: EcoreUtil2.java   View source code 6 votes vote down vote up
/**
 * @since 2.6
 */
public static Iterator<EObject> getNonDerivedContents(EObject eObject) {
	EClassImpl.FeatureSubsetSupplier featureSupplier = (EClassImpl.FeatureSubsetSupplier) eObject.eClass().getEAllStructuralFeatures();
	EStructuralFeature[] eStructuralFeatures = featureSupplier.containments();

	return (eStructuralFeatures == null 
			? EContentsEList.<EObject> emptyContentsEList()
			: new EContentsEList<EObject>(eObject, eStructuralFeatures) {
				@Override
				protected ListIterator<EObject> newResolvingListIterator() {
					return new ResolvingFeatureIteratorImpl<EObject>(eObject, eStructuralFeatures) {
						@Override
						protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
							return !eStructuralFeature.isDerived();
						}
					};
				}
			}).iterator();
}
 
Example 2
Project: MMINT   File: ICMT15.java   View source code 6 votes vote down vote up
private List<String> generateModelEncodings(@NonNull EObject inputRootModelObj) {

		List<String> modelEncodings = new ArrayList<>();
		TreeIterator<EObject> iter = inputRootModelObj.eAllContents();
		while (iter.hasNext()) {
			EObject modelObj = iter.next();
			try {
				modelEncodings.add(getModelObjectEncoding(modelObj));
				EContentsEList.FeatureIterator<EObject> crossIter = (EContentsEList.FeatureIterator<EObject>) modelObj.eCrossReferences().iterator();
				while (crossIter.hasNext()) {
					modelEncodings.add(getModelReferenceEncoding(modelObj, crossIter.next(), crossIter.feature()));
				}
			}
			catch (MMINTException e) {
				continue;
			}
		}

		return modelEncodings;
	}
 
Example 3
Project: emf-fragments   File: FInternalObjectImpl.java   View source code 6 votes vote down vote up
private EList<EObject> eContentsWithOutFragments() {
	EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) this.eClass().getEAllStructuralFeatures()).containments();
	EStructuralFeature[] eStructuralFeaturesWithOutFragmentsArray = null;
	if (eStructuralFeatures != null) {
		List<EStructuralFeature> eStructuralFeaturesWithOutFragments = new ArrayList<EStructuralFeature>(eStructuralFeatures.length);
		for (EStructuralFeature eStructuralFeature : eStructuralFeatures) {
			FragmentationType fragmentationType = EMFFragUtil.getFragmentationType(eStructuralFeature);
			if (fragmentationType == FragmentationType.None || eStructuralFeature instanceof EAttribute) {
				eStructuralFeaturesWithOutFragments.add(eStructuralFeature);
			}
		}
		eStructuralFeaturesWithOutFragmentsArray = eStructuralFeaturesWithOutFragments
				.toArray(new EStructuralFeature[eStructuralFeaturesWithOutFragments.size()]);
	}

	EContentsEList<EObject> eContentsEListWithOutFragments = eStructuralFeaturesWithOutFragmentsArray == null ? EContentsEList
			.<EObject> emptyContentsEList() : new EContentsEList<EObject>(this, eStructuralFeaturesWithOutFragmentsArray);

	return eContentsEListWithOutFragments;
}
 
Example 4
Project: statecharts   File: CrossDocumentContentAdapter.java   View source code 5 votes vote down vote up
@Override
protected void setTarget(EObject target) {
	super.setTarget(target);
	for (EContentsEList.FeatureIterator<EObject> featureIterator = (EContentsEList.FeatureIterator<EObject>) target
			.eCrossReferences().iterator(); featureIterator.hasNext();) {
		Notifier notifier = featureIterator.next();
		EStructuralFeature feature = featureIterator.feature();
		if (shouldAdapt(feature)) {
			addAdapter(notifier);
		}
	}
}
 
Example 5
Project: statecharts   File: CrossDocumentContentAdapter.java   View source code 5 votes vote down vote up
@Override
protected void unsetTarget(EObject target) {
	super.unsetTarget(target);
	for (EContentsEList.FeatureIterator<EObject> featureIterator = (EContentsEList.FeatureIterator<EObject>) target
			.eCrossReferences().iterator(); featureIterator.hasNext();) {
		Notifier notifier = featureIterator.next();
		EStructuralFeature feature = featureIterator.feature();
		if (shouldAdapt(feature)) {
			removeAdapter(notifier);
		}
	}
}
 
Example 6
Project: eclipse-avro   File: FlatEObjectImpl.java   View source code 5 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  if (eContents == null)
  {
    eContents = EContentsEList.createEContentsEList(this);
  }
  return eContents;
}
 
Example 7
Project: eclipse-avro   File: BasicEObjectImpl.java   View source code 5 votes vote down vote up
public EList<EObject> eContents()
{
  EList<EObject> result = eProperties().getEContents();
  if (result == null)
  {
    eBasicProperties().setEContents(result = EContentsEList.createEContentsEList(this));
  }

  return result;
}
 
Example 8
Project: clickwatch   File: FlatEObjectImpl.java   View source code 5 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  if (eContents == null)
  {
    eContents = EContentsEList.createEContentsEList(this);
  }
  return eContents;
}
 
Example 9
Project: clickwatch   File: BasicEObjectImpl.java   View source code 5 votes vote down vote up
public EList<EObject> eContents()
{
  EList<EObject> result = eProperties().getEContents();
  if (result == null)
  {
    eBasicProperties().setEContents(result = EContentsEList.createEContentsEList(this));
  }

  return result;
}
 
Example 10
Project: eclipse-avro   File: ENamedElementImpl.java   View source code 4 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  EStructuralFeature [] eStructuralFeatures = 
    ((EClassImpl.FeatureSubsetSupplier)eClass().getEAllStructuralFeatures()).containments();
    
  return
    eStructuralFeatures == null ?
      EContentsEList.<EObject>emptyContentsEList() :
      new EContentsEList<EObject>(this, eStructuralFeatures)
      {
        @Override
        protected boolean useIsSet()
        {
          return false;
        }

        @Override
        protected ListIterator<EObject> newResolvingListIterator()
        {
          return 
            new ResolvingFeatureIteratorImpl<EObject>(eObject, eStructuralFeatures)
            {
              @Override
              protected boolean useIsSet()
              {
                return false;
              }
            };
        }

        @Override
        protected ListIterator<EObject> newNonResolvingListIterator()
        {
          return 
            new FeatureIteratorImpl<EObject>(eObject, eStructuralFeatures)
            {
              @Override
              protected boolean useIsSet()
              {
                return false;
              }
            };
        }

      };
}
 
Example 11
Project: eclipse-avro   File: MinimalEObjectImpl.java   View source code 4 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  return EContentsEList.createEContentsEList(this);
}
 
Example 12
Project: clickwatch   File: ENamedElementImpl.java   View source code 4 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  EStructuralFeature [] eStructuralFeatures = 
    ((EClassImpl.FeatureSubsetSupplier)eClass().getEAllStructuralFeatures()).containments();
    
  return
    eStructuralFeatures == null ?
      EContentsEList.<EObject>emptyContentsEList() :
      new EContentsEList<EObject>(this, eStructuralFeatures)
      {
        @Override
        protected boolean useIsSet()
        {
          return false;
        }

        @Override
        protected ListIterator<EObject> newResolvingListIterator()
        {
          return 
            new ResolvingFeatureIteratorImpl<EObject>(eObject, eStructuralFeatures)
            {
              @Override
              protected boolean useIsSet()
              {
                return false;
              }
            };
        }

        @Override
        protected ListIterator<EObject> newNonResolvingListIterator()
        {
          return 
            new FeatureIteratorImpl<EObject>(eObject, eStructuralFeatures)
            {
              @Override
              protected boolean useIsSet()
              {
                return false;
              }
            };
        }

      };
}
 
Example 13
Project: clickwatch   File: MinimalEObjectImpl.java   View source code 4 votes vote down vote up
@Override
public EList<EObject> eContents()
{
  return EContentsEList.createEContentsEList(this);
}
 
Example 14
Project: eclectic   File: StreamedEmfModel.java   View source code 4 votes vote down vote up
@Override
public Collection<Object> receive(IStreamedFragment<EObject, ?> frg) {
	EmfFragment fragment = (EmfFragment) frg;
	LinkedList<Object> newObjects = new LinkedList<Object>();
	
	// System.out.println("Received: " + receivedObjectsByKey.size());
	
	Object[] objects = fragment.getObjects();
	for(int i = 0; i < objects.length; i++) {
		EObject eobject = (EObject) objects[i];
		if ( ! classesWithoutKey.contains(eobject.eClass().getName()) ) {
			String key = findKey(eobject, explicitKey);
			if ( key != null ) {
				
				if ( receivedObjectsByKey.containsKey(key) ) {
					// System.out.println("* " + eobject);
					for(int j = 0; j < objects.length; j++) {
						EContentsEList.FeatureIterator it = (EContentsEList.FeatureIterator) ((EObject) objects[j]).eCrossReferences().iterator();
						while ( it.hasNext() ) {
							EObject refObject = (EObject) it.next();
							if ( refObject == eobject ) {
								EStructuralFeature f = it.feature();
								EcoreUtil.replace((EObject) objects[j], f, eobject, receivedObjectsByKey.get(key));
							}
						}
					}
					// System.out.println(eobject.eCrossReferences());
					// REPLACE THE ARRIVED OBJECT WITH THE EXISTING ONE!!
					//((EObject) objects[i]).ese
					// Force opposite...
					continue;
				}
				
				receivedObjectsByKey.put(key, (EObject) objects[i]);
			}
		}
		
		newObjects.add(objects[i]);
		handler.addToResource((EObject) objects[i]);
	}
	// handler.packRootElements();

	// TODO: Now assuming the same proxy is not referenced from several places
	IsProxyAnnotation[] annotations = fragment.getProxyAnnotations();
	for(int i = 0; i < annotations.length; i++) {
		EObject object = (EObject) annotations[i].getObject();
		String k       = findKey(object, false);
		if ( receivedObjectsByKey.containsKey(k) ) {
			EObject realObj = receivedObjectsByKey.get(k);
			
			// TODO: Assuming mono-valued reference
			EcoreUtil.replace(annotations[i].getReferenceSource(), 
					annotations[i].getObject().eClass().getEStructuralFeature(annotations[i].getReferenceName()), 
					object, realObj);
			
			// Now it seems that it does not work
			// EcoreUtil.replace(object, realObj);
		} 
		else {
			// Needed for "needsWaiting"
			proxiesTemp.put(object, annotations[i]);			
		}
	}

	return newObjects;
}