001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: RenderItemProviderAdapterFactory.java 21423 2006-09-14 19:17:05Z jeichar $
006: */package net.refractions.udig.project.internal.render.provider;
007:
008: import java.util.ArrayList;
009: import java.util.Collection;
010:
011: import net.refractions.udig.project.internal.render.util.RenderAdapterFactory;
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. The
029: * adapters generated by this factory convert EMF adapter notifications into calls to
030: * {@link #fireNotifyChanged fireNotifyChanged}. The adapters also support Eclipse property sheets.
031: * Note that most of the adapters are shared among multiple instances. <!-- begin-user-doc --> <!--
032: * end-user-doc -->
033: *
034: * @generated
035: */
036: public class RenderItemProviderAdapterFactory extends
037: RenderAdapterFactory implements ComposeableAdapterFactory,
038: IChangeNotifier {
039: /**
040: * <!-- begin-user-doc --> <!-- end-user-doc -->
041: *
042: * @generated
043: */
044: 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$
045:
046: /**
047: * This keeps track of the root adapter factory that delegates to this adapter factory. <!--
048: * begin-user-doc --> <!-- end-user-doc -->
049: *
050: * @generated
051: */
052: protected ComposedAdapterFactory parentAdapterFactory;
053:
054: /**
055: * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. <!--
056: * begin-user-doc --> <!-- end-user-doc -->
057: *
058: * @generated
059: */
060: protected IChangeNotifier changeNotifier = new ChangeNotifier();
061:
062: /**
063: * This keeps track of all the supported types checked by
064: * {@link #isFactoryForType isFactoryForType}. <!-- begin-user-doc --> <!-- end-user-doc -->
065: *
066: * @generated
067: */
068: protected Collection supportedTypes = new ArrayList();
069:
070: /**
071: * This constructs an instance. <!-- begin-user-doc --> <!-- end-user-doc -->
072: *
073: * @generated
074: */
075: public RenderItemProviderAdapterFactory() {
076: supportedTypes.add(IEditingDomainItemProvider.class);
077: supportedTypes.add(IStructuredItemContentProvider.class);
078: supportedTypes.add(ITreeItemContentProvider.class);
079: supportedTypes.add(IItemLabelProvider.class);
080: supportedTypes.add(IItemPropertySource.class);
081: }
082:
083: /**
084: * This keeps track of the one adapter used for all
085: * {@link net.refractions.udig.project.internal.render.RenderManager} instances. <!--
086: * begin-user-doc --> <!-- end-user-doc -->
087: *
088: * @generated
089: */
090: protected RenderManagerItemProvider renderManagerItemProvider;
091:
092: /**
093: * This creates an adapter for a
094: * {@link net.refractions.udig.project.internal.render.RenderManager}. <!-- begin-user-doc -->
095: * <!-- end-user-doc -->
096: *
097: * @generated
098: */
099: public Adapter createRenderManagerAdapter() {
100: if (renderManagerItemProvider == null) {
101: renderManagerItemProvider = new RenderManagerItemProvider(
102: this );
103: }
104:
105: return renderManagerItemProvider;
106: }
107:
108: /**
109: * This keeps track of the one adapter used for all
110: * {@link net.refractions.udig.project.internal.render.Style} instances. <!-- begin-user-doc -->
111: * <!-- end-user-doc -->
112: *
113: * @generated
114: */
115: protected StyleItemProvider styleItemProvider;
116:
117: /**
118: * This creates an adapter for a {@link net.refractions.udig.project.internal.render.Style}.
119: * <!-- begin-user-doc --> <!-- end-user-doc -->
120: *
121: * @generated
122: */
123: public Adapter createStyleAdapter() {
124: if (styleItemProvider == null) {
125: styleItemProvider = new StyleItemProvider(this );
126: }
127:
128: return styleItemProvider;
129: }
130:
131: /**
132: * This keeps track of the one adapter used for all
133: * {@link net.refractions.udig.project.internal.render.ViewportModel} instances. <!--
134: * begin-user-doc --> <!-- end-user-doc -->
135: *
136: * @generated
137: */
138: protected ViewportModelItemProvider viewportModelItemProvider;
139:
140: /**
141: * This creates an adapter for a
142: * {@link net.refractions.udig.project.internal.render.ViewportModel}. <!-- begin-user-doc -->
143: * <!-- end-user-doc -->
144: *
145: * @generated
146: */
147: public Adapter createViewportModelAdapter() {
148: if (viewportModelItemProvider == null) {
149: viewportModelItemProvider = new ViewportModelItemProvider(
150: this );
151: }
152:
153: return viewportModelItemProvider;
154: }
155:
156: /**
157: * This keeps track of the one adapter used for all
158: * {@link net.refractions.udig.project.internal.render.RenderExecutor} instances. <!--
159: * begin-user-doc --> <!-- end-user-doc -->
160: *
161: * @generated
162: */
163: protected RenderExecutorItemProvider renderExecutorItemProvider;
164:
165: /**
166: * This creates an adapter for a
167: * {@link net.refractions.udig.project.internal.render.RenderExecutor}. <!-- begin-user-doc -->
168: * <!-- end-user-doc -->
169: *
170: * @generated
171: */
172: public Adapter createRenderExecutorAdapter() {
173: if (renderExecutorItemProvider == null) {
174: renderExecutorItemProvider = new RenderExecutorItemProvider(
175: this );
176: }
177:
178: return renderExecutorItemProvider;
179: }
180:
181: /**
182: * This returns the root adapter factory that contains this factory. <!-- begin-user-doc -->
183: * <!-- end-user-doc -->
184: *
185: * @generated
186: */
187: public ComposeableAdapterFactory getRootAdapterFactory() {
188: return parentAdapterFactory == null ? this
189: : parentAdapterFactory.getRootAdapterFactory();
190: }
191:
192: /**
193: * This sets the composed adapter factory that contains this factory. <!-- begin-user-doc -->
194: * <!-- end-user-doc -->
195: *
196: * @generated
197: */
198: public void setParentAdapterFactory(
199: ComposedAdapterFactory parentAdapterFactory) {
200: this .parentAdapterFactory = parentAdapterFactory;
201: }
202:
203: /**
204: * <!-- begin-user-doc --> <!-- end-user-doc -->
205: *
206: * @generated
207: */
208: public boolean isFactoryForType(Object type) {
209: return supportedTypes.contains(type)
210: || super .isFactoryForType(type);
211: }
212:
213: /**
214: * This implementation substitutes the factory itself as the key for the adapter. <!--
215: * begin-user-doc --> <!-- end-user-doc -->
216: *
217: * @generated
218: */
219: public Adapter adapt(Notifier notifier, Object type) {
220: return super .adapt(notifier, this );
221: }
222:
223: /**
224: * <!-- begin-user-doc --> <!-- end-user-doc -->
225: *
226: * @generated
227: */
228: public Object adapt(Object object, Object type) {
229: if (isFactoryForType(type)) {
230: Object adapter = super .adapt(object, type);
231: if (!(type instanceof Class)
232: || (((Class) type).isInstance(adapter))) {
233: return adapter;
234: }
235: }
236:
237: return null;
238: }
239:
240: /**
241: * This adds a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
242: *
243: * @generated
244: */
245: public void addListener(INotifyChangedListener notifyChangedListener) {
246: changeNotifier.addListener(notifyChangedListener);
247: }
248:
249: /**
250: * This removes a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
251: *
252: * @generated
253: */
254: public void removeListener(
255: INotifyChangedListener notifyChangedListener) {
256: changeNotifier.removeListener(notifyChangedListener);
257: }
258:
259: /**
260: * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. <!--
261: * begin-user-doc --> <!-- end-user-doc -->
262: *
263: * @generated
264: */
265: public void fireNotifyChanged(Notification notification) {
266: changeNotifier.fireNotifyChanged(notification);
267:
268: if (parentAdapterFactory != null) {
269: parentAdapterFactory.fireNotifyChanged(notification);
270: }
271: }
272:
273: }
|