1 | package de.uka.ipd.sdq.pcmbench.tabs.operations; |
2 | |
3 | import org.eclipse.emf.common.notify.AdapterFactory; |
4 | import org.eclipse.emf.edit.provider.DecoratorAdapterFactory; |
5 | import org.eclipse.emf.edit.provider.IChangeNotifier; |
6 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
7 | import org.eclipse.emf.edit.provider.IItemProviderDecorator; |
8 | import org.eclipse.emf.edit.provider.ITableItemLabelProvider; |
9 | |
10 | /** |
11 | * Factory for an event types tab item provider adapter. |
12 | * This is can be used as an input for EMF AdapterFactoryLabelProviders |
13 | * to create an event type item provider. |
14 | * |
15 | * @author Benjamin Klatt |
16 | * |
17 | */ |
18 | public class EventTypesTabItemProviderAdapterFactory extends |
19 | DecoratorAdapterFactory { |
20 | |
21 | public EventTypesTabItemProviderAdapterFactory(AdapterFactory adapterFactory) { |
22 | super(adapterFactory); |
23 | } |
24 | |
25 | @Override |
26 | protected IItemProviderDecorator createItemProviderDecorator(Object target, |
27 | Object type) { |
28 | IItemProviderDecorator decorator = new EventTypesTabItemProvider(this); |
29 | if (type == ITableItemLabelProvider.class) { |
30 | decorator |
31 | .setDecoratedItemProvider((IChangeNotifier) decoratedAdapterFactory |
32 | .adapt(target, IItemLabelProvider.class)); |
33 | } else { |
34 | decorator |
35 | .setDecoratedItemProvider((IChangeNotifier) decoratedAdapterFactory |
36 | .adapt(target, type)); |
37 | } |
38 | return decorator; |
39 | } |
40 | |
41 | @Override |
42 | public Object adapt(Object target, Object type) { |
43 | if (type == ITableItemLabelProvider.class) |
44 | return createItemProviderDecorator(target, type); |
45 | return super.adapt(target, type); |
46 | } |
47 | } |