|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.ui.nodes.elements; import java.beans.*; import java.awt.Image; import java.util.ResourceBundle; import org.openide.util.NbBundle; import org.openide.util.Utilities; import org.openide.ErrorManager; /** BeanInfo for source options. * * @author Petr Hamernik */ public final class SourceOptionsBeanInfo extends SimpleBeanInfo { /** Prefix of the icon location. */ public BeanDescriptor getBeanDescriptor() { ResourceBundle bundle = NbBundle.getBundle(SourceOptionsBeanInfo.class); BeanDescriptor desc = new BeanDescriptor(SourceOptions.class); desc.setDisplayName(bundle.getString("MSG_sourceOptions")); // NOI18N /* for Post-FCS desc.setShortDescription(bundle.getString("HINT_sourceOptions")); */ return desc; } /* * @return Returns an array of PropertyDescriptors * describing the editable properties supported by this bean. */ public PropertyDescriptor[] getPropertyDescriptors () { try { ResourceBundle bundle = NbBundle.getBundle(SourceOptionsBeanInfo.class); PropertyDescriptor[] descriptors = new PropertyDescriptor[SourceOptions.PROP_NAMES.length]; for (int i = 0; i < descriptors.length; i++) { if (i == 7) { descriptors[i] = new PropertyDescriptor( SourceOptions.PROP_NAMES[i], SourceOptions.class, makeGetter(SourceOptions.PROP_NAMES[i]), null); } else { descriptors[i] = new PropertyDescriptor(SourceOptions.PROP_NAMES[i], SourceOptions.class); } descriptors[i].setDisplayName(bundle.getString("PROP_" + SourceOptions.PROP_NAMES[i])); // NOI18N descriptors[i].setShortDescription(bundle.getString("HINT_" + SourceOptions.PROP_NAMES[i])); // NOI18N descriptors[i].setPropertyEditorClass(ElementFormatEditor.class); } // descriptors[6] = new PropertyDescriptor(SourceOptions.PROP_CATEGORIES_USAGE, SourceOptions.class); // descriptors[6].setDisplayName(bundle.getString("PROP_"+SourceOptions.PROP_CATEGORIES_USAGE)); // descriptors[6].setShortDescription(bundle.getString("HINT_"+SourceOptions.PROP_CATEGORIES_USAGE)); return descriptors; } catch (IntrospectionException e) { ErrorManager.getDefault().notify(e); return null; } } private static String makeGetter(String propName) { char[] cs = propName.toCharArray(); cs[0] = Character.toUpperCase(cs[0]); return "get" + String.valueOf(cs); // NOI18N } /* @param type Desired type of the icon * @return returns the Java loader's icon */ public Image getIcon(final int type) { if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) { return Utilities.loadImage("org/openide/src/resources/sourceOptions.gif"); // NOI18N } else { return Utilities.loadImage("org/openide/src/resources/sourceOptions32.gif"); // NOI18N } } public static final class ElementFormatEditor extends PropertyEditorSupport { public ElementFormatEditor() { } public String getAsText() { Object o = getValue(); if (o instanceof ElementFormat) { return ((ElementFormat) o).getPattern(); } else { return String.valueOf(o); } } public void setAsText(String text) throws IllegalArgumentException { setValue(new ElementFormat(text.trim())); } } } |
... 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.