package org.eclipse.uml2.diagram.activity.edit.policies;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
import org.eclipse.uml2.diagram.activity.providers.UMLElementTypes;
/**
* @generated
*/
public class ActionLocalPreconditionItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
/**
* @generated
*/
public ActionLocalPreconditionItemSemanticEditPolicy() {
super(UMLElementTypes.ActionLocalPrecondition_4003);
}
/**
* @generated
*/
protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
return getGEFWrapper(new DestroyReferenceCommand(req) {
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
EObject referencedObject = getReferencedObject();
Resource resource = referencedObject.eResource();
CommandResult result = super.doExecuteWithResult(progressMonitor, info);
if (resource != null) {
resource.getContents().add(referencedObject);
}
return result;
}
});
}
}