1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTTemplate.provider; |
8 | |
9 | import QVTTemplate.util.QVTTemplateAdapterFactory; |
10 | |
11 | import java.util.ArrayList; |
12 | import java.util.Collection; |
13 | |
14 | import org.eclipse.emf.common.notify.Adapter; |
15 | import org.eclipse.emf.common.notify.Notification; |
16 | import org.eclipse.emf.common.notify.Notifier; |
17 | |
18 | import org.eclipse.emf.edit.provider.ChangeNotifier; |
19 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
20 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
21 | import org.eclipse.emf.edit.provider.IChangeNotifier; |
22 | import org.eclipse.emf.edit.provider.IDisposable; |
23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
25 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
26 | import org.eclipse.emf.edit.provider.INotifyChangedListener; |
27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
29 | |
30 | /** |
31 | * This is the factory that is used to provide the interfaces needed to support Viewers. |
32 | * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. |
33 | * The adapters also support Eclipse property sheets. |
34 | * Note that most of the adapters are shared among multiple instances. |
35 | * <!-- begin-user-doc --> |
36 | * <!-- end-user-doc --> |
37 | * @generated |
38 | */ |
39 | public class QVTTemplateItemProviderAdapterFactory extends QVTTemplateAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { |
40 | /** |
41 | * This keeps track of the root adapter factory that delegates to this adapter factory. |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @generated |
45 | */ |
46 | protected ComposedAdapterFactory parentAdapterFactory; |
47 | |
48 | /** |
49 | * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | protected IChangeNotifier changeNotifier = new ChangeNotifier(); |
55 | |
56 | /** |
57 | * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | protected Collection<Object> supportedTypes = new ArrayList<Object>(); |
63 | |
64 | /** |
65 | * This constructs an instance. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | public QVTTemplateItemProviderAdapterFactory() { |
71 | supportedTypes.add(IEditingDomainItemProvider.class); |
72 | supportedTypes.add(IStructuredItemContentProvider.class); |
73 | supportedTypes.add(ITreeItemContentProvider.class); |
74 | supportedTypes.add(IItemLabelProvider.class); |
75 | supportedTypes.add(IItemPropertySource.class); |
76 | } |
77 | |
78 | /** |
79 | * This keeps track of the one adapter used for all {@link QVTTemplate.CollectionTemplateExp} instances. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected CollectionTemplateExpItemProvider collectionTemplateExpItemProvider; |
85 | |
86 | /** |
87 | * This creates an adapter for a {@link QVTTemplate.CollectionTemplateExp}. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | public Adapter createCollectionTemplateExpAdapter() { |
94 | if (collectionTemplateExpItemProvider == null) { |
95 | collectionTemplateExpItemProvider = new CollectionTemplateExpItemProvider(this); |
96 | } |
97 | |
98 | return collectionTemplateExpItemProvider; |
99 | } |
100 | |
101 | /** |
102 | * This keeps track of the one adapter used for all {@link QVTTemplate.ObjectTemplateExp} instances. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | protected ObjectTemplateExpItemProvider objectTemplateExpItemProvider; |
108 | |
109 | /** |
110 | * This creates an adapter for a {@link QVTTemplate.ObjectTemplateExp}. |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | @Override |
116 | public Adapter createObjectTemplateExpAdapter() { |
117 | if (objectTemplateExpItemProvider == null) { |
118 | objectTemplateExpItemProvider = new ObjectTemplateExpItemProvider(this); |
119 | } |
120 | |
121 | return objectTemplateExpItemProvider; |
122 | } |
123 | |
124 | /** |
125 | * This keeps track of the one adapter used for all {@link QVTTemplate.PropertyTemplateItem} instances. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | protected PropertyTemplateItemItemProvider propertyTemplateItemItemProvider; |
131 | |
132 | /** |
133 | * This creates an adapter for a {@link QVTTemplate.PropertyTemplateItem}. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Adapter createPropertyTemplateItemAdapter() { |
140 | if (propertyTemplateItemItemProvider == null) { |
141 | propertyTemplateItemItemProvider = new PropertyTemplateItemItemProvider(this); |
142 | } |
143 | |
144 | return propertyTemplateItemItemProvider; |
145 | } |
146 | |
147 | /** |
148 | * This returns the root adapter factory that contains this factory. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | public ComposeableAdapterFactory getRootAdapterFactory() { |
154 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
155 | } |
156 | |
157 | /** |
158 | * This sets the composed adapter factory that contains this factory. |
159 | * <!-- begin-user-doc --> |
160 | * <!-- end-user-doc --> |
161 | * @generated |
162 | */ |
163 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
164 | this.parentAdapterFactory = parentAdapterFactory; |
165 | } |
166 | |
167 | /** |
168 | * <!-- begin-user-doc --> |
169 | * <!-- end-user-doc --> |
170 | * @generated |
171 | */ |
172 | @Override |
173 | public boolean isFactoryForType(Object type) { |
174 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
175 | } |
176 | |
177 | /** |
178 | * This implementation substitutes the factory itself as the key for the adapter. |
179 | * <!-- begin-user-doc --> |
180 | * <!-- end-user-doc --> |
181 | * @generated |
182 | */ |
183 | @Override |
184 | public Adapter adapt(Notifier notifier, Object type) { |
185 | return super.adapt(notifier, this); |
186 | } |
187 | |
188 | /** |
189 | * <!-- begin-user-doc --> |
190 | * <!-- end-user-doc --> |
191 | * @generated |
192 | */ |
193 | @Override |
194 | public Object adapt(Object object, Object type) { |
195 | if (isFactoryForType(type)) { |
196 | Object adapter = super.adapt(object, type); |
197 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
198 | return adapter; |
199 | } |
200 | } |
201 | |
202 | return null; |
203 | } |
204 | |
205 | /** |
206 | * This adds a listener. |
207 | * <!-- begin-user-doc --> |
208 | * <!-- end-user-doc --> |
209 | * @generated |
210 | */ |
211 | public void addListener(INotifyChangedListener notifyChangedListener) { |
212 | changeNotifier.addListener(notifyChangedListener); |
213 | } |
214 | |
215 | /** |
216 | * This removes a listener. |
217 | * <!-- begin-user-doc --> |
218 | * <!-- end-user-doc --> |
219 | * @generated |
220 | */ |
221 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
222 | changeNotifier.removeListener(notifyChangedListener); |
223 | } |
224 | |
225 | /** |
226 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
227 | * <!-- begin-user-doc --> |
228 | * <!-- end-user-doc --> |
229 | * @generated |
230 | */ |
231 | public void fireNotifyChanged(Notification notification) { |
232 | changeNotifier.fireNotifyChanged(notification); |
233 | |
234 | if (parentAdapterFactory != null) { |
235 | parentAdapterFactory.fireNotifyChanged(notification); |
236 | } |
237 | } |
238 | |
239 | /** |
240 | * This disposes all of the item providers created by this factory. |
241 | * <!-- begin-user-doc --> |
242 | * <!-- end-user-doc --> |
243 | * @generated |
244 | */ |
245 | public void dispose() { |
246 | if (collectionTemplateExpItemProvider != null) collectionTemplateExpItemProvider.dispose(); |
247 | if (objectTemplateExpItemProvider != null) objectTemplateExpItemProvider.dispose(); |
248 | if (propertyTemplateItemItemProvider != null) propertyTemplateItemItemProvider.dispose(); |
249 | } |
250 | |
251 | } |