1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.allocation.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.allocation.util.AllocationAdapterFactory; |
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 AllocationItemProviderAdapterFactory extends AllocationAdapterFactory 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 AllocationItemProviderAdapterFactory() { |
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 keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.allocation.AllocationContext} instances. |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @generated |
88 | */ |
89 | protected AllocationContextItemProvider allocationContextItemProvider; |
90 | |
91 | /** |
92 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.allocation.AllocationContext}. |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | @Override |
98 | public Adapter createAllocationContextAdapter() { |
99 | if (allocationContextItemProvider == null) { |
100 | allocationContextItemProvider = new AllocationContextItemProvider(this); |
101 | } |
102 | |
103 | return allocationContextItemProvider; |
104 | } |
105 | |
106 | /** |
107 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.allocation.Allocation} instances. |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | protected AllocationItemProvider allocationItemProvider; |
113 | |
114 | /** |
115 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.allocation.Allocation}. |
116 | * <!-- begin-user-doc --> |
117 | * <!-- end-user-doc --> |
118 | * @generated |
119 | */ |
120 | @Override |
121 | public Adapter createAllocationAdapter() { |
122 | if (allocationItemProvider == null) { |
123 | allocationItemProvider = new AllocationItemProvider(this); |
124 | } |
125 | |
126 | return allocationItemProvider; |
127 | } |
128 | |
129 | /** |
130 | * This returns the root adapter factory that contains this factory. |
131 | * <!-- begin-user-doc --> |
132 | * <!-- end-user-doc --> |
133 | * @generated |
134 | */ |
135 | public ComposeableAdapterFactory getRootAdapterFactory() { |
136 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
137 | } |
138 | |
139 | /** |
140 | * This sets the composed adapter factory that contains this factory. |
141 | * <!-- begin-user-doc --> |
142 | * <!-- end-user-doc --> |
143 | * @generated |
144 | */ |
145 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
146 | this.parentAdapterFactory = parentAdapterFactory; |
147 | } |
148 | |
149 | /** |
150 | * <!-- begin-user-doc --> |
151 | * <!-- end-user-doc --> |
152 | * @generated |
153 | */ |
154 | @Override |
155 | public boolean isFactoryForType(Object type) { |
156 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
157 | } |
158 | |
159 | /** |
160 | * This implementation substitutes the factory itself as the key for the adapter. |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | @Override |
166 | public Adapter adapt(Notifier notifier, Object type) { |
167 | return super.adapt(notifier, this); |
168 | } |
169 | |
170 | /** |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | @Override |
176 | public Object adapt(Object object, Object type) { |
177 | if (isFactoryForType(type)) { |
178 | Object adapter = super.adapt(object, type); |
179 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
180 | return adapter; |
181 | } |
182 | } |
183 | |
184 | return null; |
185 | } |
186 | |
187 | /** |
188 | * This adds a listener. |
189 | * <!-- begin-user-doc --> |
190 | * <!-- end-user-doc --> |
191 | * @generated |
192 | */ |
193 | public void addListener(INotifyChangedListener notifyChangedListener) { |
194 | changeNotifier.addListener(notifyChangedListener); |
195 | } |
196 | |
197 | /** |
198 | * This removes a listener. |
199 | * <!-- begin-user-doc --> |
200 | * <!-- end-user-doc --> |
201 | * @generated |
202 | */ |
203 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
204 | changeNotifier.removeListener(notifyChangedListener); |
205 | } |
206 | |
207 | /** |
208 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
209 | * <!-- begin-user-doc --> |
210 | * <!-- end-user-doc --> |
211 | * @generated |
212 | */ |
213 | public void fireNotifyChanged(Notification notification) { |
214 | changeNotifier.fireNotifyChanged(notification); |
215 | |
216 | if (parentAdapterFactory != null) { |
217 | parentAdapterFactory.fireNotifyChanged(notification); |
218 | } |
219 | } |
220 | |
221 | /** |
222 | * This disposes all of the item providers created by this factory. |
223 | * <!-- begin-user-doc --> |
224 | * <!-- end-user-doc --> |
225 | * @generated |
226 | */ |
227 | public void dispose() { |
228 | if (allocationContextItemProvider != null) allocationContextItemProvider.dispose(); |
229 | if (allocationItemProvider != null) allocationItemProvider.dispose(); |
230 | } |
231 | |
232 | } |