Skip to content

Commit 5b4fd55

Browse files
committed
UIService: be careful setting status/progress
It is reasonable to want to reset only the status or progress of a UI using a StatusEvent. However, the setting of both was being enforced by the DefaultUIService's implementation. Now, we check the received StatusEvent. The progress is only set if the max is >= 0, and the message is only set if the string is not null.
1 parent 6cfca44 commit 5b4fd55

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/scijava/ui/DefaultUIService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,16 @@ protected void onEvent(final StatusEvent event) {
448448
final int val = event.getProgressValue();
449449
final int max = event.getProgressMaximum();
450450
final String message = getStatusMessage(event);
451+
if (max < 0 && message == null) return;
451452
for (UserInterface ui : getAvailableUIs()) {
452453
final StatusBar statusBar = ui.getStatusBar();
453454
if (statusBar != null) {
454-
statusBar.setStatus(message);
455-
statusBar.setProgress(val, max);
455+
if (max >= 0) {
456+
statusBar.setProgress(val, max);
457+
}
458+
if (message != null) {
459+
statusBar.setStatus(message);
460+
}
456461
}
457462
}
458463
}

0 commit comments

Comments
 (0)