/** * Performs the command activity required to <code>undo</code> the effects of a preceding * <code>execute</code> (or <code>redo</code>). The effect, if any, of calling * <code>undo</code> before <code>execute</code> or <code>redo</code> have been called, or * when canUndo returns <code>false</code>, is undefined. */ public void undo() { if (oldIsSet_) eObject_.eSet(feature_, oldValue_); else eObject_.eUnset(feature_); }
private void undoSingle() { Object child = target_.eGet(childFeature_); target_.eUnset(childFeature_); if (!isCopy_) source_.eSet(childFeature_, child); }
/** * Removes the value from the feature of the object. * @param eObject the object holding the value. * @param eStructuralFeature the feature of the object holding the value. * @param value the value to remove. */ public static void remove(EObject eObject, EStructuralFeature eStructuralFeature, Object value) { if (FeatureMapUtil.isMany(eObject, eStructuralFeature)) { ((List<?>)eObject.eGet(eStructuralFeature)).remove(value); } else { eObject.eUnset(eStructuralFeature); } }
/** * Removes the value from the feature of the object. * @param eObject the object holding the value. * @param eStructuralFeature the feature of the object holding the value. * @param value the value to remove. */ public static void remove(EObject eObject, EStructuralFeature eStructuralFeature, Object value) { if (FeatureMapUtil.isMany(eObject, eStructuralFeature)) { ((List<?>)eObject.eGet(eStructuralFeature)).remove(value); } else { eObject.eUnset(eStructuralFeature); } }
private void executeChangeRecords(Collection changeRecords) { Iterator it = changeRecords.iterator(); while (it.hasNext()) { ChangeRecord r = (ChangeRecord) it.next(); if (r.isSet) { if (r.feature.isMany()) { Collection c = (Collection) r.element.eGet(r.feature); c.clear(); c.addAll((Collection) r.value); } else { r.element.eSet(r.feature, r.value); } } else { r.element.eUnset(r.feature); } } }
/** * Removes the values from the feature of the object. * * @param eObject the object holding the value. * @param eStructuralFeature the feature of the object holding the value. * @param values the values to remove. * @see EcoreUtil#remove(EObject, EStructuralFeature, Object) * @since 2.13 */ public static void removeAll(EObject eObject, EStructuralFeature eStructuralFeature, Collection<?> values) { if (FeatureMapUtil.isMany(eObject, eStructuralFeature)) { ((List<?>)eObject.eGet(eStructuralFeature)).removeAll(values); } else { // The feature is assumed to hold the value. eObject.eUnset(eStructuralFeature); } }
protected void setObjectSingleAttribute(EObject anObject, EStructuralFeature aFeature, Object aValue, boolean shouldUnsetValue) { if (shouldUnsetValue) anObject.eUnset(aFeature); else if (aFeature.getEType() instanceof EEnum) setObjectEnumAttribute(anObject, aFeature, aValue); else anObject.eSet(aFeature, aValue); }
/** * Performs the command activity required to <code>undo</code> the effects of a preceding * <code>execute</code> (or <code>redo</code>). The effect, if any, of calling * <code>undo</code> before <code>execute</code> or <code>redo</code> have been called, or * when canUndo returns <code>false</code>, is undefined. */ public void undo() { if (childFeature_.isMany()) { if (child_ != null) ((EList) parent_.eGet(childFeature_)).add(child_); } else { if (oldChildSet_) parent_.eSet(childFeature_, oldChild_); else parent_.eUnset(childFeature_); } }
/** * 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 void adaptParent() { if (parent_ != null && child_ != null) { EList childFeatures = childEClass_.getEAllStructuralFeatures(); for (Iterator it = childFeatures.iterator(); it.hasNext();) { EStructuralFeature childFeature = (EStructuralFeature) it.next(); boolean isFeatureSet; Object grandchild = child_.eGet(childFeature); if (grandchild != null && grandchild instanceof EList) isFeatureSet = !((EList) grandchild).isEmpty(); else isFeatureSet = child_.eIsSet(childFeature); if (isFeatureSet) { parent_.eSet(feature_, child_); return; } } parent_.eUnset(feature_); } } }
/** * Sets the value of the object's ID attribute according to the value represented by the String. * A <code>null</code> ID will unset the attribute rather than setting it to <code>null</code>. * @param eObject the object in question. * @param id the String value of the new ID. * @throws IllegalArgumentException if the object has no ID attribute. * @see #getID(EObject) * @see org.eclipse.emf.ecore.EAttribute#isID * @see org.eclipse.emf.ecore.EClass#getEIDAttribute */ public static void setID(EObject eObject, String id) { EClass eClass = eObject.eClass(); EAttribute eIDAttribute = eClass.getEIDAttribute(); if (eIDAttribute == null) { throw new IllegalArgumentException("The object doesn't have an ID feature."); } else if (id == null) { eObject.eUnset(eIDAttribute); } else { eObject.eSet(eIDAttribute, createFromString(eIDAttribute.getEAttributeType(), id)); } }
/** * Sets the value of the object's ID attribute according to the value represented by the String. * A <code>null</code> ID will unset the attribute rather than setting it to <code>null</code>. * @param eObject the object in question. * @param id the String value of the new ID. * @throws IllegalArgumentException if the object has no ID attribute. * @see #getID(EObject) * @see org.eclipse.emf.ecore.EAttribute#isID * @see org.eclipse.emf.ecore.EClass#getEIDAttribute */ public static void setID(EObject eObject, String id) { EClass eClass = eObject.eClass(); EAttribute eIDAttribute = eClass.getEIDAttribute(); if (eIDAttribute == null) { throw new IllegalArgumentException("The object doesn't have an ID feature."); } else if (id == null) { eObject.eUnset(eIDAttribute); } else { eObject.eSet(eIDAttribute, createFromString(eIDAttribute.getEAttributeType(), id)); } }
private void executeSingle() { Object child = source_.eGet(childFeature_); if (isCopy_) target_.eSet(childFeature_, cloneObject(child)); else { source_.eUnset(childFeature_); target_.eSet(childFeature_, child); } }
/** * We add typeRefs without Nodes on the fly, so we should remove them before relinking. */ @Override protected void clearReference(EObject obj, EReference ref) { super.clearReference(obj, ref); if (obj.eIsSet(ref) && ref.getEType().equals(XtextPackage.Literals.TYPE_REF)) { INode node = NodeModelUtils.getNode((EObject) obj.eGet(ref)); if (node == null) obj.eUnset(ref); } if (obj.eIsSet(ref) && ref == XtextPackage.Literals.CROSS_REFERENCE__TERMINAL) { INode node = NodeModelUtils.getNode((EObject) obj.eGet(ref)); if (node == null) obj.eUnset(ref); } }
/** * Performs the command activity required to <code>undo</code> the effects of a preceding * <code>execute</code> (or <code>redo</code>). The effect, if any, of calling * <code>undo</code> before <code>execute</code> or <code>redo</code> have been called, or * when canUndo returns <code>false</code>, is undefined. */ public void undo() { if (childFeature_.isMany()) { if (newChild_ != null) ((EList) parent_.eGet(childFeature_)).remove(newChild_); } else { if (oldChildSet_) parent_.eSet(childFeature_, oldChild_); else parent_.eUnset(childFeature_); } }
protected void clearReference(EObject obj, EReference ref) { if (!ref.isContainment() && !ref.isContainer() && !ref.isDerived() && ref.isChangeable() && !ref.isTransient()) obj.eUnset(ref); }
/** * Performs the command activity required to <code>undo</code> the effects of a preceding * <code>execute</code> (or <code>redo</code>). The effect, if any, of calling * <code>undo</code> before <code>execute</code> or <code>redo</code> have been called, or * when canUndo returns <code>false</code>, is undefined. */ public void undo() { if (childFeature_.isMany() && !(newChild_ instanceof EList)) { if (oldChild_ != null && newChild_ != null) { EList eList = (EList) parent_.eGet(childFeature_); int index = eList.indexOf(newChild_); if (index != -1) eList.set(index, oldChild_); } } else { if (oldChildSet_) parent_.eSet(childFeature_, oldChild_); else parent_.eUnset(childFeature_); } }
/** * 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() { if (childFeature_.isMany()) { if (child_ != null) ((EList) parent_.eGet(childFeature_)).remove(child_); } else { oldChild_ = parent_.eGet(childFeature_); oldChildSet_ = parent_.eIsSet(childFeature_); if (nillable_) parent_.eUnset(childFeature_); else parent_.eSet(childFeature_, null); } }
/** * 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() { if (childFeature_.isMany() && !(newChild_ instanceof EList)) { if (oldChild_ != null && newChild_ != null) { EList eList = (EList) parent_.eGet(childFeature_); int index = eList.indexOf(oldChild_); if (index != -1) eList.set(index, newChild_); } } else { oldChild_ = parent_.eGet(childFeature_); oldChildSet_ = parent_.eIsSet(childFeature_); if (newChild_ != null) parent_.eSet(childFeature_, newChild_); else parent_.eUnset(childFeature_); } }
/** * Removes the object from its {@link EObject#eResource containing} resource * and/or its {@link EObject#eContainer containing} object. * @param eObject the object to remove. */ public static void remove(EObject eObject) { InternalEObject internalEObject = (InternalEObject)eObject; EObject container = internalEObject.eInternalContainer(); if (container != null) { EReference feature = eObject.eContainmentFeature(); if (FeatureMapUtil.isMany(container, feature)) { ((EList<?>)container.eGet(feature)).remove(eObject); } else { container.eUnset(feature); } } Resource resource = internalEObject.eDirectResource(); if (resource != null) { resource.getContents().remove(eObject); } }