parent
62e436274c
commit
93aff6d876
@ -21,8 +21,7 @@ public class PropertyEditorProvider {
|
||||
* So better use the one based on PropertyDescriptor if possible.
|
||||
*/
|
||||
public static PropertyEditor findEditor(Class<?> cls) {
|
||||
PropertyEditor editor = null;
|
||||
editor = PropertyEditorManager.findEditor(cls);
|
||||
PropertyEditor editor = PropertyEditorManager.findEditor(cls);
|
||||
|
||||
if ((editor == null) && useDefaultGOE) {
|
||||
if (cls.isArray()) {
|
||||
@ -46,6 +45,7 @@ public class PropertyEditorProvider {
|
||||
PropertyEditor editor = null;
|
||||
Class pec = prop.getPropertyEditorClass();
|
||||
Class type = prop.getPropertyType();
|
||||
|
||||
try {
|
||||
if (pec != null) {
|
||||
editor = (PropertyEditor) pec.newInstance();
|
||||
@ -56,8 +56,14 @@ public class PropertyEditorProvider {
|
||||
|
||||
if (editor == null) {
|
||||
if (value != null) {
|
||||
|
||||
// ToDo: This should be handled by the registerEditor below. findEditor however always returns the sun.beans.editor stuff.
|
||||
if (value instanceof Enum) {
|
||||
editor = new EnumEditor();
|
||||
} else {
|
||||
editor = PropertyEditorManager.findEditor(value.getClass());
|
||||
}
|
||||
}
|
||||
if (editor == null && (BeanInspector.isJavaPrimitive(value.getClass()))) {
|
||||
Class<?> prim = BeanInspector.getBoxedType(value.getClass());
|
||||
if (prim != null) {
|
||||
@ -103,6 +109,9 @@ public class PropertyEditorProvider {
|
||||
/**
|
||||
*/
|
||||
public static void installEditors() {
|
||||
// First unregister the default EnumEditor provided by sun.*
|
||||
PropertyEditorManager.registerEditor(Enum.class, null);
|
||||
|
||||
PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class);
|
||||
PropertyEditorManager.registerEditor(Enum.class, EnumEditor.class);
|
||||
PropertyEditorManager.registerEditor(int[].class, GenericArrayEditor.class);
|
||||
|
@ -9,11 +9,7 @@ import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 27.06.2003
|
||||
* Time: 11:41:01
|
||||
* To change this template use Options | File Templates.
|
||||
*
|
||||
*/
|
||||
public class EnumEditor extends PropertyEditorSupport {
|
||||
/**
|
||||
@ -92,4 +88,10 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
}
|
||||
}
|
||||
|
||||
enum TestEnum {asdf, sdf, asdfa}
|
||||
enum TestEnum {
|
||||
asdf, sdf, asdfa;
|
||||
|
||||
public String toString() {
|
||||
return "Foo";
|
||||
}
|
||||
}
|
@ -4,6 +4,26 @@ public enum DEType {
|
||||
DE1_Rand_1, DE2_CurrentToBest, DE_Best_1, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
|
||||
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch(this) {
|
||||
case DE1_Rand_1:
|
||||
return "DE/rand/1";
|
||||
case DE2_CurrentToBest:
|
||||
return "DE/current-to-best/1";
|
||||
case DE_Best_1:
|
||||
return "DE/best/1";
|
||||
case DE_Best_2:
|
||||
return "DE/best/2";
|
||||
case TrigonometricDE:
|
||||
return this.name();
|
||||
case DE_CurrentToRand:
|
||||
return "DE/current-to-rand";
|
||||
default:
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to translate the "old" integer tags into the enum type.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user