1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.protocol.provider; |
7 | |
8 | import java.util.ArrayList; |
9 | import java.util.Collection; |
10 | |
11 | import org.eclipse.emf.common.notify.Adapter; |
12 | import org.eclipse.emf.common.notify.Notification; |
13 | import org.eclipse.emf.common.notify.Notifier; |
14 | import org.eclipse.emf.edit.provider.ChangeNotifier; |
15 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
16 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
17 | import org.eclipse.emf.edit.provider.IChangeNotifier; |
18 | import org.eclipse.emf.edit.provider.IDisposable; |
19 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
20 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
21 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
22 | import org.eclipse.emf.edit.provider.INotifyChangedListener; |
23 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
24 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
25 | |
26 | import de.uka.ipd.sdq.pcm.protocol.util.ProtocolAdapterFactory; |
27 | |
28 | /** |
29 | * This is the factory that is used to provide the interfaces needed to support Viewers. |
30 | * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. |
31 | * The adapters also support Eclipse property sheets. |
32 | * Note that most of the adapters are shared among multiple instances. |
33 | * <!-- begin-user-doc --> |
34 | * <!-- end-user-doc --> |
35 | * @generated |
36 | */ |
37 | public class ProtocolItemProviderAdapterFactory extends ProtocolAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { |
38 | /** |
39 | * <!-- begin-user-doc --> |
40 | * <!-- end-user-doc --> |
41 | * @generated |
42 | */ |
43 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
44 | |
45 | /** |
46 | * This keeps track of the root adapter factory that delegates to this adapter factory. |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | protected ComposedAdapterFactory parentAdapterFactory; |
52 | |
53 | /** |
54 | * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @generated |
58 | */ |
59 | protected IChangeNotifier changeNotifier = new ChangeNotifier(); |
60 | |
61 | /** |
62 | * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @generated |
66 | */ |
67 | protected Collection<Object> supportedTypes = new ArrayList<Object>(); |
68 | |
69 | /** |
70 | * This constructs an instance. |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @generated |
74 | */ |
75 | public ProtocolItemProviderAdapterFactory() { |
76 | supportedTypes.add(IEditingDomainItemProvider.class); |
77 | supportedTypes.add(IStructuredItemContentProvider.class); |
78 | supportedTypes.add(ITreeItemContentProvider.class); |
79 | supportedTypes.add(IItemLabelProvider.class); |
80 | supportedTypes.add(IItemPropertySource.class); |
81 | } |
82 | |
83 | /** |
84 | * This returns the root adapter factory that contains this factory. |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @generated |
88 | */ |
89 | public ComposeableAdapterFactory getRootAdapterFactory() { |
90 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
91 | } |
92 | |
93 | /** |
94 | * This sets the composed adapter factory that contains this factory. |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
100 | this.parentAdapterFactory = parentAdapterFactory; |
101 | } |
102 | |
103 | /** |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @generated |
107 | */ |
108 | @Override |
109 | public boolean isFactoryForType(Object type) { |
110 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
111 | } |
112 | |
113 | /** |
114 | * This implementation substitutes the factory itself as the key for the adapter. |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | @Override |
120 | public Adapter adapt(Notifier notifier, Object type) { |
121 | return super.adapt(notifier, this); |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | @Override |
130 | public Object adapt(Object object, Object type) { |
131 | if (isFactoryForType(type)) { |
132 | Object adapter = super.adapt(object, type); |
133 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
134 | return adapter; |
135 | } |
136 | } |
137 | |
138 | return null; |
139 | } |
140 | |
141 | /** |
142 | * This adds a listener. |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | public void addListener(INotifyChangedListener notifyChangedListener) { |
148 | changeNotifier.addListener(notifyChangedListener); |
149 | } |
150 | |
151 | /** |
152 | * This removes a listener. |
153 | * <!-- begin-user-doc --> |
154 | * <!-- end-user-doc --> |
155 | * @generated |
156 | */ |
157 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
158 | changeNotifier.removeListener(notifyChangedListener); |
159 | } |
160 | |
161 | /** |
162 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
163 | * <!-- begin-user-doc --> |
164 | * <!-- end-user-doc --> |
165 | * @generated |
166 | */ |
167 | public void fireNotifyChanged(Notification notification) { |
168 | changeNotifier.fireNotifyChanged(notification); |
169 | |
170 | if (parentAdapterFactory != null) { |
171 | parentAdapterFactory.fireNotifyChanged(notification); |
172 | } |
173 | } |
174 | |
175 | /** |
176 | * This disposes all of the item providers created by this factory. |
177 | * <!-- begin-user-doc --> |
178 | * <!-- end-user-doc --> |
179 | * @generated |
180 | */ |
181 | public void dispose() { |
182 | } |
183 | |
184 | } |