/***************************************************************************** * Copyright (c) 2009 Atos Origin. * * * 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: * Atos Origin - Initial API and implementation * *****************************************************************************/ package org.eclipse.papyrus.uml.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.papyrus.uml.diagram.activity.providers.UMLElementTypes; /** * @generated */ public class ActionLocalPreconditionItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy { /** * @generated */ public ActionLocalPreconditionItemSemanticEditPolicy() { super(UMLElementTypes.ActionLocalPrecondition_4001); } /** * @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; } }); } }