/** * Sets a property of an eobject. * * @param eobject THe object. * @param property The property to set. * @param value The value of the property. */ public static void set(EObject eobject, String property, Object value) { EStructuralFeature feature = feature(eobject, property); eobject.eSet(feature, value); }
static void set(EObject object, String featureName, Object value) { EStructuralFeature feature = object.eClass().getEStructuralFeature(featureName); if (feature != null) { object.eSet(feature, value); } }
/** * Copies all the properties from one object to anoter. * * @param source The object to copy from. * @param target The object to copy to. */ public static void copy(EObject source, EObject target) { for (Iterator i = source.eClass().getEStructuralFeatures().iterator(); i.hasNext(); ) { EStructuralFeature feature = (EStructuralFeature) i.next(); target.eSet(feature, source.eGet(feature)); } } }
/** * Clones an eobject, with the option of performing a deep clone in which referenced eobjects * are also cloned. * * @param prototype The object to be cloned from. * @param factory The factory used to create the clone. * @param deepFlag indicating wether to perform a deep clone. * @return THe cloned object, with all properties the same to the original. */ public static EObject clone(EObject prototype, EFactory factory, boolean deep) { EObject clone = factory.create(prototype.eClass()); for (Iterator i = clone.eClass().getEStructuralFeatures().iterator(); i.hasNext(); ) { EStructuralFeature feature = (EStructuralFeature) i.next(); Object value = prototype.eGet(feature); if (deep && value instanceof EObject) { EObject evalue = (EObject) value; // recursively call // TODO:handle cycles in reference graph value = clone(evalue, evalue.eClass().getEPackage().getEFactoryInstance(), deep); } clone.eSet(feature, value); } return clone; }
/** * Adds a value to a multi-valued propert of an eobject. * * <p>The <param>feature</param> must map to a multi-valued property of the eobject. The {@link * #isCollection(EStructuralFeature)} method can be used to test this. * * @param eobject The object. * @param feature The multi-valued feature. * @param value The value to add. */ public static void add(EObject eobject, EStructuralFeature feature, Object value) { if (isCollection(eobject, feature)) { Collection collection = (Collection) eobject.eGet(feature); if (collection == null) { // most likely not an ECollection collection = createEmptyCollection(feature); eobject.eSet(feature, collection); } Collection addCollection = collection(value); collection.addAll(addCollection); } }
eObject.eSet(feature, value);
@Override protected void doSetValue(Object value) { eObject.eSet(eStructuralFeature, value); }
@Override public void setValue(T v) throws ClassCastException { this.eo.eSet(this.f, v); } }
@Override protected void doSetValue(Object value) { eObject.eSet(eStructuralFeature, value); }
@Override protected void doSetValue(Object source, Object value) { EObject eObject = (EObject)source; eObject.eSet(eStructuralFeature, value); }
waitingObject.getObject().eSet(waitingObject.getEReference(), eObject); } else { throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void doMoveTo(EObject what, EObject newContainer, EReference reference, int index) throws ModelManipulationException { if (reference.isMany()) { ((EList)newContainer.eGet(reference)).add(index, what); } else{ newContainer.eSet(reference, what); } }
private EObject createChild() { EFactory childFactory = childEClass_.getEPackage().getEFactoryInstance(); EObject child = childFactory.create(childEClass_); for (int i = 0; i < features_.length; i++) { if (!featuresNillable_[i]) child.eSet(features_[i], ""); //$NON-NLS-1$ } return child; }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected EObject doCreate(EObject container, EReference reference, EClass clazz) { EObject obj = EcoreUtil.create(clazz); if (reference.isMany()) { ((EList) container.eGet(reference)).add(obj); } else { container.eSet(reference, obj); } return obj; }
protected void doRename(final EObject target, final RenameChange change, final RenameContext context) { final EAttribute nameAttribute = this.getNameEAttribute(target); if ((nameAttribute != null)) { target.eSet(nameAttribute, change.getNewName()); } else { String _name = target.eClass().getName(); String _plus = ("Element of class " + _name); String _plus_1 = (_plus + " cannot be renamed."); context.getIssues().add(RefactoringIssueAcceptor.Severity.WARNING, _plus_1); } }
private EObject setChild() { EObject child = createChild(); parent_.eAdapters().remove(this); parent_.eSet(childFeature_, child); parent_.eAdapters().add(this); return child; }
/** * Performs the command activity required for the effect. The effect of calling * <code>execute</code> when <code>canExecute</code> returns <code>false</code>, or when * <code>canExecute</code> hasn't been called, is undefined. */ public void execute() { oldIsSet_ = eObject_.eIsSet(feature_); oldValue_ = eObject_.eGet(feature_); eObject_.eSet(feature_, newValue_); if (nillable_ && newValue_ == null) eObject_.eUnset(feature_); }
private boolean checkPermission(final EObject pObjectInstance, final EObject permissionInstance) { final Permission permission = (Permission) permissionInstance.eClass(); permissionInstance.eSet(permission.getEStructuralFeature(IPermissionConstant.OBJECT), pObjectInstance); final String expession = permission.getConstraint().getExpession(); final Expression exp = parser.parseExpression(expession); final StandardEvaluationContext context = new StandardEvaluationContext(permissionInstance); context.addPropertyAccessor(new EmfPropertyAccessor()); return exp.getValue(context, Boolean.class).booleanValue(); }