public void execute() { newMapping = domain.getMappingRoot().createMapping(inputs, outputs); StrictCompoundCommand subcommands = new StrictCompoundCommand(); subcommands.appendAndExecute(AddMappingCommand.create(domain, newMapping)); subcommand = subcommands.unwrap(); }
@Override public void execute() { // We need to check canExecute() in case optimize is true. // if (super.canExecute()) { super.execute(); } else { // Thread.dumpStack(); } }
protected boolean prepare() { if (getJ2EEClipboard() == null) return false; command = new StrictCompoundCommand(); copyCommand = new J2EECopyFromClipboardCommand((J2EEUIEditingDomain) domain); command.append(copyCommand); command.append(new CommandWrapper() { protected Command createCommand() { Command addCommand = AddCommand.create(getDomain(), getOwner(), getFeature(), copyCommand.getResult(), getIndex()); return addCommand; } }); prepareBindingCommand(copyCommand); prepareExtensionCommand(copyCommand); boolean result; if (optimize) { // This will determine canExecute as efficiently as possible. // result = optimizedCanExecute(); } else { // This will actually execute the copy command in order to check if the add can execute. // result = command.canExecute(); } return result; }
@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 boolean canExecute() { boolean result; if (optimize) { // We'll assume that all the CreateCopyCommand's and InitializeCopyCommand's can execute. // result = true; } else { // This will call prepare() which will partially execute the command. // result = super.canExecute(); } return result; }
boolean result = super.prepare();
command = new StrictCompoundCommand(); command.append(copyCommand); command.append (new CommandWrapper() result = command.canExecute();
@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); }
public void execute() { newMapping = domain.getMappingRoot().createMapping(inputs, outputs); StrictCompoundCommand subcommands = new StrictCompoundCommand(); subcommands.appendAndExecute(AddMappingCommand.create(domain, newMapping)); subcommand = subcommands.unwrap(); }
@Override public void doExecute() { // We need to check canExecute() here in case prepare() went down the "optimize" path. // if (command.canExecute()) { command.execute(); } else { // Thread.dumpStack(); } }