try {
Object args[] = { };
Object value = getter.invoke(m_Target, args);
m_Values[i] = value;
PropertyEditor editor = null;
Class pec = m_Properties[i].getPropertyEditorClass();
if (pec != null) {
try {
editor = (PropertyEditor)pec.newInstance();
} catch (Exception ex) {
// Drop through.
}
}
if (editor == null) {
editor = PropertyEditorManager.findEditor(type);
}
m_Editors[i] = editor;
// If we can't edit this component, skip it.
if (editor == null) {
// If it's a user-defined property we give a warning.
String getterClass = m_Properties[i].getReadMethod()
.getDeclaringClass().getName();
/*
if (getterClass.indexOf("java.") != 0) {
System.err.println("Warning: Can't find public property editor"
+ " for property \"" + name + "\" (class \""
+ type.getName() + "\"). Skipping.");
}
*/
continue;
}
if (editor instanceof GenericObjectEditor) {
((GenericObjectEditor) editor).setClassType(type);
}
if (editor instanceof EnvironmentHandler) {
((EnvironmentHandler)editor).setEnvironment(m_env);
}
// Don't try to set null values:
if (value == null) {
// If it's a user-defined property we give a warning.
String getterClass = m_Properties[i].getReadMethod()
.getDeclaringClass().getName();
/*
if (getterClass.indexOf("java.") != 0) {
System.err.println("Warning: Property \"" + name
+ "\" has null initial value. Skipping.");
}
*/
continue;
}
editor.setValue(value);
// now look for a TipText method for this property
String tipName = name + "TipText";
for (int j = 0; j < m_Methods.length; j++) {
String mname = m_Methods[j].getDisplayName();
Method meth = m_Methods[j].getMethod();
if (mname.equals(tipName)) {
if (meth.getReturnType().equals(String.class)) {
try {
String tempTip = (String)(meth.invoke(m_Target, args));
int ci = tempTip.indexOf('.');
if (ci < 0) {
m_TipTexts[i] = tempTip;
} else {
m_TipTexts[i] = tempTip.substring(0, ci);
}
if (m_HelpText != null) {
if (firstTip) {
m_HelpText.append("OPTIONS\n");
firstTip = false;
}
m_HelpText.append(name).append(" -- ");
m_HelpText.append(tempTip).append("\n\n");
//jt.setText(m_HelpText.toString());
}
} catch (Exception ex) {
}
break;
}
}
}
// Now figure out how to display it...
if (editor.isPaintable() && editor.supportsCustomEditor()) {
view = new PropertyPanel(editor);
} else if (editor.supportsCustomEditor() && (editor.getCustomEditor() instanceof JComponent)) {
view = (JComponent) editor.getCustomEditor();
} else if (editor.getTags() != null) {
view = new PropertyValueSelector(editor);
} else if (editor.getAsText() != null) {
view = new PropertyText(editor);
} else {
System.err.println("Warning: Property \"" + name
+ "\" has non-displayabale editor. Skipping.");
continue;
}
editor.addPropertyChangeListener(this);
} catch (InvocationTargetException ex) {
System.err.println("Skipping property " + name
+ " ; exception on target: "
+ ex.getTargetException());