*/
@SuppressWarnings("unchecked")
@Override
public boolean addChildTo(EObject tParent, EReference tParent2tChildRef,
EObject tChild, Integer position, IContext context) throws SimTLException{
if(tParent==null) throw new SimTLException("tParent is null");
else if(tParent2tChildRef==null) throw new SimTLException("tParent2tChildRef is null");
else if(tChild==null) return false;
log.info("Add " + Util.getFullName(tChild) + " to " + Util.getFullName(tParent) + " at reference " + tParent2tChildRef.getName() + " and position " + position);
if(tParent2tChildRef.isMany()){
List<EObject> listOfChildren = ((List<EObject>)tParent.eGet(tParent2tChildRef));
if(!listOfChildren.contains(tChild)){
if(position==null||position==Util.NO_POSITION){
listOfChildren.add(tChild);
} else {
listOfChildren.add(position, tChild);
}
return true;
}
} else {
if(position!=null || position!=Util.NO_POSITION){
throw new SimTLException("Cannot set element. Position given ("+position+")");
} else {
tParent.eSet(tParent2tChildRef, tChild);
}
return true;
}