Merge remote-tracking branch 'origin/GT-3579_rev308_integer_spinner_fixes'

This commit is contained in:
ghidorahrex 2020-03-16 08:11:43 -04:00
commit 47b71c4740

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;
}