Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4f998efc6d6b175862f0c0d117990f9dc0271878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<%@ jet package="org.eclipse.gmf.codegen.templates.parts" class="DiagramExternalNodeLabelEditPartGenerator"
	imports="org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.*"%>
<%
GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
%>
<%@ include file="../copyright4java.jetinc"%>
package <%=genDiagram.getEditPartsPackageName()%>;

<%ImportUtil importManager = new ImportUtil(genDiagram.getEditPartsPackageName());%>
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.diagram.ui.figures.LabelLocator;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
<%importManager.markImportLocation(stringBuffer);%>

/**
 * @generated
 */
public class <%=genDiagram.getBaseExternalNodeLabelEditPartClassName()%> extends LabelEditPart {

	/**
	 * @generated
	 */
	public static final int BOTTOM_GAP = 5;

	/**
	 * @generated
	 */
	public <%=genDiagram.getBaseExternalNodeLabelEditPartClassName()%>(View view) {
		super(view);
	}

	/**
	 * @generated
	 */
	public void refreshBounds() {
		IFigure refFigure = ((GraphicalEditPart) getParent()).getFigure();
		int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
		int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
		Point offset = new Point(dx, dy);
		getFigure().getParent().setConstraint(getFigure(), new LabelLocator(refFigure, offset, getKeyPoint()) {

			public void relocate(IFigure target) {
				Point location = getReferencePoint().getTranslated(getOffset());
				location.translate(-target.getBounds().width / 2, 0);
				target.setLocation(location);
				target.setSize(new Dimension(target.getPreferredSize().width, target.getPreferredSize().height));
			}

			protected Point getReferencePoint() {
				return getLabelLocation(parent);
			}
		});
	}

	/**
	 * @generated
	 */
	public Point getReferencePoint() {
		return getLabelLocation(((GraphicalEditPart) getParent()).getFigure());
	}

	/**
	 * @generated
	 */
	protected Point getLabelLocation(IFigure parent) {
		return parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP);
	}
}
<%importManager.emitSortedImports();%>

Back to the top