Skip to content
Snippets Groups Projects
Commit 9c640596 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

DefaultComboBoxModel and JComboBox are parametered with generics

parent 0edca915
Branches
Tags
No related merge requests found
......@@ -31,36 +31,38 @@ import fr.soleil.model.scanserver.Axis;
public class AxisCellEditor extends DefaultCellEditor {
private static final long serialVersionUID = 2640997631269648791L;
private static final String[] spectrumChoices = { Axis.NONE, Axis.Y1, Axis.Y2, Axis.X };
private static String[] imageChoices;
private static final long serialVersionUID = -6613973648755544493L;
private DefaultComboBoxModel spectrumComboBoxModel;
private DefaultComboBoxModel imageComboBoxModel;
private static final String[] SPECTRUM_CHOICES = { Axis.NONE, Axis.Y1, Axis.Y2, Axis.X };
// private static String[] imageChoices;
private DefaultComboBoxModel<String> spectrumComboBoxModel;
private DefaultComboBoxModel<String> imageComboBoxModel;
private Axis currentValue = null;
public AxisCellEditor(boolean allowDisplayImageAsSpectrum) {
super(new JComboBox());
super(new JComboBox<>());
String[] defaultImageChoices = { Axis.NONE, Axis.Z };
String[] fullImageChoices = { Axis.NONE, Axis.Z, Axis.Y1, Axis.Y2, Axis.X };
if (allowDisplayImageAsSpectrum) {
imageComboBoxModel = new DefaultComboBoxModel(fullImageChoices);
imageComboBoxModel = new DefaultComboBoxModel<>(fullImageChoices);
} else {
imageComboBoxModel = new DefaultComboBoxModel(defaultImageChoices);
imageComboBoxModel = new DefaultComboBoxModel<>(defaultImageChoices);
}
spectrumComboBoxModel = new DefaultComboBoxModel(spectrumChoices);
spectrumComboBoxModel = new DefaultComboBoxModel<>(SPECTRUM_CHOICES);
}
@SuppressWarnings("unchecked")
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected,
final int row, final int column) {
if (value instanceof Axis) {
currentValue = (Axis) value;
if (currentValue.isSpectrum()) {
((JComboBox) editorComponent).setModel(spectrumComboBoxModel);
((JComboBox<String>) editorComponent).setModel(spectrumComboBoxModel);
} else {
((JComboBox) editorComponent).setModel(imageComboBoxModel);
((JComboBox<String>) editorComponent).setModel(imageComboBoxModel);
}
((JComboBox) editorComponent).setSelectedItem(currentValue.toString());
}
......@@ -71,8 +73,8 @@ public class AxisCellEditor extends DefaultCellEditor {
public Object getCellEditorValue() {
Axis newValue = null;
if (editorComponent instanceof JComboBox) {
Object item = ((JComboBox) editorComponent).getSelectedItem();
if (item != null && currentValue != null) {
Object item = ((JComboBox<?>) editorComponent).getSelectedItem();
if ((item != null) && (currentValue != null)) {
String axis = item.toString();
newValue = currentValue.clone();
newValue.setAxis(axis);
......
......@@ -14,9 +14,9 @@ import fr.soleil.model.scanserver.Axis;
public class DataFitterConfigurationBean extends JPanel {
private static final long serialVersionUID = -5406628340979125809L;
private static final long serialVersionUID = 508815913271833844L;
private final JComboBox comboBoxSpectrum = new SpectrumComboBox(true);
private final JComboBox<String> comboBoxSpectrum = new SpectrumComboBox(true);
private static final Proxy proxyPanel = new Proxy();
private final static String FITTED_DATAY = "fitteddatay";
private final static JPanel axisSelectionPanel = new JPanel();
......
......@@ -4,9 +4,9 @@ import javax.swing.JComboBox;
import fr.soleil.model.scanserver.Axis;
public class SpectrumComboBox extends JComboBox {
public class SpectrumComboBox extends JComboBox<String> {
private static final long serialVersionUID = 4295742102913204365L;
private static final long serialVersionUID = 2309870736577649058L;
public SpectrumComboBox() {
this(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment