From 37e53fb916ef469eda6fd042701e116d56ff3c0b Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 11 Dec 2018 17:09:51 +0000 Subject: [PATCH] JAL-3130 Turns out Quit/About/Preferences handlers are Mac specific, d'oh. Moved build.xml to build-j11.xml --- build.xml => build-j11.xml | 0 src/jalview/gui/Desktop.java | 151 +++++++++++++++++++++--------------------- 2 files changed, 77 insertions(+), 74 deletions(-) rename build.xml => build-j11.xml (100%) diff --git a/build.xml b/build-j11.xml similarity index 100% rename from build.xml rename to build-j11.xml diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 7c08705..9e8624a 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -381,80 +381,83 @@ public class Desktop extends jalview.jbgui.GDesktop try { - if (desktopClass.getDeclaredMethod("setAboutHandler", - new Class[] - { AboutHandler.class }) != null) - { - - hdesktop.setAboutHandler(new AboutHandler() - { - @Override - public void handleAbout(AboutEvent e) - { - aboutMenuItem_actionPerformed(null); - } - }); - - } - - if (desktopClass.getDeclaredMethod("setPreferencesHandler", - new Class[] - { PreferencesHandler.class }) != null) - { - - hdesktop.setPreferencesHandler(new PreferencesHandler() - { - @Override - public void handlePreferences(PreferencesEvent e) - { - preferences_actionPerformed(null); - } - }); - - } - - if (desktopClass.getDeclaredMethod("setQuitHandler", - new Class[] - { QuitHandler.class }) != null) - { - - hdesktop.setQuitHandler(new QuitHandler() - { - @Override - public void handleQuitRequestWith(QuitEvent e, QuitResponse r) - { - boolean confirmQuit = jalview.bin.Cache - .getDefault(CONFIRM_KEYBOARD_QUIT, true); - int n; - if (confirmQuit) - { - n = JOptionPane.showConfirmDialog(null, - MessageManager.getString("label.quit_jalview"), - MessageManager.getString("action.quit"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.PLAIN_MESSAGE, null); - } - else - { - n = JOptionPane.OK_OPTION; - } - if (n == JOptionPane.OK_OPTION) - { - System.out.println("Shortcut Quit confirmed by user"); - quit(); - r.performQuit(); // probably won't reach this line, but just in - // case - } - else - { - r.cancelQuit(); - System.out.println("Shortcut Quit cancelled by user"); - } - } - }); - hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS); - - } + if (Platform.isAMac()) + { + if (desktopClass.getDeclaredMethod("setAboutHandler", + new Class[] + { AboutHandler.class }) != null) + { + + hdesktop.setAboutHandler(new AboutHandler() + { + @Override + public void handleAbout(AboutEvent e) + { + aboutMenuItem_actionPerformed(null); + } + }); + + } + + if (desktopClass.getDeclaredMethod("setPreferencesHandler", + new Class[] + { PreferencesHandler.class }) != null) + { + + hdesktop.setPreferencesHandler(new PreferencesHandler() + { + @Override + public void handlePreferences(PreferencesEvent e) + { + preferences_actionPerformed(null); + } + }); + + } + + if (desktopClass.getDeclaredMethod("setQuitHandler", + new Class[] + { QuitHandler.class }) != null) + { + + hdesktop.setQuitHandler(new QuitHandler() + { + @Override + public void handleQuitRequestWith(QuitEvent e, QuitResponse r) + { + boolean confirmQuit = jalview.bin.Cache + .getDefault(CONFIRM_KEYBOARD_QUIT, true); + int n; + if (confirmQuit) + { + n = JOptionPane.showConfirmDialog(null, + MessageManager.getString("label.quit_jalview"), + MessageManager.getString("action.quit"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.PLAIN_MESSAGE, null); + } + else + { + n = JOptionPane.OK_OPTION; + } + if (n == JOptionPane.OK_OPTION) + { + System.out.println("Shortcut Quit confirmed by user"); + quit(); + r.performQuit(); // probably won't reach this line, but just in + // case + } + else + { + r.cancelQuit(); + System.out.println("Shortcut Quit cancelled by user"); + } + } + }); + hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS); + + } + } } catch (NoSuchMethodException e) { -- 1.7.10.2