/******************************************************************************* | |
* <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.features.add; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.features.context.IAddContext; | |
import org.eclipse.graphiti.mm.algorithms.Rectangle; | |
import org.eclipse.graphiti.mm.pictograms.ContainerShape; | |
import org.eclipse.graphiti.mm.pictograms.PictogramElement; | |
/** | |
* Add Feature class responsible for adding the graphical representation of a | |
* common feature area to the diagram. | |
* | |
* @author Benjamin Schmeling | |
* | |
*/ | |
public class CommonFeatureAreaAddFeature extends ShapeAddFeature { | |
/** | |
* Main constructor. | |
* | |
* @param featureProvider | |
* The feature provider. | |
*/ | |
public CommonFeatureAreaAddFeature(IFeatureProvider featureProvider) { | |
super(featureProvider); | |
} | |
/** | |
* Constructor allowing to set whether the the area should be linked with a | |
* domain model object. | |
* | |
* @param featureProvider | |
* The feature provider. | |
* @param linked | |
* True if the pictogram element should be linked to a model | |
* object. | |
*/ | |
public CommonFeatureAreaAddFeature(IFeatureProvider featureProvider, boolean linked) { | |
super(featureProvider); | |
super.linked = linked; | |
} | |
@Override | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.func.IAdd#add(org.eclipse.graphiti.features.context | |
* .IAddContext) | |
*/ | |
public PictogramElement add(IAddContext context) { | |
ContainerShape newShape = pe.createContainerShape( | |
context.getTargetContainer(), true); | |
Rectangle rec = ga.createRectangle(newShape); | |
rec.setLineVisible(false); | |
rec.setBackground(manageColor(200, 200, 200)); | |
ga.setLocationAndSize(rec, context.getX(), context.getY(), | |
getWidth(context), getHeight(context)); | |
addText(newShape, context.getNewObject()); | |
pe.createChopboxAnchor(newShape); | |
if (linked) | |
link(newShape, context.getNewObject()); | |
return newShape; | |
} | |
} |