-
Notifications
You must be signed in to change notification settings - Fork 220
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
feat: Added menu item icon to show whether updates are available #519
base: master
Are you sure you want to change the base?
Changes from 5 commits
9e02f6b
a2a94e7
9ce3afb
c7fe0da
2b94b2f
4d14d8a
ee65d35
d3202ec
1fa4a33
aed8b86
91c5919
4e86eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,9 +64,9 @@ public class AppSettings { | |
|
||
private static String sceneBuilderVersion; | ||
private static String latestVersion; | ||
|
||
private static String latestVersionText; | ||
private static String latestVersionAnnouncementURL; | ||
private static boolean isUpdateAvailable = false; | ||
|
||
private static final JsonReaderFactory readerFactory = Json.createReaderFactory(null); | ||
|
||
|
@@ -114,6 +114,10 @@ public static boolean isCurrentVersionLowerThan(String version) { | |
return false; | ||
} | ||
|
||
public static boolean isUpdateAvailable() { | ||
return isUpdateAvailable; | ||
} | ||
|
||
public static void getLatestVersion(Consumer<String> consumer) { | ||
|
||
if (latestVersion == null) { | ||
|
@@ -136,6 +140,13 @@ public static void getLatestVersion(Consumer<String> consumer) { | |
ex.printStackTrace(); | ||
} | ||
latestVersion = onlineVersionNumber; | ||
|
||
try { | ||
isUpdateAvailable = isCurrentVersionLowerThan(latestVersion); | ||
} catch (NumberFormatException e) { | ||
e.printStackTrace(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to Logger.logSevere ? We shouldn't print stacktraces to console as they get lost unless you run from command line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just following what the rest of the code in the block was doing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand, but we have logs for a reason, and that's how new PRs should be tackling exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did a search of how Logging is being done elsewhere. Seems we have two patterns:-
or
With the second one seeming to be a bit more common. Any recommentation on which to use? I'm assuming from the output that it will be clear its an exception, making the "An exception was thrown:" text redundant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
consumer.accept(latestVersion); | ||
}, "GetLatestVersion").start(); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,10 @@ menu.title.no.window = No Window | |
# Help menu items | ||
menu.title.scene.builder.help = Scene Builder Help | ||
menu.title.show.welcome = Show Welcome Page | ||
menu.title.check.updates = Check for Update... | ||
menu.title.check.updates = Checking for updates... | ||
menu.title.check.updates.available = Update available | ||
menu.title.check.updates.ok = All up-to-date! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
menu.title.about = About Scene Builder | ||
menu.title.register = Register... | ||
menu.title.help.javafx=JavaFX | ||
|
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.
Do we need to make this change at all? If the update is not available, the item is disabled, so not clickable. I think the existing behaviour is fine here.
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.
Yes. The checks are performed every time you open the menu. Even with disabling the menu item in the FXML file, if we leave this hard coded to a
true
response, it will re-enable the item when you open the menu.