X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAPQHandlers.java;fp=src%2Fjalview%2Fjbgui%2FAPQHandlers.java;h=00ec2176bb678f1b8c223dcb56e7d34821c9ac60;hb=50caa2bce4379ecdb02a2c0eccc44078487f2f0b;hp=1a7e971cdfd77d1beba40bc00d87cc3e1f233c18;hpb=327e8459a091858b0207ddac4cadd8cb23f4cdeb;p=jalview.git diff --git a/src/jalview/jbgui/APQHandlers.java b/src/jalview/gui/APQHandlers.java similarity index 55% rename from src/jalview/jbgui/APQHandlers.java rename to src/jalview/gui/APQHandlers.java index 1a7e971..00ec217 100644 --- a/src/jalview/jbgui/APQHandlers.java +++ b/src/jalview/gui/APQHandlers.java @@ -18,15 +18,11 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.jbgui; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; +package jalview.gui; import com.formdev.flatlaf.extras.FlatDesktop; import com.formdev.flatlaf.extras.FlatDesktop.Action; -import jalview.util.MessageManager; import jalview.util.Platform; public class APQHandlers @@ -37,7 +33,7 @@ public class APQHandlers public static boolean setQuit = false; - public static boolean setAPQHandlers(GDesktop desktop) + public static boolean setAPQHandlers(Desktop desktop) { if (Platform.isJS()) { @@ -59,47 +55,7 @@ public class APQHandlers } if (FlatDesktop.isSupported(Action.APP_QUIT_HANDLER)) { - FlatDesktop.setQuitHandler(response -> { - boolean confirmQuit = jalview.bin.Cache.getDefault( - jalview.gui.Desktop.CONFIRM_KEYBOARD_QUIT, true); - boolean canQuit = !confirmQuit; - int n; - if (confirmQuit) - { - // ensure Jalview window is brought to front for Quit confirmation - // window to be visible - - // this method of raising the Jalview window is broken in java - // jalviewDesktop.setVisible(true); - // jalviewDesktop.toFront(); - - // a better hack which works instead - JFrame dialogParent = new JFrame(); - dialogParent.setAlwaysOnTop(true); - - n = JOptionPane.showConfirmDialog(dialogParent, - MessageManager.getString("label.quit_jalview"), - MessageManager.getString("action.quit"), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, - null); - - dialogParent.setAlwaysOnTop(false); - dialogParent.dispose(); - } - else - { - n = JOptionPane.OK_OPTION; - } - canQuit = (n == JOptionPane.OK_OPTION); - if (canQuit) - { - response.performQuit(); - } - else - { - response.cancelQuit(); - } - }); + QuitHandler.setQuitHandler(); setQuit = true; } // if we got to here, no exceptions occurred when we set the handlers.