/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 SAP AG. | |
* 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: | |
* SAP AG - initial API, implementation and documentation | |
* | |
* </copyright> | |
* | |
*******************************************************************************/ | |
package org.eclipse.fmc.blockdiagram.editor.meta.features; | |
import org.eclipse.emf.ecore.EObject; | |
import org.eclipse.fmc.blockdiagram.editor.meta.util.FMCMetaUtil; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.mm.pictograms.ContainerShape; | |
import org.eclipse.graphiti.mm.pictograms.Diagram; | |
import org.eclipse.graphiti.mm.pictograms.Shape; | |
import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil; | |
import org.eclipse.fmc.mm.FMCNode; | |
/** | |
* Feature Class for moving a business object. | |
* | |
* @author Patrick Jahnke | |
* | |
*/ | |
public class MoveShapeMetaFeature extends | |
org.eclipse.fmc.blockdiagram.editor.features.ShapeMoveFeature { | |
/** | |
* Constructor just calls the super constructor. | |
* | |
* @param fp | |
* The FeatureProvider object. | |
*/ | |
public MoveShapeMetaFeature(IFeatureProvider fp) { | |
super(fp); | |
} | |
/** | |
* Reorder and set a new parent of the business model. | |
*/ | |
@Override | |
protected void moveDomainObjects(Shape shapeToMove, | |
ContainerShape newContainerShape) { | |
EObject boToMove = FMCUtil.getBO(shapeToMove); | |
EObject boNewContainer = FMCUtil.getBO(newContainerShape); | |
if (boToMove != null && boToMove instanceof FMCNode) { | |
FMCNode nodeToMove = (FMCNode) boToMove; | |
if (boNewContainer != null && boNewContainer instanceof FMCNode) { | |
FMCNode nodeNewContainer = (FMCNode) boNewContainer; | |
nodeToMove.setContainer(nodeNewContainer); | |
} else if (newContainerShape instanceof Diagram) { | |
nodeToMove.setContainer(null); | |
FMCMetaUtil.addModelObject(nodeToMove, getDiagram(), | |
getFeatureProvider()); | |
} | |
} | |
} | |
} |