Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3374f9687796f82e7aa087be89250cda215740b8 (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
/*
 * Copyright (c) 2006, 2009 Borland Software Corporation
 * 
 * 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:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 *    Alexander Shatalin (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«EXTENSION xpt::diagram::editparts::Utils»

«DEFINE contsructor FOR gmfgen::GenCompartment-»
	«EXPAND xpt::Common::generatedMemberComment»
	public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
		super(view);
	}
«ENDDEFINE»

«DEFINE hasModelChildrenChanged FOR gmfgen::GenCompartment-»
	«IF listLayout-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected boolean hasModelChildrenChanged(org.eclipse.emf.common.notify.Notification evt) {
			return false;
		}
	«ENDIF-»
«ENDDEFINE»

«DEFINE getCompartmentName FOR gmfgen::GenCompartment-»
	«EXPAND xpt::Common::generatedMemberComment»
	public String getCompartmentName() {
		return «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCompartmentTitle(self)) FOR getDiagram().editorGen»;
	}
«ENDDEFINE»

«DEFINE createFigure FOR gmfgen::GenCompartment-»
	«IF not needsTitle-»
		«REM»By default titles are shown even if there are no TitleStyle, we need to switch it off«ENDREM»«-»
		«EXPAND xpt::Common::generatedMemberComment»
		public org.eclipse.draw2d.IFigure createFigure() {
			org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure result = (org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure) super.createFigure();
			result.setTitleVisibility(false);
			return result;
		}
	«ENDIF-»
«ENDDEFINE»

«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenCompartment-»
	super.createDefaultEditPolicies();
	«IF canCollapse-»
		installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy());
	«ENDIF-»
	«EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
	«IF childNodes->size() > 0-»
		installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy());
		installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
	«ENDIF-»
	«EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
	«EXPAND xpt::diagram::editparts::Common::behaviour-»
«ENDDEFINE»

«DEFINE refreshVisuals FOR gmfgen::GenCompartment-»
	«IF isStoringChildPositions(node)-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected void refreshVisuals() {
			super.refreshVisuals();
			refreshBounds();
		}
	«ENDIF-»
«ENDDEFINE»
	
«DEFINE handleNotificationEventBody FOR gmfgen::GenCompartment-»
	super.handleNotificationEvent(notification);
	Object feature = notification.getFeature();
	if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width().equals(feature)
			|| org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height().equals(feature)
			|| org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X().equals(feature)
			|| org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
		refreshBounds();
	} 
«ENDDEFINE»
	
«DEFINE refreshBounds FOR gmfgen::GenCompartment-»
	«IF isStoringChildPositions(node)-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected void refreshBounds() {
			int x = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X())).intValue();
			int y = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y())).intValue();
			int width = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width())).intValue();
			int height = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height())).intValue();
			((org.eclipse.gef.GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new org.eclipse.draw2d.geometry.Rectangle(x, y, width, height));
		}
	«ENDIF-»
«ENDDEFINE»

«DEFINE setRatio FOR gmfgen::GenCompartment-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void setRatio(Double ratio) {
		«IF gmfgen::ViewmapLayoutType::UNKNOWN = node.getLayoutType()-»
		if (getFigure().getParent().getLayoutManager() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout) {
			super.setRatio(ratio);
		}
		«ELSE-»
		// nothing to do -- parent layout does not accept Double constraints as ratio
		// super.setRatio(ratio); 
		«ENDIF-»
	}
«ENDDEFINE»

«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
«EXPAND internal_i18nAccessors FOREACH compartments»
«ENDDEFINE»

«DEFINE internal_i18nAccessors FOR gmfgen::GenCompartment-»
«IF null <> title»«EXPAND xpt::Externalizer::accessorField(i18nKeyForCompartmentTitle(self))»«ENDIF-»
«ENDDEFINE»

«DEFINE i18nValues FOR gmfgen::GenDiagram-»
«EXPAND internal_i18nValues FOREACH compartments»
«ENDDEFINE»

«DEFINE internal_i18nValues FOR gmfgen::GenCompartment-»
«IF null <> title»«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCompartmentTitle(self), title)»«ENDIF-»
«ENDDEFINE»

Back to the top