blob: 4e9725dcf6d63386ad8aa4737589c97257ea5202 [file] [log] [blame]
/***********************************************************************************************************************
* Copyright (c) 2010 Attensity Europe GmbH. 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
**********************************************************************************************************************/
package org.eclipse.smila.processing.designer.ui.commands;
import java.util.List;
import org.eclipse.bpel.ui.commands.AddToListCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
/**
* Adds a new value to a {@link List} attribute of an {@link EObject}.
*
* Copyright (c) 2011 Attensity Europe GmbH
*
* @author Tobias Liefke
*/
public class AddToListFeatureCommand extends AddToListCommand {
private final EStructuralFeature feature;
/**
* Creates a new instance of AddToListFeatureCommand.
*
* @param target
* the object that contains the list to modify
* @param newElement
* the new element to add to the list
* @param feature
* the id of the list attribute
*/
public AddToListFeatureCommand(EObject target, Object newElement, EStructuralFeature feature) {
this(target, newElement, feature, "Add value");
}
/**
* Creates a new instance of RemoveFromListFeatureCommand.
*
* @param target
* the object that contains the list to modify
* @param newElement
* the new element to add to the list
* @param feature
* the id of the list attribute
* @param label
* the label of the command (for undo)
*/
public AddToListFeatureCommand(EObject target, Object newElement, EStructuralFeature feature, String label) {
super(target, newElement, label);
this.feature = feature;
}
@Override
protected List<?> getList() {
return (List<?>) target.eGet(feature);
}
}