1 19 20 package org.netbeans.modules.editor.options; 21 22 import java.beans.*; 23 import java.awt.Image ; 24 import org.openide.util.NbBundle; 25 26 30 public class BasePrintOptionsBeanInfo extends SimpleBeanInfo { 31 32 33 private String iconPrefix; 34 35 36 private Image icon; 37 private Image icon32; 38 39 public BasePrintOptionsBeanInfo() { 40 this("/org/netbeans/modules/editor/resources/baseOptions"); } 42 43 public BasePrintOptionsBeanInfo(String iconPrefix) { 44 this.iconPrefix = iconPrefix; 45 } 46 47 51 public PropertyDescriptor[] getPropertyDescriptors () { 52 PropertyDescriptor[] descriptors; 53 String [] propNames = getPropNames(); 54 try { 55 descriptors = new PropertyDescriptor[propNames.length]; 56 57 for (int i = 0; i < propNames.length; i++) { 58 descriptors[i] = new PropertyDescriptor(propNames[i], getBeanClass()); 59 descriptors[i].setDisplayName(getString("PROP_" + propNames[i])); descriptors[i].setShortDescription(getString("HINT_" + propNames[i])); if (BasePrintOptions.PRINT_COLORING_MAP_PROP.equals(propNames[i])) { 62 descriptors[i].setPropertyEditorClass(ColoringArrayEditor.class); 63 } 64 } 65 } catch (IntrospectionException e) { 66 descriptors = new PropertyDescriptor[0]; 67 } 68 return descriptors; 69 } 70 71 protected String getString(String s) { 72 return NbBundle.getMessage(BasePrintOptionsBeanInfo.class, s); 73 } 74 75 protected Class getBeanClass() { 76 return BasePrintOptions.class; 77 } 78 79 protected String [] getPropNames() { 80 return BasePrintOptions.BASE_PROP_NAMES; 81 } 82 83 86 public Image getIcon(final int type) { 87 if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { 88 if (icon == null) 89 icon = loadImage(iconPrefix + ".gif"); return icon; 91 } 92 else { 93 if (icon32 == null) 94 icon32 = loadImage(iconPrefix + "32.gif"); return icon32; 96 } 97 } 98 } 99 | Popular Tags |