| //------------------------------------------------------------------------------ |
| // 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 org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.epf.diagramming.base.commands.ActivityPartitionDestroyCommand; |
| import org.eclipse.epf.diagramming.base.commands.CreateActivityNodeInActivityPartition; |
| import org.eclipse.epf.diagramming.providers.UMLElementTypes; |
| import org.eclipse.gef.commands.Command; |
| import org.eclipse.gef.commands.UnexecutableCommand; |
| import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; |
| import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; |
| import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; |
| import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; |
| import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; |
| import org.eclipse.gmf.runtime.notation.View; |
| import org.eclipse.uml2.uml.UMLPackage; |
| |
| /** |
| * @generated |
| */ |
| public class ActivityPartitionPartitionCampartmentItemSemanticEditPolicy extends |
| UMLBaseItemSemanticEditPolicy { |
| |
| /** |
| * @modified |
| */ |
| protected Command getCreateCommand(CreateElementRequest req) { |
| if (UMLElementTypes.ActivityPartition_2001 == req.getElementType()) { |
| if (req.getContainmentFeature() == null) { |
| req.setContainmentFeature(UMLPackage.eINSTANCE |
| .getActivityPartition_Subpartition()); |
| } |
| return getMSLWrapper(new CreateActivityPartition_2001Command(req)); |
| } |
| // modified START |
| Command command = getCreateActivityNodeCommand(req); |
| if (command != null) { |
| |
| // command = command.chain(getMSLWrapper(new UpdateActivityCommand(req))); |
| // command = command.chain(new UmaActivityCreationCommand(req)); |
| return command; |
| } |
| // modified END |
| |
| return super.getCreateCommand(req); |
| } |
| |
| /** |
| * @generated |
| */ |
| private static class CreateActivityPartition_2001Command extends |
| CreateElementCommand { |
| |
| /** |
| * @generated |
| */ |
| public CreateActivityPartition_2001Command(CreateElementRequest req) { |
| super(req); |
| } |
| |
| /** |
| * @generated |
| */ |
| protected EClass getEClassToEdit() { |
| return UMLPackage.eINSTANCE.getActivityPartition(); |
| }; |
| |
| /** |
| * @generated |
| */ |
| protected EObject getElementToEdit() { |
| EObject container = ((CreateElementRequest) getRequest()) |
| .getContainer(); |
| if (container instanceof View) { |
| container = ((View) container).getElement(); |
| } |
| return container; |
| } |
| } |
| |
| /** |
| * @custom |
| */ |
| private Command getCreateActivityNodeCommand(CreateElementRequest req) { |
| if (UMLElementTypes.StructuredActivityNode_1007 == req.getElementType() |
| || UMLElementTypes.StructuredActivityNode_1010 == req |
| .getElementType() |
| || UMLElementTypes.StructuredActivityNode_1011 == req |
| .getElementType() |
| || UMLElementTypes.MergeNode_1002 == req.getElementType() |
| || UMLElementTypes.ForkNode_1003 == req.getElementType() |
| || UMLElementTypes.InitialNode_1004 == req.getElementType() |
| || UMLElementTypes.DecisionNode_1005 == req.getElementType() |
| || UMLElementTypes.JoinNode_1006 == req.getElementType() |
| || UMLElementTypes.ActivityFinalNode_1001 == req |
| .getElementType() |
| || UMLElementTypes.ActivityParameterNode_1009 == req |
| .getElementType() |
| || UMLElementTypes.ActivityParameterNode_1012 == req |
| .getElementType()) { |
| if (req.getContainmentFeature() == null) { |
| req.setContainmentFeature(UMLPackage.eINSTANCE |
| .getActivityPartition_Node()); |
| } |
| return getMSLWrapper(new CreateActivityNodeInActivityPartition(req)); |
| } |
| return null; |
| } |
| |
| /** |
| * @see org.eclipse.epf.gmf.diagram.edit.policies.UMLBaseItemSemanticEditPolicy#getCreateOutgoing(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) |
| * @modiifed |
| */ |
| protected Command getCreateOutgoing(CreateRelationshipRequest req) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| |
| /* |
| * @custom |
| */ |
| // private void updateActivityCommand(CreateElementRequest request, Command cmd){ |
| // EObject obj = request.getNewElement(); |
| // if (obj != null) { |
| // EObject parent = obj; |
| // while (!(parent.eContainer() instanceof Activity)) { |
| // parent = parent.eContainer(); |
| // } |
| // EStructuralFeature feature = UMLPackage.eINSTANCE |
| // .getActivity_Node(); |
| // SetRequest req = new SetRequest(parent, feature, request |
| // .getNewElement()); |
| // cmd.chain(getMSLWrapper(new SetValueCommand(req))); |
| // } |
| // } |
| /* |
| * (non-Javadoc) |
| * @see org.eclipse.epf.diagramming.edit.policies.UMLBaseItemSemanticEditPolicy#getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) |
| * @modified |
| */ |
| protected Command getDestroyElementCommand(DestroyElementRequest req) { |
| /* modify START */ |
| return getMSLWrapper(new ActivityPartitionDestroyCommand(req, getHost())); |
| /* modify END */ |
| } |
| |
| /* |
| * (non-Javadoc) |
| * @see org.eclipse.epf.diagramming.edit.policies.UMLBaseItemSemanticEditPolicy#getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest) |
| * @modified |
| */ |
| protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) { |
| return super.getDestroyReferenceCommand(req); |
| } |
| } |