/******************************************************************************* * Copyright (c) 2012 VMware, Inc. * 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: * VMware, Inc. - initial API and implementation *******************************************************************************/ package org.springframework.ide.eclipse.config.graph.policies; import java.util.List; import org.eclipse.gef.EditPart; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.editpolicies.ContainerEditPolicy; import org.eclipse.gef.requests.CreateRequest; import org.eclipse.gef.requests.GroupRequest; import org.springframework.ide.eclipse.config.graph.model.Activity; import org.springframework.ide.eclipse.config.graph.model.StructuredActivity; import org.springframework.ide.eclipse.config.graph.model.commands.OrphanChildCommand; /** * ActivityContainerEditPolicy * @author Leo Dos Santos * @author Christian Dupuis */ public class ActivityContainerEditPolicy extends ContainerEditPolicy { /** * @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest) */ @Override protected Command getCreateCommand(CreateRequest request) { return null; } /** * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getOrphanChildrenCommand(org.eclipse.gef.requests.GroupRequest) */ @Override protected Command getOrphanChildrenCommand(GroupRequest request) { List parts = request.getEditParts(); CompoundCommand result = new CompoundCommand(); for (int i = 0; i < parts.size(); i++) { Activity child = (Activity) ((EditPart) parts.get(i)).getModel(); OrphanChildCommand orphan = new OrphanChildCommand(child.getDiagram().getTextEditor()); orphan.setChild(child); orphan.setParent((StructuredActivity) getHost().getModel()); result.add(orphan); } return result.unwrap(); } }