1 17 package org.eclipse.emf.ecore.sdo.provider; 18 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 23 import org.eclipse.emf.common.notify.Adapter; 24 import org.eclipse.emf.common.notify.Notification; 25 import org.eclipse.emf.common.notify.Notifier; 26 import org.eclipse.emf.ecore.sdo.util.SDOAdapterFactory; 27 import org.eclipse.emf.edit.provider.ChangeNotifier; 28 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 29 import org.eclipse.emf.edit.provider.ComposedAdapterFactory; 30 import org.eclipse.emf.edit.provider.IChangeNotifier; 31 import org.eclipse.emf.edit.provider.IDisposable; 32 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 33 import org.eclipse.emf.edit.provider.IItemLabelProvider; 34 import org.eclipse.emf.edit.provider.IItemPropertySource; 35 import org.eclipse.emf.edit.provider.INotifyChangedListener; 36 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 37 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 38 39 40 49 public class SDOItemProviderAdapterFactory extends SDOAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable 50 { 51 57 protected ComposedAdapterFactory parentAdapterFactory; 58 59 65 protected IChangeNotifier changeNotifier = new ChangeNotifier(); 66 67 73 protected Collection supportedTypes = new ArrayList (); 74 75 81 public SDOItemProviderAdapterFactory() 82 { 83 supportedTypes.add(IEditingDomainItemProvider.class); 84 supportedTypes.add(IStructuredItemContentProvider.class); 85 supportedTypes.add(ITreeItemContentProvider.class); 86 supportedTypes.add(IItemLabelProvider.class); 87 supportedTypes.add(IItemPropertySource.class); 88 } 89 90 96 protected EChangeSummaryItemProvider eChangeSummaryItemProvider; 97 98 104 public Adapter createEChangeSummaryAdapter() 105 { 106 if (eChangeSummaryItemProvider == null) 107 { 108 eChangeSummaryItemProvider = new EChangeSummaryItemProvider(this); 109 } 110 111 return eChangeSummaryItemProvider; 112 } 113 114 120 protected EChangeSummarySettingItemProvider eChangeSummarySettingItemProvider; 121 122 128 public Adapter createEChangeSummarySettingAdapter() 129 { 130 if (eChangeSummarySettingItemProvider == null) 131 { 132 eChangeSummarySettingItemProvider = new EChangeSummarySettingItemProvider(this); 133 } 134 135 return eChangeSummarySettingItemProvider; 136 } 137 138 144 protected EDataGraphItemProvider eDataGraphItemProvider; 145 146 152 public Adapter createEDataGraphAdapter() 153 { 154 if (eDataGraphItemProvider == null) 155 { 156 eDataGraphItemProvider = new EDataGraphItemProvider(this); 157 } 158 159 return eDataGraphItemProvider; 160 } 161 162 168 protected EDataObjectItemProvider eDataObjectItemProvider; 169 170 176 public Adapter createEDataObjectAdapter() 177 { 178 if (eDataObjectItemProvider == null) 179 { 180 eDataObjectItemProvider = new EDataObjectItemProvider(this); 181 } 182 183 return eDataObjectItemProvider; 184 } 185 186 192 protected EPropertyItemProvider ePropertyItemProvider; 193 194 200 public Adapter createEPropertyAdapter() 201 { 202 if (ePropertyItemProvider == null) 203 { 204 ePropertyItemProvider = new EPropertyItemProvider(this); 205 } 206 207 return ePropertyItemProvider; 208 } 209 210 216 protected ETypeItemProvider eTypeItemProvider; 217 218 224 public Adapter createETypeAdapter() 225 { 226 if (eTypeItemProvider == null) 227 { 228 eTypeItemProvider = new ETypeItemProvider(this); 229 } 230 231 return eTypeItemProvider; 232 } 233 234 240 protected EDataObjectAnyTypeItemProvider eDataObjectAnyTypeItemProvider; 241 242 248 public Adapter createEDataObjectAnyTypeAdapter() 249 { 250 if (eDataObjectAnyTypeItemProvider == null) 251 { 252 eDataObjectAnyTypeItemProvider = new EDataObjectAnyTypeItemProvider(this); 253 } 254 255 return eDataObjectAnyTypeItemProvider; 256 } 257 258 264 protected EDataObjectSimpleAnyTypeItemProvider eDataObjectSimpleAnyTypeItemProvider; 265 266 272 public Adapter createEDataObjectSimpleAnyTypeAdapter() 273 { 274 if (eDataObjectSimpleAnyTypeItemProvider == null) 275 { 276 eDataObjectSimpleAnyTypeItemProvider = new EDataObjectSimpleAnyTypeItemProvider(this); 277 } 278 279 return eDataObjectSimpleAnyTypeItemProvider; 280 } 281 282 288 public ComposeableAdapterFactory getRootAdapterFactory() 289 { 290 return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); 291 } 292 293 299 public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) 300 { 301 this.parentAdapterFactory = parentAdapterFactory; 302 } 303 304 309 public boolean isFactoryForType(Object type) 310 { 311 return supportedTypes.contains(type) || super.isFactoryForType(type); 312 } 313 314 320 public Adapter adapt(Notifier notifier, Object type) 321 { 322 return super.adapt(notifier, this); 323 } 324 325 330 public Object adapt(Object object, Object type) 331 { 332 if (isFactoryForType(type)) 333 { 334 Object adapter = super.adapt(object, type); 335 if (!(type instanceof Class ) || (((Class )type).isInstance(adapter))) 336 { 337 return adapter; 338 } 339 } 340 341 return null; 342 } 343 344 350 public void addListener(INotifyChangedListener notifyChangedListener) 351 { 352 changeNotifier.addListener(notifyChangedListener); 353 } 354 355 361 public void removeListener(INotifyChangedListener notifyChangedListener) 362 { 363 changeNotifier.removeListener(notifyChangedListener); 364 } 365 366 372 public void fireNotifyChanged(Notification notification) 373 { 374 changeNotifier.fireNotifyChanged(notification); 375 376 if (parentAdapterFactory != null) 377 { 378 parentAdapterFactory.fireNotifyChanged(notification); 379 } 380 } 381 382 388 public void dispose() 389 { 390 if (eChangeSummaryItemProvider != null) eChangeSummaryItemProvider.dispose(); 391 if (eChangeSummarySettingItemProvider != null) eChangeSummarySettingItemProvider.dispose(); 392 if (eDataGraphItemProvider != null) eDataGraphItemProvider.dispose(); 393 if (eDataObjectItemProvider != null) eDataObjectItemProvider.dispose(); 394 if (ePropertyItemProvider != null) ePropertyItemProvider.dispose(); 395 if (eTypeItemProvider != null) eTypeItemProvider.dispose(); 396 if (eDataObjectAnyTypeItemProvider != null) eDataObjectAnyTypeItemProvider.dispose(); 397 if (eDataObjectSimpleAnyTypeItemProvider != null) eDataObjectSimpleAnyTypeItemProvider.dispose(); 398 } 399 400 } 401 | Popular Tags |