Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4ae4f4ee2cdb08e1c149f5ab777e31b3b96b6ead (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
 * Copyright (c) 2007 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:
 *    bblajer (Borland) - initial API and implementation
 */

«IMPORT "http://www.eclipse.org/gmf/2005/GenModel/2.0"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::GenModelUtils»
«EXTENSION xpt::diagram::parts::NotationModelRefresher»
«EXTENSION xpt::diagram::parts::LinkNotationModelRefresher»
«EXTENSION xpt::diagram::LinkFinder»

«DEFINE DiagramInitializer FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedClassComment»
private static class DiagramInitializer {
	«EXPAND xpt::Common::generatedMemberComment»
	private void initDiagramContents(org.eclipse.gmf.runtime.notation.Diagram diagram) {
«IF getAllInitableContainers().size() > 0-»
		create«getUniqueIdentifier()»Children(diagram);
«ENDIF-»
«IF links.size() > 0-»
		myViewService = new org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.NaiveViewService(diagram);
		create«getUniqueIdentifier()»ChildLinks(diagram);
«ENDIF-»
	}

«LET getAllInitableContainers() AS containers2Generate-»
«FOREACH containers2Generate AS nextContainer-»
«EXPAND createChildren FOR nextContainer-»
	«IF nextContainer.needsNotationModelRefresher()-»
«EXPAND getSemanticChildNodes FOR nextContainer-»
«EXPAND getCreateNotationalChildNodeCommand FOR nextContainer-»
	«ENDIF-»
«ENDFOREACH-»
«ENDLET-»

«IF links.size() > 0-»
	«LET getLinkContainersWithAncestors() AS linkContainersWithAncestors»
	«FOREACH linkContainersWithAncestors AS nextContainer-»
	«EXPAND createChildLinks(linkContainersWithAncestors) FOR nextContainer-»
		«IF nextContainer.containedLinks().size() > 0-»
	«EXPAND getSemanticChildLinks FOR nextContainer-»
	«EXPAND getCreateNotationalChildLinkCommand FOR nextContainer-»
		«ENDIF-»
	«ENDFOREACH-»
	«ENDLET-»
«ENDIF-»
	«EXPAND viewService-»
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE createChildren FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void create«getUniqueIdentifier()»Children(org.eclipse.gmf.runtime.notation.View viewObject) {
	«EXPAND createChildrenOfCompartments-»
	«IF needsNotationModelRefresher()-»
	java.util.List semanticChildren = get«getUniqueIdentifier()»SemanticChildNodes(viewObject);
	for(java.util.Iterator it = semanticChildren.iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor nextDescriptor = (org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor) it.next();
		org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand createCommand = getCreate«getUniqueIdentifier()»NotationalChildNodeCommand(viewObject, nextDescriptor);
		if (createCommand != null && createCommand.canExecute()) {
			createCommand.execute();
		«LET getInitableGrandChildren() AS initableGrandChildren-»
		«IF initableGrandChildren.size() > 0-»
			org.eclipse.gmf.runtime.notation.View nextChild = createCommand.getCreatedView();
			int childVisualID = nextDescriptor.getVisualID();
			switch (childVisualID) {
			«EXPAND createGrandChildren("nextChild") FOREACH initableGrandChildren-»
			}
		«ENDIF-»
		«ENDLET-»
		}
	}
	«ENDIF-»
}
«ENDDEFINE»

«DEFINE createChildrenOfCompartments FOR gmfgen::GenContainerBase»«ENDDEFINE»

«DEFINE createChildrenOfCompartments FOR gmfgen::GenNode-»
«LET getInitableCompartments() AS initableCompartments-»
«IF initableCompartments.size() > 0-»
	for(java.util.Iterator it = viewObject.getChildren().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildren("next") FOREACH initableCompartments-»
		}
	}
«ENDIF-»
«ENDLET-»
«ENDDEFINE»

«DEFINE createGrandChildren(String viewCode) FOR gmfgen::GenContainerBase-»
case «getEditPartQualifiedClassName()».VISUAL_ID:
	create«getUniqueIdentifier()»Children(«viewCode»);
	break;
«ENDDEFINE»

«DEFINE getSemanticChildNodes FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private java.util.List get«getUniqueIdentifier()»SemanticChildNodes(org.eclipse.gmf.runtime.notation.View parentView) {
	«EXPAND xpt::diagram::parts::semanticChildren::semanticChildren("parentView")-»
}
«ENDDEFINE»

«DEFINE getCreateNotationalChildNodeCommand FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand getCreate«getUniqueIdentifier()»NotationalChildNodeCommand(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
	«EXPAND xpt::commands::createNotationalElementCommand::createNotationalNodeCommand("parentView")-»
}
«ENDDEFINE»

«DEFINE createChildLinks(Collection[gmfgen::GenCommonBase] allContainersWithAncestors) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void create«getUniqueIdentifier()»ChildLinks(org.eclipse.gmf.runtime.notation.View viewObject) {
«IF containedLinks().size() > 0-»
	java.util.List semanticChildLinks = get«getUniqueIdentifier()»SemanticChildLinks(viewObject);
	for(java.util.Iterator it = semanticChildLinks.iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor nextDescriptor = (org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor) it.next();
		org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand createCommand = getCreate«getUniqueIdentifier()»NotationalChildLinkCommand(viewObject, nextDescriptor);
		if (createCommand != null && createCommand.canExecute()) {
			createCommand.execute();
		}
	}
«ENDIF-»
		«LET getContainedContainers().select(e| allContainersWithAncestors.contains(e)) AS containedLinkContainers-»
		«LET containedLinkContainers.typeSelect(gmfgen::GenLink) AS linkContainersContainedInSourceEdges-»
		«LET (Collection[gmfgen::GenCommonBase]) containedLinkContainers.without(linkContainersContainedInSourceEdges) AS linkContainersContainedInChildren-»
		«IF linkContainersContainedInChildren.size() > 0-»
	for(java.util.Iterator it = viewObject.getChildren().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildLinks FOREACH linkContainersContainedInChildren-»
		}
	}
		«ENDIF-»
		«IF linkContainersContainedInSourceEdges.size() > 0-»
	for(java.util.Iterator it = viewObject.getSourceEdges().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildLinks FOREACH linkContainersContainedInSourceEdges-»
		}
	}
		«ENDIF-»
		«ENDLET-»
		«ENDLET-»
		«ENDLET-»
}
«ENDDEFINE»

«DEFINE createGrandChildLinks FOR gmfgen::GenCommonBase-»
case «getEditPartQualifiedClassName()».VISUAL_ID:
	create«getUniqueIdentifier()»ChildLinks(next);
	break;
«ENDDEFINE»

«DEFINE getSemanticChildLinks FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private java.util.List get«getUniqueIdentifier()»SemanticChildLinks(org.eclipse.gmf.runtime.notation.View parentView) {
	«EXPAND xpt::diagram::parts::semanticChildLinks::semanticChildLinks("parentView")-»
}
«ENDDEFINE»

«DEFINE getCreateNotationalChildLinkCommand FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand getCreate«getUniqueIdentifier()»NotationalChildLinkCommand(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor linkDescriptor) {
	«EXPAND xpt::commands::createNotationalElementCommand::createNotationalEdgeCommand("parentView.getDiagram()")-»
}
«ENDDEFINE»

«DEFINE viewService FOR gmfgen::GenDiagram-»
«IF links.size() > 0-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.IViewService myViewService;

«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.IViewService getViewService() {
	return myViewService;
}
«ENDIF-»
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»

Back to the top