/** * This creates a command instance that creates a copy of owner. */ public CreateCopyOverrideCommand(MappingDomain domain, CreateCopyCommand createCommand) { super(createCommand.doGetLabel(), createCommand.doGetDescription()); this.mappingDomain = domain; this.owner = createCommand.getOwner(); this.copyHelper = createCommand.getCopyHelper(); }
/** * This creates a primitive {@link org.eclipse.emf.edit.command.CreateCopyCommand}. */ protected Command createCreateCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper) { return new CreateCopyCommand(domain, owner, helper); }
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); } } }
protected Command createCreateCopyOverrideCommand(CreateCopyCommand createCopyCommand) { if (mappingRoot.isInputObject(createCopyCommand.getOwner())) { return new CreateCopyOverrideCommand(this, createCopyCommand); } return null; }
@Override protected boolean optimizedCanExecute() { if (collection == null) { return false; } // We'll try adding a shallow copy of the clipboard contents, instead of a full copy. // Note: we can't just try adding the clipboard contents itself, because the copy may be a // different type then what's on the clipboard (e.g. EJB Field -> RDB Column). // CopyCommand.Helper copyHelper = new CopyCommand.Helper(); CompoundCommand shallowCopyCommand = new CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); for (Object object : collection) { if (!shallowCopyCommand.appendAndExecute(CreateCopyCommand.create(domain, object, copyHelper))) { shallowCopyCommand.dispose(); return false; } } Command addCommand = AddCommand.create(domain, owner, null, shallowCopyCommand.getResult()); boolean result = addCommand.canExecute(); shallowCopyCommand.dispose(); addCommand.dispose(); return result; }
protected Command createCreateCopyOverrideCommand(CreateCopyCommand createCopyCommand) { if (mappingRoot.isInputObject(createCopyCommand.getOwner())) { return new CreateCopyOverrideCommand(this, createCopyCommand); } return null; }
/** * This creates a command instance that creates a copy of owner. */ public CreateCopyOverrideCommand(MappingDomain domain, CreateCopyCommand createCommand) { super(createCommand.doGetLabel(), createCommand.doGetDescription()); this.mappingDomain = domain; this.owner = createCommand.getOwner(); this.copyHelper = createCommand.getCopyHelper(); }
@Override protected boolean optimizedCanExecute() { if (collection == null) { return false; } // We'll try adding a shallow copy of the clipboard contents, instead of a full copy. // Note: we can't just try adding the clipboard contents itself, because the copy may be a // different type then what's on the clipboard (e.g. EJB Field -> RDB Column). // CopyCommand.Helper copyHelper = new CopyCommand.Helper(); CompoundCommand shallowCopyCommand = new CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); for (Object object : collection) { if (!shallowCopyCommand.appendAndExecute(CreateCopyCommand.create(domain, object, copyHelper))) { shallowCopyCommand.dispose(); return false; } } Command addCommand = AddCommand.create(domain, owner, null, shallowCopyCommand.getResult()); boolean result = addCommand.canExecute(); shallowCopyCommand.dispose(); addCommand.dispose(); return result; }
owners.add(((CreateCopyCommand)command).getOwner());
@Override protected boolean optimizedCanExecute() { Collection<?> collection = domain.getClipboard(); if (collection == null) { return false; } // We'll try adding a shallow copy of the clipboard contents, instead of a full copy. // Note: we can't just try adding the clipboard contents itself, because the copy may be a // different type then what's on the clipboard (e.g. EJB Field -> RDB Column). // CopyCommand.Helper copyHelper = new CopyCommand.Helper(); CompoundCommand shallowCopyCommand = new CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); for (Object object : collection) { if (!shallowCopyCommand.appendAndExecute(CreateCopyCommand.create(domain, object, copyHelper))) { shallowCopyCommand.dispose(); return false; } } Command addCommand = AddCommand.create(domain, owner, feature, shallowCopyCommand.getResult()); boolean result = addCommand.canExecute(); shallowCopyCommand.dispose(); addCommand.dispose(); return result; }
@Override protected boolean optimizedCanExecute() { Collection<?> collection = domain.getClipboard(); if (collection == null) { return false; } // We'll try adding a shallow copy of the clipboard contents, instead of a full copy. // Note: we can't just try adding the clipboard contents itself, because the copy may be a // different type then what's on the clipboard (e.g. EJB Field -> RDB Column). // CopyCommand.Helper copyHelper = new CopyCommand.Helper(); CompoundCommand shallowCopyCommand = new CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); for (Object object : collection) { if (!shallowCopyCommand.appendAndExecute(CreateCopyCommand.create(domain, object, copyHelper))) { shallowCopyCommand.dispose(); return false; } } Command addCommand = AddCommand.create(domain, owner, feature, shallowCopyCommand.getResult()); boolean result = addCommand.canExecute(); shallowCopyCommand.dispose(); addCommand.dispose(); return result; }