Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: abebed619e8f2b2e6ace15cf9fe868a3cce653c5 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright (c) 2006 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
 */

«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
«EXTENSION xpt::StringOperations»

«DEFINE visualIDConstant FOR gmfgen::GenCommonBase-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static final int VISUAL_ID = «visualID»;
«ENDDEFINE»

«DEFINE behaviour FOR gmfgen::GenCommonBase-»
	«EXPAND behaviour FOREACH behaviour-»
«ENDDEFINE»

«DEFINE behaviour FOR gmfgen::Behaviour-»
«ENDDEFINE»

«DEFINE behaviour FOR gmfgen::CustomBehaviour-»
«IF editPolicyQualifiedClassName = null or editPolicyQualifiedClassName.trim().xpandLength() = 0-»
	removeEditPolicy(«key»); «IF key.xpandStartsWith('\"') and key.xpandEndsWith('\"')»«EXPAND xpt::Common::nonNLS»«ENDIF»
«ELSE-»
	installEditPolicy(«key», new «getEditPolicyQualifiedClassName()»()); «IF key.xpandStartsWith('\"') and key.xpandEndsWith('\"')»«EXPAND xpt::Common::nonNLS»«ENDIF»
«ENDIF-»
«ENDDEFINE»

«DEFINE behaviour FOR gmfgen::OpenDiagramBehaviour-»
	installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.OPEN_ROLE,
		new «getEditPolicyQualifiedClassName()»());
«ENDDEFINE»

«DEFINE labelFigure FOR gmfgen::ParentAssignedViewmap-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure createFigure() {
		// Parent should assign one using «EXPAND impl::diagram::editparts::TextAware::labelSetterName»() method
		return null;
	}
«ENDDEFINE»

«DEFINE labelFigure FOR gmfgen::Viewmap-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure createFigure() {
		org.eclipse.draw2d.IFigure label = createFigurePrim();
		defaultText = getLabelTextHelper(label);
		return label;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure createFigurePrim() {
		«EXPAND labelFigurePrim FOR self-»
«ENDDEFINE»

«DEFINE labelFigurePrim FOR gmfgen::FigureViewmap-»
«IF figureQualifiedClassName = null-»
	return new org.eclipse.draw2d.Label();
«ELSE-»
	return new «figureQualifiedClassName»();
«ENDIF-»
	}
«ENDDEFINE»

«DEFINE labelFigurePrim FOR gmfgen::SnippetViewmap-»
	return «body»;
	}
«ENDDEFINE»

«DEFINE labelFigurePrim FOR gmfgen::InnerClassViewmap-»
	return new «className»();
	}

	«classBody»
«ENDDEFINE»

«DEFINE labelFigurePrim FOR gmfgen::Viewmap-»
	«ERROR 'Unknown viewmap: ' + self.repr()-»
	}
«ENDDEFINE»

«DEFINE notationalListeners FOR gmfgen::GenCommonBase-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void addNotationalListeners() {
		super.addNotationalListeners();
		addListenerFilter("PrimaryView", this, getPrimaryView()); «EXPAND xpt::Common::nonNLS»
	}

	«EXPAND xpt::Common::generatedMemberComment»
	protected void removeNotationalListeners() {
		super.removeNotationalListeners();
		removeListenerFilter("PrimaryView"); «EXPAND xpt::Common::nonNLS»
	}
«ENDDEFINE»

«DEFINE handleBounds FOR gmfgen::GenCommonBase-»
	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 handleText FOR gmfgen::GenCommonBase-»
	if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
		Integer c = (Integer) event.getNewValue();
		setFontColor(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry.getInstance().getColor(c));
	} else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
		refreshUnderline();
	} else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
		refreshStrikeThrough();
	} else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) ||
			org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) ||
			org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) ||
			org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
		refreshFont();
	} else {
		if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
			refreshLabel();
		}
		if (getParser() instanceof org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) {
			org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser modelParser =
				(org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) getParser();
			if (modelParser.areSemanticElementsAffected(null, event)) {
				removeSemanticListeners();
				if (resolveSemanticElement() != null) {
					addSemanticListeners();
				}
				refreshLabel();
			}
		}
	}
«ENDDEFINE»

«DEFINE installSemanticEditPolicy FOR gmfgen::GenCommonBase-»
	«IF sansDomain-»
removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE);
	«ELSE-»
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE, new «getItemSemanticEditPolicyQualifiedClassName()»());
	«ENDIF-»
«ENDDEFINE»

«DEFINE installCanonicalEditPolicy FOR gmfgen::GenContainerBase-»
	«IF needsCanonicalEditPolicy()-»
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new «getCanonicalEditPolicyQualifiedClassName()»());
	«ENDIF-»
«ENDDEFINE»

Back to the top