Java 类java.beans.PropertyEditor 实例源码

项目:incubator-netbeans    文件:FormCustomEditor.java   
/**
 * Used by PropertyAction to mimic property sheet behavior - trying to invoke
 * PropertyEnv listener of the current property editor (we can't create our
 * own PropertyEnv instance).
 * 
 * @return current value
 * @throws java.beans.PropertyVetoException if someone vetoes this change.
 */
public Object commitChanges() throws PropertyVetoException {
    int currentIndex = editorsCombo.getSelectedIndex();
    PropertyEditor currentEditor = currentIndex > -1 ? allEditors[currentIndex] : null;
    if (currentEditor instanceof ExPropertyEditor) {
        // we can only guess - according to the typical pattern the propetry
        // editor itself or the custom editor usually implement the listener
        // registered in PropertyEnv
        PropertyChangeEvent evt = new PropertyChangeEvent(
                this, PropertyEnv.PROP_STATE, null, PropertyEnv.STATE_VALID);
        if (currentEditor instanceof VetoableChangeListener) {
            ((VetoableChangeListener)currentEditor).vetoableChange(evt);
        }
        Component currentCustEd = currentIndex > -1 ? allCustomEditors[currentIndex] : null;
        if (currentCustEd instanceof VetoableChangeListener) {
            ((VetoableChangeListener)currentCustEd).vetoableChange(evt);
        }
        if (currentEditor instanceof PropertyChangeListener) {
            ((PropertyChangeListener)currentEditor).propertyChange(evt);
        }
        if (currentCustEd instanceof PropertyChangeListener) {
            ((PropertyChangeListener)currentCustEd).propertyChange(evt);
        }
    }
    return commitChanges0();
}
项目:gemini.blueprint    文件:OsgiPropertyEditorRegistrar.java   
@SuppressWarnings("unchecked")
private void createEditors(Properties configuration) {

    boolean trace = log.isTraceEnabled();
    // load properties using this class class loader
    ClassLoader classLoader = getClass().getClassLoader();

    for (Map.Entry<Object, Object> entry : configuration.entrySet()) {
        // key represents type
        Class<?> key;
        // value represents property editor
        Class<?> editorClass;
        try {
            key = classLoader.loadClass((String) entry.getKey());
            editorClass = classLoader.loadClass((String) entry.getValue());
        } catch (ClassNotFoundException ex) {
            throw (RuntimeException) new IllegalArgumentException("Cannot load class").initCause(ex);
        }

        Assert.isAssignable(PropertyEditor.class, editorClass);

        if (trace)
            log.trace("Adding property editor[" + editorClass + "] for type[" + key + "]");
        editors.put(key, (Class<? extends PropertyEditor>) editorClass);
    }
}
项目:MaxSim    文件:FontChooserDialog.java   
public static Font show(Font initialFont) {
    PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
    if (pe == null) {
        throw new RuntimeException("Could not find font editor component.");
    }
    pe.setValue(initialFont);
    DialogDescriptor dd = new DialogDescriptor(
            pe.getCustomEditor(),
            "Choose Font");
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        Font f = (Font)pe.getValue();
        return f;
    }
    return initialFont;
}
项目:incubator-netbeans    文件:ValuePropertyEditor.java   
private static PropertyEditor findThePropertyEditor(Class clazz) {
    PropertyEditor pe;
    if (Object.class.equals(clazz)) {
        pe = null;
    } else {
        pe = PropertyEditorManager.findEditor(clazz);
        if (pe == null) {
            Class sclazz = clazz.getSuperclass();
            if (sclazz != null) {
                pe = findPropertyEditor(sclazz);
            }
        }
    }
    classesWithPE.put(clazz, pe != null);
    return pe;
}
项目:incubator-netbeans    文件:ValuePropertyEditor.java   
boolean setValueWithMirror(Object value, Object valueMirror) {
    this.currentValue = value;
    Class clazz = valueMirror.getClass();
    PropertyEditor propertyEditor = findPropertyEditor(clazz);
    propertyEditor = testPropertyEditorOnValue(propertyEditor, valueMirror);
    if (propertyEditor == null) {
        return false;
    }
    boolean doAttach = false;
    mirrorClass = clazz;
    delegatePropertyEditor = propertyEditor;
    if (env != null && propertyEditor instanceof ExPropertyEditor) {
        doAttach = true;
    }
    delegateValue = valueMirror;
    delegatePropertyEditor.setValue(valueMirror);
    if (doAttach) {
        ((ExPropertyEditor) delegatePropertyEditor).attachEnv(env);
    }
    return doAttach;
}
项目:incubator-netbeans    文件:RevisionNode.java   
@Override
public PropertyEditor getPropertyEditor() {
    return new PropertyEditorSupport() {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            if (text instanceof String) {
                try {
                    entry.setMessage(!text.equals("") ? text : null);
                } catch (IOException ex) {
                    History.LOG.log(Level.WARNING, null, ex);
                }
                return;
            }
            throw new java.lang.IllegalArgumentException(text);
        }
        @Override
        public String getAsText() {
            return te.getDisplayValue();
        }
    };
}
项目:incubator-netbeans    文件:RendererPropertyDisplayer.java   
public void setRadioButtonMax(int i) {
    if (i != radioButtonMax) {
        Dimension oldPreferredSize = null;

        if (isShowing()) {
            oldPreferredSize = getPreferredSize();
        }

        int old = radioButtonMax;
        radioButtonMax = i;

        if (oldPreferredSize != null) {
            //see if the change will affect anything
            PropertyEditor ed = PropUtils.getPropertyEditor(prop);
            String[] tags = ed.getTags();

            if (tags != null) {
                if ((tags.length >= i) != (tags.length >= old)) {
                    firePropertyChange("preferredSize", oldPreferredSize, getPreferredSize()); //NOI18N
                }
            }
        }
    }
}
项目:incubator-netbeans    文件:SheetTable.java   
@Override
public void actionPerformed(ActionEvent ae) {
    int i = getSelectedRow();

    if (i != -1) {
        FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(i);

        if (fd instanceof Property) {
            java.beans.PropertyEditor ped = PropUtils.getPropertyEditor((Property) fd);
            System.err.println(ped.getClass().getName());
        } else {
            System.err.println("PropertySets - no editor"); //NOI18N
        }
    } else {
        System.err.println("No selection"); //NOI18N
    }
}
项目:lams    文件:JspRuntimeLibrary.java   
public static Object getValueFromBeanInfoPropertyEditor(
               Class attrClass, String attrName, String attrValue,
           Class propertyEditorClass) 
throws JasperException 
   {
try {
    PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
    pe.setAsText(attrValue);
    return pe.getValue();
} catch (Exception ex) {
    throw new JasperException(
               Localizer.getMessage("jsp.error.beans.property.conversion",
                 attrValue, attrClass.getName(), attrName,
                 ex.getMessage()));
}
   }
项目:incubator-netbeans    文件:EditablePropertyDisplayer.java   
PropertyEditor getPropertyEditor() { //package private for unit tests

        PropertyEditor result;

        if (editor != null) {
            return editor;
        }

        if (getInplaceEditor() != null) {
            result = getInplaceEditor().getPropertyEditor();
        } else {
            result = PropUtils.getPropertyEditor(getProperty());
        }

        editor = result;

        return result;
    }
项目:lams    文件:PropertyEditorRegistrySupport.java   
private PropertyEditor getPropertyEditor(Class<?> requiredType) {
    // Special case: If no required type specified, which usually only happens for
    // Collection elements, or required type is not assignable to registered type,
    // which usually only happens for generic properties of type Object -
    // then return PropertyEditor if not registered for Collection or array type.
    // (If not registered for Collection or array, it is assumed to be intended
    // for elements.)
    if (this.registeredType == null ||
            (requiredType != null &&
            (ClassUtils.isAssignable(this.registeredType, requiredType) ||
            ClassUtils.isAssignable(requiredType, this.registeredType))) ||
            (requiredType == null &&
            (!Collection.class.isAssignableFrom(this.registeredType) && !this.registeredType.isArray()))) {
        return this.propertyEditor;
    }
    else {
        return null;
    }
}
项目:incubator-netbeans    文件:ModelProperty.java   
public PropertyEditor getPropertyEditor() {
    if (mdl.getPropertyEditorClass() != null) {
        try {
            //System.err.println("ModelProperty creating a " 
            //+ mdl.getPropertyEditorClass());
            Constructor c = mdl.getPropertyEditorClass().getConstructor();
            c.setAccessible(true);

            return (PropertyEditor) c.newInstance(new Object[0]);
        } catch (Exception e) {
            Exceptions.printStackTrace(e);

            return new PropUtils.NoPropertyEditorEditor();
        }
    }

    return super.getPropertyEditor();
}
项目:neoscada    文件:PropertyEditorRegistry.java   
/**
 * @param requiredType
 * @param propertyPath
 * @return
 */
public PropertyEditor findCustomEditor ( final Class<?> requiredType, final String propertyPath )
{
    // first try to find exact match
    String key = requiredType.getCanonicalName () + ":" + propertyPath;
    PropertyEditor pe = this.propertyEditors.get ( key );
    // 2nd: try to find for class only
    if ( pe == null )
    {
        key = requiredType.getCanonicalName () + ":";
        pe = this.propertyEditors.get ( key );
    }
    // 3rd: try to get internal
    if ( pe == null )
    {
        pe = PropertyEditorManager.findEditor ( requiredType );
    }
    return pe;
}
项目:lazycat    文件:JspRuntimeLibrary.java   
public static Object getValueFromPropertyEditorManager(Class<?> attrClass, String attrName, String attrValue)
        throws JasperException {
    try {
        PropertyEditor propEditor = PropertyEditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                    Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
                attrClass.getName(), attrName, ex.getMessage()));
    }
}
项目:incubator-netbeans    文件:SuiteCustomizerLibraries.java   
@Override
public PropertyEditor getPropertyEditor() {
    if (editor == null) {
        editor = super.getPropertyEditor();
    }
    return editor;
}
项目:incubator-netbeans    文件:BiFeatureNode.java   
@Override
public PropertyEditor getPropertyEditor() {
    return new PropertyEditorSupport() {
        @Override
        public java.awt.Component getCustomEditor() {
            return new CustomCodeEditor(CodePropertySupportRW.this);
        }

        @Override
        public boolean supportsCustomEditor() {
            return true;
        }
    };            
}
项目:spring-seed    文件:BeanPropertyUtil.java   
private static Object getValueFromPropertyEditorManager(Class attrClass, String attrValue) {
    PropertyEditor propEditor = PropertyEditorManager.findEditor(attrClass);
    if (propEditor != null) {
        propEditor.setAsText(attrValue);
        return propEditor.getValue();
    } else {
        throw new IllegalArgumentException("beans property editor not registered");
    }
}
项目:etomica    文件:PropertyText.java   
public PropertyText(PropertyEditor pe) {
        super(pe.getAsText());
        editor = pe;
        addKeyListener(this);
        addFocusListener(this);
        editor.addPropertyChangeListener(this);
//      setBorder(PropertySheet.EMPTY_BORDER);
    }
项目:jdk8u-jdk    文件:TestPropertyEditor.java   
private static void test(Class<?> type, Class<? extends PropertyEditor> expected) {
    PropertyEditor actual = PropertyEditorManager.findEditor(type);
    if ((actual == null) && (expected != null)) {
        throw new Error("expected editor is not found");
    }
    if ((actual != null) && !actual.getClass().equals(expected)) {
        throw new Error("found unexpected editor");
    }
}
项目:incubator-netbeans    文件:PEAnnotationProcessorTest.java   
public void testPERegistered() {
    NodeOp.registerPropertyEditors();
    PropertyEditor pEditor = PropertyEditorManager.findEditor(Double[].class);
    assertEquals("org.netbeans.modules.openide.nodes.TestPropertyEditor", pEditor.getClass().getName());
    pEditor = PropertyEditorManager.findEditor(Integer.class);
    assertEquals("org.netbeans.modules.openide.nodes.TestPropertyEditor", pEditor.getClass().getName());
    pEditor = PropertyEditorManager.findEditor(char[][].class);
    assertEquals("org.netbeans.modules.openide.nodes.TestPropertyEditor", pEditor.getClass().getName());
    pEditor = PropertyEditorManager.findEditor(short.class);
    assertEquals("org.netbeans.modules.openide.nodes.TestPropertyEditor", pEditor.getClass().getName());
}
项目:incubator-netbeans    文件:ResourceSupport.java   
private static String getStringValue(FormProperty prop, Object value) {
    if (value instanceof String)
        return (String) value;

    PropertyEditor prEd = prop.getCurrentEditor();
    prEd.setValue(value);
    return prEd.getAsText(); // [this does not work correctly with IconEditor...]
}
项目:lams    文件:TypeConverterDelegate.java   
/**
 * Find a default editor for the given type.
 * @param requiredType the type to find an editor for
 * @return the corresponding editor, or {@code null} if none
 */
private PropertyEditor findDefaultEditor(Class<?> requiredType) {
    PropertyEditor editor = null;
    if (requiredType != null) {
        // No custom editor -> check BeanWrapperImpl's default editors.
        editor = this.propertyEditorRegistry.getDefaultEditor(requiredType);
        if (editor == null && !String.class.equals(requiredType)) {
            // No BeanWrapper default editor -> check standard JavaBean editor.
            editor = BeanUtils.findEditorByConvention(requiredType);
        }
    }
    return editor;
}
项目:incubator-netbeans    文件:ValuePropertyEditor.java   
/**
 * Test if the property editor can act on the provided value. We can never be sure. :-(
 * @param propertyEditor
 * @param valueMirror
 * @return the property editor, or <code>null</code>
 */
private static PropertyEditor testPropertyEditorOnValue(PropertyEditor propertyEditor, Object valueMirror) {
    propertyEditor.setValue(valueMirror);
    Object value = propertyEditor.getValue();
    if (value != valueMirror && (value == null || !value.equals(valueMirror))) {
        // Returns something that we did not set. Give up.
        return null;
    }
    return propertyEditor;
}
项目:lazycat    文件:JspRuntimeLibrary.java   
public static Object getValueFromBeanInfoPropertyEditor(Class<?> attrClass, String attrName, String attrValue,
        Class<?> propertyEditorClass) throws JasperException {
    try {
        PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
        pe.setAsText(attrValue);
        return pe.getValue();
    } catch (Exception ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
                attrClass.getName(), attrName, ex.getMessage()));
    }
}
项目:lams    文件:PropertyEditorRegistrySupport.java   
/**
 * Get custom editor for the given type. If no direct match found,
 * try custom editor for superclass (which will in any case be able
 * to render a value as String via {@code getAsText}).
 * @param requiredType the type to look for
 * @return the custom editor, or {@code null} if none found for this type
 * @see java.beans.PropertyEditor#getAsText()
 */
private PropertyEditor getCustomEditor(Class<?> requiredType) {
    if (requiredType == null || this.customEditors == null) {
        return null;
    }
    // Check directly registered editor for type.
    PropertyEditor editor = this.customEditors.get(requiredType);
    if (editor == null) {
        // Check cached editor for type, registered for superclass or interface.
        if (this.customEditorCache != null) {
            editor = this.customEditorCache.get(requiredType);
        }
        if (editor == null) {
            // Find editor for superclass or interface.
            for (Iterator<Class<?>> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) {
                Class<?> key = it.next();
                if (key.isAssignableFrom(requiredType)) {
                    editor = this.customEditors.get(key);
                    // Cache editor for search type, to avoid the overhead
                    // of repeated assignable-from checks.
                    if (this.customEditorCache == null) {
                        this.customEditorCache = new HashMap<Class<?>, PropertyEditor>();
                    }
                    this.customEditorCache.put(requiredType, editor);
                }
            }
        }
    }
    return editor;
}
项目:gemini.blueprint    文件:OsgiPropertyEditorRegistrar.java   
public void registerCustomEditors(PropertyEditorRegistry registry) {
    for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : editors.entrySet()) {
        Class<?> type = entry.getKey();
        PropertyEditor editorInstance;
        editorInstance = BeanUtils.instantiate(entry.getValue());
        registry.registerCustomEditor(type, editorInstance);
    }

    // register non-externalized types
    registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class));
    registry.registerCustomEditor(Properties.class, new PropertiesEditor());
    registry.registerCustomEditor(Class.class, new ClassEditor(userClassLoader));
    registry.registerCustomEditor(Class[].class, new ClassArrayEditor(userClassLoader));
}
项目:X4J    文件:DynamicParsers.java   
@Override
public Object parseImp(String input, ParserHelper helper) {
    PropertyEditor editor = findEditor(helper.getRawTargetClass());
    if (editor == null) {
        return TRY_NEXT;
    }
    editor.setAsText(input);
    return editor.getValue();
}
项目:incubator-netbeans    文件:OutlineView.java   
private boolean openCustomEditor(ActionEvent e) {
    if (getSelectedRowCount() != 1 || getSelectedColumnCount() != 1) {
        return false;
    }
    int row = getSelectedRow();
    if (row < 0) return false;
    int column = getSelectedColumn();
    if (column < 0) return false;
    Object o = getValueAt(row, column);
    if (!(o instanceof Node.Property)) {
        return false;
    }
    Node.Property p = (Node.Property) o;
    if (!Boolean.TRUE.equals(p.getValue("suppressCustomEditor"))) { //NOI18N
        PropertyPanel panel = new PropertyPanel(p);
        @SuppressWarnings("deprecation")
        PropertyEditor ed = panel.getPropertyEditor();

        if ((ed != null) && ed.supportsCustomEditor()) {
            Action act = panel.getActionMap().get("invokeCustomEditor"); //NOI18N

            if (act != null) {
                act.actionPerformed(null);

                return true;
            }
        }
    }
    return false;
}
项目:Pogamut3    文件:Folder.java   
/**
 * Initializes folder from the properties object.
 * @param props
 */
protected void loadFromProperties(Properties props, String prefix) throws IntrospectionException {
    Enumeration<String> keys = (Enumeration<String>) props.propertyNames();
    prefix = prefix + getName() + ".";
    // load properties in this folder
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (key.startsWith(prefix)) {
            String posfix = key.replaceFirst(prefix, "");
            if (!posfix.contains(".")) {
                // the posfix represents a name of a property
                Property prop = getProperty(posfix);
                if (prop == null) {
                    continue;
                }
                // exploit the JavaBeans property editors to convert the values from text
                PropertyEditor editor = PropertyEditorManager.findEditor(prop.getType());
                if (editor == null) {
                    continue;
                }
                editor.setAsText(props.getProperty(key));
                prop.setValue(editor.getValue());

            }
        }
        ;
    }

    // load all subfolders
    for (Folder folder : getFolders()) {
        folder.loadFromProperties(props, prefix);
    }

}
项目:incubator-netbeans    文件:DiffNode.java   
@Override
public PropertyEditor getPropertyEditor() {
    try {
        return new DiffNode.DiffPropertyEditor(getValue());
    } catch (Exception e) {
        return super.getPropertyEditor();
    }
}
项目:incubator-netbeans    文件:StringEditorTest.java   
public void testNullValueSupport() throws Exception {
    NP np = new NP();
    String defaultValue = "<null value>";
    String customValue = "Hello world!";
    np.setValue(ObjectEditor.PROP_NULL, defaultValue);

    PropertyEditor p = np.getPropertyEditor();
    assertNotNull("There is some editor", p);
    assertEquals("It is StringEditor", StringEditor.class, p.getClass());
    ((StringEditor) p).readEnv(np);

    p.setValue(null);
    String value = (String)p.getValue ();
    assertNull(value);
    assertEquals(defaultValue, p.getAsText());

    p.setValue(customValue);
    value = (String)p.getValue ();
    assertEquals(customValue, value);
    assertEquals(customValue, p.getAsText());

    np.setValue(ObjectEditor.PROP_NULL, Boolean.TRUE);
    ((StringEditor) p).readEnv(np);
    p.setValue(null);
    value = (String)p.getValue ();
    assertNull(value);
    assertFalse("we've better than default 'null' string", "null".equals(defaultValue));
}
项目:incubator-netbeans    文件:CustomEditorDisplayer.java   
PropertyEditor getPropertyEditor() { //Package private for unit tests

        if (editor == null) {
            setPropertyEditor(PropUtils.getPropertyEditor(getProperty()));
        }

        return editor;
    }
项目:openjdk-jdk10    文件:TestPropertyEditor.java   
private static void test(Class<?> type, Class<? extends PropertyEditor> expected) {
    PropertyEditor actual = PropertyEditorManager.findEditor(type);
    if ((actual == null) && (expected != null)) {
        throw new Error("expected editor is not found");
    }
    if ((actual != null) && !actual.getClass().equals(expected)) {
        throw new Error("found unexpected editor");
    }
}
项目:incubator-netbeans    文件:EditablePropertyDisplayer.java   
public boolean isValueModified() {
    boolean result = false;
    PropertyEditor peditor = getPropertyEditor();

    Object enteredValue = getEnteredValue();
    Object realValue = null;

    //Get the value from the editor to make sure getAsText() does not lie
    Object editorValue = null;

    try {
        editorValue = peditor.getValue();
    } catch (ProxyNode.DifferentValuesException dve) {
        return false;
    }

    //some editors provide a single from getTags()
    //but the value is null by default
    if ((enteredValue == null) != (editorValue == null)) {
        return true;
    }

    if (realValue == null) {
        //try to check the editor value if the editor does not support
        //getAsText
        realValue = editorValue;
    }

    if ((realValue == null) != (enteredValue == null)) {
        result = true;
    } else if (realValue == enteredValue) {
        result = false;
    } else if (realValue != null) {
        result = !realValue.equals(enteredValue);
    } else {
        result = false;
    }

    return result;
}
项目:incubator-netbeans    文件:EditablePropertyDisplayer.java   
public void valueChanged(PropertyEditor editor) {
    failed = false;

    try {
        //                System.err.println("ValueChanged - new value " + editor.getValue());
        if (getInplaceEditor() != null) {
            setEnteredValue(getProperty().getValue());
        } else {
            //Handle case where our parent PropertyPanel is no longer showing, but
            //the custom editor we invoked still is.  Issue 38004
            PropertyModel mdl = (modelRef != null) ? modelRef.get() : null;

            if (mdl != null) {
                FeatureDescriptor fd = null;

                if (mdl instanceof ExPropertyModel) {
                    fd = ((ExPropertyModel) mdl).getFeatureDescriptor();
                }

                String title = null;

                if (fd != null) {
                    title = fd.getDisplayName();
                }

                failed = PropUtils.updateProp(mdl, editor, title); //XXX
            }
        }
    } catch (Exception e) {
        throw (IllegalStateException) new IllegalStateException("Problem setting entered value from custom editor").initCause(e);
    }
}
项目:incubator-netbeans    文件:RendererFactory.java   
private IconPanel prepareIconPanel(PropertyEditor ed, PropertyEnv env, InplaceEditor inner) {
    IconPanel icp = iconPanel();
    icp.setInplaceEditor(inner);
    icp.connect(ed, env);

    return icp;
}
项目:incubator-netbeans    文件:I18nServiceImpl.java   
/**
 * Provides a component usable as property customizer (so typically a modal
 * dialog) that allows to choose (or create) a properties bundle file within
 * the project of given form data object. The selected file should be
 * written to the given property editor (via setValue) as a resource name
 * string.
 */
@Override
public Component getBundleSelectionComponent(final PropertyEditor prEd, FileObject srcFile) {
    try {
        final FileSelector fs = new FileSelector(srcFile, JavaResourceHolder.getTemplate());
        return fs.getDialog(NbBundle.getMessage(I18nServiceImpl.class, "CTL_SELECT_BUNDLE_TITLE"), // NOI18N
                            new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent ev) {
                DataObject bundleDO = fs.getSelectedDataObject();
                if (bundleDO != null) {
                    ClassPath cp = ClassPath.getClassPath(bundleDO.getPrimaryFile(), ClassPath.SOURCE);
                    if (cp != null) {
                        String bundleName = cp.getResourceName(bundleDO.getPrimaryFile(), '/', false);
                        prEd.setValue(bundleName);
                    }
                }
            }
        });
    }
    catch (IOException ex) {
        // means that template for properties file was not found - unlikely
        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
    }
    return null;
}
项目:incubator-netbeans    文件:RendererFactory.java   
private JComponent prepareCheckbox(PropertyEditor editor, PropertyEnv env) {
    CheckboxRenderer ren = checkboxRenderer();
    ren.setUseTitle(useLabels);
    ren.clear();
    ren.setEnabled(true);
    ren.connect(editor, env);

    return ren.getComponent();
}
项目:incubator-netbeans    文件:StringCustomEditor.java   
/** Create a StringCustomEditor.
  * @param value the initial value for the string
  * @param editable whether to show the editor in read only or read-write mode
  * @param oneline whether the text component should be a single-line or multi-line component
  * @param instructions any instructions that should be displayed
  */
 StringCustomEditor (String value, boolean editable, boolean oneline, String instructions, PropertyEditor editor, PropertyEnv env) {
     this.oneline = oneline;
     this.instructions = instructions;
     this.env = env;
     this.editor = editor;

     this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
     this.env.addPropertyChangeListener(this);

     init (value, editable);
}
项目:jdk8u-jdk    文件:PropertyEditorFinder.java   
public PropertyEditorFinder() {
    super(PropertyEditor.class, false, "Editor", DEFAULT);

    this.registry = new WeakCache<Class<?>, Class<?>>();
    this.registry.put(Byte.TYPE, ByteEditor.class);
    this.registry.put(Short.TYPE, ShortEditor.class);
    this.registry.put(Integer.TYPE, IntegerEditor.class);
    this.registry.put(Long.TYPE, LongEditor.class);
    this.registry.put(Boolean.TYPE, BooleanEditor.class);
    this.registry.put(Float.TYPE, FloatEditor.class);
    this.registry.put(Double.TYPE, DoubleEditor.class);
}