1 19 20 package org.netbeans.modules.java.settings; 21 22 import java.awt.Image ; 23 import java.beans.*; 24 import java.util.ResourceBundle ; 25 26 import org.openide.ErrorManager; 27 import org.openide.util.NbBundle; 28 import org.openide.util.Utilities; 29 30 35 public class JavaSynchronizationSettingsBeanInfo extends SimpleBeanInfo { 36 37 38 public Image getIcon(int type) { 39 if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) || (type == java.beans.BeanInfo.ICON_MONO_16x16)) { 40 return Utilities.loadImage("org/netbeans/modules/java/resources/synchronizeSettings.gif"); } else { 42 return Utilities.loadImage("org/netbeans/modules/java/settings/javaSynchronizationSettings32.gif"); } 44 } 45 46 49 public PropertyDescriptor[] getPropertyDescriptors () { 50 try { 51 PropertyDescriptor[] desc = new PropertyDescriptor[] { 52 new PropertyDescriptor(JavaSynchronizationSettings.PROP_GENERATE_RETURN, 53 JavaSynchronizationSettings.class, "getGenerateReturn", "setGenerateReturn"), }; 55 ResourceBundle bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class); 56 57 desc[0].setDisplayName(bundle.getString("PROP_GENERATE_RETURN")); 58 desc[0].setShortDescription(bundle.getString("HINT_GENERATE_RETURN")); 59 desc[0].setPropertyEditorClass(RetGenEditor.class); 60 61 return desc; 62 } 63 catch (IntrospectionException ex) { 64 ErrorManager.getDefault().notify(ex); 65 return null; 66 } 67 } 68 69 public BeanDescriptor getBeanDescriptor() { 70 BeanDescriptor desc = new BeanDescriptor(JavaSettings.class); 71 desc.setDisplayName(JavaSettings.getString("CTL_JavaSynchronization_Settings")); 72 return desc; 73 } 74 75 76 public static class RetGenEditor extends PropertyEditorSupport { 77 78 private static final String [] tags; 79 80 static { 81 tags = new String [3]; 82 ResourceBundle bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class); 83 tags[JavaSynchronizationSettings.RETURN_GEN_NOTHING] = bundle.getString("CTL_RETURN_GEN_NOTHING"); 84 tags[JavaSynchronizationSettings.RETURN_GEN_EXCEPTION] = bundle.getString("CTL_RETURN_GEN_EXCEPTION"); 85 tags[JavaSynchronizationSettings.RETURN_GEN_NULL] = bundle.getString("CTL_RETURN_GEN_NULL"); 86 } 87 88 public String [] getTags () { 89 return tags; 90 } 91 92 public String getAsText () { 93 return tags[((Integer ) getValue ()).intValue ()]; 94 } 95 96 public void setAsText (String text) throws IllegalArgumentException { 97 for (int i = 0; i < tags.length; i++) { 98 if (tags[i].equals (text)) { 99 setValue (new Integer (i)); 100 return; 101 } 102 } 103 throw new IllegalArgumentException (); 104 } 105 } 106 107 } 108 109 | Popular Tags |