|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.settings; import java.awt.Image; import java.beans.*; import java.util.ResourceBundle; import org.openide.ErrorManager; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** BeanInfo for class JavaSynchronizationSettings. * It describes three properties one with special editor. * * @author Petr Hamernik */ public class JavaSynchronizationSettingsBeanInfo extends SimpleBeanInfo { /** Returns the ExternalCompilerSettings' icon */ public Image getIcon(int type) { if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) || (type == java.beans.BeanInfo.ICON_MONO_16x16)) { return Utilities.loadImage("org/netbeans/modules/java/resources/synchronizeSettings.gif"); // NOI18N } else { return Utilities.loadImage("org/netbeans/modules/java/settings/javaSynchronizationSettings32.gif"); // NOI18N } } /** Descriptor of valid properties * @return array of properties */ public PropertyDescriptor[] getPropertyDescriptors () { try { PropertyDescriptor[] desc = new PropertyDescriptor[] { new PropertyDescriptor(JavaSynchronizationSettings.PROP_GENERATE_RETURN, JavaSynchronizationSettings.class, "getGenerateReturn", "setGenerateReturn"), // NOI18N new PropertyDescriptor(JavaSynchronizationSettings.PROP_ENABLED, JavaSynchronizationSettings.class, "isEnabled", "setEnabled") // NOI18N }; ResourceBundle bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class); desc[0].setDisplayName(bundle.getString("PROP_GENERATE_RETURN")); desc[0].setShortDescription(bundle.getString("HINT_GENERATE_RETURN")); desc[0].setPropertyEditorClass(RetGenEditor.class); desc[1].setDisplayName(bundle.getString("PROP_ENABLED")); desc[1].setShortDescription(bundle.getString("HINT_ENABLED")); return desc; } catch (IntrospectionException ex) { ErrorManager.getDefault().notify(ex); return null; } } public BeanDescriptor getBeanDescriptor() { BeanDescriptor desc = new BeanDescriptor(JavaSettings.class); desc.setDisplayName(JavaSettings.getString("CTL_JavaSynchronization_Settings")); return desc; } /** Simple property editor for two-item pulldown. */ public static class RetGenEditor extends PropertyEditorSupport { private static final String[] tags; static { tags = new String[3]; ResourceBundle bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class); tags[JavaSynchronizationSettings.RETURN_GEN_NOTHING] = bundle.getString("CTL_RETURN_GEN_NOTHING"); tags[JavaSynchronizationSettings.RETURN_GEN_EXCEPTION] = bundle.getString("CTL_RETURN_GEN_EXCEPTION"); tags[JavaSynchronizationSettings.RETURN_GEN_NULL] = bundle.getString("CTL_RETURN_GEN_NULL"); } public String[] getTags () { return tags; } public String getAsText () { return tags[((Integer) getValue ()).intValue ()]; } public void setAsText (String text) throws IllegalArgumentException { for (int i = 0; i < tags.length; i++) { if (tags[i].equals (text)) { setValue (new Integer (i)); return; } } throw new IllegalArgumentException (); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.