diff --git a/src/eva2/gui/BeanInspector.java b/src/eva2/gui/BeanInspector.java index 6286e545..787538b7 100644 --- a/src/eva2/gui/BeanInspector.java +++ b/src/eva2/gui/BeanInspector.java @@ -10,6 +10,7 @@ import eva2.util.annotation.Description; import eva2.util.annotation.Parameter; import java.beans.*; +import java.lang.annotation.Annotation; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -984,6 +985,30 @@ public class BeanInspector { } } + /** + * Annotations on Fields are not retained when inherited. This method traverses the + * superclass hierarchy and looks for an annotation on a given field name. + * + * @param name Name of the field in the class + * @param c Class to start searching for the field with the annotation + * @param annotation The annotation to look for + * @param + * @return Returns the annotation of the field if found, null otherwise + */ + public static T getAnnotationFromField(final String name, final Class c, final Class annotation) { + for (Field field : c.getDeclaredFields()) { + if (field.isAnnotationPresent(annotation) && field.getName().equals(name)) { + return field.getAnnotation(annotation); + } + } + + if (!c.getSuperclass().equals(Object.class)) { + return getAnnotationFromField(name, c.getSuperclass(), annotation); + } else { + return null; + } + } + /** * This method simply looks for an appropriate tiptext * @@ -998,11 +1023,9 @@ public class BeanInspector { // Find by annotation Parameter[] parameters= target.getClass().getAnnotationsByType(Parameter.class); - for (Field field : target.getClass().getDeclaredFields()) { - if (field.isAnnotationPresent(Parameter.class) && field.getName().equals(name)) { - Parameter parameter = field.getAnnotation(Parameter.class); - return parameter.description(); - } + Parameter parameter = BeanInspector.getAnnotationFromField(name, target.getClass(), Parameter.class); + if (parameter != null) { + return parameter.description(); } // Find by deprecated TipText method diff --git a/src/eva2/gui/PropertySheetPanel.java b/src/eva2/gui/PropertySheetPanel.java index b28da3ee..90570611 100644 --- a/src/eva2/gui/PropertySheetPanel.java +++ b/src/eva2/gui/PropertySheetPanel.java @@ -292,7 +292,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener itemIndex++; newView = getView(propertyEditors[i]); if (newView == null) { - System.err.println("Warning: Property \"" + name + "\" has non-displayabale editor. Skipping."); + System.err.println("Warning: Property \"" + name + "\" has non-displayable editor. Skipping."); continue; } } catch (Exception ex) { @@ -424,7 +424,6 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener * @return */ private PropertyDescriptor[] reorderProperties(Method meth) { -// Mathematics.revertArray(oldProps, newProps); Object[] args = {}; Object retV = null; PropertyDescriptor[] newProps = null; diff --git a/src/eva2/problems/InterfaceAdditionalPopulationInformer.java b/src/eva2/problems/InterfaceAdditionalPopulationInformer.java index 965c820a..7f73e140 100644 --- a/src/eva2/problems/InterfaceAdditionalPopulationInformer.java +++ b/src/eva2/problems/InterfaceAdditionalPopulationInformer.java @@ -14,7 +14,6 @@ public interface InterfaceAdditionalPopulationInformer { /** * This method returns the header for additional statistical data. * - * @param pop The population of the optimization run. * @return String */ public String[] getAdditionalDataHeader(); @@ -22,7 +21,6 @@ public interface InterfaceAdditionalPopulationInformer { /** * Optionally return informative descriptions of the data fields. * - * @param pop * @return */ public String[] getAdditionalDataInfo(); diff --git a/src/eva2/problems/InterfaceOptimizationProblem.java b/src/eva2/problems/InterfaceOptimizationProblem.java index cfc73d07..7925bcd5 100644 --- a/src/eva2/problems/InterfaceOptimizationProblem.java +++ b/src/eva2/problems/InterfaceOptimizationProblem.java @@ -19,7 +19,7 @@ public interface InterfaceOptimizationProblem extends InterfaceAdditionalPopulat public Object clone(); /** - * This method inits the Problem to log multiruns + * This method initializes the Problem to log multiruns */ public void initializeProblem(); diff --git a/src/eva2/util/annotation/Parameter.java b/src/eva2/util/annotation/Parameter.java index 0dbc69f5..875954ae 100644 --- a/src/eva2/util/annotation/Parameter.java +++ b/src/eva2/util/annotation/Parameter.java @@ -1,9 +1,9 @@ package eva2.util.annotation; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) public @interface Parameter { String name();