mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-15 01:57:39 -05:00
Update IntegerFormatter.java for negative squelch value (#2187)
Two issues: (1)documentation for change.getText() says it can be an empty string but never null. (2)Need to allow for typing a minus sign before validating min/max.
This commit is contained in:
@@ -85,7 +85,7 @@ public class IntegerFormatter extends TextFormatter<Integer>
|
|||||||
public Change apply(Change change)
|
public Change apply(Change change)
|
||||||
{
|
{
|
||||||
//Only validate if the user added text to the control. Otherwise, allow it to go through
|
//Only validate if the user added text to the control. Otherwise, allow it to go through
|
||||||
if(change.getText() != null)
|
if(!change.getText().equals(""))
|
||||||
{
|
{
|
||||||
String updatedText = change.getControlNewText();
|
String updatedText = change.getControlNewText();
|
||||||
|
|
||||||
@@ -94,6 +94,12 @@ public class IntegerFormatter extends TextFormatter<Integer>
|
|||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't validate yet if input is only a minus sign
|
||||||
|
if(updatedText.equals("-"))
|
||||||
|
{
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
if(!updatedText.matches(DECIMAL_REGEX) || !isValid(updatedText))
|
if(!updatedText.matches(DECIMAL_REGEX) || !isValid(updatedText))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user