mapCommand = !subcommands.isEmpty() ? subcommands.unwrap() : null; removeCommand.doExecute();
mapCommand = !subcommands.isEmpty() ? subcommands.unwrap() : null; removeCommand.doExecute();
/** * 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(); }
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(); }
return removeCommand.unwrap();
return addCommand.unwrap();
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; }
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; }
public void execute() { // This will deal with all the subcommands to modifying the root mapping tree. // CompoundCommand subcommands = new CompoundCommand(); // For each mapping being removed... // for (Object object : collection) { Mapping mapping = (Mapping)object; Mapping parentMapping = mapping.getNestedIn(); // Make sure the back pointers to this mapping from the mapped objects is set. // domain.getMappingRoot().deregister(mapping); // Create a command to do parentMapping.getNested().remove(mapping). // //subcommands.appendAndExecute(new RemoveCommand(domain, parentMapping, parentMapping.ePackageMapping().getMapping_Nested(), mapping)); subcommands.appendAndExecute(new RemoveCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), mapping)); Collection<Mapping> nestedMappings = new ArrayList<Mapping>(mapping.getNested()); if (!nestedMappings.isEmpty()) { //subcommands.appendAndExecute(new RemoveCommand(domain, mapping, mapping.ePackageMapping().getMapping_Nested(), nestedMappings)); //subcommands.appendAndExecute(new AddCommand(domain, parentMapping, parentMapping.ePackageMapping().getMapping_Nested(), nestedMappings)); subcommands.appendAndExecute(new RemoveCommand(domain, mapping, MappingPackage.eINSTANCE.getMapping_Nested(), nestedMappings)); subcommands.appendAndExecute(new AddCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), nestedMappings)); } } subcommand = subcommands.unwrap(); }
public void execute() { // This will deal with all the subcommands to modifying the root mapping tree. // CompoundCommand subcommands = new CompoundCommand(); // For each mapping being removed... // for (Object object : collection) { Mapping mapping = (Mapping)object; Mapping parentMapping = mapping.getNestedIn(); // Make sure the back pointers to this mapping from the mapped objects is set. // domain.getMappingRoot().deregister(mapping); // Create a command to do parentMapping.getNested().remove(mapping). // //subcommands.appendAndExecute(new RemoveCommand(domain, parentMapping, parentMapping.ePackageMapping().getMapping_Nested(), mapping)); subcommands.appendAndExecute(new RemoveCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), mapping)); Collection<Mapping> nestedMappings = new ArrayList<Mapping>(mapping.getNested()); if (!nestedMappings.isEmpty()) { //subcommands.appendAndExecute(new RemoveCommand(domain, mapping, mapping.ePackageMapping().getMapping_Nested(), nestedMappings)); //subcommands.appendAndExecute(new AddCommand(domain, parentMapping, parentMapping.ePackageMapping().getMapping_Nested(), nestedMappings)); subcommands.appendAndExecute(new RemoveCommand(domain, mapping, MappingPackage.eINSTANCE.getMapping_Nested(), nestedMappings)); subcommands.appendAndExecute(new AddCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), nestedMappings)); } } subcommand = subcommands.unwrap(); }
mapCommand = subcommands.unwrap(); if (mapCommand.canExecute())
mapCommand = subcommands.unwrap(); if (mapCommand.canExecute())
append(createCommand.unwrap());
return removeCommand.unwrap();
subcommand = subcommands.unwrap();
subcommand = subcommands.unwrap();