/*
* Copyright (c) 2006, 2008 Borland Software Corp.
*
* 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:
* Alexander Shatalin (Borland) - initial API and implementation
*/
package org.eclipse.gmf.ecore.edit.parts;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.ecore.edit.policies.EReference2ItemSemanticEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.notation.View;
/**
* @generated
*/
public class EReference2EditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart {
/**
* @generated
*/
public static final int VISUAL_ID = 4003;
/**
* @generated
*/
public EReference2EditPart(View view) {
super(view);
}
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EReference2ItemSemanticEditPolicy());
}
/**
* Creates figure for this edit part.
*
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
protected Connection createConnectionFigure() {
return new SolidLineWSrcDiamond();
}
/**
* @generated
*/
public SolidLineWSrcDiamond getPrimaryShape() {
return (SolidLineWSrcDiamond) getFigure();
}
/**
* @generated
*/
public class SolidLineWSrcDiamond extends PolylineConnectionEx {
/**
* @generated
*/
public SolidLineWSrcDiamond() {
setSourceDecoration(createSourceDecoration());
}
/**
* @generated
*/
private RotatableDecoration createSourceDecoration() {
PolygonDecoration df = new PolygonDecoration();
df.setFill(true);
PointList pl = new PointList();
pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1));
pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-1));
pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(0));
pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1));
df.setTemplate(pl);
df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
return df;
}
}
}