Skip to content

Commit

Permalink
DefaultLegacyHooks: make open window test a method
Browse files Browse the repository at this point in the history
We are going to make it more complicated, so let's keep things DRY.
  • Loading branch information
ctrueden committed Jul 9, 2014
1 parent f3bfa22 commit 57a4cca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/net/imagej/legacy/DefaultLegacyHooks.java
Expand Up @@ -521,11 +521,11 @@ public boolean interceptCloseAllWindows() {
if (win == legacyService.getIJ1Helper().getIJ()) {
continue;
}
if (win.isVisible()) {
if (isOpenWindow(win)) {
// give user a chance to cancel the closing of this visible window
win.dispatchEvent(new WindowEvent(win, WindowEvent.WINDOW_CLOSING));
}
if (win.isVisible() && win.getWindowListeners().length > 0) {
if (isOpenWindow(win) && win.getWindowListeners().length > 0) {
// NB: We assume the user canceled closing of the window; abort quit.
// However, there are situations where this heuristic may fail.
// If this logic blocks the shutdown of ImageJ1, we will need to
Expand Down Expand Up @@ -557,4 +557,10 @@ public boolean disposing() {
return true;
}

// -- Helper methods --

private boolean isOpenWindow(final Window window) {
return window.isVisible();
}

}

0 comments on commit 57a4cca

Please sign in to comment.