/*****************************************************************************
* Copyright (c) 2012 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.FillStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.swt.graphics.Color;
public abstract class DeploymentNodeEditPart extends AbstractBorderedShapeEditPart implements IPapyrusEditPart {
public DeploymentNodeEditPart(View view) {
super(view);
}
@Override
protected NodeFigure createMainFigure() {
return createNodeFigure();
}
public abstract IPapyrusNodeFigure getPrimaryShape();
@Override
public boolean supportsGradient() {
return true;
}
@Override
protected void handleNotificationEvent(Notification event) {
super.handleNotificationEvent(event);
}
@Override
protected void setTransparency(int transp) {
getPrimaryShape().setTransparency(transp);
}
/**
* sets the back ground color of this edit part
*/
@Override
protected void setBackgroundColor(Color color) {
getPrimaryShape().setBackgroundColor(color);
getPrimaryShape().setIsUsingGradient(false);
getPrimaryShape().setGradientData(-1, -1, 0);
}
/**
* Override to set the gradient data to the correct figure
*/
@Override
protected void setGradient(GradientData gradient) {
IPapyrusNodeFigure fig = getPrimaryShape();
FillStyle style = (FillStyle)getPrimaryView().getStyle(NotationPackage.Literals.FILL_STYLE);
if(gradient != null) {
fig.setIsUsingGradient(true);;
fig.setGradientData(style.getFillColor(), gradient.getGradientColor1(), gradient.getGradientStyle());
} else {
fig.setIsUsingGradient(false);
}
}
@Override
protected void setForegroundColor(Color color) {
getPrimaryShape().setForegroundColor(color);
}
}