-
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?
Conversation
Looks great! It seems there are 3 cases: OK, update available, exception. I think we can simplify this for the user: case exception: (the user doesn't need to know there is an error, so just fall through to case OK) case update available: we should show download icon and say "Update available..." Is there any way we can do this in FXML? Perhaps add both of these buttons and then make them visible / invisible as needed from code. |
You could go with "All OK" in FXML with the appropriate icon. Then, in code, check for updates and overwrite if an update is available. Let me know if you need help with the FXML part of it. |
Oh, thanks @jperedadnr. I'll have a play round. |
Seems that |
My original proposal was to use something like |
That won't work for Mac, see https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassSystemMenu.java#L293: only ImageView... |
In which case, for this PR, we could ditch the visual indicator and do:
Later, once we have a notification service of some sort like a non-modal pop-up in the top-right corner or something, we can make use of that to notify the update is available. |
Thanks for all the feedback. @AlmasB I agree with the simpler UX for the user, so I removed the exception state, and the default if anything goes wrong is to show the OK message, as you suggested. However, when simulating a delay in the thread that goes off and grabs the version number from the web, I felt some kind of user feedback that something was happening in the background would be better. So I added an initial state of "Checking for update...". This is what it looks likes with a forced 10s delay (sorry about the washed out gif colours):- Since there is now no image for the default state, I've not added anything else to the FXML. If you still want to experiment with that, then I'll have to take you up on your offer for some FXML assistance because I couldn't figure that bit out. @jperedadnr I found an article from Dirk Lemmermann and updated the images and code accordingly. However the same oversized icon was rendered, so this is deffo a bug in the Mac code as it correctly identified a high-res system and loaded This is how it looks on Mac:- And on Linux:- And on Linux when there's an update available:- |
FYI: I think I fixed the icon rendering issue in openjfx:- openjdk/jfx#743. So hopefully we can put some high res icons back in play at some point in the future (if/when that PR gets merged). |
@@ -235,6 +234,10 @@ public boolean canPerformControlAction(ApplicationControlAction a, DocumentWindo | |||
result = true; | |||
break; | |||
|
|||
case CHECK_UPDATES: |
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.
app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java
Outdated
Show resolved
Hide resolved
app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java
Outdated
Show resolved
Hide resolved
…em when there is an available update.
app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java
Outdated
Show resolved
Hide resolved
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.
Looks good, thanks.
@jperedadnr did you want to have another look at this? If not, we are good to go.
@@ -191,7 +191,9 @@ 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.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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Platform.runLater(() -> { | ||
checkUpdatesMenuItem.setGraphic(iconView); | ||
checkUpdatesMenuItem.disableProperty().setValue(false); |
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.
try { | ||
isUpdateAvailable = isCurrentVersionLowerThan(latestVersion); | ||
} catch (NumberFormatException e) { | ||
e.printStackTrace(); |
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.
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 comment
The 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. e.printStackTrace()
seems to be used quite a lot.
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 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 comment
The 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:-
Logger.getLogger(AppSettings.class.getName()).log(Level.SEVERE, "An exception was thrown:", ex);
or
Logger.getLogger(PreferencesRecordDocument.class.getName()).log(Level.SEVERE, null, ex);
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The String
message should normally include some useful information. So in the above case it might say: "Cannot parse version string" or something similar.
@Gargoyle Would you mind to have a look at the conflicts? May be we can get this one eventually merged. It technically looks fine to me. |
I had a quick look this evening and got myself into a rebase nightmare. 🙄 I've hardly looked at SceneBuilder (or even done much JavaFX) in the last two years, so what will probably be best is that I'll see if I can find some time in the next week or so to get back into it a bit, and just re-implement this on a fresh branch cut from the latest main/master. My fix for MacOS icon rendering did make it into JavaFX 20, so if SceneBuilder is targeting that or later as a min requirement, I can redo the high res versions of the icons too? Will need to pair up with someone though, as I don't even have my old Mac to check even basic stuff anymore. |
Hi Paul, I still have my old MacBook so I can help out there. Very cool that you'checked in Here. Thanks!
|
Issue
Fixes #489
Adds an icon to the "Help -> Check for Update..." menu and displays in one of the following states:-
All OK and up-to-date:-
Update is available:-
Exception thrown in the existing version checking code:-
Progress