Refine search
PropertyEditor editor = PropertyEditorManager.findEditor(clazz); if (editor != null) { editor.setAsText((String) value); return editor.getValue();
/** * ValidationBeanInfo constructor. * * <p>Description */ public ValidationBeanInfo() { super(); PropertyEditorManager.registerEditor(URL.class, URLPropertyEditor.class); }
@Override void init() { if (originalPath == null) { originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath()); } } };
public static String convertToString(Object value, Class<?> type) { PropertyEditor editor = PropertyEditorManager.findEditor(type); if (editor != null) { editor.setValue(value); return editor.getAsText(); } return null; }
/** * 查找类型转换器 {@link PropertyEditor} * * @param type 需要转换的目标类型 * @return {@link PropertyEditor} */ public static PropertyEditor findEditor(Class<?> type) { return PropertyEditorManager.findEditor(type); }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (column != 0) { return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } PropertyEditor editor = PropertyEditorManager.findEditor(configuration.getMetadata().getColumnByName(nodeColumnName).getColumnClass()); if (editor != null && value != null && !(value + "").trim().equals("")) { // NOI18N editor.setAsText(value.toString()); return super.getTableCellRendererComponent(table, editor.getAsText(), isSelected, hasFocus, row, column); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }
public Component getCustomiser(DataThing dataThing) { PropertyEditor editor = PropertyEditorManager.findEditor( Scanner.class); if(editor != null) { editor.setValue(this); return editor.getCustomEditor(); } else { return null; } }
/** * Makes sure that, at least, basic property editors are available for serializing and deserializing */ private void initBasicPropertyEditors() { if (PropertyEditorManager.findEditor(DependantColor.class) == null) { PropertyEditorManager.registerEditor(DependantColor.class, BasicDependantColorPropertyEditor.class); } if (PropertyEditorManager.findEditor(DependantOriginalColor.class) == null) { PropertyEditorManager.registerEditor(DependantOriginalColor.class, BasicDependantOriginalColorPropertyEditor.class); } if (PropertyEditorManager.findEditor(EdgeColor.class) == null) { PropertyEditorManager.registerEditor(EdgeColor.class, BasicEdgeColorPropertyEditor.class); } }
private void initEditor() { try { Object val = getValue(); Class cls = val == null ? getValueClass() : val.getClass(); cellEditor = editorMap.get(cls); if (cellEditor != null) { return; } if (cls.isEnum()) { JComboBox comboBox = new JComboBox(cls.getEnumConstants()); cellEditor = new DefaultCellEditor(comboBox); return; } for (Class class1 : assignableClasses) { if (class1.isAssignableFrom(cls)) { cellEditor = editorMap.get(class1); return; } } editor = java.beans.PropertyEditorManager.findEditor(cls); if (editor != null && editor.supportsCustomEditor()) { cellEditor = new PropertyEditorAdapter(editor, this); return; } System.out.println("Warning no editor found for property '" + name + "' with class " + cls); } catch (Exception e) { e.printStackTrace(); } }
private static void doInitEditors() { String[] currentPath = PropertyEditorManager.getEditorSearchPath(); int length = currentPath != null ? currentPath.length : 0; String[] newPath = new String[length+2]; System.arraycopy(currentPath, 0, newPath, 2, length); // Put the JBoss editor path first // The default editors are not very flexible newPath[0] = "org.jboss.util.propertyeditor"; newPath[1] = "org.jboss.mx.util.propertyeditor"; PropertyEditorManager.setEditorSearchPath(newPath); /* Register the editor types that will not be found using the standard class name to editor name algorithm. For example, the type String[] has a name '[Ljava.lang.String;' which does not map to a XXXEditor name. */ Class<String[]> strArrayType = String[].class; PropertyEditorManager.registerEditor(strArrayType, StringArrayEditor.class); @SuppressWarnings("unchecked") Class<Class[]> clsArrayType = Class[].class; PropertyEditorManager.registerEditor(clsArrayType, ClassArrayEditor.class); Class<int[]> intArrayType = int[].class; PropertyEditorManager.registerEditor(intArrayType, IntArrayEditor.class); }
@Override public void restored() { String[] old = PropertyEditorManager.getEditorSearchPath(); List<String> l = new ArrayList<>(Arrays.asList(old)); l.add("nl.cloudfarming.client.editors"); PropertyEditorManager.setEditorSearchPath(l.toArray(new String[l.size()])); }
@Override void register() { Set<String> newPath = new LinkedHashSet<String> (); for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) { PEPackageRegistration pkgReg = (PEPackageRegistration) it.next(); newPath.add(pkgReg.pkg); } newPath.addAll(originalPath); PropertyEditorManager.setEditorSearchPath(newPath.toArray(new String[newPath.size()])); }
public static String convertToString(Object value, Class<?> type) { PropertyEditor editor = PropertyEditorManager.findEditor(type); if (editor != null) { editor.setValue(value); return editor.getAsText(); } return null; }
/** * 查找类型转换器 {@link PropertyEditor} * * @param type 需要转换的目标类型 * @return {@link PropertyEditor} */ public static PropertyEditor findEditor(Class<?> type) { return PropertyEditorManager.findEditor(type); }
public static PropertyEditor get(final Class<?> type) { final PropertyEditor editor = PropertyEditorManager.findEditor(type); if (editor != null) return editor; final Class<Editors> c = Editors.class; try { final Class<?> editorClass = c.getClassLoader().loadClass(c.getName().replace("Editors", type.getSimpleName() + "Editor")); PropertyEditorManager.registerEditor(type, editorClass); return PropertyEditorManager.findEditor(type); } catch (final ClassNotFoundException e) { return null; } }
/** * Sets the package names that will be searched for property editors. * * @param path The serach path. */ public void setEditorSearchPath(final String[] path) { PropertyEditorManager.setEditorSearchPath(path); }
import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String returnValue = ... return convert(method.getReturnType(), returnValue); } private Object convert(Class<?> targetType, String text) { PropertyEditor editor = PropertyEditorManager.findEditor(targetType); editor.setAsText(text); return editor.getValue(); }
public static String convertToString(Object value, Class<?> type) { PropertyEditor editor = PropertyEditorManager.findEditor(type); if (editor != null) { editor.setValue(value); return editor.getAsText(); } return null; }
/** Get a property editor for individual elements in this property. * @return the property editor for elements */ public PropertyEditor getIndexedPropertyEditor() { return java.beans.PropertyEditorManager.findEditor(elementType); }
@Override void register() { ClassLoader clsLoader = findClsLoader(); for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) { PEClassRegistration clsReg = (PEClassRegistration) it.next(); for (String type : clsReg.targetTypes) { try { Class<?> cls = getClassFromCanonicalName(type); Class<?> editorCls = Class.forName(clsReg.editorClass, true, clsLoader); PropertyEditorManager.registerEditor(cls, editorCls); } catch (ClassNotFoundException ex) { Exceptions.printStackTrace(ex); } } } }