| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.identifier.provider; |
| 8 | |
| 9 | import de.uka.ipd.sdq.identifier.util.IdentifierAdapterFactory; |
| 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 IdentifierItemProviderAdapterFactory extends IdentifierAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { |
| 40 | /** |
| 41 | * <!-- begin-user-doc --> |
| 42 | * <!-- end-user-doc --> |
| 43 | * @generated |
| 44 | */ |
| 45 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 46 | |
| 47 | /** |
| 48 | * This keeps track of the root adapter factory that delegates to this adapter factory. |
| 49 | * <!-- begin-user-doc --> |
| 50 | * <!-- end-user-doc --> |
| 51 | * @generated |
| 52 | */ |
| 53 | protected ComposedAdapterFactory parentAdapterFactory; |
| 54 | |
| 55 | /** |
| 56 | * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. |
| 57 | * <!-- begin-user-doc --> |
| 58 | * <!-- end-user-doc --> |
| 59 | * @generated |
| 60 | */ |
| 61 | protected IChangeNotifier changeNotifier = new ChangeNotifier(); |
| 62 | |
| 63 | /** |
| 64 | * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @generated |
| 68 | */ |
| 69 | protected Collection<Object> supportedTypes = new ArrayList<Object>(); |
| 70 | |
| 71 | /** |
| 72 | * This constructs an instance. |
| 73 | * <!-- begin-user-doc --> |
| 74 | * <!-- end-user-doc --> |
| 75 | * @generated |
| 76 | */ |
| 77 | public IdentifierItemProviderAdapterFactory() { |
| 78 | supportedTypes.add(IEditingDomainItemProvider.class); |
| 79 | supportedTypes.add(IStructuredItemContentProvider.class); |
| 80 | supportedTypes.add(ITreeItemContentProvider.class); |
| 81 | supportedTypes.add(IItemLabelProvider.class); |
| 82 | supportedTypes.add(IItemPropertySource.class); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * This returns the root adapter factory that contains this factory. |
| 87 | * <!-- begin-user-doc --> |
| 88 | * <!-- end-user-doc --> |
| 89 | * @generated |
| 90 | */ |
| 91 | public ComposeableAdapterFactory getRootAdapterFactory() { |
| 92 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * This sets the composed adapter factory that contains this factory. |
| 97 | * <!-- begin-user-doc --> |
| 98 | * <!-- end-user-doc --> |
| 99 | * @generated |
| 100 | */ |
| 101 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
| 102 | this.parentAdapterFactory = parentAdapterFactory; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * <!-- begin-user-doc --> |
| 107 | * <!-- end-user-doc --> |
| 108 | * @generated |
| 109 | */ |
| 110 | @Override |
| 111 | public boolean isFactoryForType(Object type) { |
| 112 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * This implementation substitutes the factory itself as the key for the adapter. |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | @Override |
| 122 | public Adapter adapt(Notifier notifier, Object type) { |
| 123 | return super.adapt(notifier, this); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | @Override |
| 132 | public Object adapt(Object object, Object type) { |
| 133 | if (isFactoryForType(type)) { |
| 134 | Object adapter = super.adapt(object, type); |
| 135 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
| 136 | return adapter; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | return null; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * This adds a listener. |
| 145 | * <!-- begin-user-doc --> |
| 146 | * <!-- end-user-doc --> |
| 147 | * @generated |
| 148 | */ |
| 149 | public void addListener(INotifyChangedListener notifyChangedListener) { |
| 150 | changeNotifier.addListener(notifyChangedListener); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * This removes a listener. |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @generated |
| 158 | */ |
| 159 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
| 160 | changeNotifier.removeListener(notifyChangedListener); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
| 165 | * <!-- begin-user-doc --> |
| 166 | * <!-- end-user-doc --> |
| 167 | * @generated |
| 168 | */ |
| 169 | public void fireNotifyChanged(Notification notification) { |
| 170 | changeNotifier.fireNotifyChanged(notification); |
| 171 | |
| 172 | if (parentAdapterFactory != null) { |
| 173 | parentAdapterFactory.fireNotifyChanged(notification); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * This disposes all of the item providers created by this factory. |
| 179 | * <!-- begin-user-doc --> |
| 180 | * <!-- end-user-doc --> |
| 181 | * @generated |
| 182 | */ |
| 183 | public void dispose() { |
| 184 | } |
| 185 | |
| 186 | } |