diff --git a/src/eva2/gui/PropertyEditorProvider.java b/src/eva2/gui/PropertyEditorProvider.java index 841a7f42..cd8e0b47 100644 --- a/src/eva2/gui/PropertyEditorProvider.java +++ b/src/eva2/gui/PropertyEditorProvider.java @@ -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,7 +56,13 @@ public class PropertyEditorProvider { if (editor == null) { if (value != null) { - editor = PropertyEditorManager.findEditor(value.getClass()); + + // 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()); @@ -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); diff --git a/src/eva2/gui/editor/EnumEditor.java b/src/eva2/gui/editor/EnumEditor.java index d936f072..5e3e30bd 100644 --- a/src/eva2/gui/editor/EnumEditor.java +++ b/src/eva2/gui/editor/EnumEditor.java @@ -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} \ No newline at end of file +enum TestEnum { + asdf, sdf, asdfa; + + public String toString() { + return "Foo"; + } +} \ No newline at end of file diff --git a/src/eva2/optimization/enums/DEType.java b/src/eva2/optimization/enums/DEType.java index aed515a2..e9dd1598 100644 --- a/src/eva2/optimization/enums/DEType.java +++ b/src/eva2/optimization/enums/DEType.java @@ -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. *