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