1 | package de.uka.ipd.sdq.pcmbench.navigator; |
2 | |
3 | import org.eclipse.emf.common.notify.AdapterFactory; |
4 | import org.eclipse.emf.ecore.EObject; |
5 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
6 | import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; |
7 | import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; |
8 | import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; |
9 | import org.eclipse.jface.viewers.ILabelProvider; |
10 | import org.eclipse.jface.viewers.ILabelProviderListener; |
11 | import org.eclipse.swt.graphics.Image; |
12 | |
13 | import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory; |
14 | import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory; |
15 | import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory; |
16 | import de.uka.ipd.sdq.pcmbench.ui.provider.categoryaware.CategoryAwareItemProviderAdapterFactory; |
17 | import de.uka.ipd.sdq.pcmbench.ui.provider.categoryaware.PalladioCategoryDescriptions; |
18 | |
19 | public class PCMNavigatorLabelProvider implements ILabelProvider { |
20 | |
21 | private ComposedAdapterFactory adapterFactory; |
22 | private AdapterFactoryLabelProvider labelContentProvider; |
23 | |
24 | public PCMNavigatorLabelProvider() |
25 | { |
26 | adapterFactory = new ComposedAdapterFactory(); |
27 | adapterFactory |
28 | .addAdapterFactory(new ResourceItemProviderAdapterFactory()); |
29 | adapterFactory |
30 | .addAdapterFactory(new RepositoryItemProviderAdapterFactory()); |
31 | adapterFactory.addAdapterFactory(new SeffItemProviderAdapterFactory()); |
32 | adapterFactory |
33 | .addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); |
34 | |
35 | AdapterFactory palladioFactory = new PalladioItemProviderAdapterFactory(adapterFactory); |
36 | AdapterFactory decoratorFactory = new CategoryAwareItemProviderAdapterFactory(palladioFactory, new PalladioCategoryDescriptions()); |
37 | |
38 | labelContentProvider = new AdapterFactoryLabelProvider(decoratorFactory); |
39 | } |
40 | |
41 | public Image getImage(Object element) { |
42 | if (element instanceof EObject) |
43 | { |
44 | return labelContentProvider.getImage(element); |
45 | } |
46 | return null; |
47 | } |
48 | |
49 | public String getText(Object element) { |
50 | if (element instanceof LinkedRepositoriesNode) |
51 | { |
52 | return "Linked Repositories"; |
53 | } |
54 | return labelContentProvider.getText(element); |
55 | } |
56 | |
57 | public void addListener(ILabelProviderListener listener) { |
58 | labelContentProvider.addListener(listener); |
59 | } |
60 | |
61 | public void dispose() { |
62 | labelContentProvider.dispose(); |
63 | } |
64 | |
65 | public boolean isLabelProperty(Object element, String property) { |
66 | return true; |
67 | } |
68 | |
69 | public void removeListener(ILabelProviderListener listener) { |
70 | labelContentProvider.removeListener(listener); |
71 | } |
72 | |
73 | } |