Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2002-2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* IBM - Initial API and implementation
*/
package org.eclipse.emf.edit.command;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.EMFEditPlugin;
import org.eclipse.emf.edit.domain.EditingDomain;
/**
* The replace command logically acts upon an owner object that has a collection-type feature
* in which an object can be replaced by a collection of other objects.
* The static create methods delegate command creation to {@link EditingDomain#createCommand EditingDomain.createCommand},
* which may or may not result in the actual creation of an instance of this class.
*
*
* The implementation of this class is low-level and EMF specific;
* it allows an object from a many-valued feature of an owner to be replaced by a collection of other objects.
* i.e., it is equivalent of the call
*
* int index = ((EList)((EObject)owner).eGet((EStructuralFeature)feature)).indexOf(value);
* ((EList)((EObject)owner).eGet((EStructuralFeature)feature)).remove(value);
* ((EList)((EObject)owner).eGet((EStructuralFeature)feature)).addAll(index, (Collection)collection);
*
*
*
* It can also be used as an equivalent to the call
*
* int index = ((EList)extent).indexOf(value);
* ((EList)extent).remove(value);
* ((EList)extent).addAll(index, (Collection)collection);
*
* which is how root objects are replaced in the contents of a resource.
* Like all the low level commands in this package, the replace command is undoable.
*
*
* A replace command is an {@link OverrideableCommand}.
*/
public class ReplaceCommand extends AbstractOverrideableCommand
{
/**
* This creates a command to replace an object with a collection of replacements.
*/
public static Command create(EditingDomain domain, Object value, Collection> collection)
{
return create(domain, null, null, value, collection);
}
/**
* This creates a command to replace a particular value in the specified feature of the owner with a collection replacements objects.
*/
public static Command create(EditingDomain domain, Object owner, Object feature, Object value, Collection> collection)
{
return domain.createCommand(ReplaceCommand.class, new CommandParameter(owner, feature, value, collection));
}
/**
* This caches the label.
*/
protected static final String LABEL = EMFEditPlugin.INSTANCE.getString("_UI_ReplaceCommand_label");
/**
* This caches the description.
*/
protected static final String DESCRIPTION = EMFEditPlugin.INSTANCE.getString("_UI_ReplaceCommand_description");
/**
* This is the owner object upon which the command will act.
* It could be null, in the case that we are dealing with an {@link org.eclipse.emf.common.util.EList}.
*/
protected EObject owner;
/**
* This is the feature of the owner object upon the command will act.
* It could be null, in the case that we are dealing with an {@link org.eclipse.emf.common.util.EList}.
*/
protected EStructuralFeature feature;
/**
* This is the list from which the command will replace.
*/
protected EList