|
1 /* |
|
2 * Copyright (c) 2006,2007 Borland Software Corporation |
|
3 * |
|
4 * All rights reserved. This program and the accompanying materials |
|
5 * are made available under the terms of the Eclipse Public License v1.0 |
|
6 * which accompanies this distribution, and is available at |
|
7 * http://www.eclipse.org/legal/epl-v10.html |
|
8 * |
|
9 * Contributors: |
|
10 * Alexander Shatalin (Borland) - initial API and implementation |
|
11 */ |
|
12 |
|
13 «IMPORT "http://www.eclipse.org/gmf/2008/GenModel"» |
|
14 «IMPORT "http://www.eclipse.org/emf/2002/Ecore"» |
|
15 «EXTENSION xpt::navigator::Utils» |
|
16 |
|
17 «DEFINE NavigatorContentProvider FOR gmfgen::GenNavigator-» |
|
18 «EXPAND xpt::Common::copyright FOR editorGen-» |
|
19 package «packageName»; |
|
20 |
|
21 «EXPAND xpt::Common::generatedClassComment» |
|
22 public class «contentProviderClassName» implements org.eclipse.ui.navigator.ICommonContentProvider { |
|
23 |
|
24 «EXPAND attributes-» |
|
25 |
|
26 «EXPAND constructor-» |
|
27 |
|
28 «EXPAND iContentProvider-» |
|
29 |
|
30 «EXPAND iStructuredContentProvider-» |
|
31 |
|
32 «EXPAND iMementoAware-» |
|
33 |
|
34 «EXPAND iCommonContentProvider-» |
|
35 |
|
36 «EXPAND iTreeContentProvider-» |
|
37 |
|
38 «EXPAND additions-» |
|
39 } |
|
40 «ENDDEFINE» |
|
41 |
|
42 «DEFINE attributes FOR gmfgen::GenNavigator-» |
|
43 «EXPAND xpt::Common::generatedMemberComment» |
|
44 private static final Object[] EMPTY_ARRAY = new Object[0]; |
|
45 |
|
46 «EXPAND xpt::Common::generatedMemberComment» |
|
47 private org.eclipse.jface.viewers.Viewer myViewer; |
|
48 |
|
49 «EXPAND xpt::Common::generatedMemberComment» |
|
50 private org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain myEditingDomain; |
|
51 |
|
52 «EXPAND xpt::Common::generatedMemberComment» |
|
53 private org.eclipse.emf.workspace.util.WorkspaceSynchronizer myWorkspaceSynchronizer; |
|
54 |
|
55 «EXPAND xpt::Common::generatedMemberComment» |
|
56 private Runnable myViewerRefreshRunnable; |
|
57 «ENDDEFINE» |
|
58 |
|
59 «DEFINE constructor FOR gmfgen::GenNavigator-» |
|
60 «EXPAND xpt::Common::generatedMemberComment» |
|
61 public «contentProviderClassName»() { |
|
62 «EXPAND initCommonAttributes-» |
|
63 } |
|
64 «ENDDEFINE» |
|
65 |
|
66 «DEFINE initCommonAttributes FOR gmfgen::GenNavigator-» |
|
67 org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = «EXPAND createEditingDomain»; |
|
68 myEditingDomain = (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) editingDomain; |
|
69 myEditingDomain.setResourceToReadOnlyMap(new java.util.HashMap() { |
|
70 public Object get(Object key) { |
|
71 if (!containsKey(key)) { |
|
72 put(key, Boolean.TRUE); |
|
73 } |
|
74 return super.get(key); |
|
75 } |
|
76 }); |
|
77 myViewerRefreshRunnable = new Runnable() { |
|
78 public void run() { |
|
79 if (myViewer != null) { |
|
80 myViewer.refresh(); |
|
81 } |
|
82 } |
|
83 }; |
|
84 myWorkspaceSynchronizer = new org.eclipse.emf.workspace.util.WorkspaceSynchronizer(editingDomain, new org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate() { |
|
85 public void dispose() { |
|
86 } |
|
87 |
|
88 public boolean handleResourceChanged(final org.eclipse.emf.ecore.resource.Resource resource) { |
|
89 «EXPAND processChanges-» |
|
90 } |
|
91 |
|
92 public boolean handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource) { |
|
93 «EXPAND processChanges-» |
|
94 } |
|
95 |
|
96 public boolean handleResourceMoved(org.eclipse.emf.ecore.resource.Resource resource, final org.eclipse.emf.common.util.URI newURI) { |
|
97 «EXPAND processChanges-» |
|
98 } |
|
99 }); |
|
100 «ENDDEFINE» |
|
101 |
|
102 «DEFINE processChanges FOR gmfgen::GenNavigator-» |
|
103 for (java.util.Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { |
|
104 org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next(); |
|
105 nextResource.unload(); |
|
106 } |
|
107 if (myViewer != null) { |
|
108 myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); |
|
109 } |
|
110 return true; |
|
111 «ENDDEFINE» |
|
112 |
|
113 «DEFINE iContentProvider FOR gmfgen::GenNavigator-» |
|
114 «EXPAND dispose-» |
|
115 |
|
116 «EXPAND inputChanged-» |
|
117 «ENDDEFINE» |
|
118 |
|
119 «DEFINE dispose FOR gmfgen::GenNavigator-» |
|
120 «EXPAND xpt::Common::generatedMemberComment» |
|
121 public void dispose() { |
|
122 myWorkspaceSynchronizer.dispose(); |
|
123 myWorkspaceSynchronizer = null; |
|
124 myViewerRefreshRunnable = null; |
|
125 for (java.util.Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { |
|
126 org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) it.next(); |
|
127 resource.unload(); |
|
128 } |
|
129 ((org.eclipse.emf.transaction.TransactionalEditingDomain) myEditingDomain).dispose(); |
|
130 myEditingDomain = null; |
|
131 } |
|
132 «ENDDEFINE» |
|
133 |
|
134 «DEFINE inputChanged FOR gmfgen::GenNavigator-» |
|
135 «EXPAND xpt::Common::generatedMemberComment» |
|
136 public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) { |
|
137 myViewer = viewer; |
|
138 } |
|
139 «ENDDEFINE» |
|
140 |
|
141 «DEFINE iStructuredContentProvider FOR gmfgen::GenNavigator-» |
|
142 «EXPAND xpt::Common::generatedMemberComment» |
|
143 public Object[] getElements(Object inputElement) { |
|
144 return getChildren(inputElement); |
|
145 } |
|
146 «ENDDEFINE» |
|
147 |
|
148 «DEFINE iMementoAware FOR gmfgen::GenNavigator-» |
|
149 «EXPAND xpt::Common::generatedMemberComment» |
|
150 public void restoreState(org.eclipse.ui.IMemento aMemento) { |
|
151 } |
|
152 |
|
153 «EXPAND xpt::Common::generatedMemberComment» |
|
154 public void saveState(org.eclipse.ui.IMemento aMemento) { |
|
155 } |
|
156 «ENDDEFINE» |
|
157 |
|
158 «DEFINE iCommonContentProvider FOR gmfgen::GenNavigator-» |
|
159 «EXPAND xpt::Common::generatedMemberComment» |
|
160 public void init(org.eclipse.ui.navigator.ICommonContentExtensionSite aConfig) { |
|
161 } |
|
162 «ENDDEFINE» |
|
163 |
|
164 «DEFINE iTreeContentProvider FOR gmfgen::GenNavigator-» |
|
165 «EXPAND getChildren-» |
|
166 |
|
167 «EXPAND getParent-» |
|
168 |
|
169 «EXPAND hasChildren-» |
|
170 «ENDDEFINE» |
|
171 |
|
172 «DEFINE getChildren FOR gmfgen::GenNavigator-» |
|
173 «EXPAND xpt::Common::generatedMemberComment» |
|
174 public Object[] getChildren(Object parentElement) { |
|
175 if (parentElement instanceof org.eclipse.core.resources.IFile) { |
|
176 «EXPAND getFileChildren-» |
|
177 } |
|
178 |
|
179 if (parentElement instanceof «getNavigatorGroupQualifiedClassName()») { |
|
180 «EXPAND getGroupChildren-» |
|
181 } |
|
182 |
|
183 if (parentElement instanceof «getNavigatorItemQualifiedClassName()») { |
|
184 «EXPAND getItemChildren-» |
|
185 } |
|
186 |
|
187 «IF editorGen.diagram.generateShortcutIcon()-» |
|
188 «EXPAND getAdaptableChildren» |
|
189 «ENDIF-» |
|
190 «EXPAND getOtherChildren-» |
|
191 } |
|
192 |
|
193 «EXPAND getViewChildren-» |
|
194 |
|
195 «EXPAND utilityMethods-» |
|
196 «ENDDEFINE» |
|
197 |
|
198 «DEFINE getParent FOR gmfgen::GenNavigator-» |
|
199 «EXPAND xpt::Common::generatedMemberComment» |
|
200 public Object getParent(Object element) { |
|
201 if (element instanceof «getAbstractNavigatorItemQualifiedClassName()») { |
|
202 «getAbstractNavigatorItemQualifiedClassName()» abstractNavigatorItem = («getAbstractNavigatorItemQualifiedClassName()») element; |
|
203 return abstractNavigatorItem.getParent(); |
|
204 } |
|
205 return null; |
|
206 } |
|
207 «ENDDEFINE» |
|
208 |
|
209 «DEFINE hasChildren FOR gmfgen::GenNavigator-» |
|
210 «EXPAND xpt::Common::generatedMemberComment» |
|
211 public boolean hasChildren(Object element) { |
|
212 return element instanceof org.eclipse.core.resources.IFile || getChildren(element).length > 0; |
|
213 } |
|
214 «ENDDEFINE» |
|
215 |
|
216 «DEFINE getFileChildren FOR gmfgen::GenNavigator-» |
|
217 «EXPAND getFileResoruce-» |
|
218 java.util.Collection result = new java.util.ArrayList(); |
|
219 «LET getChildReferencesFrom(this, null) AS references-» |
|
220 «EXPAND initGroupVariables(this, references, 'file', null) FOREACH getGroupNames(references)-» |
|
221 «FOREACH references AS ref-» |
|
222 «EXPAND addNavigatorItemsPrefix FOR ref»selectViewsByType(resource.getContents(), «EXPAND getChildViewType FOR ref.child»)«EXPAND addNavigatorItemsSuffix('file', false) FOR ref-» |
|
223 «ENDFOREACH-» |
|
224 «EXPAND addGroups(references) FOREACH getGroupNames(references)-» |
|
225 «ENDLET-» |
|
226 return result.toArray(); |
|
227 «ENDDEFINE» |
|
228 |
|
229 «DEFINE getFileResoruce FOR gmfgen::GenNavigator-» |
|
230 org.eclipse.core.resources.IFile file = (org.eclipse.core.resources.IFile) parentElement; |
|
231 org.eclipse.emf.common.util.URI fileURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(file.getFullPath().toString(), true); |
|
232 org.eclipse.emf.ecore.resource.Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true); |
|
233 «ENDDEFINE» |
|
234 |
|
235 «DEFINE getGroupChildren FOR gmfgen::GenNavigator-» |
|
236 «getNavigatorGroupQualifiedClassName()» group = («getNavigatorGroupQualifiedClassName()») parentElement; |
|
237 return group.getChildren(); |
|
238 «ENDDEFINE» |
|
239 |
|
240 «DEFINE getItemChildren FOR gmfgen::GenNavigator-» |
|
241 «getNavigatorItemQualifiedClassName()» navigatorItem = («getNavigatorItemQualifiedClassName()») parentElement; |
|
242 if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) { |
|
243 return EMPTY_ARRAY; |
|
244 } |
|
245 return getViewChildren(navigatorItem.getView(), parentElement); |
|
246 «ENDDEFINE» |
|
247 |
|
248 «DEFINE getAdaptableChildren FOR gmfgen::GenNavigator-» |
|
249 /* |
|
250 * Due to plugin.xml restrictions this code will be called only for views representing |
|
251 * shortcuts to this diagram elements created on other diagrams. |
|
252 */ |
|
253 if (parentElement instanceof org.eclipse.core.runtime.IAdaptable) { |
|
254 org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) parentElement).getAdapter(org.eclipse.gmf.runtime.notation.View.class); |
|
255 if (view != null) { |
|
256 return getViewChildren(view, parentElement); |
|
257 } |
|
258 } |
|
259 «ENDDEFINE» |
|
260 |
|
261 «DEFINE getOtherChildren FOR gmfgen::GenNavigator-» |
|
262 return EMPTY_ARRAY; |
|
263 «ENDDEFINE» |
|
264 |
|
265 «DEFINE getViewChildren FOR gmfgen::GenNavigator-» |
|
266 «EXPAND xpt::Common::generatedMemberComment» |
|
267 private Object[] getViewChildren(org.eclipse.gmf.runtime.notation.View view, Object parentElement) { |
|
268 switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) { |
|
269 «EXPAND caseNavigatorNode(this) FOREACH getNavigatorContainerNodes(this)-» |
|
270 } |
|
271 return EMPTY_ARRAY; |
|
272 } |
|
273 «ENDDEFINE» |
|
274 |
|
275 «DEFINE utilityMethods FOR gmfgen::GenNavigator-» |
|
276 «EXPAND xpt::Common::generatedMemberComment» |
|
277 private java.util.Collection getLinksSourceByType(java.util.Collection edges, int visualID) { |
|
278 java.util.Collection result = new java.util.ArrayList(); |
|
279 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
280 for (java.util.Iterator it = edges.iterator(); it.hasNext();) { |
|
281 org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) it.next(); |
|
282 org.eclipse.gmf.runtime.notation.View nextEdgeSource = nextEdge.getSource(); |
|
283 if (type.equals(nextEdgeSource.getType()) && isOwnView(nextEdgeSource)) { |
|
284 result.add(nextEdgeSource); |
|
285 } |
|
286 } |
|
287 return result; |
|
288 } |
|
289 |
|
290 «EXPAND xpt::Common::generatedMemberComment» |
|
291 private java.util.Collection getLinksTargetByType(java.util.Collection edges, int visualID) { |
|
292 java.util.Collection result = new java.util.ArrayList(); |
|
293 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
294 for (java.util.Iterator it = edges.iterator(); it.hasNext();) { |
|
295 org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) it.next(); |
|
296 org.eclipse.gmf.runtime.notation.View nextEdgeTarget = nextEdge.getTarget(); |
|
297 if (type.equals(nextEdgeTarget.getType()) && isOwnView(nextEdgeTarget)) { |
|
298 result.add(nextEdgeTarget); |
|
299 } |
|
300 } |
|
301 return result; |
|
302 } |
|
303 |
|
304 «EXPAND xpt::Common::generatedMemberComment» |
|
305 private java.util.Collection getOutgoingLinksByType(java.util.Collection nodes, int visualID) { |
|
306 java.util.Collection result = new java.util.ArrayList(); |
|
307 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
308 for (java.util.Iterator it = nodes.iterator(); it.hasNext();) { |
|
309 org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next(); |
|
310 result.addAll(selectViewsByType(nextNode.getSourceEdges(), type)); |
|
311 } |
|
312 return result; |
|
313 } |
|
314 |
|
315 «EXPAND xpt::Common::generatedMemberComment» |
|
316 private java.util.Collection getIncomingLinksByType(java.util.Collection nodes, int visualID) { |
|
317 java.util.Collection result = new java.util.ArrayList(); |
|
318 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
319 for (java.util.Iterator it = nodes.iterator(); it.hasNext();) { |
|
320 org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next(); |
|
321 result.addAll(selectViewsByType(nextNode.getTargetEdges(), type)); |
|
322 } |
|
323 return result; |
|
324 } |
|
325 |
|
326 «EXPAND xpt::Common::generatedMemberComment» |
|
327 private java.util.Collection getChildrenByType(java.util.Collection nodes, int visualID) { |
|
328 java.util.Collection result = new java.util.ArrayList(); |
|
329 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
330 for (java.util.Iterator it = nodes.iterator(); it.hasNext();) { |
|
331 org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next(); |
|
332 result.addAll(selectViewsByType(nextNode.getChildren(), type)); |
|
333 } |
|
334 return result; |
|
335 } |
|
336 |
|
337 «EXPAND xpt::Common::generatedMemberComment» |
|
338 private java.util.Collection getDiagramLinksByType(java.util.Collection diagrams, int visualID) { |
|
339 java.util.Collection result = new java.util.ArrayList(); |
|
340 «EXPAND getTypeByVID FOR editorGen.diagram-» |
|
341 for (java.util.Iterator it = diagrams.iterator(); it.hasNext();) { |
|
342 org.eclipse.gmf.runtime.notation.Diagram nextDiagram = (org.eclipse.gmf.runtime.notation.Diagram) it.next(); |
|
343 result.addAll(selectViewsByType(nextDiagram.getEdges(), type)); |
|
344 } |
|
345 return result; |
|
346 } |
|
347 |
|
348 «EXPAND xpt::Common::generatedMemberComment» |
|
349 private java.util.Collection selectViewsByType(java.util.Collection views, String type) { |
|
350 java.util.Collection result = new java.util.ArrayList(); |
|
351 for (java.util.Iterator it = views.iterator(); it.hasNext();) { |
|
352 org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next(); |
|
353 if (type.equals(nextView.getType()) && isOwnView(nextView)) { |
|
354 result.add(nextView); |
|
355 } |
|
356 } |
|
357 return result; |
|
358 } |
|
359 |
|
360 «EXPAND xpt::Common::generatedMemberComment» |
|
361 private boolean isOwnView(org.eclipse.gmf.runtime.notation.View view) { |
|
362 return «EXPAND xpt::editor::VisualIDRegistry::modelID FOR editorGen.diagram».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall FOR editorGen.diagram»(view)); |
|
363 } |
|
364 |
|
365 «EXPAND xpt::Common::generatedMemberComment» |
|
366 private java.util.Collection createNavigatorItems(java.util.Collection views, Object parent, boolean isLeafs) { |
|
367 java.util.Collection result = new java.util.ArrayList(); |
|
368 for (java.util.Iterator it = views.iterator(); it.hasNext();) { |
|
369 result.add(new «getNavigatorItemQualifiedClassName()»((org.eclipse.gmf.runtime.notation.View) it.next(), parent, isLeafs)); |
|
370 } |
|
371 return result; |
|
372 } |
|
373 «EXPAND getForeignShortcuts-» |
|
374 «ENDDEFINE» |
|
375 |
|
376 «DEFINE getTypeByVID FOR gmfgen::GenDiagram-» |
|
377 String type = «EXPAND xpt::editor::VisualIDRegistry::getTypeMethodCall»(visualID); |
|
378 «ENDDEFINE» |
|
379 |
|
380 «DEFINE getType(String varName) FOR gmfgen::GenDiagram»«EXPAND xpt::editor::VisualIDRegistry::getTypeMethodCall»(«varName»)«ENDDEFINE» |
|
381 |
|
382 «DEFINE getForeignShortcuts FOR gmfgen::GenNavigator-» |
|
383 «IF editorGen.diagram.generateCreateShortcutAction() && getChildReferencesFrom(this, editorGen.diagram).size() > 0-» |
|
384 |
|
385 «EXPAND xpt::Common::generatedMemberComment» |
|
386 private java.util.Collection getForeignShortcuts(org.eclipse.gmf.runtime.notation.Diagram diagram, Object parent) { |
|
387 java.util.Collection result = new java.util.ArrayList(); |
|
388 for (java.util.Iterator it = diagram.getChildren().iterator(); it.hasNext();) { |
|
389 org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next(); |
|
390 if (!isOwnView(nextView) && nextView.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS» |
|
391 result.add(nextView); |
|
392 } |
|
393 } |
|
394 return createNavigatorItems(result, parent, false); |
|
395 } |
|
396 «ENDIF-» |
|
397 «ENDDEFINE» |
|
398 |
|
399 «DEFINE createEditingDomain FOR gmfgen::GenNavigator»org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain()«ENDDEFINE» |
|
400 |
|
401 «DEFINE initGroupVariables(gmfgen::GenNavigator navigator, List[gmfgen::GenNavigatorChildReference] references, String parentVarName, gmfgen::GenCommonBase contextElement) FOR String-» |
|
402 «navigator.getNavigatorGroupQualifiedClassName()» «asValidJavaIdentifier(this)» = new «navigator.getNavigatorGroupQualifiedClassName()»( |
|
403 «EXPAND xpt::Externalizer::accessorCall(i18nKeyForGroup(this, contextElement)) FOR navigator.editorGen», |
|
404 "«getNavigatorReference(this, references).groupIcon»", «parentVarName»); «EXPAND xpt::Common::nonNLS» |
|
405 «ENDDEFINE» |
|
406 |
|
407 «DEFINE addNavigatorItemsPrefix FOR gmfgen::GenNavigatorChildReference»«IF isInsideGroup()»«asValidJavaIdentifier(groupName)».addChildren(«ELSE»result.addAll(«ENDIF»createNavigatorItems(«ENDDEFINE» |
|
408 |
|
409 «DEFINE addNavigatorItemsSuffix(String parentVarName, Boolean isLeaf) FOR gmfgen::GenNavigatorChildReference-» |
|
410 , «IF isInsideGroup()»«asValidJavaIdentifier(groupName)»«ELSE»«parentVarName»«ENDIF», «isLeaf»)); |
|
411 «ENDDEFINE» |
|
412 |
|
413 «DEFINE addGroups(List[gmfgen::GenNavigatorChildReference] references) FOR String-» |
|
414 «LET getNavigatorReference(this, references) AS ref-» |
|
415 «IF ref.hideIfEmpty-» |
|
416 if (!«asValidJavaIdentifier(this)».isEmpty()) {«ENDIF-» |
|
417 result.add(«asValidJavaIdentifier(this)»); |
|
418 «IF ref.hideIfEmpty-» |
|
419 }«ENDIF-» |
|
420 «ENDLET-» |
|
421 «ENDDEFINE» |
|
422 |
|
423 «DEFINE getChildViewType FOR gmfgen::GenDiagram»«EXPAND xpt::editor::VisualIDRegistry::modelID»«ENDDEFINE» |
|
424 |
|
425 «DEFINE getChildViewType FOR gmfgen::GenCommonBase»«EXPAND xpt::editor::VisualIDRegistry::getTypeMethodCall FOR getDiagram()»(«EXPAND xpt::editor::VisualIDRegistry::visualID»)«ENDDEFINE» |
|
426 |
|
427 «DEFINE caseNavigatorNode(gmfgen::GenNavigator navigator) FOR gmfgen::GenCommonBase» |
|
428 «EXPAND xpt::Common::caseVisualID» { |
|
429 java.util.Collection result = new java.util.ArrayList(); |
|
430 «EXPAND addForeignShortcuts FOR this-» |
|
431 «LET getChildReferencesFrom(navigator, this) AS references-» |
|
432 «EXPAND initGroupVariables(navigator, references, 'parentElement', this) FOREACH getGroupNames(references)-» |
|
433 «FOREACH references AS reference ITERATOR referencesIterator-» |
|
434 «FOREACH reference.findConnectionPaths() AS path ITERATOR pathsIterator-» |
|
435 «FOREACH path.segments AS segment ITERATOR segmentsIterator-» |
|
436 «IF referencesIterator.isFirstIteration() && pathsIterator.isFirstIteration() && segmentsIterator.isFirstIteration()»java.util.Collection «ENDIF-» |
|
437 connectedViews = «EXPAND childrenMethodName(reference.referenceType, segment) FOR segment.from-» |
|
438 («IF segmentsIterator.isFirstIteration()»java.util.Collections.singleton(view)«ELSE»connectedViews«ENDIF-» |
|
439 , «EXPAND xpt::editor::VisualIDRegistry::visualID FOR segment.to»); |
|
440 «ENDFOREACH-» |
|
441 «EXPAND addNavigatorItemsPrefix FOR reference»connectedViews«EXPAND addNavigatorItemsSuffix('parentElement', reference.referenceType.value != gmfgen::GenNavigatorReferenceType::children.value) FOR reference-» |
|
442 «ENDFOREACH-» |
|
443 «ENDFOREACH-» |
|
444 «EXPAND addGroups(references) FOREACH getGroupNames(references)-» |
|
445 «ENDLET-» |
|
446 return result.toArray(); |
|
447 } |
|
448 «ENDDEFINE» |
|
449 |
|
450 «DEFINE addForeignShortcuts FOR gmfgen::GenDiagram-» |
|
451 «IF generateCreateShortcutAction()-» |
|
452 result.addAll(getForeignShortcuts((org.eclipse.gmf.runtime.notation.Diagram) view, parentElement)); |
|
453 «ENDIF-» |
|
454 «ENDDEFINE» |
|
455 |
|
456 «DEFINE addForeignShortcuts FOR gmfgen::GenCommonBase»«ENDDEFINE» |
|
457 |
|
458 «DEFINE childrenMethodName(gmfgen::GenNavigatorReferenceType referenceType, gmfgen::GenNavigatorPathSegment segment) FOR gmfgen::GenLink-» |
|
459 «IF referenceType.value == gmfgen::GenNavigatorReferenceType::out_target.value»getLinksTargetByType«ELSE»getLinksSourceByType«ENDIF-» |
|
460 «ENDDEFINE» |
|
461 |
|
462 «DEFINE childrenMethodName(gmfgen::GenNavigatorReferenceType referenceType, gmfgen::GenNavigatorPathSegment segment) FOR gmfgen::GenCommonBase-» |
|
463 «IF referenceType.value == gmfgen::GenNavigatorReferenceType::out_target.value-» |
|
464 getOutgoingLinksByType«ELSEIF referenceType.value == gmfgen::GenNavigatorReferenceType::in_source.value-» |
|
465 getIncomingLinksByType«ELSE-» |
|
466 «IF {segment.from}.typeSelect(gmfgen::GenDiagram).size() > 0 && {segment.to}.typeSelect(gmfgen::GenLink).size() > 0-» |
|
467 getDiagramLinksByType«ELSE-» |
|
468 getChildrenByType«ENDIF-» |
|
469 «ENDIF-» |
|
470 «ENDDEFINE» |
|
471 |
|
472 «DEFINE additions FOR gmfgen::GenNavigator-» |
|
473 «ENDDEFINE» |
|
474 |
|
475 «DEFINE i18nAccessors FOR gmfgen::GenNavigator-» |
|
476 «LET getChildReferencesFrom(this, null) AS references-» |
|
477 «EXPAND internal_i18nAccessors(null) FOREACH getGroupNames(references)-» |
|
478 «ENDLET-» |
|
479 «FOREACH getNavigatorContainerNodes(this) AS contextElement-» |
|
480 «LET getChildReferencesFrom(this, contextElement) AS references-» |
|
481 «EXPAND internal_i18nAccessors(contextElement) FOREACH getGroupNames(references)-» |
|
482 «ENDLET-» |
|
483 «ENDFOREACH-» |
|
484 «ENDDEFINE» |
|
485 |
|
486 «DEFINE internal_i18nAccessors(gmfgen::GenCommonBase contextElement) FOR String-» |
|
487 «IF null != this»«EXPAND xpt::Externalizer::accessorField(i18nKeyForGroup(contextElement))»«ENDIF-» |
|
488 «ENDDEFINE» |
|
489 |
|
490 «DEFINE i18nValues FOR gmfgen::GenNavigator-» |
|
491 «LET getChildReferencesFrom(this, null) AS references-» |
|
492 «EXPAND internal_i18nValues(null) FOREACH getGroupNames(references)-» |
|
493 «ENDLET-» |
|
494 «FOREACH getNavigatorContainerNodes(this) AS contextElement-» |
|
495 «LET getChildReferencesFrom(this, contextElement) AS references-» |
|
496 «EXPAND internal_i18nValues(contextElement) FOREACH getGroupNames(references)-» |
|
497 «ENDLET-» |
|
498 «ENDFOREACH-» |
|
499 «ENDDEFINE» |
|
500 |
|
501 «DEFINE internal_i18nValues(gmfgen::GenCommonBase contextElement) FOR String-» |
|
502 «IF null != this»«EXPAND xpt::Externalizer::messageEntry(i18nKeyForGroup(contextElement), this)»«ENDIF-» |
|
503 «ENDDEFINE» |