1 19 20 package org.netbeans.beaninfo; 21 22 import java.awt.Image ; 23 import java.beans.*; 24 25 import org.openide.loaders.DataLoader; 26 import org.openide.loaders.UniFileLoader; 27 import org.openide.loaders.MultiFileLoader; 28 import org.openide.util.Exceptions; 29 import org.openide.util.Utilities; 30 import org.openide.util.NbBundle; 31 32 public class DataLoaderPool { 33 34 36 private static PropertyDescriptor[] createExtensionsPropertyDescriptor () { 37 try { 38 PropertyDescriptor extensions = new PropertyDescriptor ("extensions", UniFileLoader.class); extensions.setDisplayName (NbBundle.getBundle (DataLoaderPool.class).getString ("PROP_UniFileLoader_extensions")); 40 extensions.setShortDescription (NbBundle.getBundle (DataLoaderPool.class).getString ("HINT_UniFileLoader_extensions")); 41 extensions.setWriteMethod(null); 42 return new PropertyDescriptor[] { extensions }; 43 } 44 catch (IntrospectionException ie) { 45 Exceptions.printStackTrace(ie); 46 return null; 47 } 48 } 49 50 public static class FolderLoaderBeanInfo extends SimpleBeanInfo { 51 52 public BeanInfo[] getAdditionalBeanInfo () { 53 try { 54 return new BeanInfo[] { Introspector.getBeanInfo (MultiFileLoader.class) }; 60 } catch (IntrospectionException ie) { 61 Exceptions.printStackTrace(ie); 62 return null; 63 } 64 } 65 66 public PropertyDescriptor[] getPropertyDescriptors () { 67 return createExtensionsPropertyDescriptor(); 68 } 69 70 public Image getIcon (int type) { 71 if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { 72 return Utilities.loadImage("org/openide/loaders/defaultFolder.gif"); } else { 74 return Utilities.loadImage("org/openide/loaders/defaultFolder32.gif"); } 76 } 77 } 78 79 public static class InstanceLoaderBeanInfo extends SimpleBeanInfo { 80 81 public BeanInfo[] getAdditionalBeanInfo () { 82 try { 83 return new BeanInfo[] { Introspector.getBeanInfo (MultiFileLoader.class) }; 89 } catch (IntrospectionException ie) { 90 Exceptions.printStackTrace(ie); 91 return null; 92 } 93 } 94 95 public PropertyDescriptor[] getPropertyDescriptors () { 96 return createExtensionsPropertyDescriptor(); 97 } 98 99 public Image getIcon (int type) { 100 if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { 101 return Utilities.loadImage("org/netbeans/core/resources/action.gif"); } else { 103 return Utilities.loadImage ("org/netbeans/core/resources/action32.gif"); } 105 } 106 107 } 108 109 public static class DefaultLoaderBeanInfo extends SimpleBeanInfo { 110 111 public BeanInfo[] getAdditionalBeanInfo () { 112 try { 113 return new BeanInfo[] { Introspector.getBeanInfo (DataLoader.class) }; 114 } catch (IntrospectionException ie) { 115 Exceptions.printStackTrace(ie); 116 return null; 117 } 118 } 119 120 public Image getIcon (int type) { 121 if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { 122 return Utilities.loadImage ("org/openide/resources/pending.gif"); } else { 124 return Utilities.loadImage ("org/openide/resources/pending32.gif"); } 126 } 127 128 } 129 130 public static class ShadowLoaderBeanInfo extends SimpleBeanInfo { 131 public BeanInfo[] getAdditionalBeanInfo () { 132 try { 133 return new BeanInfo[] { Introspector.getBeanInfo (DataLoader.class) }; 134 } catch (IntrospectionException ie) { 135 Exceptions.printStackTrace(ie); 136 return null; 137 } 138 } 139 140 public PropertyDescriptor[] getPropertyDescriptors () { 141 try { 142 Class c = Class.forName ("org.openide.loaders.DataLoaderPool$ShadowLoader"); PropertyDescriptor actions = new PropertyDescriptor ("actions", c); actions.setHidden (true); 146 return new PropertyDescriptor[] { actions }; 147 } catch (ClassNotFoundException ie) { 148 Exceptions.printStackTrace(ie); 149 return null; 150 } catch (IntrospectionException ie) { 151 Exceptions.printStackTrace(ie); 152 return null; 153 } 154 } 155 156 public Image getIcon (int type) { 157 if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { 158 return Utilities.loadImage("org/openide/resources/actions/copy.gif"); } else { 160 return null; 163 } 164 } 165 166 } 167 168 } 169 | Popular Tags |