/** * This creates a command to insert particular value at a particular index in the specified feature of the owner. * The feature will often be null because the domain will deduce it. */ public static Command create(EditingDomain domain, Object owner, Object feature, Object value, int index) { return create(domain, owner, feature, Collections.singleton(value), index); }
/** * This creates the add command that will implement this action and specifies the collection by * delegating to {@link CreateChildCommand.Helper#getCreateChildImage}. */ protected Command createCommand() { if (feature == null) { return AddCommand.create(domain, owner, null, helper.createChild(owner)); } return new AddCommand(domain, owner, feature, helper.createChild(owner)); }
protected Command createAddOverrideCommand(AddCommand addCommand) { if (!(addCommand.getOwner() instanceof Mapping)) { return new AddOverrideCommand(this, addCommand); } return null; }
/** * This returned a primitive {@link org.eclipse.emf.edit.command.AddCommand}, but it has been replaced since * this command is now used on attributes, too. The replacement method still calls this method for references, to * provide backwards compatibility. * @deprecated As of EMF 2.0, replaced by {@link #createAddCommand(EditingDomain, EObject, EStructuralFeature, Collection, int) * createAddCommand}. */ @Deprecated protected Command createAddCommand(EditingDomain domain, EObject owner, EReference feature, Collection<?> collection, int index) { return new AddCommand(domain, owner, feature, collection, index); }
public void execute() { addCommand.doExecute(); MappingRoot mappingRoot = mappingDomain.getMappingRoot(); CompoundCommand subcommands = new CompoundCommand(); for (Object addition : addCommand.getCollection()) { for (Iterator<?> objects = mappingDomain.treeIterator(addition); objects.hasNext(); ) { Object object = objects.next(); MappedObjectState mappedObjectState = mappingRoot.getMappedObjectState(object); Object originatingInput = mappedObjectState.getOriginatingInput(); // This is tricky and is done for each object here rather than once for the owner of the addCommnd. // We want to make sure the object is really part of the conceptual tree induced by the domain. // if (originatingInput == null) { mappedObjectState.setOutput(); } else if (mappingRoot.isAttachedObject(object)) { mapOutputObject(object, originatingInput, subcommands); } } } mapCommand = !subcommands.isEmpty() ? subcommands.unwrap() : null; }
@Override public Collection<?> getAffectedObjects() { Collection<Object> result = new ArrayList<Object>(); result.addAll(addCommand.doGetAffectedObjects()); if (mapCommand != null) { result.addAll(mapCommand.getAffectedObjects()); } return result; }
@Override protected boolean prepare() { return addCommand.doCanExecute(); }
@Override public void dispose() { if (mapCommand != null) { mapCommand.dispose(); } addCommand.doDispose(); }
/** * This creates a primitive {@link org.eclipse.emf.edit.command.AddCommand}. */ protected Command createAddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Collection<?> collection, int index) { if (feature instanceof EReference) { return createAddCommand(domain, owner, (EReference)feature, collection, index); } return new AddCommand(domain, owner, feature, collection, index); }
public void execute() { addCommand.doExecute(); MappingRoot mappingRoot = mappingDomain.getMappingRoot(); CompoundCommand subcommands = new CompoundCommand(); for (Object addition : addCommand.getCollection()) { for (Iterator<?> objects = mappingDomain.treeIterator(addition); objects.hasNext(); ) { Object object = objects.next(); MappedObjectState mappedObjectState = mappingRoot.getMappedObjectState(object); Object originatingInput = mappedObjectState.getOriginatingInput(); // This is tricky and is done for each object here rather than once for the owner of the addCommnd. // We want to make sure the object is really part of the conceptual tree induced by the domain. // if (originatingInput == null) { mappedObjectState.setOutput(); } else if (mappingRoot.isAttachedObject(object)) { mapOutputObject(object, originatingInput, subcommands); } } } mapCommand = !subcommands.isEmpty() ? subcommands.unwrap() : null; }
@Override public Collection<?> getAffectedObjects() { Collection<Object> result = new ArrayList<Object>(); result.addAll(addCommand.doGetAffectedObjects()); if (mapCommand != null) { result.addAll(mapCommand.getAffectedObjects()); } return result; }
@Override protected boolean prepare() { return addCommand.doCanExecute(); }
@Override public void dispose() { if (mapCommand != null) { mapCommand.dispose(); } addCommand.doDispose(); }
/** * This creates a command to add a particular value to the specified feature of the owner. * The feature will often be null because the domain will deduce it. */ public static Command create(EditingDomain domain, Object owner, Object feature, Object value) { return create(domain, owner, feature, Collections.singleton(value), CommandParameter.NO_INDEX); }
@Override protected EObject doCreate(Resource res, EClass clazz) throws ModelManipulationException { EObject obj = EcoreUtil.create(clazz); Command createCommand = new AddCommand(domain, res.getContents(), obj); executeCommand(createCommand); return obj; }
protected Command createAddOverrideCommand(AddCommand addCommand) { if (!(addCommand.getOwner() instanceof Mapping)) { return new AddOverrideCommand(this, addCommand); } return null; }
@Override protected void doAdd(EObject container, EStructuralFeature feature, Collection<? extends Object> elements) throws ModelManipulationException { Command addCommand = AddCommand.create(domain, container, feature, elements); executeCommand(addCommand); }
if (subcommands.appendAndExecute(new AddCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), mapping))) (new AddCommand(domain, mapping, MappingPackage.eINSTANCE.getMapping_Nested(), siblingsToReparent));
owners.add(((AddCommand)command).getOwner());
@Override protected void doAdd(EObject container, EStructuralFeature feature, Object element, int index) throws ModelManipulationException { Command addCommand = AddCommand.create(domain, container, feature, element, index); executeCommand(addCommand); }