@@ -7,12 +7,9 @@ import eva2.tools.SelectedTag;
 | 
				
			|||||||
import eva2.tools.StringTools;
 | 
					import eva2.tools.StringTools;
 | 
				
			||||||
import eva2.tools.Tag;
 | 
					import eva2.tools.Tag;
 | 
				
			||||||
import eva2.util.annotation.Description;
 | 
					import eva2.util.annotation.Description;
 | 
				
			||||||
import eva2.util.annotation.Parameter;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.beans.*;
 | 
					import java.beans.*;
 | 
				
			||||||
import java.lang.annotation.Annotation;
 | 
					 | 
				
			||||||
import java.lang.reflect.Array;
 | 
					import java.lang.reflect.Array;
 | 
				
			||||||
import java.lang.reflect.Field;
 | 
					 | 
				
			||||||
import java.lang.reflect.Method;
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@@ -985,30 +982,6 @@ 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 <T>
 | 
					 | 
				
			||||||
     * @return Returns the annotation of the field if found, null otherwise
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public static <T extends Annotation> T getAnnotationFromField(final String name, final Class c, final Class<T> 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
 | 
					     * This method simply looks for an appropriate tiptext
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -1021,12 +994,6 @@ public class BeanInspector {
 | 
				
			|||||||
        String result = "";
 | 
					        String result = "";
 | 
				
			||||||
        String tipName = name + "TipText";
 | 
					        String tipName = name + "TipText";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Find by annotation
 | 
					 | 
				
			||||||
        Parameter parameter = BeanInspector.getAnnotationFromField(name, target.getClass(), Parameter.class);
 | 
					 | 
				
			||||||
        if (parameter != null) {
 | 
					 | 
				
			||||||
            return parameter.description();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Find by deprecated TipText method
 | 
					        // Find by deprecated TipText method
 | 
				
			||||||
        for (MethodDescriptor method : methods) {
 | 
					        for (MethodDescriptor method : methods) {
 | 
				
			||||||
            String mname = method.getDisplayName();
 | 
					            String mname = method.getDisplayName();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
package eva2.gui;
 | 
					package eva2.gui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eva2.gui.editor.GenericObjectEditor;
 | 
					import eva2.gui.editor.GenericObjectEditor;
 | 
				
			||||||
import eva2.optimization.strategies.InterfaceOptimizer;
 | 
					 | 
				
			||||||
import eva2.tools.EVAHELP;
 | 
					import eva2.tools.EVAHELP;
 | 
				
			||||||
import eva2.util.annotation.Description;
 | 
					import eva2.util.annotation.Description;
 | 
				
			||||||
import eva2.util.annotation.Hidden;
 | 
					import eva2.util.annotation.Hidden;
 | 
				
			||||||
 | 
					import eva2.util.annotation.Parameter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.swing.*;
 | 
					import javax.swing.*;
 | 
				
			||||||
import javax.swing.table.DefaultTableModel;
 | 
					import javax.swing.table.DefaultTableModel;
 | 
				
			||||||
@@ -16,7 +16,6 @@ import java.awt.event.ActionEvent;
 | 
				
			|||||||
import java.awt.event.ActionListener;
 | 
					import java.awt.event.ActionListener;
 | 
				
			||||||
import java.awt.event.MouseEvent;
 | 
					import java.awt.event.MouseEvent;
 | 
				
			||||||
import java.beans.*;
 | 
					import java.beans.*;
 | 
				
			||||||
import java.lang.annotation.Annotation;
 | 
					 | 
				
			||||||
import java.lang.reflect.InvocationTargetException;
 | 
					import java.lang.reflect.InvocationTargetException;
 | 
				
			||||||
import java.lang.reflect.Method;
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
import java.util.EventObject;
 | 
					import java.util.EventObject;
 | 
				
			||||||
@@ -290,7 +289,13 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
 | 
				
			|||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                toolTips[itemIndex] = BeanInspector.getToolTipText(name, methodDescriptors, targetObject, stripToolTipToFirstPoint, tipTextLineLen);
 | 
					                // If the property's setter has the Parameter annotation use the description as tipText
 | 
				
			||||||
 | 
					                if (propertyDescriptors[i].getWriteMethod() != null && propertyDescriptors[i].getWriteMethod().isAnnotationPresent(Parameter.class)) {
 | 
				
			||||||
 | 
					                    Parameter parameter = propertyDescriptors[i].getWriteMethod().getAnnotation(Parameter.class);
 | 
				
			||||||
 | 
					                    toolTips[itemIndex] = parameter.description();
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    toolTips[itemIndex] = BeanInspector.getToolTipText(name, methodDescriptors, targetObject);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                itemIndex++;
 | 
					                itemIndex++;
 | 
				
			||||||
                newView = getView(propertyEditors[i]);
 | 
					                newView = getView(propertyEditors[i]);
 | 
				
			||||||
                if (newView == null) {
 | 
					                if (newView == null) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ import eva2.gui.PropertyEditorProvider;
 | 
				
			|||||||
import eva2.gui.PropertySheetPanel;
 | 
					import eva2.gui.PropertySheetPanel;
 | 
				
			||||||
import eva2.gui.editor.GenericObjectEditor;
 | 
					import eva2.gui.editor.GenericObjectEditor;
 | 
				
			||||||
import eva2.tools.EVAHELP;
 | 
					import eva2.tools.EVAHELP;
 | 
				
			||||||
 | 
					import eva2.util.annotation.Parameter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.swing.*;
 | 
					import javax.swing.*;
 | 
				
			||||||
import java.awt.*;
 | 
					import java.awt.*;
 | 
				
			||||||
@@ -265,7 +266,13 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans
 | 
				
			|||||||
                result.propertyType = propertyDescriptor.getPropertyType();
 | 
					                result.propertyType = propertyDescriptor.getPropertyType();
 | 
				
			||||||
                result.name = propertyDescriptor.getDisplayName();
 | 
					                result.name = propertyDescriptor.getDisplayName();
 | 
				
			||||||
                result.label = new JLabel(result.name, SwingConstants.RIGHT);
 | 
					                result.label = new JLabel(result.name, SwingConstants.RIGHT);
 | 
				
			||||||
                result.tipText = BeanInspector.getToolTipText(result.name, methods, target);
 | 
					                // If the property's setter has the Parameter annotation use the description as tipText
 | 
				
			||||||
 | 
					                if (propertyDescriptor.getWriteMethod() != null && propertyDescriptor.getWriteMethod().isAnnotationPresent(Parameter.class)) {
 | 
				
			||||||
 | 
					                    Parameter parameter = propertyDescriptor.getWriteMethod().getAnnotation(Parameter.class);
 | 
				
			||||||
 | 
					                    result.tipText = parameter.description();
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    result.tipText = BeanInspector.getToolTipText(result.name, methods, target);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    result.value = result.getMethod.invoke(target, args);
 | 
					                    result.value = result.getMethod.invoke(target, args);
 | 
				
			||||||
                    result.editor = PropertyEditorProvider.findEditor(propertyDescriptor, result.value);
 | 
					                    result.editor = PropertyEditorProvider.findEditor(propertyDescriptor, result.value);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user