Try unboxing when searching for an editor
This commit is contained in:
parent
6c13d1bb9b
commit
eb1c33549b
@ -509,6 +509,23 @@ public class BeanInspector {
|
||||
} else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a Java primitive wrapper class return the corresponding
|
||||
* primitive class.
|
||||
**/
|
||||
public static Class getUnboxedType(Class cls) {
|
||||
if (cls == Double.class) return double.class;
|
||||
else if (cls == Character.class) return char.class;
|
||||
else if (cls == Integer.class) return int.class;
|
||||
else if (cls == Boolean.class) return boolean.class;
|
||||
else if (cls == Byte.class) return byte.class;
|
||||
else if (cls == Short.class) return short.class;
|
||||
else if (cls == Long.class) return long.class;
|
||||
else if (cls == Float.class) return float.class;
|
||||
else if (cls == Void.class) return void.class;
|
||||
else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just concatenates getClassDescription(obj) and getMemberDescriptions(obj, withValues).
|
||||
*
|
||||
|
@ -90,7 +90,7 @@ public class PropertyEditorProvider {
|
||||
PropertyEditor editor = null;
|
||||
Class pec = prop.getPropertyEditorClass();
|
||||
Class type = prop.getPropertyType();
|
||||
|
||||
if (TRACE) System.out.println("PropertyEditorProvider: Searching editor for " + value.getClass());
|
||||
try {
|
||||
if (pec != null) editor = (PropertyEditor)pec.newInstance();
|
||||
} catch (Exception e) {
|
||||
@ -102,16 +102,30 @@ public class PropertyEditorProvider {
|
||||
|
||||
//@todo Streiche: Here i'm looking for a specialized editor
|
||||
//if (TRACE) System.out.println("PropertySheetPanel.setTarget(): trying to find specialised editor for "+value.getClass()+".");
|
||||
if (TRACE) System.out.println("A PropertySheetPanel.makeEditor(): checking " + value.getClass());
|
||||
if (value != null) editor = PropertyEditorManager.findEditor(value.getClass());
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
||||
|
||||
if (editor == null) editor = PropertyEditorManager.findEditor(type);
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by type" : ("Found " + editor.getClass()));
|
||||
|
||||
if (editor == null && (BeanInspector.isJavaPrimitive(value.getClass()))) {
|
||||
Class<?> prim = BeanInspector.getJavaPrimitive(value.getClass());
|
||||
Class<?> prim = BeanInspector.getBoxedType(value.getClass());
|
||||
if (TRACE) System.out.println("B1 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
if (prim!=null) editor = PropertyEditorManager.findEditor(prim);
|
||||
if (editor ==null) {
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by boxed type " : ("Found " + editor.getClass()));
|
||||
|
||||
prim = BeanInspector.getUnboxedType(value.getClass());
|
||||
if (TRACE) System.out.println("B2 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
if (prim!=null) editor = PropertyEditorManager.findEditor(prim);
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by unboxed type " : ("Found " + editor.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
if (editor == null) {
|
||||
if (TRACE) System.out.println("C PropertySheetPanel.makeEditor(): checking " + type);
|
||||
editor = PropertyEditorManager.findEditor(type);
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by type" : ("Found " + editor.getClass()));
|
||||
}
|
||||
|
||||
if ((editor == null) && useDefaultGOE ) {
|
||||
if (type.isArray()) editor = new GenericArrayEditor();
|
||||
else if (type.isEnum()) editor = new EnumEditor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user