1 | package de.uka.ipd.sdq.pcmbench.tabs.generic; |
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 | import org.eclipse.emf.edit.provider.ItemProviderDecorator; |
10 | |
11 | import de.uka.ipd.sdq.pcmbench.tabs.operations.OperationsTabItemProvider; |
12 | |
13 | public class TabItemProviderAdapterFactory<T extends ItemProviderDecorator> extends |
14 | DecoratorAdapterFactory { |
15 | |
16 | public TabItemProviderAdapterFactory(AdapterFactory decoratedAdapterFactory) { |
17 | super(decoratedAdapterFactory); |
18 | } |
19 | |
20 | |
21 | /* (non-Javadoc) |
22 | * @see org.eclipse.emf.edit.provider.DecoratorAdapterFactory#createItemProviderDecorator(java.lang.Object, java.lang.Object) |
23 | */ |
24 | @Override |
25 | protected IItemProviderDecorator createItemProviderDecorator(Object target, |
26 | Object type) { |
27 | IItemProviderDecorator decorator = new OperationsTabItemProvider(this); |
28 | if (type == ITableItemLabelProvider.class) { |
29 | decorator |
30 | .setDecoratedItemProvider((IChangeNotifier) decoratedAdapterFactory |
31 | .adapt(target, IItemLabelProvider.class)); |
32 | } else { |
33 | decorator |
34 | .setDecoratedItemProvider((IChangeNotifier) decoratedAdapterFactory |
35 | .adapt(target, type)); |
36 | } |
37 | return decorator; |
38 | } |
39 | |
40 | /* (non-Javadoc) |
41 | * @see org.eclipse.emf.edit.provider.DecoratorAdapterFactory#adapt(java.lang.Object, java.lang.Object) |
42 | */ |
43 | @Override |
44 | public Object adapt(Object target, Object type) { |
45 | if (type == ITableItemLabelProvider.class) |
46 | return createItemProviderDecorator(target, type); |
47 | return super.adapt(target, type); |
48 | } |
49 | |
50 | // private T getItemProviderDecorator(Class<T> decoratorClass, ){ |
51 | // try { |
52 | // return decoratorClass.; |
53 | // } catch (InstantiationException e) { |
54 | // // TODO Auto-generated catch block |
55 | // e.printStackTrace(); |
56 | // } catch (IllegalAccessException e) { |
57 | // // TODO Auto-generated catch block |
58 | // e.printStackTrace(); |
59 | // } |
60 | // } |
61 | |
62 | } |