1 | /* |
2 | * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.composite.navigator; |
5 | |
6 | import java.util.ArrayList; |
7 | import java.util.Collection; |
8 | import java.util.Collections; |
9 | import java.util.HashMap; |
10 | import java.util.Iterator; |
11 | |
12 | import org.eclipse.core.resources.IFile; |
13 | import org.eclipse.emf.common.util.URI; |
14 | import org.eclipse.emf.ecore.resource.Resource; |
15 | import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; |
16 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
17 | import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; |
18 | import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; |
19 | import org.eclipse.gmf.runtime.notation.Diagram; |
20 | import org.eclipse.gmf.runtime.notation.Edge; |
21 | import org.eclipse.gmf.runtime.notation.View; |
22 | import org.eclipse.jface.viewers.Viewer; |
23 | import org.eclipse.ui.IMemento; |
24 | import org.eclipse.ui.navigator.ICommonContentExtensionSite; |
25 | import org.eclipse.ui.navigator.ICommonContentProvider; |
26 | |
27 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyConnectorEditPart; |
28 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyContextEditPart; |
29 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyEventConnectorEditPart; |
30 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyInfrastructureConnectorEditPart; |
31 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntity2EditPart; |
32 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart; |
33 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityEditPart; |
34 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureProvidedRoleEditPart; |
35 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureRequiredRoleEditPart; |
36 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRole2EditPart; |
37 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEditPart; |
38 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRole2EditPart; |
39 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEditPart; |
40 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ProvidedDelegationConnectorEditPart; |
41 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.RequiredDelegationConnectorEditPart; |
42 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SinkRoleEditPart; |
43 | import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SourceRoleEditPart; |
44 | import de.uka.ipd.sdq.pcm.gmf.composite.part.Messages; |
45 | import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry; |
46 | |
47 | /** |
48 | * @generated |
49 | */ |
50 | public class PalladioComponentModelNavigatorContentProvider implements |
51 | ICommonContentProvider { |
52 | |
53 | /** |
54 | * @generated |
55 | */ |
56 | private static final Object[] EMPTY_ARRAY = new Object[0]; |
57 | |
58 | /** |
59 | * @generated |
60 | */ |
61 | private Viewer myViewer; |
62 | |
63 | /** |
64 | * @generated |
65 | */ |
66 | private AdapterFactoryEditingDomain myEditingDomain; |
67 | |
68 | /** |
69 | * @generated |
70 | */ |
71 | private WorkspaceSynchronizer myWorkspaceSynchronizer; |
72 | |
73 | /** |
74 | * @generated |
75 | */ |
76 | private Runnable myViewerRefreshRunnable; |
77 | |
78 | /** |
79 | * @generated |
80 | */ |
81 | public PalladioComponentModelNavigatorContentProvider() { |
82 | TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE |
83 | .createEditingDomain(); |
84 | myEditingDomain = (AdapterFactoryEditingDomain) editingDomain; |
85 | myEditingDomain.setResourceToReadOnlyMap(new HashMap() { |
86 | public Object get(Object key) { |
87 | if (!containsKey(key)) { |
88 | put(key, Boolean.TRUE); |
89 | } |
90 | return super.get(key); |
91 | } |
92 | }); |
93 | myViewerRefreshRunnable = new Runnable() { |
94 | public void run() { |
95 | if (myViewer != null) { |
96 | myViewer.refresh(); |
97 | } |
98 | } |
99 | }; |
100 | myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, |
101 | new WorkspaceSynchronizer.Delegate() { |
102 | public void dispose() { |
103 | } |
104 | |
105 | public boolean handleResourceChanged(final Resource resource) { |
106 | for (Iterator it = myEditingDomain.getResourceSet() |
107 | .getResources().iterator(); it.hasNext();) { |
108 | Resource nextResource = (Resource) it.next(); |
109 | nextResource.unload(); |
110 | } |
111 | if (myViewer != null) { |
112 | myViewer.getControl().getDisplay().asyncExec( |
113 | myViewerRefreshRunnable); |
114 | } |
115 | return true; |
116 | } |
117 | |
118 | public boolean handleResourceDeleted(Resource resource) { |
119 | for (Iterator it = myEditingDomain.getResourceSet() |
120 | .getResources().iterator(); it.hasNext();) { |
121 | Resource nextResource = (Resource) it.next(); |
122 | nextResource.unload(); |
123 | } |
124 | if (myViewer != null) { |
125 | myViewer.getControl().getDisplay().asyncExec( |
126 | myViewerRefreshRunnable); |
127 | } |
128 | return true; |
129 | } |
130 | |
131 | public boolean handleResourceMoved(Resource resource, |
132 | final URI newURI) { |
133 | for (Iterator it = myEditingDomain.getResourceSet() |
134 | .getResources().iterator(); it.hasNext();) { |
135 | Resource nextResource = (Resource) it.next(); |
136 | nextResource.unload(); |
137 | } |
138 | if (myViewer != null) { |
139 | myViewer.getControl().getDisplay().asyncExec( |
140 | myViewerRefreshRunnable); |
141 | } |
142 | return true; |
143 | } |
144 | }); |
145 | } |
146 | |
147 | /** |
148 | * @generated |
149 | */ |
150 | public void dispose() { |
151 | myWorkspaceSynchronizer.dispose(); |
152 | myWorkspaceSynchronizer = null; |
153 | myViewerRefreshRunnable = null; |
154 | for (Iterator it = myEditingDomain.getResourceSet().getResources() |
155 | .iterator(); it.hasNext();) { |
156 | Resource resource = (Resource) it.next(); |
157 | resource.unload(); |
158 | } |
159 | ((TransactionalEditingDomain) myEditingDomain).dispose(); |
160 | myEditingDomain = null; |
161 | } |
162 | |
163 | /** |
164 | * @generated |
165 | */ |
166 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
167 | myViewer = viewer; |
168 | } |
169 | |
170 | /** |
171 | * @generated |
172 | */ |
173 | public Object[] getElements(Object inputElement) { |
174 | return getChildren(inputElement); |
175 | } |
176 | |
177 | /** |
178 | * @generated |
179 | */ |
180 | public void restoreState(IMemento aMemento) { |
181 | } |
182 | |
183 | /** |
184 | * @generated |
185 | */ |
186 | public void saveState(IMemento aMemento) { |
187 | } |
188 | |
189 | /** |
190 | * @generated |
191 | */ |
192 | public void init(ICommonContentExtensionSite aConfig) { |
193 | } |
194 | |
195 | /** |
196 | * @generated |
197 | */ |
198 | public Object[] getChildren(Object parentElement) { |
199 | if (parentElement instanceof IFile) { |
200 | IFile file = (IFile) parentElement; |
201 | URI fileURI = URI.createPlatformResourceURI(file.getFullPath() |
202 | .toString(), true); |
203 | Resource resource = myEditingDomain.getResourceSet().getResource( |
204 | fileURI, true); |
205 | Collection result = new ArrayList(); |
206 | result.addAll(createNavigatorItems(selectViewsByType(resource |
207 | .getContents(), |
208 | ComposedProvidingRequiringEntityEditPart.MODEL_ID), file, |
209 | false)); |
210 | return result.toArray(); |
211 | } |
212 | |
213 | if (parentElement instanceof PalladioComponentModelNavigatorGroup) { |
214 | PalladioComponentModelNavigatorGroup group = (PalladioComponentModelNavigatorGroup) parentElement; |
215 | return group.getChildren(); |
216 | } |
217 | |
218 | if (parentElement instanceof PalladioComponentModelNavigatorItem) { |
219 | PalladioComponentModelNavigatorItem navigatorItem = (PalladioComponentModelNavigatorItem) parentElement; |
220 | if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) { |
221 | return EMPTY_ARRAY; |
222 | } |
223 | return getViewChildren(navigatorItem.getView(), parentElement); |
224 | } |
225 | |
226 | return EMPTY_ARRAY; |
227 | } |
228 | |
229 | /** |
230 | * @generated |
231 | */ |
232 | private Object[] getViewChildren(View view, Object parentElement) { |
233 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
234 | |
235 | case ComposedProvidingRequiringEntityEditPart.VISUAL_ID: { |
236 | Collection result = new ArrayList(); |
237 | PalladioComponentModelNavigatorGroup links = new PalladioComponentModelNavigatorGroup( |
238 | Messages.NavigatorGroupName_ComposedProvidingRequiringEntity_1000_links, |
239 | "icons/linksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
240 | Collection connectedViews = getChildrenByType( |
241 | Collections.singleton(view), |
242 | PalladioComponentModelVisualIDRegistry |
243 | .getType(ComposedProvidingRequiringEntity2EditPart.VISUAL_ID)); |
244 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
245 | false)); |
246 | connectedViews = getDiagramLinksByType(Collections.singleton(view), |
247 | PalladioComponentModelVisualIDRegistry |
248 | .getType(AssemblyConnectorEditPart.VISUAL_ID)); |
249 | links |
250 | .addChildren(createNavigatorItems(connectedViews, links, |
251 | false)); |
252 | connectedViews = getDiagramLinksByType(Collections.singleton(view), |
253 | PalladioComponentModelVisualIDRegistry |
254 | .getType(AssemblyEventConnectorEditPart.VISUAL_ID)); |
255 | links |
256 | .addChildren(createNavigatorItems(connectedViews, links, |
257 | false)); |
258 | connectedViews = getDiagramLinksByType( |
259 | Collections.singleton(view), |
260 | PalladioComponentModelVisualIDRegistry |
261 | .getType(RequiredDelegationConnectorEditPart.VISUAL_ID)); |
262 | links |
263 | .addChildren(createNavigatorItems(connectedViews, links, |
264 | false)); |
265 | connectedViews = getDiagramLinksByType( |
266 | Collections.singleton(view), |
267 | PalladioComponentModelVisualIDRegistry |
268 | .getType(ProvidedDelegationConnectorEditPart.VISUAL_ID)); |
269 | links |
270 | .addChildren(createNavigatorItems(connectedViews, links, |
271 | false)); |
272 | connectedViews = getDiagramLinksByType( |
273 | Collections.singleton(view), |
274 | PalladioComponentModelVisualIDRegistry |
275 | .getType(AssemblyInfrastructureConnectorEditPart.VISUAL_ID)); |
276 | links |
277 | .addChildren(createNavigatorItems(connectedViews, links, |
278 | false)); |
279 | if (!links.isEmpty()) { |
280 | result.add(links); |
281 | } |
282 | return result.toArray(); |
283 | } |
284 | |
285 | case ComposedProvidingRequiringEntity2EditPart.VISUAL_ID: { |
286 | Collection result = new ArrayList(); |
287 | Collection connectedViews = getChildrenByType( |
288 | Collections.singleton(view), |
289 | PalladioComponentModelVisualIDRegistry |
290 | .getType(ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart.VISUAL_ID)); |
291 | connectedViews = getChildrenByType(connectedViews, |
292 | PalladioComponentModelVisualIDRegistry |
293 | .getType(AssemblyContextEditPart.VISUAL_ID)); |
294 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
295 | false)); |
296 | connectedViews = getChildrenByType(Collections.singleton(view), |
297 | PalladioComponentModelVisualIDRegistry |
298 | .getType(OperationProvidedRole2EditPart.VISUAL_ID)); |
299 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
300 | false)); |
301 | connectedViews = getChildrenByType(Collections.singleton(view), |
302 | PalladioComponentModelVisualIDRegistry |
303 | .getType(OperationRequiredRole2EditPart.VISUAL_ID)); |
304 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
305 | false)); |
306 | return result.toArray(); |
307 | } |
308 | |
309 | case AssemblyContextEditPart.VISUAL_ID: { |
310 | Collection result = new ArrayList(); |
311 | Collection connectedViews = getChildrenByType(Collections |
312 | .singleton(view), PalladioComponentModelVisualIDRegistry |
313 | .getType(OperationProvidedRoleEditPart.VISUAL_ID)); |
314 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
315 | false)); |
316 | connectedViews = getChildrenByType(Collections.singleton(view), |
317 | PalladioComponentModelVisualIDRegistry |
318 | .getType(OperationRequiredRoleEditPart.VISUAL_ID)); |
319 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
320 | false)); |
321 | connectedViews = getChildrenByType(Collections.singleton(view), |
322 | PalladioComponentModelVisualIDRegistry |
323 | .getType(SourceRoleEditPart.VISUAL_ID)); |
324 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
325 | false)); |
326 | connectedViews = getChildrenByType(Collections.singleton(view), |
327 | PalladioComponentModelVisualIDRegistry |
328 | .getType(SinkRoleEditPart.VISUAL_ID)); |
329 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
330 | false)); |
331 | connectedViews = getChildrenByType( |
332 | Collections.singleton(view), |
333 | PalladioComponentModelVisualIDRegistry |
334 | .getType(InfrastructureProvidedRoleEditPart.VISUAL_ID)); |
335 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
336 | false)); |
337 | connectedViews = getChildrenByType( |
338 | Collections.singleton(view), |
339 | PalladioComponentModelVisualIDRegistry |
340 | .getType(InfrastructureRequiredRoleEditPart.VISUAL_ID)); |
341 | result.addAll(createNavigatorItems(connectedViews, parentElement, |
342 | false)); |
343 | return result.toArray(); |
344 | } |
345 | |
346 | case OperationProvidedRoleEditPart.VISUAL_ID: { |
347 | Collection result = new ArrayList(); |
348 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
349 | Messages.NavigatorGroupName_OperationProvidedRole_3007_incominglinks, |
350 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
351 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
352 | Messages.NavigatorGroupName_OperationProvidedRole_3007_outgoinglinks, |
353 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
354 | Collection connectedViews = getIncomingLinksByType(Collections |
355 | .singleton(view), PalladioComponentModelVisualIDRegistry |
356 | .getType(AssemblyConnectorEditPart.VISUAL_ID)); |
357 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
358 | incominglinks, true)); |
359 | connectedViews = getIncomingLinksByType( |
360 | Collections.singleton(view), |
361 | PalladioComponentModelVisualIDRegistry |
362 | .getType(ProvidedDelegationConnectorEditPart.VISUAL_ID)); |
363 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
364 | incominglinks, true)); |
365 | connectedViews = getOutgoingLinksByType( |
366 | Collections.singleton(view), |
367 | PalladioComponentModelVisualIDRegistry |
368 | .getType(ProvidedDelegationConnectorEditPart.VISUAL_ID)); |
369 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
370 | outgoinglinks, true)); |
371 | if (!incominglinks.isEmpty()) { |
372 | result.add(incominglinks); |
373 | } |
374 | if (!outgoinglinks.isEmpty()) { |
375 | result.add(outgoinglinks); |
376 | } |
377 | return result.toArray(); |
378 | } |
379 | |
380 | case OperationRequiredRoleEditPart.VISUAL_ID: { |
381 | Collection result = new ArrayList(); |
382 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
383 | Messages.NavigatorGroupName_OperationRequiredRole_3008_outgoinglinks, |
384 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
385 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
386 | Messages.NavigatorGroupName_OperationRequiredRole_3008_incominglinks, |
387 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
388 | Collection connectedViews = getOutgoingLinksByType(Collections |
389 | .singleton(view), PalladioComponentModelVisualIDRegistry |
390 | .getType(AssemblyConnectorEditPart.VISUAL_ID)); |
391 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
392 | outgoinglinks, true)); |
393 | connectedViews = getIncomingLinksByType( |
394 | Collections.singleton(view), |
395 | PalladioComponentModelVisualIDRegistry |
396 | .getType(RequiredDelegationConnectorEditPart.VISUAL_ID)); |
397 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
398 | incominglinks, true)); |
399 | connectedViews = getOutgoingLinksByType( |
400 | Collections.singleton(view), |
401 | PalladioComponentModelVisualIDRegistry |
402 | .getType(RequiredDelegationConnectorEditPart.VISUAL_ID)); |
403 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
404 | outgoinglinks, true)); |
405 | if (!outgoinglinks.isEmpty()) { |
406 | result.add(outgoinglinks); |
407 | } |
408 | if (!incominglinks.isEmpty()) { |
409 | result.add(incominglinks); |
410 | } |
411 | return result.toArray(); |
412 | } |
413 | |
414 | case SourceRoleEditPart.VISUAL_ID: { |
415 | Collection result = new ArrayList(); |
416 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
417 | Messages.NavigatorGroupName_SourceRole_3013_outgoinglinks, |
418 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
419 | Collection connectedViews = getOutgoingLinksByType(Collections |
420 | .singleton(view), PalladioComponentModelVisualIDRegistry |
421 | .getType(AssemblyEventConnectorEditPart.VISUAL_ID)); |
422 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
423 | outgoinglinks, true)); |
424 | if (!outgoinglinks.isEmpty()) { |
425 | result.add(outgoinglinks); |
426 | } |
427 | return result.toArray(); |
428 | } |
429 | |
430 | case SinkRoleEditPart.VISUAL_ID: { |
431 | Collection result = new ArrayList(); |
432 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
433 | Messages.NavigatorGroupName_SinkRole_3014_incominglinks, |
434 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
435 | Collection connectedViews = getIncomingLinksByType(Collections |
436 | .singleton(view), PalladioComponentModelVisualIDRegistry |
437 | .getType(AssemblyEventConnectorEditPart.VISUAL_ID)); |
438 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
439 | incominglinks, true)); |
440 | if (!incominglinks.isEmpty()) { |
441 | result.add(incominglinks); |
442 | } |
443 | return result.toArray(); |
444 | } |
445 | |
446 | case InfrastructureProvidedRoleEditPart.VISUAL_ID: { |
447 | Collection result = new ArrayList(); |
448 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
449 | Messages.NavigatorGroupName_InfrastructureProvidedRole_3015_incominglinks, |
450 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
451 | Collection connectedViews = getIncomingLinksByType(Collections |
452 | .singleton(view), PalladioComponentModelVisualIDRegistry |
453 | .getType(AssemblyInfrastructureConnectorEditPart.VISUAL_ID)); |
454 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
455 | incominglinks, true)); |
456 | if (!incominglinks.isEmpty()) { |
457 | result.add(incominglinks); |
458 | } |
459 | return result.toArray(); |
460 | } |
461 | |
462 | case InfrastructureRequiredRoleEditPart.VISUAL_ID: { |
463 | Collection result = new ArrayList(); |
464 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
465 | Messages.NavigatorGroupName_InfrastructureRequiredRole_3016_outgoinglinks, |
466 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
467 | Collection connectedViews = getOutgoingLinksByType(Collections |
468 | .singleton(view), PalladioComponentModelVisualIDRegistry |
469 | .getType(AssemblyInfrastructureConnectorEditPart.VISUAL_ID)); |
470 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
471 | outgoinglinks, true)); |
472 | if (!outgoinglinks.isEmpty()) { |
473 | result.add(outgoinglinks); |
474 | } |
475 | return result.toArray(); |
476 | } |
477 | |
478 | case OperationProvidedRole2EditPart.VISUAL_ID: { |
479 | Collection result = new ArrayList(); |
480 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
481 | Messages.NavigatorGroupName_OperationProvidedRole_3011_incominglinks, |
482 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
483 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
484 | Messages.NavigatorGroupName_OperationProvidedRole_3011_outgoinglinks, |
485 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
486 | Collection connectedViews = getIncomingLinksByType(Collections |
487 | .singleton(view), PalladioComponentModelVisualIDRegistry |
488 | .getType(AssemblyConnectorEditPart.VISUAL_ID)); |
489 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
490 | incominglinks, true)); |
491 | connectedViews = getIncomingLinksByType( |
492 | Collections.singleton(view), |
493 | PalladioComponentModelVisualIDRegistry |
494 | .getType(ProvidedDelegationConnectorEditPart.VISUAL_ID)); |
495 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
496 | incominglinks, true)); |
497 | connectedViews = getOutgoingLinksByType( |
498 | Collections.singleton(view), |
499 | PalladioComponentModelVisualIDRegistry |
500 | .getType(ProvidedDelegationConnectorEditPart.VISUAL_ID)); |
501 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
502 | outgoinglinks, true)); |
503 | if (!incominglinks.isEmpty()) { |
504 | result.add(incominglinks); |
505 | } |
506 | if (!outgoinglinks.isEmpty()) { |
507 | result.add(outgoinglinks); |
508 | } |
509 | return result.toArray(); |
510 | } |
511 | |
512 | case OperationRequiredRole2EditPart.VISUAL_ID: { |
513 | Collection result = new ArrayList(); |
514 | PalladioComponentModelNavigatorGroup outgoinglinks = new PalladioComponentModelNavigatorGroup( |
515 | Messages.NavigatorGroupName_OperationRequiredRole_3012_outgoinglinks, |
516 | "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
517 | PalladioComponentModelNavigatorGroup incominglinks = new PalladioComponentModelNavigatorGroup( |
518 | Messages.NavigatorGroupName_OperationRequiredRole_3012_incominglinks, |
519 | "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
520 | Collection connectedViews = getOutgoingLinksByType(Collections |
521 | .singleton(view), PalladioComponentModelVisualIDRegistry |
522 | .getType(AssemblyConnectorEditPart.VISUAL_ID)); |
523 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
524 | outgoinglinks, true)); |
525 | connectedViews = getIncomingLinksByType( |
526 | Collections.singleton(view), |
527 | PalladioComponentModelVisualIDRegistry |
528 | .getType(RequiredDelegationConnectorEditPart.VISUAL_ID)); |
529 | incominglinks.addChildren(createNavigatorItems(connectedViews, |
530 | incominglinks, true)); |
531 | connectedViews = getOutgoingLinksByType( |
532 | Collections.singleton(view), |
533 | PalladioComponentModelVisualIDRegistry |
534 | .getType(RequiredDelegationConnectorEditPart.VISUAL_ID)); |
535 | outgoinglinks.addChildren(createNavigatorItems(connectedViews, |
536 | outgoinglinks, true)); |
537 | if (!outgoinglinks.isEmpty()) { |
538 | result.add(outgoinglinks); |
539 | } |
540 | if (!incominglinks.isEmpty()) { |
541 | result.add(incominglinks); |
542 | } |
543 | return result.toArray(); |
544 | } |
545 | |
546 | case AssemblyConnectorEditPart.VISUAL_ID: { |
547 | Collection result = new ArrayList(); |
548 | PalladioComponentModelNavigatorGroup target = new PalladioComponentModelNavigatorGroup( |
549 | Messages.NavigatorGroupName_AssemblyConnector_4004_target, |
550 | "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
551 | PalladioComponentModelNavigatorGroup source = new PalladioComponentModelNavigatorGroup( |
552 | Messages.NavigatorGroupName_AssemblyConnector_4004_source, |
553 | "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
554 | Collection connectedViews = getLinksTargetByType(Collections |
555 | .singleton(view), PalladioComponentModelVisualIDRegistry |
556 | .getType(OperationProvidedRoleEditPart.VISUAL_ID)); |
557 | target.addChildren(createNavigatorItems(connectedViews, target, |
558 | true)); |
559 | connectedViews = getLinksTargetByType(Collections.singleton(view), |
560 | PalladioComponentModelVisualIDRegistry |
561 | .getType(OperationProvidedRole2EditPart.VISUAL_ID)); |
562 | target.addChildren(createNavigatorItems(connectedViews, target, |
563 | true)); |
564 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
565 | PalladioComponentModelVisualIDRegistry |
566 | .getType(OperationRequiredRoleEditPart.VISUAL_ID)); |
567 | source.addChildren(createNavigatorItems(connectedViews, source, |
568 | true)); |
569 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
570 | PalladioComponentModelVisualIDRegistry |
571 | .getType(OperationRequiredRole2EditPart.VISUAL_ID)); |
572 | source.addChildren(createNavigatorItems(connectedViews, source, |
573 | true)); |
574 | if (!target.isEmpty()) { |
575 | result.add(target); |
576 | } |
577 | if (!source.isEmpty()) { |
578 | result.add(source); |
579 | } |
580 | return result.toArray(); |
581 | } |
582 | |
583 | case AssemblyEventConnectorEditPart.VISUAL_ID: { |
584 | Collection result = new ArrayList(); |
585 | PalladioComponentModelNavigatorGroup target = new PalladioComponentModelNavigatorGroup( |
586 | Messages.NavigatorGroupName_AssemblyEventConnector_4007_target, |
587 | "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
588 | PalladioComponentModelNavigatorGroup source = new PalladioComponentModelNavigatorGroup( |
589 | Messages.NavigatorGroupName_AssemblyEventConnector_4007_source, |
590 | "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
591 | Collection connectedViews = getLinksTargetByType(Collections |
592 | .singleton(view), PalladioComponentModelVisualIDRegistry |
593 | .getType(SinkRoleEditPart.VISUAL_ID)); |
594 | target.addChildren(createNavigatorItems(connectedViews, target, |
595 | true)); |
596 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
597 | PalladioComponentModelVisualIDRegistry |
598 | .getType(SourceRoleEditPart.VISUAL_ID)); |
599 | source.addChildren(createNavigatorItems(connectedViews, source, |
600 | true)); |
601 | if (!target.isEmpty()) { |
602 | result.add(target); |
603 | } |
604 | if (!source.isEmpty()) { |
605 | result.add(source); |
606 | } |
607 | return result.toArray(); |
608 | } |
609 | |
610 | case RequiredDelegationConnectorEditPart.VISUAL_ID: { |
611 | Collection result = new ArrayList(); |
612 | PalladioComponentModelNavigatorGroup target = new PalladioComponentModelNavigatorGroup( |
613 | Messages.NavigatorGroupName_RequiredDelegationConnector_4005_target, |
614 | "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
615 | PalladioComponentModelNavigatorGroup source = new PalladioComponentModelNavigatorGroup( |
616 | Messages.NavigatorGroupName_RequiredDelegationConnector_4005_source, |
617 | "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
618 | Collection connectedViews = getLinksTargetByType(Collections |
619 | .singleton(view), PalladioComponentModelVisualIDRegistry |
620 | .getType(OperationRequiredRoleEditPart.VISUAL_ID)); |
621 | target.addChildren(createNavigatorItems(connectedViews, target, |
622 | true)); |
623 | connectedViews = getLinksTargetByType(Collections.singleton(view), |
624 | PalladioComponentModelVisualIDRegistry |
625 | .getType(OperationRequiredRole2EditPart.VISUAL_ID)); |
626 | target.addChildren(createNavigatorItems(connectedViews, target, |
627 | true)); |
628 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
629 | PalladioComponentModelVisualIDRegistry |
630 | .getType(OperationRequiredRoleEditPart.VISUAL_ID)); |
631 | source.addChildren(createNavigatorItems(connectedViews, source, |
632 | true)); |
633 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
634 | PalladioComponentModelVisualIDRegistry |
635 | .getType(OperationRequiredRole2EditPart.VISUAL_ID)); |
636 | source.addChildren(createNavigatorItems(connectedViews, source, |
637 | true)); |
638 | if (!target.isEmpty()) { |
639 | result.add(target); |
640 | } |
641 | if (!source.isEmpty()) { |
642 | result.add(source); |
643 | } |
644 | return result.toArray(); |
645 | } |
646 | |
647 | case ProvidedDelegationConnectorEditPart.VISUAL_ID: { |
648 | Collection result = new ArrayList(); |
649 | PalladioComponentModelNavigatorGroup target = new PalladioComponentModelNavigatorGroup( |
650 | Messages.NavigatorGroupName_ProvidedDelegationConnector_4006_target, |
651 | "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
652 | PalladioComponentModelNavigatorGroup source = new PalladioComponentModelNavigatorGroup( |
653 | Messages.NavigatorGroupName_ProvidedDelegationConnector_4006_source, |
654 | "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
655 | Collection connectedViews = getLinksTargetByType(Collections |
656 | .singleton(view), PalladioComponentModelVisualIDRegistry |
657 | .getType(OperationProvidedRoleEditPart.VISUAL_ID)); |
658 | target.addChildren(createNavigatorItems(connectedViews, target, |
659 | true)); |
660 | connectedViews = getLinksTargetByType(Collections.singleton(view), |
661 | PalladioComponentModelVisualIDRegistry |
662 | .getType(OperationProvidedRole2EditPart.VISUAL_ID)); |
663 | target.addChildren(createNavigatorItems(connectedViews, target, |
664 | true)); |
665 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
666 | PalladioComponentModelVisualIDRegistry |
667 | .getType(OperationProvidedRoleEditPart.VISUAL_ID)); |
668 | source.addChildren(createNavigatorItems(connectedViews, source, |
669 | true)); |
670 | connectedViews = getLinksSourceByType(Collections.singleton(view), |
671 | PalladioComponentModelVisualIDRegistry |
672 | .getType(OperationProvidedRole2EditPart.VISUAL_ID)); |
673 | source.addChildren(createNavigatorItems(connectedViews, source, |
674 | true)); |
675 | if (!target.isEmpty()) { |
676 | result.add(target); |
677 | } |
678 | if (!source.isEmpty()) { |
679 | result.add(source); |
680 | } |
681 | return result.toArray(); |
682 | } |
683 | |
684 | case AssemblyInfrastructureConnectorEditPart.VISUAL_ID: { |
685 | Collection result = new ArrayList(); |
686 | PalladioComponentModelNavigatorGroup target = new PalladioComponentModelNavigatorGroup( |
687 | Messages.NavigatorGroupName_AssemblyInfrastructureConnector_4008_target, |
688 | "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
689 | PalladioComponentModelNavigatorGroup source = new PalladioComponentModelNavigatorGroup( |
690 | Messages.NavigatorGroupName_AssemblyInfrastructureConnector_4008_source, |
691 | "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ |
692 | Collection connectedViews = getLinksTargetByType(Collections |
693 | .singleton(view), PalladioComponentModelVisualIDRegistry |
694 | .getType(InfrastructureProvidedRoleEditPart.VISUAL_ID)); |
695 | target.addChildren(createNavigatorItems(connectedViews, target, |
696 | true)); |
697 | connectedViews = getLinksSourceByType( |
698 | Collections.singleton(view), |
699 | PalladioComponentModelVisualIDRegistry |
700 | .getType(InfrastructureRequiredRoleEditPart.VISUAL_ID)); |
701 | source.addChildren(createNavigatorItems(connectedViews, source, |
702 | true)); |
703 | if (!target.isEmpty()) { |
704 | result.add(target); |
705 | } |
706 | if (!source.isEmpty()) { |
707 | result.add(source); |
708 | } |
709 | return result.toArray(); |
710 | } |
711 | } |
712 | return EMPTY_ARRAY; |
713 | } |
714 | |
715 | /** |
716 | * @generated |
717 | */ |
718 | private Collection getLinksSourceByType(Collection edges, String type) { |
719 | Collection result = new ArrayList(); |
720 | for (Iterator it = edges.iterator(); it.hasNext();) { |
721 | Edge nextEdge = (Edge) it.next(); |
722 | View nextEdgeSource = nextEdge.getSource(); |
723 | if (type.equals(nextEdgeSource.getType()) |
724 | && isOwnView(nextEdgeSource)) { |
725 | result.add(nextEdgeSource); |
726 | } |
727 | } |
728 | return result; |
729 | } |
730 | |
731 | /** |
732 | * @generated |
733 | */ |
734 | private Collection getLinksTargetByType(Collection edges, String type) { |
735 | Collection result = new ArrayList(); |
736 | for (Iterator it = edges.iterator(); it.hasNext();) { |
737 | Edge nextEdge = (Edge) it.next(); |
738 | View nextEdgeTarget = nextEdge.getTarget(); |
739 | if (type.equals(nextEdgeTarget.getType()) |
740 | && isOwnView(nextEdgeTarget)) { |
741 | result.add(nextEdgeTarget); |
742 | } |
743 | } |
744 | return result; |
745 | } |
746 | |
747 | /** |
748 | * @generated |
749 | */ |
750 | private Collection getOutgoingLinksByType(Collection nodes, String type) { |
751 | Collection result = new ArrayList(); |
752 | for (Iterator it = nodes.iterator(); it.hasNext();) { |
753 | View nextNode = (View) it.next(); |
754 | result.addAll(selectViewsByType(nextNode.getSourceEdges(), type)); |
755 | } |
756 | return result; |
757 | } |
758 | |
759 | /** |
760 | * @generated |
761 | */ |
762 | private Collection getIncomingLinksByType(Collection nodes, String type) { |
763 | Collection result = new ArrayList(); |
764 | for (Iterator it = nodes.iterator(); it.hasNext();) { |
765 | View nextNode = (View) it.next(); |
766 | result.addAll(selectViewsByType(nextNode.getTargetEdges(), type)); |
767 | } |
768 | return result; |
769 | } |
770 | |
771 | /** |
772 | * @generated |
773 | */ |
774 | private Collection getChildrenByType(Collection nodes, String type) { |
775 | Collection result = new ArrayList(); |
776 | for (Iterator it = nodes.iterator(); it.hasNext();) { |
777 | View nextNode = (View) it.next(); |
778 | result.addAll(selectViewsByType(nextNode.getChildren(), type)); |
779 | } |
780 | return result; |
781 | } |
782 | |
783 | /** |
784 | * @generated |
785 | */ |
786 | private Collection getDiagramLinksByType(Collection diagrams, String type) { |
787 | Collection result = new ArrayList(); |
788 | for (Iterator it = diagrams.iterator(); it.hasNext();) { |
789 | Diagram nextDiagram = (Diagram) it.next(); |
790 | result.addAll(selectViewsByType(nextDiagram.getEdges(), type)); |
791 | } |
792 | return result; |
793 | } |
794 | |
795 | /** |
796 | * @generated |
797 | */ |
798 | private Collection selectViewsByType(Collection views, String type) { |
799 | Collection result = new ArrayList(); |
800 | for (Iterator it = views.iterator(); it.hasNext();) { |
801 | View nextView = (View) it.next(); |
802 | if (type.equals(nextView.getType()) && isOwnView(nextView)) { |
803 | result.add(nextView); |
804 | } |
805 | } |
806 | return result; |
807 | } |
808 | |
809 | /** |
810 | * @generated |
811 | */ |
812 | private boolean isOwnView(View view) { |
813 | return ComposedProvidingRequiringEntityEditPart.MODEL_ID |
814 | .equals(PalladioComponentModelVisualIDRegistry.getModelID(view)); |
815 | } |
816 | |
817 | /** |
818 | * @generated |
819 | */ |
820 | private Collection createNavigatorItems(Collection views, Object parent, |
821 | boolean isLeafs) { |
822 | Collection result = new ArrayList(); |
823 | for (Iterator it = views.iterator(); it.hasNext();) { |
824 | result.add(new PalladioComponentModelNavigatorItem( |
825 | (View) it.next(), parent, isLeafs)); |
826 | } |
827 | return result; |
828 | } |
829 | |
830 | /** |
831 | * @generated |
832 | */ |
833 | public Object getParent(Object element) { |
834 | if (element instanceof PalladioComponentModelAbstractNavigatorItem) { |
835 | PalladioComponentModelAbstractNavigatorItem abstractNavigatorItem = (PalladioComponentModelAbstractNavigatorItem) element; |
836 | return abstractNavigatorItem.getParent(); |
837 | } |
838 | return null; |
839 | } |
840 | |
841 | /** |
842 | * @generated |
843 | */ |
844 | public boolean hasChildren(Object element) { |
845 | return element instanceof IFile || getChildren(element).length > 0; |
846 | } |
847 | |
848 | } |