/** * 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); }
/** * 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); }
/** * 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)); }
@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; }
if (subcommands.appendAndExecute(new AddCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), mapping))) (new AddCommand(domain, mapping, MappingPackage.eINSTANCE.getMapping_Nested(), siblingsToReparent));
if (subcommands.appendAndExecute(new AddCommand(domain, parentMapping, MappingPackage.eINSTANCE.getMapping_Nested(), mapping))) (new AddCommand(domain, mapping, MappingPackage.eINSTANCE.getMapping_Nested(), siblingsToReparent));
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(); }
domain.getCommandStack().execute(new AddCommand(domain, resource.getContents(), eObject)); domain = new AdapterFactoryEditingDomain(null, new BasicCommandStack(), (ResourceSet) null); resourceSet = domain.getResourceSet(); domain.getCommandStack().execute(new AddCommand(domain, resourceSet.getResources(), resource)); return domain;