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-2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*/
package org.eclipse.emf.edit.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
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 remove command logically acts upon an owner object that has a collection-type feature from which objects can be removed.
* 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 one or more objects to be removed from a many-valued feature of an owner.
* i.e., it is almost equivalent of the call
*
* which is how root objects are removed from the contents of a resource.
*
*
* The one difference is that, while EList.removeAll(Collection) removes all values equal to a value in
* the collection, this command will remove no more than one value per value in the collection. When duplicates are
* allowed and present in the list, this command will first look for identical (==) values, in order, and
* failing that, equal values (.equals()).
*
*
* Like all the low-level commands in this package, the remove command is undoable.
*
*
* A remove command is an {@link OverrideableCommand}.
*/
public class RemoveCommand extends AbstractOverrideableCommand
{
/**
* This creates a command to remove an object.
*/
public static Command create(EditingDomain domain, Object value)
{
return create(domain, Collections.singleton(value));
}
/**
* This creates a command to remove a particular value from the specified feature of the owner.
*/
public static Command create(EditingDomain domain, Object owner, Object feature, Object value)
{
return create(domain, owner, feature, Collections.singleton(value));
}
/**
* This creates a command to remove multiple objects.
*/
public static Command create(final EditingDomain domain, final Collection> collection)
{
return create(domain, null, null, collection);
}
/**
* This creates a command to remove a collection of values from the specified feature of the owner.
*/
public static Command create(final EditingDomain domain, final Object owner, final Object feature, final Collection> collection)
{
return domain.createCommand(RemoveCommand.class, new CommandParameter(owner, feature, collection));
}
/**
* This caches the label.
*/
protected static final String LABEL = EMFEditPlugin.INSTANCE.getString("_UI_RemoveCommand_label");
/**
* This caches the description.
*/
protected static final String DESCRIPTION = EMFEditPlugin.INSTANCE.getString("_UI_RemoveCommand_description");
/**
* This caches the description for a list-based command.
*/
protected static final String DESCRIPTION_FOR_LIST = EMFEditPlugin.INSTANCE.getString("_UI_RemoveCommand_description_for_list");
/**
* 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 remove.
*/
protected EList