Commit 3dbb8290 authored by Fabian Becker's avatar Fabian Becker

Remove unused code in EnumEditor

parent eb506876
Pipeline #120 passed with stage
package eva2.gui.editor;
import eva2.gui.PropertyValueSelector;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyEditorSupport;
/**
......@@ -36,9 +30,9 @@ public class EnumEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
for (int i = 0; i < enumConstants.length; i++) {
if (text.equals(enumConstants[i].toString())) {
setValue(enumConstants[i]);
for (Enum enumConstant : enumConstants) {
if (text.equals(enumConstant.toString())) {
setValue(enumConstant);
return;
}
}
......@@ -56,40 +50,4 @@ public class EnumEditor extends PropertyEditorSupport {
}
return tags;
}
/**
* Test the editor.
*
* @param args ignored
*/
public static void main(String[] args) {
try {
Enum<?> initial = TestEnum.asdf;
EnumEditor ed = new EnumEditor();
ed.setValue(initial);
PropertyValueSelector ps = new PropertyValueSelector(ed);
JFrame f = new JFrame();
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(ps, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
System.err.println(ex.getMessage());
}
}
}
enum TestEnum {
asdf, sdf, asdfa;
public String toString() {
return "Foo" + name();
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment