Remove Generic from most editors. They are not generic at all.

This commit is contained in:
Fabian Becker 2014-11-09 18:57:50 +01:00
parent 8f35b0c6d4
commit 6386c03f43
13 changed files with 61 additions and 75 deletions

View File

@ -25,7 +25,7 @@ public class PropertyEditorProvider {
if ((editor == null) && useDefaultGOE) { if ((editor == null) && useDefaultGOE) {
if (cls.isArray()) { if (cls.isArray()) {
editor = new GenericArrayEditor(); editor = new ArrayEditor();
} else if (cls.isEnum()) { } else if (cls.isEnum()) {
editor = new EnumEditor(); editor = new EnumEditor();
} else { } else {
@ -84,7 +84,7 @@ public class PropertyEditorProvider {
if ((editor == null) && useDefaultGOE) { if ((editor == null) && useDefaultGOE) {
if (type.isArray()) { if (type.isArray()) {
editor = new GenericArrayEditor(); editor = new ArrayEditor();
} else if (type.isEnum()) { } else if (type.isEnum()) {
editor = new EnumEditor(); editor = new EnumEditor();
} else { } else {
@ -114,25 +114,25 @@ public class PropertyEditorProvider {
PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class); PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class);
PropertyEditorManager.registerEditor(Enum.class, EnumEditor.class); PropertyEditorManager.registerEditor(Enum.class, EnumEditor.class);
PropertyEditorManager.registerEditor(int[].class, GenericArrayEditor.class); PropertyEditorManager.registerEditor(int[].class, ArrayEditor.class);
PropertyEditorManager.registerEditor(double[].class, GenericArrayEditor.class); PropertyEditorManager.registerEditor(double[].class, ArrayEditor.class);
PropertyEditorManager.registerEditor(InterfaceTerminator[].class, GenericArrayEditor.class); PropertyEditorManager.registerEditor(InterfaceTerminator[].class, ArrayEditor.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, AreaEditor.class);
PropertyEditorManager.registerEditor(PropertyDoubleArray.class, GenericDoubleArrayEditor.class); PropertyEditorManager.registerEditor(PropertyDoubleArray.class, DoubleArrayEditor.class);
PropertyEditorManager.registerEditor(PropertyIntArray.class, GenericIntArrayEditor.class); PropertyEditorManager.registerEditor(PropertyIntArray.class, IntArrayEditor.class);
PropertyEditorManager.registerEditor(PropertyEpsilonThreshold.class, GenericEpsilonThresholdEditor.class); PropertyEditorManager.registerEditor(PropertyEpsilonThreshold.class, EpsilonThresholdEditor.class);
PropertyEditorManager.registerEditor(PropertyEpsilonConstraint.class, GenericEpsilonConstraintEditor.class); PropertyEditorManager.registerEditor(PropertyEpsilonConstraint.class, EpsilonConstraintEditor.class);
PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, GenericWeigthedLPTchebycheffEditor.class); PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, WeigthedLPTchebycheffEditor.class);
PropertyEditorManager.registerEditor(PropertyFilePath.class, GenericFilePathEditor.class); PropertyEditorManager.registerEditor(PropertyFilePath.class, FilePathEditor.class);
PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class, GenericOptimizationObjectivesEditor.class); PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class, OptimizationObjectivesEditor.class);
PropertyEditorManager.registerEditor(PropertyOptimizationObjectivesWithParam.class, GenericOptimizationObjectivesWithParamEditor.class); PropertyEditorManager.registerEditor(PropertyOptimizationObjectivesWithParam.class, OptimizationObjectivesWithParamEditor.class);
PropertyEditorManager.registerEditor(eva2.gui.MultiLineString.class, MultiLineStringEditor.class); PropertyEditorManager.registerEditor(eva2.gui.MultiLineString.class, MultiLineStringEditor.class);
PropertyEditorManager.registerEditor(PropertySelectableList.class, GenericArrayEditor.class); PropertyEditorManager.registerEditor(PropertySelectableList.class, ArrayEditor.class);
} }
} }

View File

@ -6,13 +6,13 @@ import eva2.optimization.individuals.codings.gp.GPArea;
/** /**
* *
*/ */
public class GenericAreaEditor extends AbstractListSelectionEditor { public class AreaEditor extends AbstractListSelectionEditor {
/** /**
* The GPArea that is to be edited * The GPArea that is to be edited
*/ */
private GPArea areaObject; private GPArea areaObject;
public GenericAreaEditor() { public AreaEditor() {
// compiled code // compiled code
} }

View File

@ -19,9 +19,9 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
public class GenericArrayEditor extends JPanel implements PropertyEditor { public class ArrayEditor extends JPanel implements PropertyEditor {
private final static Logger LOGGER = Logger.getLogger(GenericArrayEditor.class.getName()); private final static Logger LOGGER = Logger.getLogger(ArrayEditor.class.getName());
/** /**
* Handles property change notification * Handles property change notification
*/ */
@ -126,7 +126,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
} }
propChangeSupport.firePropertyChange("", null, null); propChangeSupport.firePropertyChange("", null, null);
} catch (Exception ex) { } catch (Exception ex) {
JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(ArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
} else if (e.getSource() == setAllButton) { } else if (e.getSource() == setAllButton) {
Object addObj = elementEditor.getValue(); Object addObj = elementEditor.getValue();
@ -134,7 +134,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
try { try {
listModel.setElementAt(new SerializedObject(addObj).getObject(), i); listModel.setElementAt(new SerializedObject(addObj).getObject(), i);
} catch (Exception e1) { } catch (Exception e1) {
JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(ArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
} }
propChangeSupport.firePropertyChange("", null, null); propChangeSupport.firePropertyChange("", null, null);
@ -145,7 +145,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
try { try {
listModel.setElementAt(new SerializedObject(addObj).getObject(), selected); listModel.setElementAt(new SerializedObject(addObj).getObject(), selected);
} catch (Exception e1) { } catch (Exception e1) {
JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(ArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
propChangeSupport.firePropertyChange("", null, null); propChangeSupport.firePropertyChange("", null, null);
} }
@ -193,7 +193,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
/** /**
* Sets up the array editor. * Sets up the array editor.
*/ */
public GenericArrayEditor() { public ArrayEditor() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(cantEditLabel, BorderLayout.CENTER); add(cantEditLabel, BorderLayout.CENTER);
deleteButton.addActionListener(innerActionListener); deleteButton.addActionListener(innerActionListener);
@ -213,9 +213,9 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
private class ActionJList extends MouseAdapter { private class ActionJList extends MouseAdapter {
protected JList list; protected JList list;
GenericArrayEditor gae = null; ArrayEditor gae = null;
public ActionJList(JList l, GenericArrayEditor genAE) { public ActionJList(JList l, ArrayEditor genAE) {
list = l; list = l;
gae = genAE; gae = genAE;
} }
@ -628,7 +628,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
for (JMenuItem item : popupItemList) { for (JMenuItem item : popupItemList) {
popupMenu.add(item); popupMenu.add(item);
} }
popupMenu.show(GenericArrayEditor.this, e.getX(), e.getY()); popupMenu.show(ArrayEditor.this, e.getX(), e.getY());
} }
} }
}); });

View File

@ -16,9 +16,9 @@ import java.beans.PropertyEditor;
*/ */
class MyFocusListener implements FocusListener { class MyFocusListener implements FocusListener {
private int myID = -1; private int myID = -1;
private GenericDoubleArrayEditor arrEditor = null; private DoubleArrayEditor arrEditor = null;
public MyFocusListener(int id, GenericDoubleArrayEditor gdae) { public MyFocusListener(int id, DoubleArrayEditor gdae) {
myID = id; myID = id;
this.arrEditor = gdae; this.arrEditor = gdae;
} }
@ -46,9 +46,7 @@ class MyFocusListener implements FocusListener {
/** /**
* A generic editor for PropertyDoubleArray. * A generic editor for PropertyDoubleArray.
*/ */
public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor { public class DoubleArrayEditor extends JPanel implements PropertyEditor {
private static final long serialVersionUID = 7749892624600018812L;
/** /**
* Handles property change notification * Handles property change notification
*/ */
@ -74,7 +72,7 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
*/ */
private int lastFocussedRow = -1; private int lastFocussedRow = -1;
public GenericDoubleArrayEditor() { public DoubleArrayEditor() {
// compiled code // compiled code
} }

View File

@ -12,7 +12,7 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor { public class EpsilonConstraintEditor extends JPanel implements PropertyEditor {
/** /**
* Handles property change notification * Handles property change notification
@ -35,7 +35,7 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
private JComboBox objectiveComboBox; private JComboBox objectiveComboBox;
private JButton okButton; private JButton okButton;
public GenericEpsilonConstraintEditor() { public EpsilonConstraintEditor() {
// compiled code // compiled code
} }

View File

@ -12,16 +12,12 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor { public class EpsilonThresholdEditor extends JPanel implements PropertyEditor {
/** /**
* Handles property change notification * Handles property change notification
*/ */
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
/**
* The label for when we can't edit that type
*/
private JLabel label = new JLabel("Can't edit", SwingConstants.CENTER);
/** /**
* The filePath that is to be edited * The filePath that is to be edited
*/ */
@ -35,7 +31,7 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
private JComboBox objectiveComboBox; private JComboBox objectiveComboBox;
private JButton okButton; private JButton okButton;
public GenericEpsilonThresholdEditor() { public EpsilonThresholdEditor() {
// compiled code // compiled code
} }

View File

@ -14,16 +14,12 @@ import java.io.File;
/** /**
* *
*/ */
public class GenericFilePathEditor extends JPanel implements PropertyEditor { public class FilePathEditor extends JPanel implements PropertyEditor {
/** /**
* Handles property change notification * Handles property change notification
*/ */
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
/**
* The label for when we can't edit that type
*/
private JLabel label = new JLabel("Can't edit", SwingConstants.CENTER);
/** /**
* The filePath that is to be edited * The filePath that is to be edited
*/ */
@ -35,7 +31,7 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
private JFileChooser fileChooser; private JFileChooser fileChooser;
private JPanel panel; private JPanel panel;
public GenericFilePathEditor() { public FilePathEditor() {
// compiled code // compiled code
} }

View File

@ -15,16 +15,12 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericIntArrayEditor extends JPanel implements PropertyEditor { public class IntArrayEditor extends JPanel implements PropertyEditor {
/** /**
* Handles property change notification * Handles property change notification
*/ */
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
/**
* The label for when we can't edit that type
*/
private JLabel label = new JLabel("Can't edit", SwingConstants.CENTER);
/** /**
* The filePath that is to be edited * The filePath that is to be edited
*/ */
@ -37,7 +33,7 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
private JTextField[] inputTextField; private JTextField[] inputTextField;
private JButton okButton; private JButton okButton;
public GenericIntArrayEditor() { public IntArrayEditor() {
// compiled code // compiled code
} }

View File

@ -5,10 +5,10 @@ import eva2.gui.PropertySelectableList;
/** /**
* An editor for a selectable List. * An editor for a selectable List.
*/ */
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor { public class ObjectListSelectionEditor extends AbstractListSelectionEditor {
private PropertySelectableList objList; private PropertySelectableList objList;
public GenericObjectListSelectionEditor() { public ObjectListSelectionEditor() {
} }
@Override @Override

View File

@ -22,7 +22,7 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener { public class OptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
/** /**
* Handles property change notification * Handles property change notification
@ -48,7 +48,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
private GeneralOptimizationEditorProperty[] editors; private GeneralOptimizationEditorProperty[] editors;
private PropertyChangeListener self; private PropertyChangeListener self;
public GenericOptimizationObjectivesEditor() { public OptimizationObjectivesEditor() {
self = this; self = this;
} }

View File

@ -23,7 +23,7 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener { public class OptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
/** /**
* Handles property change notification * Handles property change notification
@ -50,7 +50,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
private GeneralOptimizationEditorProperty[] editors; private GeneralOptimizationEditorProperty[] editors;
private PropertyChangeListener self; private PropertyChangeListener self;
public GenericOptimizationObjectivesWithParamEditor() { public OptimizationObjectivesWithParamEditor() {
self = this; self = this;
} }

View File

@ -15,7 +15,7 @@ import java.beans.PropertyEditor;
/** /**
* *
*/ */
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor { public class WeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
/** /**
* Handles property change notification * Handles property change notification
@ -38,7 +38,7 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
private JTextField pvalueTextField; private JTextField pvalueTextField;
private JButton okButton; private JButton okButton;
public GenericWeigthedLPTchebycheffEditor() { public WeigthedLPTchebycheffEditor() {
// compiled code // compiled code
} }

View File

@ -2,7 +2,7 @@ package eva2.optimization.statistics;
import eva2.gui.JParaPanel; import eva2.gui.JParaPanel;
import eva2.gui.PropertySelectableList; import eva2.gui.PropertySelectableList;
import eva2.gui.editor.GenericArrayEditor; import eva2.gui.editor.ArrayEditor;
import eva2.optimization.enums.StatisticsOnSingleDataSet; import eva2.optimization.enums.StatisticsOnSingleDataSet;
import eva2.optimization.enums.StatisticsOnTwoSampledData; import eva2.optimization.enums.StatisticsOnTwoSampledData;
import eva2.optimization.go.InterfaceOptimizationParameters; import eva2.optimization.go.InterfaceOptimizationParameters;
@ -155,14 +155,14 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
* @return * @return
*/ */
public static PropertyEditor makeEditor(final Component parent, final OptimizationJobList jobList) { public static PropertyEditor makeEditor(final Component parent, final OptimizationJobList jobList) {
final GenericArrayEditor genericArrayEditor = new GenericArrayEditor(); final ArrayEditor arrayEditor = new ArrayEditor();
genericArrayEditor.setWithAddButton(false); arrayEditor.setWithAddButton(false);
genericArrayEditor.setWithSetButton(false); arrayEditor.setWithSetButton(false);
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
StatisticalEvaluation.evaluate(jobList, jobList.getObjects(), genericArrayEditor.getSelectedIndices(), StatisticalEvaluation.evaluate(jobList, jobList.getObjects(), arrayEditor.getSelectedIndices(),
(StatisticsOnSingleDataSet[]) StatisticalEvaluation.statsParams.getOneSampledStats().getSelectedEnum(StatisticsOnSingleDataSet.values()), (StatisticsOnSingleDataSet[]) StatisticalEvaluation.statsParams.getOneSampledStats().getSelectedEnum(StatisticsOnSingleDataSet.values()),
(StatisticsOnTwoSampledData[]) StatisticalEvaluation.statsParams.getTwoSampledStats().getSelectedEnum(StatisticsOnTwoSampledData.values())); (StatisticsOnTwoSampledData[]) StatisticalEvaluation.statsParams.getTwoSampledStats().getSelectedEnum(StatisticsOnTwoSampledData.values()));
} }
@ -171,28 +171,28 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
genericArrayEditor.selectDeselectAll(); arrayEditor.selectDeselectAll();
} }
}; };
ActionListener sal = new ActionListener() { ActionListener sal = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
jobList.saveSelectedJobs(genericArrayEditor); jobList.saveSelectedJobs(arrayEditor);
} }
}; };
genericArrayEditor.addUpperActionButton("(De-)Sel. all", sl); arrayEditor.addUpperActionButton("(De-)Sel. all", sl);
genericArrayEditor.addUpperActionButton("Test Stats", al); arrayEditor.addUpperActionButton("Test Stats", al);
genericArrayEditor.addLowerActionButton("Save selected", sal); arrayEditor.addLowerActionButton("Save selected", sal);
genericArrayEditor.addPopupItem("Reuse as current settings", getReuseActionListener(parent, jobList)); arrayEditor.addPopupItem("Reuse as current settings", getReuseActionListener(parent, jobList));
genericArrayEditor.setAdditionalCenterPane(createStatsPanel(jobList, genericArrayEditor)); arrayEditor.setAdditionalCenterPane(createStatsPanel(jobList, arrayEditor));
genericArrayEditor.setValue(jobList); arrayEditor.setValue(jobList);
return genericArrayEditor; return arrayEditor;
} }
private static JComponent createStatsPanel(final OptimizationJobList jobList, final GenericArrayEditor edi) { private static JComponent createStatsPanel(final OptimizationJobList jobList, final ArrayEditor edi) {
JParaPanel pan = new JParaPanel(StatisticalEvaluation.statsParams, "Statistics"); JParaPanel pan = new JParaPanel(StatisticalEvaluation.statsParams, "Statistics");
return pan.makePanel(); return pan.makePanel();
} }