/** * This creates a command to set the owner's feature to the specified value. */ public static Command create(EditingDomain domain, final Object owner, Object feature, Object value) { return create(domain, owner, feature, value, CommandParameter.NO_INDEX); }
@Override protected void doSet(EObject container, EStructuralFeature feature, Object value) throws ModelManipulationException { Command setCommand = SetCommand.create(domain, container, feature, value); executeCommand(setCommand); }
/** * Returns a command that will set the value on the model object. The wrapper is used as the owner of the command, * unless overridden, so that it can specialize the command that eventually gets created. */ protected Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value) { return SetCommand.create(domain, getCommandOwner(WrapperItemProvider.this), null, value); }
/** * Returns a wrapped set command that returns as its affected object the replacement wrapper for the value. */ @Override protected Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value, int index) { return new ReplacementAffectedObjectCommand(SetCommand.create(domain, this.owner, this.feature, value, this.index)); }
@Override protected void doSet(EObject container, EStructuralFeature feature, Object value) throws ModelManipulationException { Command setCommand = SetCommand.create(domain, container, feature, value); executeCommand(setCommand); }
@Override protected Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value) { if (needsEncoding(feature)) { value = decode((String)value); } return SetCommand.create(domain, getCommandOwner(FeatureMapEntryWrapperItemProvider.this), null, value); }
(SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ETYPE_ARGUMENTS, Collections.EMPTY_LIST)); command.appendIfCanExecute (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ECLASSIFIER, null)); command.appendIfCanExecute (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__EUPPER_BOUND, null)); command.appendIfCanExecute (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ELOWER_BOUND, null)); command.append (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ETYPE_PARAMETER, value)); editingDomain.getCommandStack().execute(command);
@Override protected EObject doCreate(EObject container, EReference reference, EClass clazz) throws ModelManipulationException { EObject obj = EcoreUtil.create(clazz); Command command; if(reference.isMany()) { command = AddCommand.create(domain, container, reference, obj); } else { command = SetCommand.create(domain, container, reference, obj); } executeCommand(command); return obj; }
/** * This creates the wrapped {@link AddCommand} or {@link SetCommand} that * adds the child object to the model. If the owner, feature, or child * is <code>null</code>, or if the feature is single-valued and has * already been set to an object, {@link UnexecutableCommand#INSTANCE} * will be returned. */ @Override protected Command createCommand() { if (owner == null || feature == null || child == null) { return UnexecutableCommand.INSTANCE; } if (feature.isMany()) { return AddCommand.create(domain, owner, feature, child, index); } else if (owner.eGet(feature) == null) { return SetCommand.create(domain, owner, feature, child); } else { return UnexecutableCommand.INSTANCE; } }
/** * This attempts to prepare a drop link on operation. */ protected boolean prepareDropLinkOn() { dragCommand = IdentityCommand.INSTANCE; dropCommand = SetCommand.create(domain, owner, null, collection); // If we can't set the collection, try setting use the single value of the collection. // if (!dropCommand.canExecute() && collection.size() == 1) { dropCommand.dispose(); dropCommand = SetCommand.create(domain, owner, null, collection.iterator().next()); } if (!dropCommand.canExecute() || !analyzeForNonContainment(dropCommand)) { dropCommand.dispose(); dropCommand = AddCommand.create(domain, owner, null, collection); if (!analyzeForNonContainment(dropCommand)) { dropCommand.dispose(); dropCommand = UnexecutableCommand.INSTANCE; } } boolean result = dropCommand.canExecute(); return result; }
/** * Returns a wrapped set command that returns as its affected object the replacement wrapper for the value. * A feature map entry is also created for the value, and used as the value of the set command. */ @Override protected Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value, int index) { // Check that the value is type compatible with the entry feature. // if (getEntryFeature().getEType().isInstance(value)) { FeatureMap.Entry entry = FeatureMapUtil.createEntry(getEntryFeature(), value); return new ReplacementAffectedObjectCommand(SetCommand.create(domain, this.owner, this.feature, entry, this.index)); } return UnexecutableCommand.INSTANCE; }
public void doExecute() { CMPAttribute cmpAttribute = (CMPAttribute) this.owner; JavaHelpers type = cmpAttribute.getType(); super.doExecute(); if (cmpAttribute.getType() != type) { setTypeCommand = SetCommand.create(this.domain, this.owner, EcorePackage.eINSTANCE.getETypedElement_EType(), type); if (setTypeCommand.canExecute()) { setTypeCommand.execute(); } else { setTypeCommand.dispose(); setTypeCommand = null; } } }
@Override public void setPropertyValue(Object object, Object value) { EObject eObject = (EObject)object; EditingDomain editingDomain = getEditingDomain(object); value = normalizeInstanceTypeName(stripToNull((String)value)); if (editingDomain == null) { eObject.eSet(EcorePackage.Literals.ECLASSIFIER__INSTANCE_CLASS_NAME, value); } else { // Set the instance type name instead, since that will also set the instance class name // but this way will make undo restore the current instance type name correctly // editingDomain.getCommandStack().execute (SetCommand.create(editingDomain, getCommandOwner(eObject), EcorePackage.Literals.ECLASSIFIER__INSTANCE_TYPE_NAME, value)); } } });
(SetCommand.create(editingDomain, object, EcorePackage.Literals.ETYPED_ELEMENT__EGENERIC_TYPE, eGenericType));
(SetCommand.create (editingDomain, xsdAttributeDeclaration,
(SetCommand.create (editingDomain, xsdElementDeclaration,
@Override public void setPropertyValue(Object o, Object value) { XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)o; if (xsdAttributeDeclaration.isAttributeDeclarationReference()) { XSDAttributeDeclaration newResolvedAttributeDeclaration = xsdAttributeDeclaration.resolveAttributeDeclaration(xsdAttributeDeclaration.getTargetNamespace(), (String)value); EditingDomain editingDomain = getEditingDomain(xsdAttributeDeclaration); if (editingDomain == null) { xsdAttributeDeclaration.setResolvedAttributeDeclaration(newResolvedAttributeDeclaration); } else { editingDomain.getCommandStack().execute (SetCommand.create (editingDomain, xsdAttributeDeclaration, xsdPackage.getXSDAttributeDeclaration_ResolvedAttributeDeclaration(), newResolvedAttributeDeclaration)); } } else { super.setPropertyValue(o, value); } } });
@Override public void setPropertyValue(Object o, Object value) { XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)o; if (xsdElementDeclaration.isElementDeclarationReference()) { XSDElementDeclaration newResolvedElementDeclaration = xsdElementDeclaration.resolveElementDeclaration(xsdElementDeclaration.getTargetNamespace(), (String)value); EditingDomain editingDomain = getEditingDomain(xsdElementDeclaration); if (editingDomain == null) { xsdElementDeclaration.setResolvedElementDeclaration(newResolvedElementDeclaration); } else { editingDomain.getCommandStack().execute (SetCommand.create (editingDomain, xsdElementDeclaration, xsdPackage.getXSDElementDeclaration_ResolvedElementDeclaration(), newResolvedElementDeclaration)); } } else { super.setPropertyValue(o, value); } } });
/** * Return a SetCommand that will be executed by a CommandStack. */ protected Command createSingleCommand(ModifierHelper aHelper) { Object value = getValue(aHelper); Command command = null; if (valueChanged(aHelper.getOwner(), aHelper.getFeature(), value, aHelper.shouldUnsetValue())) { command = SetCommand.create(getEditingDomain(), aHelper.getOwner(), aHelper.getFeature(), value); ((AbstractCommand) command).setLabel(createCommandLabel(SET_PATTERN, aHelper.getFeature())); setStatus(VALUE_CHANGE); } else { setStatus(NO_VALUE_CHANGE); } return command; }
result = SetCommand.create(domain, commandOwner, feature, commandParameter.getValue(), commandParameter.getIndex());