1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.pde.internal.core.ifeature.*; 15 import org.eclipse.pde.internal.ui.*; 16 import org.eclipse.swt.graphics.*; 17 import org.eclipse.ui.views.properties.*; 18 19 public class FeatureAdapterFactory implements IAdapterFactory { 20 private Image errorImage; 21 22 public FeatureAdapterFactory() { 23 errorImage = PDEPluginImages.DESC_ERROR_ST_OBJ.createImage(); 24 } 25 public void dispose() { 26 errorImage.dispose(); 27 } 28 public Object getAdapter(Object adaptableObject, Class adapterType) { 29 if (adapterType.equals(IPropertySource.class)) 30 return getProperties(adaptableObject); 31 return null; 32 } 33 public Class [] getAdapterList() { 34 return new Class [] { IPropertySource.class }; 35 } 36 private IPropertySource getProperties(Object object) { 37 if (object instanceof IFeatureURLElement) 38 return getURLProperties((IFeatureURLElement) object); 39 if (object instanceof IFeaturePlugin) 40 return getReferenceProperties((IFeaturePlugin) object); 41 if (object instanceof IFeatureData) 42 return getDataProperties((IFeatureData) object); 43 if (object instanceof IFeatureChild) 44 return getChildProperties((IFeatureChild) object); 45 return null; 46 } 47 private IPropertySource getReferenceProperties(IFeaturePlugin ref) { 48 return new ReferencePropertySource(ref, errorImage); 49 } 50 private IPropertySource getURLProperties(IFeatureURLElement element) { 51 return new URLElementPropertySource(element); 52 } 53 54 private IPropertySource getDataProperties(IFeatureData data) { 55 return new FeatureEntryPropertySource(data); 56 } 57 58 private IPropertySource getChildProperties(IFeatureChild child) { 59 return new FeatureChildPropertySource(child); 60 } 61 } 62 | Popular Tags |