-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes the issue "Non valid number as font size results in an uncaught exception." #7438
Conversation
Please fix the checkstyle issues, otherwise lgtm! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use org.jabref.gui.util.OnlyIntegerFormatter
@calixtus The problem is that the OnlyIntegerFormatter returns null for no value and this will throw an exception in the spinner IntegerConverter (was my first attempt either) |
Just to comment on that @Siedlerchr, the |
Isn't it possible to pass a default value as an argument to the constructor? |
@calixtus Are you referring to the |
The Database tests fail. Can someone elaborate on this. |
The database test sometimes fail for no reason, not related to you changes |
I was referring to the OnlyIntegerFormatter. But I am satisfied. Thank you for your work here. |
@calixtus you are welcome. |
@calixtus I think you need to approve before we can merge, since you requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few very minor remarks from my side. Apart from this, +1 for merge.
if (Pattern.matches("\\d*", c.getText())) { | ||
return c; | ||
} | ||
c.setText("0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think returning null
here is slightly better, at least according to the documentation "Returning null rejects the change." https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TextFormatter.html#getFilter--
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comments in this thread. Returning null will produce an exception in the spinner
@@ -27,6 +31,16 @@ | |||
|
|||
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer(); | |||
|
|||
// The fontSizeFormatter formats the input given to the fontSize spinner so that non valid values cannot be entered. | |||
private TextFormatter<Integer> fontSizeFormatter = new TextFormatter<Integer>(new IntegerStringConverter(), 9, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this might be handy also in other places, I would propose to extract this to a static method in the a helper class gui.util.TextFormatter
@@ -27,6 +31,16 @@ | |||
|
|||
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer(); | |||
|
|||
// The fontSizeFormatter formats the input given to the fontSize spinner so that non valid values cannot be entered. | |||
private TextFormatter<Integer> fontSizeFormatter = new TextFormatter<Integer>(new IntegerStringConverter(), 9, | |||
c -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't use abbreviations as variable names. Here change
would be good.
* upstream/master: Bump pascalgn/automerge-action from v0.13.0 to v0.13.1 (#7445) Auto-approve depend-a-bot-PRs (#7332) Clarify that changelog is user-facing Remove unmaintained AUTHORS file Fixes the issue "Non valid number as font size results in an uncaught exception." (#7438) Zbmath fetcher (#7440) Bump me.champeau.gradle.jmh from 0.5.2 to 0.5.3 (#7444) Bump styfle/cancel-workflow-action from 0.7.0 to 0.8.0 (#7446)
Fixes #7415