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