GT-3579 - Fixed type casts

This commit is contained in:
rev308 2020-03-04 11:05:49 -05:00
parent 534fd5253a
commit a7ea897acb

View file

@ -28,7 +28,7 @@ import javax.swing.event.*;
import docking.widgets.textfield.IntegerTextField;
/**
* Creates a component for editing Integer values using an integerTextField and a Jspinner.
* Creates a component for editing Integer values using an {@link IntegerTextField} and a {@link JSpinner}.
*/
public class IntegerSpinner {
@ -46,10 +46,11 @@ public class IntegerSpinner {
spinner = new JSpinner(spinnerModel);
integerTextField = new IntegerTextField(10, (Long) spinnerModel.getValue());
integerTextField = new IntegerTextField(10, ((Number) spinnerModel.getValue()).longValue());
integerTextField.getComponent().setName("integer.spinner.editor");
Long maximum = (Long) spinnerModel.getMaximum();
integerTextField.setMaxValue(maximum == null ? null : BigInteger.valueOf(maximum));
Number maximum = (Number) spinnerModel.getMaximum();
integerTextField.setMaxValue(
maximum == null ? null : BigInteger.valueOf(maximum.longValue()));
spinner.setEditor(integerTextField.getComponent());
@ -89,15 +90,13 @@ public class IntegerSpinner {
if (previousValue != null) {
spinner.setValue(previousValue);
}
}
else {
} else {
Object nextValue = model.getNextValue();
if (nextValue != null) {
spinner.setValue(nextValue);
}
}
}
catch (IllegalArgumentException iae) {
} catch (IllegalArgumentException iae) {
// ignored
}
});
@ -112,6 +111,11 @@ public class IntegerSpinner {
}
/**
* Returns the JSpinner that has been attached to the text field.
*
* @return the JSpinner that has been attached to the text field
*/
public JSpinner getSpinner() {
return spinner;
}
@ -119,7 +123,7 @@ public class IntegerSpinner {
/**
* Returns the IntegerTextField that has been attached to the spinner.
*
* @return the IntegerTextField that has been attached to the spinner.
* @return the IntegerTextField that has been attached to the spinner.
*/
public IntegerTextField getTextField() {
return integerTextField;