001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ProjectItemProviderAdapterFactory.java 22387 2006-10-25 18:40:20Z jeichar $
006: */package net.refractions.udig.project.internal.provider;
007:
008: import java.util.ArrayList;
009: import java.util.Collection;
010:
011: import net.refractions.udig.project.internal.util.ProjectAdapterFactory;
012:
013: import org.eclipse.emf.common.notify.Adapter;
014: import org.eclipse.emf.common.notify.Notification;
015: import org.eclipse.emf.common.notify.Notifier;
016: import org.eclipse.emf.edit.provider.ChangeNotifier;
017: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
018: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
019: import org.eclipse.emf.edit.provider.IChangeNotifier;
020: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
021: import org.eclipse.emf.edit.provider.IItemLabelProvider;
022: import org.eclipse.emf.edit.provider.IItemPropertySource;
023: import org.eclipse.emf.edit.provider.INotifyChangedListener;
024: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
025: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
026:
027: /**
028: * This is the factory that is used to provide the interfaces needed to support Viewers.
029: * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
030: * The adapters also support Eclipse property sheets.
031: * Note that most of the adapters are shared among multiple instances.
032: * <!-- begin-user-doc --> <!--
033: * end-user-doc -->
034: * @generated
035: */
036: public class ProjectItemProviderAdapterFactory extends
037: ProjectAdapterFactory implements ComposeableAdapterFactory,
038: IChangeNotifier {
039: /**
040: * <!-- begin-user-doc --> <!-- end-user-doc -->
041: * @generated
042: */
043: public static final String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
044:
045: /**
046: * This keeps track of the root adapter factory that delegates to this adapter factory. <!--
047: * begin-user-doc --> <!-- end-user-doc -->
048: *
049: * @generated
050: */
051: protected ComposedAdapterFactory parentAdapterFactory;
052:
053: /**
054: * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. <!--
055: * begin-user-doc --> <!-- end-user-doc -->
056: *
057: * @generated
058: */
059: protected IChangeNotifier changeNotifier = new ChangeNotifier();
060:
061: /**
062: * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
063: * <!-- begin-user-doc --> <!-- end-user-doc -->
064: * @generated
065: */
066: protected Collection supportedTypes = new ArrayList();
067:
068: /**
069: * This constructs an instance.
070: * <!-- begin-user-doc --> <!-- end-user-doc -->
071: * @generated
072: */
073: public ProjectItemProviderAdapterFactory() {
074: supportedTypes.add(IEditingDomainItemProvider.class);
075: supportedTypes.add(IStructuredItemContentProvider.class);
076: supportedTypes.add(ITreeItemContentProvider.class);
077: supportedTypes.add(IItemLabelProvider.class);
078: supportedTypes.add(IItemPropertySource.class);
079: }
080:
081: /**
082: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.ContextModel} instances.
083: * <!-- begin-user-doc -->
084: * <!-- end-user-doc -->
085: * @generated
086: */
087: protected ContextModelItemProvider contextModelItemProvider;
088:
089: /**
090: * This creates an adapter for a {@link net.refractions.udig.project.internal.ContextModel}.
091: * <!-- begin-user-doc --> <!-- end-user-doc -->
092: * @generated
093: */
094: public Adapter createContextModelAdapter() {
095: if (contextModelItemProvider == null) {
096: contextModelItemProvider = new ContextModelItemProvider(
097: this );
098: }
099:
100: return contextModelItemProvider;
101: }
102:
103: /**
104: * This creates an adapter for a {@link net.refractions.udig.project.internal.Layer}. <!--
105: * begin-user-doc --> <!-- end-user-doc -->
106: *
107: * @generated
108: */
109: public Adapter createLayerAdapter() {
110: return new LayerItemProvider(this );
111: }
112:
113: /**
114: * This creates an adapter for a {@link net.refractions.udig.project.internal.Map}. <!--
115: * begin-user-doc --> <!-- end-user-doc -->
116: *
117: * @generated
118: */
119: public Adapter createMapAdapter() {
120: return new MapItemProvider(this );
121: }
122:
123: /**
124: * This creates an adapter for a {@link net.refractions.udig.project.internal.Project}. <!--
125: * begin-user-doc --> <!-- end-user-doc -->
126: *
127: * @generated
128: */
129: public Adapter createProjectAdapter() {
130: return new ProjectItemProvider(this );
131: }
132:
133: /**
134: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.ProjectRegistry} instances.
135: * <!-- begin-user-doc
136: * --> <!-- end-user-doc -->
137: * @generated
138: */
139: protected ProjectRegistryItemProvider projectRegistryItemProvider;
140:
141: /**
142: * This creates an adapter for a {@link net.refractions.udig.project.internal.ProjectRegistry}.
143: * <!-- begin-user-doc --> <!-- end-user-doc -->
144: * @generated
145: */
146: public Adapter createProjectRegistryAdapter() {
147: if (projectRegistryItemProvider == null) {
148: projectRegistryItemProvider = new ProjectRegistryItemProvider(
149: this );
150: }
151:
152: return projectRegistryItemProvider;
153: }
154:
155: /**
156: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.StyleBlackboard} instances.
157: * <!-- begin-user-doc
158: * --> <!-- end-user-doc -->
159: * @generated
160: */
161: protected StyleBlackboardItemProvider styleBlackboardItemProvider;
162:
163: /**
164: * This creates an adapter for a {@link net.refractions.udig.project.internal.StyleBlackboard}.
165: * <!-- begin-user-doc --> <!-- end-user-doc -->
166: * @generated
167: */
168: public Adapter createStyleBlackboardAdapter() {
169: if (styleBlackboardItemProvider == null) {
170: styleBlackboardItemProvider = new StyleBlackboardItemProvider(
171: this );
172: }
173:
174: return styleBlackboardItemProvider;
175: }
176:
177: /**
178: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.StyleEntry} instances.
179: * <!-- begin-user-doc -->
180: * <!-- end-user-doc -->
181: * @generated
182: */
183: protected StyleEntryItemProvider styleEntryItemProvider;
184:
185: /**
186: * This creates an adapter for a {@link net.refractions.udig.project.internal.StyleEntry}. <!--
187: * begin-user-doc --> <!-- end-user-doc -->
188: *
189: * @generated
190: */
191: public Adapter createStyleEntryAdapter() {
192: if (styleEntryItemProvider == null) {
193: styleEntryItemProvider = new StyleEntryItemProvider(this );
194: }
195:
196: return styleEntryItemProvider;
197: }
198:
199: /**
200: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.LayerFactory} instances.
201: * <!-- begin-user-doc -->
202: * <!-- end-user-doc -->
203: * @generated
204: */
205: protected LayerFactoryItemProvider layerFactoryItemProvider;
206:
207: /**
208: * This creates an adapter for a {@link net.refractions.udig.project.internal.LayerFactory}.
209: * <!-- begin-user-doc --> <!-- end-user-doc -->
210: * @generated
211: */
212: public Adapter createLayerFactoryAdapter() {
213: if (layerFactoryItemProvider == null) {
214: layerFactoryItemProvider = new LayerFactoryItemProvider(
215: this );
216: }
217:
218: return layerFactoryItemProvider;
219: }
220:
221: /**
222: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.PicoBlackboard} instances.
223: * <!-- begin-user-doc
224: * --> <!-- end-user-doc -->
225: * @generated
226: */
227: protected PicoBlackboardItemProvider picoBlackboardItemProvider;
228:
229: /**
230: * This creates an adapter for a {@link net.refractions.udig.project.internal.PicoBlackboard}.
231: * <!-- begin-user-doc --> <!-- end-user-doc -->
232: * @generated
233: */
234: public Adapter createPicoBlackboardAdapter() {
235: if (picoBlackboardItemProvider == null) {
236: picoBlackboardItemProvider = new PicoBlackboardItemProvider(
237: this );
238: }
239:
240: return picoBlackboardItemProvider;
241: }
242:
243: /**
244: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.Blackboard} instances.
245: * <!-- begin-user-doc -->
246: * <!-- end-user-doc -->
247: * @generated
248: */
249: protected BlackboardItemProvider blackboardItemProvider;
250:
251: /**
252: * This creates an adapter for a {@link net.refractions.udig.project.internal.Blackboard}. <!--
253: * begin-user-doc --> <!-- end-user-doc -->
254: *
255: * @generated
256: */
257: public Adapter createBlackboardAdapter() {
258: if (blackboardItemProvider == null) {
259: blackboardItemProvider = new BlackboardItemProvider(this );
260: }
261:
262: return blackboardItemProvider;
263: }
264:
265: /**
266: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.BlackboardEntry} instances.
267: * <!-- begin-user-doc
268: * --> <!-- end-user-doc -->
269: * @generated
270: */
271: protected BlackboardEntryItemProvider blackboardEntryItemProvider;
272:
273: /**
274: * This creates an adapter for a {@link net.refractions.udig.project.internal.BlackboardEntry}.
275: * <!-- begin-user-doc --> <!-- end-user-doc -->
276: * @generated
277: */
278: public Adapter createBlackboardEntryAdapter() {
279: if (blackboardEntryItemProvider == null) {
280: blackboardEntryItemProvider = new BlackboardEntryItemProvider(
281: this );
282: }
283:
284: return blackboardEntryItemProvider;
285: }
286:
287: /**
288: * This keeps track of the one adapter used for all {@link net.refractions.udig.project.internal.EditManager} instances.
289: * <!-- begin-user-doc -->
290: * <!-- end-user-doc -->
291: * @generated
292: */
293: protected EditManagerItemProvider editManagerItemProvider;
294:
295: /**
296: * This creates an adapter for a {@link net.refractions.udig.project.internal.EditManager}.
297: * <!-- begin-user-doc --> <!-- end-user-doc -->
298: * @generated
299: */
300: public Adapter createEditManagerAdapter() {
301: if (editManagerItemProvider == null) {
302: editManagerItemProvider = new EditManagerItemProvider(this );
303: }
304:
305: return editManagerItemProvider;
306: }
307:
308: /**
309: * This returns the root adapter factory that contains this factory.
310: * <!-- begin-user-doc -->
311: * <!-- end-user-doc -->
312: * @generated
313: */
314: public ComposeableAdapterFactory getRootAdapterFactory() {
315: return parentAdapterFactory == null ? this
316: : parentAdapterFactory.getRootAdapterFactory();
317: }
318:
319: /**
320: * This sets the composed adapter factory that contains this factory.
321: * <!-- begin-user-doc -->
322: * <!-- end-user-doc -->
323: * @generated
324: */
325: public void setParentAdapterFactory(
326: ComposedAdapterFactory parentAdapterFactory) {
327: this .parentAdapterFactory = parentAdapterFactory;
328: }
329:
330: /**
331: * <!-- begin-user-doc --> <!-- end-user-doc -->
332: * @generated
333: */
334: public boolean isFactoryForType(Object type) {
335: return supportedTypes.contains(type)
336: || super .isFactoryForType(type);
337: }
338:
339: /**
340: * This implementation substitutes the factory itself as the key for the adapter. <!--
341: * begin-user-doc --> <!-- end-user-doc -->
342: *
343: * @generated
344: */
345: public Adapter adapt(Notifier notifier, Object type) {
346: return super .adapt(notifier, this );
347: }
348:
349: /**
350: * <!-- begin-user-doc --> <!-- end-user-doc -->
351: * @generated
352: */
353: public Object adapt(Object object, Object type) {
354: if (isFactoryForType(type)) {
355: Object adapter = super .adapt(object, type);
356: if (!(type instanceof Class)
357: || (((Class) type).isInstance(adapter))) {
358: return adapter;
359: }
360: }
361:
362: return null;
363: }
364:
365: /**
366: * This adds a listener.
367: * <!-- begin-user-doc --> <!-- end-user-doc -->
368: * @generated
369: */
370: public void addListener(INotifyChangedListener notifyChangedListener) {
371: changeNotifier.addListener(notifyChangedListener);
372: }
373:
374: /**
375: * This removes a listener.
376: * <!-- begin-user-doc --> <!-- end-user-doc -->
377: * @generated
378: */
379: public void removeListener(
380: INotifyChangedListener notifyChangedListener) {
381: changeNotifier.removeListener(notifyChangedListener);
382: }
383:
384: /**
385: * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. <!--
386: * begin-user-doc --> <!-- end-user-doc -->
387: *
388: * @generated
389: */
390: public void fireNotifyChanged(Notification notification) {
391: changeNotifier.fireNotifyChanged(notification);
392:
393: if (parentAdapterFactory != null) {
394: parentAdapterFactory.fireNotifyChanged(notification);
395: }
396: }
397:
398: }
|