org.eclipse.emf.common.util.AbstractEList Java Examples

The following examples show how to use org.eclipse.emf.common.util.AbstractEList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReferenceCounter.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
		@Override
		public Reference reAttach(IdEObject mainObject) {
//			System.out.println("Re-attaching M " + getReferredObject() + " to " + mainObject + " on " + getIdEObject() + "." + geteReference().getName());
			AbstractEList list = (AbstractEList) getIdEObject().eGet(geteReference());
			int index = list.indexOf(getReferredObject());
			if (index != -1) {
				try {
					list.set(index, mainObject);
				} catch (IllegalArgumentException e) {
//					e.printStackTrace();
				}
			}

			// TODO if the old object really does exist multiple times, the new object should also exist multiple times... but it's probably a bug that it's there multiple times in the first place...
			while (list.contains(getReferredObject())) {
				list.remove(getReferredObject());
			}
			return new MultiReference(getIdEObject(), mainObject, geteReference());
		}
 
Example #2
Source File: SharedJsonDeserializer.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private void processRef(IfcModelInterface model, WaitingList<Long> waitingList, IdEObjectImpl object,
		EStructuralFeature eStructuralFeature, int index, AbstractEList list, long refOid)
				throws DeserializeException {
	EntityDefinition entityBN = model.getPackageMetaData().getSchemaDefinition().getEntityBN(object.eClass().getName());
	Attribute attributeBN = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
	if (skipInverses && attributeBN instanceof InverseAttribute && ((EReference)eStructuralFeature).getEOpposite() != null) {
		// skip
	} else {
		if (model.contains(refOid)) {
			EObject referencedObject = model.get(refOid);
			if (referencedObject != null) {
				addToList(eStructuralFeature, index, list, referencedObject);
			}
		} else {
			waitingList.add(refOid, new ListWaitingObject(-1, object, (EReference) eStructuralFeature, index));
		}
	}
}
 
Example #3
Source File: SharedJsonDeserializer.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addToList(EStructuralFeature eStructuralFeature, int index, AbstractEList list, EObject referencedObject) throws DeserializeException {
	EClass referenceEClass = referencedObject.eClass();
	if (((EClass) eStructuralFeature.getEType()).isSuperTypeOf(referenceEClass)) {
		while (list.size() <= index) {
			list.addUnique(referencedObject);
		}
	} else {
		throw new DeserializeException(DeserializerErrorCode.REFERENCED_OBJECT_CANNOT_BE_STORED_IN_THIS_FIELD, -1, referenceEClass.getName() + " cannot be stored in " + eStructuralFeature.getName());
	}
}
 
Example #4
Source File: WaitingList.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void updateNode(T expressId, EClass ec, IdEObject eObject) throws DeserializeException {
	for (WaitingObject waitingObject : waitingObjects.get(expressId)) {
		if (waitingObject.getEReference().isMany()) {
			AbstractEList<EObject> list = (AbstractEList<EObject>) waitingObject.getObject().eGet(waitingObject.getEReference());
			if (waitingObject instanceof SingleWaitingObject) {
				list.addUnique(eObject);
			} else {
				ListWaitingObject listWaitingObject = (ListWaitingObject)waitingObject;
				if (((EClass) waitingObject.getEReference().getEType()).isSuperTypeOf(eObject.eClass())) {
					while (list.size() <= listWaitingObject.getIndex()) {
						EObject create = ec.getEPackage().getEFactoryInstance().create(eObject.eClass());
						((IdEObjectImpl)create).setOid(-2);
						list.addUnique(create);
					}
					list.setUnique(listWaitingObject.getIndex(), eObject);
				} else {
					throw new DeserializeException(DeserializerErrorCode.REFERENCED_OBJECT_CANNOT_BE_STORED_IN_THIS_FIELD, waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
							+ waitingObject.getEReference().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName());
				}
			}
		} else {
			if (((EClass) waitingObject.getEReference().getEType()).isSuperTypeOf(eObject.eClass())) {
				waitingObject.getObject().eSet(waitingObject.getEReference(), eObject);
			} else {
				throw new DeserializeException(DeserializerErrorCode.NON_EXISTING_ENTITY_REFERENCED, waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
						+ waitingObject.getEReference().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName() + "/" + eObject.getOid());
			}
		}
	}
	waitingObjects.remove(expressId);
}
 
Example #5
Source File: EDelegatingList.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
public EDelegatingList(ClientIfcModel model, IdEObject subject, EStructuralFeature feature, AbstractEList<E> delegate) {
	this.model = model;
	this.subject = subject;
	this.feature = feature;
	this.delegate = delegate;
}