blob: d1efef9ea43aabebee8ebbbea8ae4c53a313790c [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 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 Corporation - initial implementation
//------------------------------------------------------------------------------
/*
* Copyright (c) 2005, 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 Corporation - initial implementation
*
*/
package org.eclipse.epf.diagramming.edit.policies;
import java.util.List;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.epf.diagramming.providers.UMLElementTypes;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.CreateRelationshipCommand;
import org.eclipse.uml2.uml.ActivityFinalNode;
import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.ControlFlow;
import org.eclipse.uml2.uml.MergeNode;
import org.eclipse.uml2.uml.StructuredActivityNode;
import org.eclipse.uml2.uml.UMLPackage;
/**
* @generated
*/
public class ActivityFinalNodeItemSemanticEditPolicy extends
UMLBaseItemSemanticEditPolicy {
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
return getMSLWrapper(new DestroyElementCommand(req) {
protected EObject getElementToDestroy() {
View view = (View) getHost().getModel();
EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
if (annotation != null) {
return view;
}
return super.getElementToDestroy();
}
});
}
/**
* @modified
*/
protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
// if (UMLElementTypes.ControlFlow_3001 == req.getElementType()) {
// return req.getTarget() == null ? getCreateStartOutgoingControlFlow3001Command(req)
// : getCreateCompleteIncomingControlFlow3001Command(req);
// }
return super.getCreateRelationshipCommand(req);
}
/**
* @generated
*/
protected Command getCreateStartOutgoingControlFlow3001Command(
CreateRelationshipRequest req) {
return new Command() {
};
}
/**
* @generated
*/
protected Command getCreateCompleteIncomingControlFlow3001Command(
CreateRelationshipRequest req) {
if (!(req.getSource() instanceof ActivityNode)) {
return UnexecutableCommand.INSTANCE;
}
final StructuredActivityNode element = (StructuredActivityNode) getRelationshipContainer(
req.getSource(), UMLPackage.eINSTANCE
.getStructuredActivityNode(), req.getElementType());
if (element == null) {
return UnexecutableCommand.INSTANCE;
}
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE
.getStructuredActivityNode_Edge());
}
return getMSLWrapper(new CreateIncomingControlFlow3001Command(req) {
/**
* @generated
*/
protected EObject getElementToEdit() {
return element;
}
});
}
/**
* @generated
*/
private static class CreateIncomingControlFlow3001Command extends
CreateRelationshipCommand {
/**
* @generated
*/
public CreateIncomingControlFlow3001Command(
CreateRelationshipRequest req) {
super(req);
}
/**
* @generated
*/
protected EClass getEClassToEdit() {
return UMLPackage.eINSTANCE.getStructuredActivityNode();
};
/**
* @generated
*/
protected void setElementToEdit(EObject element) {
throw new UnsupportedOperationException();
}
/**
* @generated
*/
protected EObject doDefaultElementCreation() {
ControlFlow newElement = (ControlFlow) super
.doDefaultElementCreation();
if (newElement != null) {
newElement.setTarget((ActivityNode) getTarget());
newElement.setSource((ActivityNode) getSource());
}
return newElement;
}
}
/**
* @see org.eclipse.epf.gmf.diagram.edit.policies.UMLBaseItemSemanticEditPolicy#getCreateOutgoing(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest)
* @modified
*/
protected Command getCreateOutgoing(CreateRelationshipRequest req) {
// Validation ActivityFinalNode node should allow only one outgoing connection.
if (req.getSource() instanceof ActivityFinalNode) {
return UnexecutableCommand.INSTANCE;
}
return super.getCreateOutgoing(req);
}
}