Refactoring
This commit is contained in:
@@ -295,8 +295,4 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
public void setOutputFullStatsToText(boolean addInfo) {
|
public void setOutputFullStatsToText(boolean addInfo) {
|
||||||
((AbstractStatistics)proc.getStatistics()).getStatisticsParameter().setOutputAllFieldsAsText(addInfo);
|
((AbstractStatistics)proc.getStatistics()).getStatisticsParameter().setOutputAllFieldsAsText(addInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void configureStats(int verbosityLevel, int outputDirection, int multiRuns, boolean additionalInfo) {
|
|
||||||
// asdf
|
|
||||||
// }
|
|
||||||
}
|
}
|
@@ -9,29 +9,28 @@ import javax.swing.JCheckBox;
|
|||||||
* A checkbox for boolean editors.
|
* A checkbox for boolean editors.
|
||||||
*/
|
*/
|
||||||
public class PropertyBoolSelector extends JCheckBox {
|
public class PropertyBoolSelector extends JCheckBox {
|
||||||
private static final long serialVersionUID = 8181005734895597714L;
|
private static final long serialVersionUID = 8181005734895597714L;
|
||||||
private PropertyEditor m_Editor;
|
private PropertyEditor propertyEditor;
|
||||||
|
|
||||||
public PropertyBoolSelector(PropertyEditor pe) {
|
public PropertyBoolSelector(PropertyEditor pe) {
|
||||||
super();
|
super();
|
||||||
m_Editor = pe;
|
propertyEditor = pe;
|
||||||
if (m_Editor.getAsText().equals("True")) {
|
if (propertyEditor.getAsText().equals("True")) {
|
||||||
setSelected(true);
|
setSelected(true);
|
||||||
}
|
} else {
|
||||||
else {
|
setSelected(false);
|
||||||
setSelected(false);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addItemListener(new ItemListener () {
|
addItemListener(new ItemListener() {
|
||||||
@Override
|
@Override
|
||||||
public void itemStateChanged (ItemEvent evt) {
|
public void itemStateChanged(ItemEvent evt) {
|
||||||
if (evt.getStateChange() == ItemEvent.SELECTED) {
|
if (evt.getStateChange() == ItemEvent.SELECTED) {
|
||||||
m_Editor.setValue(Boolean.TRUE);
|
propertyEditor.setValue(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
if (evt.getStateChange() == ItemEvent.DESELECTED) {
|
if (evt.getStateChange() == ItemEvent.DESELECTED) {
|
||||||
m_Editor.setValue(Boolean.FALSE);
|
propertyEditor.setValue(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,12 @@ import eva2.optimization.go.InterfaceTerminator;
|
|||||||
import eva2.optimization.individuals.codings.gp.GPArea;
|
import eva2.optimization.individuals.codings.gp.GPArea;
|
||||||
import eva2.tools.SelectedTag;
|
import eva2.tools.SelectedTag;
|
||||||
import eva2.tools.StringSelection;
|
import eva2.tools.StringSelection;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import java.beans.PropertyEditor;
|
import java.beans.PropertyEditor;
|
||||||
import java.beans.PropertyEditorManager;
|
import java.beans.PropertyEditorManager;
|
||||||
|
|
||||||
public class PropertyEditorProvider {
|
public class PropertyEditorProvider {
|
||||||
final static boolean TRACE = false;
|
|
||||||
// if true, we use the GenericObjectEditor whenever no specific one is registered, so keep it true
|
// if true, we use the GenericObjectEditor whenever no specific one is registered, so keep it true
|
||||||
// unless you want to register every single possibility.
|
// unless you want to register every single possibility.
|
||||||
public static boolean useDefaultGOE = true;
|
public static boolean useDefaultGOE = true;
|
||||||
@@ -20,179 +20,83 @@ public class PropertyEditorProvider {
|
|||||||
* So better use the one based on PropertyDescriptor if possible.
|
* So better use the one based on PropertyDescriptor if possible.
|
||||||
*/
|
*/
|
||||||
public static PropertyEditor findEditor(Class<?> cls) {
|
public static PropertyEditor findEditor(Class<?> cls) {
|
||||||
PropertyEditor editor = null;
|
PropertyEditor editor = null;
|
||||||
editor = PropertyEditorManager.findEditor(cls);
|
editor = PropertyEditorManager.findEditor(cls);
|
||||||
|
|
||||||
// if (TRACE) System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
if ((editor == null) && useDefaultGOE) {
|
||||||
if ((editor == null) && useDefaultGOE ) {
|
if (cls.isArray()) {
|
||||||
if (cls.isArray()) {
|
|
||||||
editor = new GenericArrayEditor();
|
editor = new GenericArrayEditor();
|
||||||
}
|
} else if (cls.isEnum()) {
|
||||||
else if (cls.isEnum()) {
|
|
||||||
editor = new EnumEditor();
|
editor = new EnumEditor();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
editor = new GenericObjectEditor();
|
editor = new GenericObjectEditor();
|
||||||
}
|
}
|
||||||
// if (TRACE) System.out.println("using GOE/GAE");
|
|
||||||
}
|
|
||||||
if (TRACE) {
|
|
||||||
System.out.println("# using "+ editor.getClass().getName() + " for " + cls.getName());
|
|
||||||
}
|
}
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
private PropertyEditor makeEditor(PropertyDescriptor prop, Object value) {
|
|
||||||
Class type = prop.getPropertyType();
|
|
||||||
Class pec = prop.getPropertyEditorClass();
|
|
||||||
|
|
||||||
PropertyEditor editor = null;
|
|
||||||
//Class pec = m_Properties[i].getPropertyEditorClass();
|
|
||||||
if (pec != null) {
|
|
||||||
try {
|
|
||||||
editor = (PropertyEditor)pec.newInstance();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (editor == null) {
|
|
||||||
if (TRACE) System.out.println("PropertySheetPanel.setTarget(): No editor from pec.");
|
|
||||||
if (STREICHE) {
|
|
||||||
//@todo Streiche: Here i'm looking for a specialized editor
|
|
||||||
//if (TRACE) System.out.println("PropertySheetPanel.setTarget(): trying to find specialised editor for "+value.getClass()+".");
|
|
||||||
if (value != null) editor = PropertyEditorManager.findEditor(value.getClass());
|
|
||||||
if (TRACE) {
|
|
||||||
if (editor == null) System.out.println("PropertySheetPanel.setTarget(): Found no editor.");
|
|
||||||
else System.out.println("PropertySheetPanel.setTarget(): Found " + editor.getClass()+".");
|
|
||||||
}
|
|
||||||
if (editor == null) editor = PropertyEditorManager.findEditor(type);
|
|
||||||
} else {
|
|
||||||
editor = PropertyEditorManager.findEditor(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((TRACE) && (editor != null)) System.out.println("PropertySheetPanel.setTarget(): editor="+editor.getClass().getName());
|
|
||||||
if (editor == null) {
|
|
||||||
// If it's a user-defined property we give a warning.
|
|
||||||
String getterClass = prop.getReadMethod().getDeclaringClass().getName();
|
|
||||||
if (getterClass.indexOf("java.") != 0) {
|
|
||||||
System.err.println("Warning: Can't find public property editor"
|
|
||||||
+ " for property \"" + prop.getDisplayName() + "\" (class \""
|
|
||||||
+ type.getName() + "\"). Skipping.");
|
|
||||||
}
|
|
||||||
} else if (editor instanceof GenericObjectEditor) ((GenericObjectEditor) editor).setClassType(type);
|
|
||||||
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param prop
|
* @param prop
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static PropertyEditor findEditor(PropertyDescriptor prop, Object value) {
|
public static PropertyEditor findEditor(PropertyDescriptor prop, Object value) {
|
||||||
PropertyEditor editor = null;
|
PropertyEditor editor = null;
|
||||||
Class pec = prop.getPropertyEditorClass();
|
Class pec = prop.getPropertyEditorClass();
|
||||||
Class type = prop.getPropertyType();
|
Class type = prop.getPropertyType();
|
||||||
if (TRACE) {
|
try {
|
||||||
System.out.println("PropertyEditorProvider: Searching editor for " + value.getClass());
|
if (pec != null) {
|
||||||
|
editor = (PropertyEditor) pec.newInstance();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
editor = null;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
if (pec != null) {
|
|
||||||
editor = (PropertyEditor)pec.newInstance();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
editor = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
if (TRACE) {
|
if (value != null) {
|
||||||
System.out.println("PropertySheetPanel.makeEditor(): No editor from PEC.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//@todo Streiche: Here i'm looking for a specialized editor
|
|
||||||
//if (TRACE) System.out.println("PropertySheetPanel.setTarget(): trying to find specialised editor for "+value.getClass()+".");
|
|
||||||
if (TRACE) {
|
|
||||||
System.out.println("A PropertySheetPanel.makeEditor(): checking " + value.getClass());
|
|
||||||
}
|
|
||||||
if (value != null) {
|
|
||||||
editor = PropertyEditorManager.findEditor(value.getClass());
|
editor = PropertyEditorManager.findEditor(value.getClass());
|
||||||
}
|
}
|
||||||
if (TRACE) {
|
if (editor == null && (BeanInspector.isJavaPrimitive(value.getClass()))) {
|
||||||
System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
Class<?> prim = BeanInspector.getBoxedType(value.getClass());
|
||||||
}
|
if (prim != null) {
|
||||||
|
editor = PropertyEditorManager.findEditor(prim);
|
||||||
|
}
|
||||||
|
if (editor == null) {
|
||||||
|
|
||||||
if (editor == null && (BeanInspector.isJavaPrimitive(value.getClass()))) {
|
prim = BeanInspector.getUnboxedType(value.getClass());
|
||||||
Class<?> prim = BeanInspector.getBoxedType(value.getClass());
|
if (prim != null) {
|
||||||
if (TRACE) {
|
|
||||||
System.out.println("B1 PropertySheetPanel.makeEditor(): checking " + prim);
|
|
||||||
}
|
|
||||||
if (prim!=null) {
|
|
||||||
editor = PropertyEditorManager.findEditor(prim);
|
editor = PropertyEditorManager.findEditor(prim);
|
||||||
}
|
}
|
||||||
if (editor ==null) {
|
}
|
||||||
if (TRACE) {
|
}
|
||||||
System.out.println((editor == null ) ? "No editor from PEM by boxed type " : ("Found " + editor.getClass()));
|
|
||||||
}
|
|
||||||
|
|
||||||
prim = BeanInspector.getUnboxedType(value.getClass());
|
if (editor == null) {
|
||||||
if (TRACE) {
|
editor = PropertyEditorManager.findEditor(type);
|
||||||
System.out.println("B2 PropertySheetPanel.makeEditor(): checking " + prim);
|
}
|
||||||
}
|
|
||||||
if (prim!=null) {
|
|
||||||
editor = PropertyEditorManager.findEditor(prim);
|
|
||||||
}
|
|
||||||
if (TRACE) {
|
|
||||||
System.out.println((editor == null ) ? "No editor from PEM by unboxed type " : ("Found " + editor.getClass()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editor == null) {
|
if ((editor == null) && useDefaultGOE) {
|
||||||
if (TRACE) {
|
if (type.isArray()) {
|
||||||
System.out.println("C PropertySheetPanel.makeEditor(): checking " + type);
|
editor = new GenericArrayEditor();
|
||||||
}
|
} else if (type.isEnum()) {
|
||||||
editor = PropertyEditorManager.findEditor(type);
|
editor = new EnumEditor();
|
||||||
if (TRACE) {
|
} else {
|
||||||
System.out.println((editor == null ) ? "No editor from PEM by type" : ("Found " + editor.getClass()));
|
editor = new GenericObjectEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((editor == null) && useDefaultGOE ) {
|
|
||||||
if (type.isArray()) {
|
|
||||||
editor = new GenericArrayEditor();
|
|
||||||
}
|
|
||||||
else if (type.isEnum()) {
|
|
||||||
editor = new EnumEditor();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor = new GenericObjectEditor();
|
|
||||||
}
|
|
||||||
if (TRACE) {
|
|
||||||
System.out.println("using GOE/GAE");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (editor == null) {
|
|
||||||
// If it's a user-defined property we give a warning.
|
|
||||||
String getterClass = prop.getReadMethod().getDeclaringClass().getName();
|
|
||||||
if (getterClass.indexOf("java.") != 0) {
|
|
||||||
System.err.println("Warning: Can't find public property editor"
|
|
||||||
+ " for property \"" + prop.getDisplayName() + "\" (class \""
|
|
||||||
+ type.getName() + "\"). Skipping.");
|
|
||||||
}
|
|
||||||
} else if (editor instanceof GenericObjectEditor) {
|
|
||||||
// hier erst noch das object setzen?
|
|
||||||
// ((GenericObjectEditor) editor).getCustomEditor();
|
|
||||||
((GenericObjectEditor) editor).setClassType(type);
|
|
||||||
}
|
|
||||||
if (TRACE) {
|
|
||||||
System.out.println("+ using "+ editor.getClass().getName() + " for " + value.getClass().getName());
|
|
||||||
}
|
}
|
||||||
return editor;
|
if (editor == null) {
|
||||||
|
// If it's a user-defined property we give a warning.
|
||||||
|
String getterClass = prop.getReadMethod().getDeclaringClass().getName();
|
||||||
|
if (getterClass.indexOf("java.") != 0) {
|
||||||
|
System.err.println("Warning: Can't find public property editor"
|
||||||
|
+ " for property \"" + prop.getDisplayName() + "\" (class \""
|
||||||
|
+ type.getName() + "\"). Skipping.");
|
||||||
|
}
|
||||||
|
} else if (editor instanceof GenericObjectEditor) {
|
||||||
|
((GenericObjectEditor) editor).setClassType(type);
|
||||||
|
}
|
||||||
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,30 +108,20 @@ public class PropertyEditorProvider {
|
|||||||
PropertyEditorManager.registerEditor(double[].class, GenericArrayEditor.class);
|
PropertyEditorManager.registerEditor(double[].class, GenericArrayEditor.class);
|
||||||
PropertyEditorManager.registerEditor(InterfaceTerminator[].class, GenericArrayEditor.class);
|
PropertyEditorManager.registerEditor(InterfaceTerminator[].class, GenericArrayEditor.class);
|
||||||
|
|
||||||
// PropertyEditorManager.registerEditor(Double.class, DoubleEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(Integer.class, IntEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(Boolean.class, BoolEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(byte.class, ByteEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(Color.class, ColorEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(short.class, ShortEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(float.class, FloatEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(long.class, LongEditor.class);
|
|
||||||
// PropertyEditorManager.registerEditor(String.class, StringEditor.class);
|
|
||||||
|
|
||||||
// The Editor for the new GO
|
// The Editor for the new GO
|
||||||
|
|
||||||
PropertyEditorManager.registerEditor(StringSelection.class , StringSelectionEditor.class);
|
PropertyEditorManager.registerEditor(StringSelection.class, StringSelectionEditor.class);
|
||||||
// // Traveling Salesman problem
|
// Traveling Salesman problem
|
||||||
PropertyEditorManager.registerEditor(GPArea.class , GenericAreaEditor.class);
|
PropertyEditorManager.registerEditor(GPArea.class, GenericAreaEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyDoubleArray.class , GenericDoubleArrayEditor.class);
|
PropertyEditorManager.registerEditor(PropertyDoubleArray.class, GenericDoubleArrayEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyIntArray.class , GenericIntArrayEditor.class);
|
PropertyEditorManager.registerEditor(PropertyIntArray.class, GenericIntArrayEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyEpsilonThreshold.class , GenericEpsilonThresholdEditor.class);
|
PropertyEditorManager.registerEditor(PropertyEpsilonThreshold.class, GenericEpsilonThresholdEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyEpsilonConstraint.class , GenericEpsilonConstraintEditor.class);
|
PropertyEditorManager.registerEditor(PropertyEpsilonConstraint.class, GenericEpsilonConstraintEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, GenericWeigthedLPTchebycheffEditor.class);
|
PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, GenericWeigthedLPTchebycheffEditor.class);
|
||||||
// PropertyEditorManager.registerEditor(PropertyStringList.class , GenericStringListSelectionEditor.class);
|
PropertyEditorManager.registerEditor(PropertyFilePath.class, GenericFilePathEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyFilePath.class , GenericFilePathEditor.class);
|
PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class, GenericOptimizationObjectivesEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class , GenericOptimizationObjectivesEditor.class);
|
PropertyEditorManager.registerEditor(PropertyOptimizationObjectivesWithParam.class, GenericOptimizationObjectivesWithParamEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertyOptimizationObjectivesWithParam.class , GenericOptimizationObjectivesWithParamEditor.class);
|
|
||||||
PropertyEditorManager.registerEditor(eva2.gui.MultiLineString.class, eva2.gui.MultiLineStringEditor.class);
|
PropertyEditorManager.registerEditor(eva2.gui.MultiLineString.class, eva2.gui.MultiLineStringEditor.class);
|
||||||
PropertyEditorManager.registerEditor(PropertySelectableList.class, GenericArrayEditor.class);
|
PropertyEditorManager.registerEditor(PropertySelectableList.class, GenericArrayEditor.class);
|
||||||
}
|
}
|
||||||
|
@@ -42,35 +42,22 @@ public class PropertyPanel extends JPanel {
|
|||||||
propertyEditor = editor;
|
propertyEditor = editor;
|
||||||
|
|
||||||
textLabel = new JLabel();
|
textLabel = new JLabel();
|
||||||
|
|
||||||
add(textLabel, gbConstraints);
|
add(textLabel, gbConstraints);
|
||||||
|
|
||||||
JButton dialogButton = new JButton("...");
|
|
||||||
dialogButton.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.LIGHT_GRAY));
|
|
||||||
dialogButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(final ActionEvent event) {
|
|
||||||
if (propertyEditor.getValue() != null) {
|
|
||||||
showDialog(getLocationOnScreen().x, getLocationOnScreen().y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
gbConstraints.weighty = 1.0;
|
|
||||||
gbConstraints.fill = GridBagConstraints.VERTICAL;
|
|
||||||
gbConstraints.anchor = GridBagConstraints.LINE_END;
|
|
||||||
gbConstraints.gridx = 1;
|
|
||||||
add(dialogButton, gbConstraints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDialog(int initX, int initY) {
|
public void showDialog(int initX, int initY) {
|
||||||
if (propertyDialog == null) {
|
if (propertyDialog == null) {
|
||||||
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY);
|
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY);
|
||||||
propertyDialog.setPreferredSize(new Dimension(500,300));
|
propertyDialog.setPreferredSize(new Dimension(500,300));
|
||||||
|
propertyDialog.setModal(true);
|
||||||
propertyDialog.setVisible(true);
|
propertyDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
propertyDialog.updateFrameTitle(propertyEditor);
|
propertyDialog.updateFrameTitle(propertyEditor);
|
||||||
propertyDialog.setVisible(false);
|
propertyDialog.setVisible(false);
|
||||||
propertyDialog.setVisible(true);
|
|
||||||
propertyDialog.requestFocus();
|
propertyDialog.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,10 +85,6 @@ public class PropertyPanel extends JPanel {
|
|||||||
getSize().width - i.right - i.left,
|
getSize().width - i.right - i.left,
|
||||||
getSize().height - i.bottom - i.top);
|
getSize().height - i.bottom - i.top);
|
||||||
propertyEditor.paintValue(g, box);
|
propertyEditor.paintValue(g, box);
|
||||||
|
|
||||||
// Rectangle box = new Rectangle(i.left,i.top,
|
|
||||||
// this.getWidth() - i.right,
|
|
||||||
// this.getHeight() - i.bottom );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyEditor getEditor() {
|
public PropertyEditor getEditor() {
|
||||||
|
@@ -176,6 +176,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
||||||
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
||||||
propertyTable.setRowHeight(20);
|
propertyTable.setRowHeight(20);
|
||||||
|
propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||||
|
|
||||||
// Close any child windows at this point
|
// Close any child windows at this point
|
||||||
removeAll();
|
removeAll();
|
||||||
@@ -763,14 +764,14 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
JComponent newView = null;
|
JComponent newView = null;
|
||||||
newView = getView(tmpEdit);
|
newView = getView(tmpEdit);
|
||||||
if (newView == null) {
|
if (newView == null) {
|
||||||
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayabale editor. Skipping.");
|
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
propertyEditors[i].addPropertyChangeListener(this);
|
propertyEditors[i].addPropertyChangeListener(this);
|
||||||
views[i] = newView;
|
views[i] = newView;
|
||||||
if (toolTips[i] != null) {
|
if (toolTips[i] != null) {
|
||||||
views[i].setToolTipText(toolTips[i]);
|
views[i].setToolTipText(toolTips[i]);
|
||||||
}
|
}
|
||||||
viewWrappers[i].removeAll();
|
viewWrappers[i].removeAll();
|
||||||
viewWrappers[i].setLayout(new BorderLayout());
|
viewWrappers[i].setLayout(new BorderLayout());
|
||||||
viewWrappers[i].add(views[i], BorderLayout.CENTER);
|
viewWrappers[i].add(views[i], BorderLayout.CENTER);
|
||||||
@@ -796,8 +797,6 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
// This could check whether i have to set the value back to
|
// This could check whether i have to set the value back to
|
||||||
// the editor, this would allow to check myu and lambda
|
// the editor, this would allow to check myu and lambda
|
||||||
// why shouldn't i do this for every property!?
|
// why shouldn't i do this for every property!?
|
||||||
// System.out.println("value: "+((Integer)value).intValue());
|
|
||||||
// System.out.println(" m_Values[i]: "+ ((Integer) m_Values[i]).intValue());
|
|
||||||
if (((Integer) newValue).intValue() != ((Integer) objectValues[i]).intValue()) {
|
if (((Integer) newValue).intValue() != ((Integer) objectValues[i]).intValue()) {
|
||||||
propertyEditors[i].setValue(objectValues[i]);
|
propertyEditors[i].setValue(objectValues[i]);
|
||||||
}
|
}
|
||||||
@@ -813,7 +812,6 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("PropertySheetPanel.wasModified(): Unexpected exception while updating " + property.getName());
|
System.out.println("PropertySheetPanel.wasModified(): Unexpected exception while updating " + property.getName());
|
||||||
}
|
}
|
||||||
//revalidate();
|
|
||||||
if (views[i] != null && views[i] instanceof PropertyPanel) {
|
if (views[i] != null && views[i] instanceof PropertyPanel) {
|
||||||
//System.err.println("Trying to repaint the property canvas");
|
//System.err.println("Trying to repaint the property canvas");
|
||||||
views[i].repaint();
|
views[i].repaint();
|
||||||
@@ -944,7 +942,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean updateFieldView(int i) {
|
private boolean updateFieldView(int i) {
|
||||||
// looking at another field (not changed explicitly, maybe implicitely
|
// looking at another field (not changed explicitly, maybe implicitly
|
||||||
boolean valChanged = false;
|
boolean valChanged = false;
|
||||||
boolean doRepaint = false;
|
boolean doRepaint = false;
|
||||||
Object args[] = {};
|
Object args[] = {};
|
||||||
@@ -1071,20 +1069,43 @@ class PropertyCellRenderer implements TableCellRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyCellEditor implements TableCellEditor {
|
class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||||
private JLabel empty = new JLabel();
|
private JLabel empty = new JLabel();
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
public JComponent getTableCellEditorComponent(JTable table, final Object value, boolean isSelected, int row, int column) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
Component component;
|
JComponent component;
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
component = empty;
|
component = empty;
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
component = new JLabel(value.toString());
|
component = new JLabel(value.toString());
|
||||||
} else if (value instanceof eva2.gui.PropertyPanel) {
|
} else if (value instanceof PropertyPanel) {
|
||||||
component = (PropertyPanel) value;
|
component = new JPanel();
|
||||||
|
component.setLayout(new GridBagLayout());
|
||||||
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
|
gbConstraints.gridx = 0;
|
||||||
|
gbConstraints.gridy = 0;
|
||||||
|
gbConstraints.weightx = 1.0;
|
||||||
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
component.add((PropertyPanel) value, gbConstraints);
|
||||||
|
JButton dialogButton = new JButton("...");
|
||||||
|
dialogButton.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.LIGHT_GRAY));
|
||||||
|
dialogButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent event) {
|
||||||
|
((PropertyPanel) value).showDialog(0, 0);
|
||||||
|
fireEditingStopped();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gbConstraints = new GridBagConstraints();
|
||||||
|
gbConstraints.weighty = 1.0;
|
||||||
|
gbConstraints.fill = GridBagConstraints.VERTICAL;
|
||||||
|
gbConstraints.anchor = GridBagConstraints.LINE_END;
|
||||||
|
gbConstraints.gridy = 0;
|
||||||
|
gbConstraints.gridx = 1;
|
||||||
|
component.add(dialogButton, gbConstraints);
|
||||||
} else if (value instanceof PropertyText) {
|
} else if (value instanceof PropertyText) {
|
||||||
component = (PropertyText) value;
|
component = (PropertyText) value;
|
||||||
} else if (value instanceof PropertyBoolSelector) {
|
} else if (value instanceof PropertyBoolSelector) {
|
||||||
@@ -1094,6 +1115,7 @@ class PropertyCellEditor implements TableCellEditor {
|
|||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
component.setForeground(table.getSelectionForeground());
|
component.setForeground(table.getSelectionForeground());
|
||||||
component.setBackground(table.getSelectionBackground());
|
component.setBackground(table.getSelectionBackground());
|
||||||
@@ -1122,26 +1144,6 @@ class PropertyCellEditor implements TableCellEditor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldSelectCell(EventObject anEvent) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stopCellEditing() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelCellEditing() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCellEditorListener(CellEditorListener l) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeCellEditorListener(CellEditorListener l) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user