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