Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ce0468147b7639e925e6663c6f3e49a64f8b86bd (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<%@ jet package="org.eclipse.gmf.codegen.templates.parts" class="CompartmentEditPartGenerator"
	imports="org.eclipse.emf.codegen.ecore.genmodel.* org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.*"
	skeleton="../common.skeleton"%>
<%
GenCompartment genCompartment = (GenCompartment) ((Object[]) argument)[0];
GenDiagram genDiagram = genCompartment.getDiagram();
%>
<%@ include file="../copyright4java.jetinc"%>
package <%=genDiagram.getEditPartsPackageName()%>;

<%ImportUtil importManager = new ImportUtil(genDiagram.getEditPartsPackageName());%>
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
<%
importManager.markImportLocation(stringBuffer);
%>

/**
 * @generated
 */
public class <%=genCompartment.getEditPartClassName()%> extends <%=genCompartment.isListLayout() ? importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart") : importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart")%> {

	/**
	 * @generated
	 */
	public <%=genCompartment.getEditPartClassName()%>(View view) {
		super(view);
	}
<%if (genCompartment.isListLayout()) {%>

	/**
	 * @generated
	 */
	protected boolean hasModelChildrenChanged(<%=importManager.getImportedName("org.eclipse.emf.common.notify.Notification")%> evt) {
		return false;
	}
<%}%>

	/**
	 * @generated
	 */
	protected String getTitleName() {
		return "<%=genCompartment.getTitle()%>";
	}

	/**
	 * @generated
	 */
	protected void createDefaultEditPolicies() {
		super.createDefaultEditPolicies();
		installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new <%=importManager.getImportedName(genCompartment.getItemSemanticEditPolicyQualifiedClassName())%>());
<%if (!genCompartment.getChildNodes().isEmpty()) {%>
		installEditPolicy(EditPolicyRoles.CREATION_ROLE, new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy")%>());
		installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy")%>());
		installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new <%=importManager.getImportedName(genCompartment.getCanonicalEditPolicyQualifiedClassName())%>());
<%}%>
	}
<%if (!genCompartment.getNode().isListLayout()) {%>

	/**
	 * @generated
	 */
	//public <%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> createFigure() {
	//	<%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> result = super.createFigure();
	//	result.setBorder(new <%=importManager.getImportedName("org.eclipse.draw2d.LineBorder")%>());
	//	return result;
	//}

	/**
	 * @generated
	 */
	protected void refreshRatio() {
	}

	/**
	 * @generated
	 */
	protected void refreshVisuals() {
		super.refreshVisuals();
		refreshBounds();
	}
	
	/**
	 * @generated
	 */
	protected void handleNotificationEvent(<%=importManager.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification) {
		super.handleNotificationEvent(notification);
		Object feature = notification.getFeature();
		if (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Width().equals(feature)
			|| <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Height().equals(feature)
			|| <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getLocation_X().equals(feature)
			|| <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getLocation_Y().equals(feature)) {
			refreshBounds();
		} 
	}
	
	/**
	 * @generated
	 */
	protected void refreshBounds() {
		int width = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Width())).intValue();
		int height = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Height())).intValue();
		<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%> size = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(width, height);
		int x = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getLocation_X())).intValue();
		int y = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getLocation_Y())).intValue();
		<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%> loc = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%>(x, y);
		((<%=importManager.getImportedName("org.eclipse.gef.GraphicalEditPart")%>) getParent()).setLayoutConstraint(this, getFigure(), new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle")%>(loc, size));
	}
<%}%>

	/**
	 * Temporary fix for the https://bugs.eclipse.org/bugs/show_bug.cgi?id=132219
	 * @generated
	 */
	public <%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> createFigure() {
		<%=importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode")%> mm = getMapMode();
		<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure")%> rcf =
			(<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure")%>) super.createFigure();
		if (rcf instanceof <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ShapeCompartmentFigure")%>) {
			<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Insets")%> insets = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Insets")%>(mm.DPtoLP(1), mm.DPtoLP(2), mm.DPtoLP(1), mm.DPtoLP(0));
			<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%> size = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(mm.DPtoLP(15), mm.DPtoLP(15));

			<%=importManager.getImportedName("org.eclipse.draw2d.ScrollPane")%> scrollpane = rcf.getScrollPane();
			scrollpane.setHorizontalScrollBar(new <%=importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ListScrollBar")%>(<%=importManager.getImportedName("org.eclipse.draw2d.Orientable")%>.HORIZONTAL, insets, size, mm.DPtoLP(10), mm.DPtoLP(50)));
			scrollpane.setVerticalScrollBar(new <%=importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ListScrollBar")%>(<%=importManager.getImportedName("org.eclipse.draw2d.Orientable")%>.VERTICAL, insets, size, mm.DPtoLP(10), mm.DPtoLP(50)));

			int MB = mm.DPtoLP(5);
			scrollpane.setBorder(new <%=importManager.getImportedName("org.eclipse.draw2d.MarginBorder")%>(MB, MB, MB, MB));
			int SZ = mm.DPtoLP(10);
			scrollpane.setMinimumSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(SZ, SZ));
		} else {
			<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Insets")%> insets = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Insets")%>(mm.DPtoLP(1), mm.DPtoLP(2), mm.DPtoLP(1), mm.DPtoLP(0));
			<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%> size = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(mm.DPtoLP(15), mm.DPtoLP(15));

			<%=importManager.getImportedName("org.eclipse.draw2d.ScrollPane")%> scrollPane = rcf.getScrollPane();
			scrollPane.setVerticalScrollBar(new <%=importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ListScrollBar")%>(<%=importManager.getImportedName("org.eclipse.draw2d.Orientable")%>.VERTICAL, insets, size, mm.DPtoLP(10), mm.DPtoLP(50)));
		}
		return rcf;
	}
}
<%importManager.emitSortedImports();%>

Back to the top