/** * Creates a new compound command, containing this command and the given command, * that delegates chain to {@link CompoundCommand#append}. * @param command the command to chain with this one. * @return a new chained compound command. */ public Command chain(Command command) { class ChainedCompoundCommand extends CompoundCommand { public ChainedCompoundCommand() { super(); } @Override public Command chain(Command c) { append(c); return this; } } CompoundCommand result = new ChainedCompoundCommand(); result.append(this); result.append(command); return result; }
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);
protected Command createCopyCommand() { CompoundCommand cmd = new J2EECompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); Iterator it = extendedSourceObjects.iterator(); EtoolsCopyUtility copyUtil = new EtoolsCopyUtility(); while (it.hasNext()) { Object o = it.next(); if (!(o instanceof EObject)) { cmd.append(UnexecutableCommand.INSTANCE); } else { EObject r = (EObject) o; cmd.append(new J2EECopyCommand(r, extendedSourceObjects.getBinding(r), extendedSourceObjects.getExtension(r), copyUtil)); } } return cmd.unwrap(); }
command.appendIfCanExecute (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ELOWER_BOUND, null)); command.append (SetCommand.create(editingDomain, object, EcorePackage.Literals.EGENERIC_TYPE__ECLASSIFIER, value)); editingDomain.getCommandStack().execute(command);
@Override public void setPropertyValue(Object thisObject, final Object value) { final MappingDomain domain = mapping.getMappingRoot().getDomain(); final Object feature = itemPropertyDescriptor.getFeature(value); CompoundCommand compound = new StrictCompoundCommand(); final Command copyCommand = CopyCommand.create(domain, typeMappingHelper); compound.append(copyCommand); compound.append (new CommandWrapper() { @Override protected Command createCommand() { return SetCommand.create(domain, copyCommand.getResult().iterator().next(), feature, value); } }); compound.append (new CommandWrapper() { @Override protected Command createCommand() { return SetCommand.create(domain, mapping, MappingPackage.eINSTANCE.getMapping_Helper(), copyCommand.getResult().iterator().next()); } }); domain.getCommandStack().execute(compound); }
@Override public void setPropertyValue(Object thisObject, final Object value) { final MappingDomain domain = mapping.getMappingRoot().getDomain(); final Object feature = itemPropertyDescriptor.getFeature(value); CompoundCommand compound = new StrictCompoundCommand(); final Command copyCommand = CopyCommand.create(domain, typeMappingHelper); compound.append(copyCommand); compound.append (new CommandWrapper() { @Override protected Command createCommand() { return SetCommand.create(domain, copyCommand.getResult().iterator().next(), feature, value); } }); compound.append (new CommandWrapper() { @Override protected Command createCommand() { return SetCommand.create(domain, mapping, MappingPackage.eINSTANCE.getMapping_Helper(), copyCommand.getResult().iterator().next()); } }); domain.getCommandStack().execute(compound); }
/** * This creates a command that copies the given collection of objects. If the collection contains more than one object, * then a compound command will be created containing individual copy commands for each object. */ public static Command create(final EditingDomain domain, final Collection<?> collection) { if (collection == null || collection.isEmpty()) { return UnexecutableCommand.INSTANCE; } Helper copyHelper = new Helper(); CompoundCommand copyCommand = new CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); for (Object object : collection) { copyCommand.append(domain.createCommand(CopyCommand.class, new CommandParameter(object, null, copyHelper))); } return copyCommand.unwrap(); }
compound.append(RemoveCommand.create(domain, owner, feature, new BasicEList<Object>(removedValues))); compound.append(MoveCommand.create(domain, owner, feature, object, count)); remainingValues.move(count, position); compound.append(AddCommand.create(domain, owner, feature, object, addIndex)); compound.append(RemoveCommand.create(domain, owner, feature, new BasicEList<Object>(oldValues))); compound.append(AddCommand.create(domain, owner, feature, values)); compound.append(domain.createCommand(SetCommand.class, new CommandParameter(owner, feature, value))); compound.append(RemoveCommand.create(domain, oldValue, eOtherEnd, owner)); compound.append(AddCommand.create(domain, owner, feature, value)); return compound; compound.append(removeCommand); compound.append(domain.createCommand(SetCommand.class, new CommandParameter(owner, eReference, value))); return compound; compound.append(RemoveCommand.create(domain, oldValue, eOtherEnd, Collections.singleton(owner))); compound.append(addCommand); return compound; compound.append(SetCommand.create(domain, value, eOtherEnd, null)); compound.append (domain.createCommand
protected void addCreateCopyCommands(CompoundCommand compoundCommand, EObject object) { // Create a command to create a copy of the object. // Command createCopyCommand = CreateCopyCommand.create(domain, object, copyHelper); compoundCommand.append(createCopyCommand); if (createCopyCommand instanceof ChildrenToCopyProvider && createCopyCommand.canExecute()) { for (Object child : ((ChildrenToCopyProvider)createCopyCommand).getChildrenToCopy()) { addCreateCopyCommands(compoundCommand, (EObject)child); } } else { // Create commands to create copies of the children. // for (EObject child : object.eContents()) { addCreateCopyCommands(compoundCommand, child); } } }
if (oldReferenceOpposite != null) compoundCommand.append(SetCommand.create(editingDomain, getCommandOwner(oldReferenceOpposite), feature, null)); if (oldOppositeOpposite != null) compoundCommand.append(SetCommand.create(editingDomain, getCommandOwner(oldOppositeOpposite), feature, null)); compoundCommand.append(SetCommand.create(editingDomain, getCommandOwner(eOpposite), feature, eReference)); compoundCommand.append(SetCommand.create(editingDomain, getCommandOwner(eReference), feature, eOpposite)); editingDomain.getCommandStack().execute(compoundCommand);