Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 897cdba50c536596cf60fc2f1537bb9750c87db1 (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
<%@ 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));
	}
<%}%>
}
<%importManager.emitSortedImports();%>

Back to the top