/***************************************************************************** * Copyright (c) 2010 CEA LIST. * * * 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: * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ActivityCompositeEditPart; import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ParameterEditPart; import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortEditPart; import org.eclipse.papyrus.uml.diagram.composite.part.UMLVisualIDRegistry; /** * This edit policy replaces the GMF generated edit policy for Behavior(s). * In particular it provides a getCreateCommands that add a ChangeBoundRequest on a created Parameter (or Port) * in order to locate it at the cursor position. * An example of code generated by GMF can be found in {@link ActivityCompositeEditPart#createLayoutEditPolicy()}. */ public class BehaviorLayoutEditPolicy extends StructuredClassifierLayoutEditPolicy { @Override protected EditPolicy createChildEditPolicy(EditPart child) { View childView = (View)child.getModel(); switch(UMLVisualIDRegistry.getVisualID(childView)) { case PortEditPart.VISUAL_ID: case ParameterEditPart.VISUAL_ID: return new BorderItemResizableEditPolicy(); } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if(result == null) { result = new NonResizableEditPolicy(); } return result; } }