From: soares Date: Fri, 12 Jun 2020 11:24:55 +0000 (+0100) Subject: JAL-3446 fixing a bad merge, sorry X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f8d65c3705e11a6aacb4fcaff1bf76e4932f1609;p=jalview.git JAL-3446 fixing a bad merge, sorry --- diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index bc21fa1..ac84846 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -22,7 +22,6 @@ package jalview.util; import java.awt.Component; import java.awt.Dimension; -import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -111,51 +110,52 @@ public class Platform : isMac); } - public static int SHORTCUT_KEY_MASK = (Platform.isMac() ? KeyEvent.META_DOWN_MASK : KeyEvent.CTRL_DOWN_MASK); - + public static int SHORTCUT_KEY_MASK = (Platform.isMac() + ? KeyEvent.META_DOWN_MASK + : KeyEvent.CTRL_DOWN_MASK); + static { - // Using non-deprecated Extended key mask modifiers, but Java 8 has no - // getMenuShortcutKeyMaskEx method - Toolkit tk = Toolkit.getDefaultToolkit(); - Method method = null; + // Using non-deprecated Extended key mask modifiers, but Java 8 has no + // getMenuShortcutKeyMaskEx method + Toolkit tk = Toolkit.getDefaultToolkit(); + Method method = null; + try + { + method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx"); + } catch (NoSuchMethodException e) + { + System.err.println( + "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask."); + } + if (method == null) + { try { - method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx"); + method = tk.getClass().getMethod("getMenuShortcutKeyMask"); } catch (NoSuchMethodException e) { System.err.println( - "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask."); - } - if (method == null) - { - try - { - method = tk.getClass().getMethod("getMenuShortcutKeyMask"); - } catch (NoSuchMethodException e) - { - System.err.println( - "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask."); - e.printStackTrace(); - } + "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask."); + e.printStackTrace(); } - if (method != null) + } + if (method != null) + { + try { - try - { - method.setAccessible(true); - SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0])); - } catch (Exception e) - { - e.printStackTrace(); - } - } - if (SHORTCUT_KEY_MASK <= 0xF) + method.setAccessible(true); + SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0])); + } catch (Exception e) { - // shift this into the extended region (was Java 8) - SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6; + e.printStackTrace(); } } + if (SHORTCUT_KEY_MASK <= 0xF) + { + // shift this into the extended region (was Java 8) + SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6; + } } /** @@ -259,12 +259,13 @@ public class Platform */ protected static boolean isControlDown(MouseEvent e, boolean aMac) { -// -// System.out.println(e.isPopupTrigger() -// + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0) -// + " " + e.isControlDown()); - return (aMac ? !e.isPopupTrigger() - && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0 + // + // System.out.println(e.isPopupTrigger() + // + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0) + // + " " + e.isControlDown()); + return (aMac + ? !e.isPopupTrigger() + && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0 : e.isControlDown()); } @@ -674,20 +675,22 @@ public class Platform public static void getURLCommandArguments() { - try { - /** - * Retrieve the first query field as command arguments to Jalview. Include - * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's __Info.args - * element to this value. - * - * @j2sNative var a = - * decodeURI((document.location.href.replace("&","?").split("?j2s")[0] - * + "?").split("?")[1].split("#")[0]); a && - * (J2S.thisApplet.__Info.args = a.split(" ")); - * - * System.out.println("URL arguments: " + a); - */ - } catch (Throwable t) { + try + { + /** + * Retrieve the first query field as command arguments to Jalview. Include + * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's + * __Info.args element to this value. + * + * @j2sNative var a = + * decodeURI((document.location.href.replace("&","?").split("?j2s")[0] + * + "?").split("?")[1].split("#")[0]); a && + * (J2S.thisApplet.__Info.args = a.split(" ")); + * + * System.out.println("URL arguments: " + a); + */ + } catch (Throwable t) + { } } @@ -851,7 +854,8 @@ public class Platform * * @param frame * a JFrame or JInternalFrame - * @param type "name", "node", "init", "dim", or any DOM attribute, such as "id" + * @param type + * "name", "node", "init", "dim", or any DOM attribute, such as "id" * @return null if frame is not embedded. */ public static Object getEmbeddedAttribute(Component frame, String type) @@ -967,17 +971,17 @@ public class Platform */ public static String getAppID(String frameType) { - + String id = Jalview.getInstance().j2sAppletID; if (id == null) { - Jalview.getInstance().j2sAppletID = id = (isJS ? (String) jsutil - .getAppletAttribute("_id") : "jalview"); + Jalview.getInstance().j2sAppletID = id = (isJS + ? (String) jsutil.getAppletAttribute("_id") + : "jalview"); } return id + (frameType == null ? "" : "-" + frameType); } - /** * Option to avoid unnecessary seeking of nonexistent resources in JavaScript. * Works in Java as well.