Example usage for java.beans PropertyEditorManager getEditorSearchPath

List of usage examples for java.beans PropertyEditorManager getEditorSearchPath

Introduction

In this page you can find the example usage for java.beans PropertyEditorManager getEditorSearchPath.

Prototype

public static String[] getEditorSearchPath() 

Source Link

Document

Gets the package names that will be searched for property editors.

Usage

From source file:org.eclipse.wb.internal.swing.model.property.editor.beans.JavaBeanEditorProvider.java

@Override
public PropertyEditor getEditorForType(Class<?> propertyType) throws Exception {
    String propertyTypeName = propertyType.getName();
    if (Object.class.isAssignableFrom(propertyType) && propertyType != char[].class
            && propertyType != byte[].class && propertyType != int[].class && propertyType != int[][].class
            && propertyTypeName.indexOf("java.lang.") == -1 && propertyTypeName.indexOf("java.util.") == -1
            && propertyTypeName.indexOf("java.awt.") == -1 && propertyTypeName.indexOf("javax.swing.") == -1
            && propertyTypeName.indexOf("org.eclipse.") == -1) {
        String[] standard_editorSearchPath = PropertyEditorManager.getEditorSearchPath();
        try {//from  www.  j  av  a2s .co  m
            PropertyEditorManager.setEditorSearchPath(
                    (String[]) ArrayUtils.removeElement(standard_editorSearchPath, "sun.beans.editors"));
            java.beans.PropertyEditor propertyEditor = PropertyEditorManager.findEditor(propertyType);
            if (propertyEditor != null) {
                return createEditor(propertyEditor);
            }
        } finally {
            PropertyEditorManager.setEditorSearchPath(standard_editorSearchPath);
        }
    }
    return null;
}

From source file:org.ppwcode.vernacular.value_III.web.RegisterPropertyEditors.java

/**
 * Register this library in the {@link PropertyEditorManager}
 * {@link PropertyEditor} lookup path.//from  w w w . j  a va  2  s.  co  m
 */
public void contextInitialized(final ServletContextEvent event) {
    assert preArgumentNotNull(event, "event");
    assert pre(event.getServletContext() != null, "event.getServletContext() != null");
    String initParameterValue = event.getServletContext().getInitParameter(INIT_PARAMETER_NAME);
    if (empty(initParameterValue) && LOG.isDebugEnabled()) {
        LOG.debug("no init parameter \"" + INIT_PARAMETER_NAME
                + "\" found; no package names added to PropertyEditorManager property editor search path");
    } else {
        LOG.debug("found init parameter \"" + INIT_PARAMETER_NAME + "\": " + initParameterValue);
        String[] split = initParameterValue.split(SPLIT_PATTERN);
        for (int i = 0; i < split.length; i++) {
            String pn = split[i];
            pn = pn.trim();
            if (!empty(pn)) {
                LOG.debug("adding package name \"" + pn
                        + "\" to PropertyEditorManager property editor search path");
                registerPropertyEditorPackage(pn);
            }
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("PropertyEditorManager property editor search path: "
                    + PropertyEditorManager.getEditorSearchPath());
        }
    }
}