JAL-3295 Fixed CMD-select of sequences in alignment window
authorBen Soares <bsoares@dundee.ac.uk>
Wed, 12 Jun 2019 16:16:35 +0000 (17:16 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Wed, 12 Jun 2019 16:16:35 +0000 (17:16 +0100)
build.gradle
src/jalview/util/Platform.java
src/jalview/util/ShortcutKeyMaskExWrapper.java
src/jalview/util/ShortcutKeyMaskExWrapper11.java [new file with mode: 0644]
src/jalview/util/ShortcutKeyMaskExWrapper8.java [new file with mode: 0644]
src/jalview/util/ShortcutKeyMaskExWrapperI.java [new file with mode: 0644]

index 0ae4e5c..1441e7d 100644 (file)
@@ -72,14 +72,18 @@ def additional_compiler_args = []
 def getdown_alt_java_min_version
 // this property is assigned below and expanded to multiple lines in the getdown task
 def getdown_alt_multi_java_location
+// this property is for the Java library used in eclipse
+def eclipse_java_runtime_name
 if (JAVA_VERSION.equals("1.8")) {
   JAVA_INTEGER_VERSION = "8"
+  //libDir = j8libDir
   libDir = j11libDir
   libDistDir = j8libDir
   compile_source_compatibility = 1.8
   compile_target_compatibility = 1.8
   getdown_alt_java_min_version = getdown_alt_java8_min_version
   getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
+  eclipse_java_runtime_name = "JavaSE-1.8"
 } else if (JAVA_VERSION.equals("11")) {
   JAVA_INTEGER_VERSION = "11"
   libDir = j11libDir
@@ -88,6 +92,7 @@ if (JAVA_VERSION.equals("1.8")) {
   compile_target_compatibility = 11
   getdown_alt_java_min_version = getdown_alt_java11_min_version
   getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
+  eclipse_java_runtime_name = "JavaSE-11"
   additional_compiler_args += [
     '--module-path', ext.modules_compileClasspath.asPath,
     '--add-modules', j11modules
@@ -298,9 +303,9 @@ eclipse {
 
   jdt {
     // for the IDE, use java 11 compatibility
-    sourceCompatibility = 11
-    targetCompatibility = 11
-    javaRuntimeName = "JavaSE-11"
+    sourceCompatibility = JAVA_VERSION
+    targetCompatibility = JAVA_VERSION
+    javaRuntimeName = eclipse_java_runtime_name
 
     file {
       withProperties { props ->
@@ -422,12 +427,14 @@ task setGitVals {
   exec {
     commandLine "git", "rev-parse", "--short", "HEAD"
     standardOutput = hashStdOut
+    ignoreExitValue true
   }
 
   def branchStdOut = new ByteArrayOutputStream()
   exec {
     commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
     standardOutput = branchStdOut
+    ignoreExitValue true
   }
 
   project.ext.gitHash = hashStdOut.toString().trim()
index c1d8228..e8558fa 100644 (file)
@@ -132,7 +132,8 @@ public class Platform
         return false;
       }
       return (jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx() // .getMenuShortcutKeyMaskEx()
-              & e.getModifiersEx()) != 0; // getModifiers()) != 0;
+              & jalview.util.ShortcutKeyMaskExWrapper
+                      .getModifiersEx(e)) != 0; // getModifiers()) != 0;
     }
     return e.isControlDown();
   }
index 7292c80..c9ed231 100644 (file)
@@ -1,57 +1,46 @@
 package jalview.util;
 
-import java.awt.Toolkit;
-import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
 
 public class ShortcutKeyMaskExWrapper
 {
 
-  private static boolean init = false;
+  private static final Float specversion;
 
-  private static final Float specversion = Float
-          .parseFloat(System.getProperty("java.specification.version"));
+  private static final float modern;
 
-  private static final float modern = 11;
+  public static final int SHIFT_DOWN_MASK;
 
-  public static int SHIFT_DOWN_MASK = KeyEvent.SHIFT_DOWN_MASK;
+  public static final int ALT_DOWN_MASK;
 
-  public static int ALT_DOWN_MASK = KeyEvent.ALT_DOWN_MASK;
+  private static final ShortcutKeyMaskExWrapperI wrapper;
 
-  public ShortcutKeyMaskExWrapper()
+  static
   {
-  }
+    specversion = Float
+            .parseFloat(System.getProperty("java.specification.version"));
+    modern = 11;
 
-  private static void init()
-  {
-    if (init)
-    {
-      return;
-    }
-    if (specversion < modern)
+    if (specversion >= modern)
     {
-      SHIFT_DOWN_MASK = KeyEvent.SHIFT_MASK;
-      ALT_DOWN_MASK = KeyEvent.ALT_MASK;
+      wrapper = new ShortcutKeyMaskExWrapper11();
     }
     else
     {
-      SHIFT_DOWN_MASK = KeyEvent.SHIFT_DOWN_MASK;
-      ALT_DOWN_MASK = KeyEvent.ALT_DOWN_MASK;
+      wrapper = new ShortcutKeyMaskExWrapper8();
     }
-
-    init = true;
+    SHIFT_DOWN_MASK = wrapper.SHIFT_DOWN_MASK;
+    ALT_DOWN_MASK = wrapper.ALT_DOWN_MASK;
   }
 
   public static int getMenuShortcutKeyMaskEx()
   {
-    init();
-    if (specversion < modern)
-    {
-      return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-    }
-    else
-    {
-      return Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
-    }
+    return wrapper.getMenuShortcutKeyMaskEx();
+  }
+
+  public static int getModifiersEx(MouseEvent e)
+  {
+    return wrapper.getModifiersEx(e);
   }
 
 }
diff --git a/src/jalview/util/ShortcutKeyMaskExWrapper11.java b/src/jalview/util/ShortcutKeyMaskExWrapper11.java
new file mode 100644 (file)
index 0000000..41a6aa0
--- /dev/null
@@ -0,0 +1,34 @@
+package jalview.util;
+
+import java.awt.GraphicsEnvironment;
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+public class ShortcutKeyMaskExWrapper11 implements ShortcutKeyMaskExWrapperI
+{
+  public final static int SHIFT_DOWN_MASK = KeyEvent.SHIFT_DOWN_MASK;
+  public final static int ALT_DOWN_MASK = KeyEvent.ALT_DOWN_MASK;
+
+  @Override
+  public int getMenuShortcutKeyMaskEx()
+  {
+    try
+    {
+      if (!GraphicsEnvironment.isHeadless())
+      {
+        return Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
+      }
+    } catch (java.lang.Throwable t)
+    {
+    }
+    return 0;
+  }
+
+  @Override
+  public int getModifiersEx(MouseEvent e)
+  {
+    return e.getModifiersEx();
+  }
+
+}
diff --git a/src/jalview/util/ShortcutKeyMaskExWrapper8.java b/src/jalview/util/ShortcutKeyMaskExWrapper8.java
new file mode 100644 (file)
index 0000000..78254b5
--- /dev/null
@@ -0,0 +1,34 @@
+package jalview.util;
+
+import java.awt.GraphicsEnvironment;
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+public class ShortcutKeyMaskExWrapper8 implements ShortcutKeyMaskExWrapperI
+{
+  public final static int SHIFT_DOWN_MASK = KeyEvent.SHIFT_MASK;
+  public final static int ALT_DOWN_MASK = KeyEvent.ALT_MASK;
+
+  @Override
+  public int getMenuShortcutKeyMaskEx()
+  {
+    try
+    {
+      if (!GraphicsEnvironment.isHeadless())
+      {
+        return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+      }
+    } catch (java.lang.Throwable t)
+    {
+    }
+    return 0;
+  }
+
+  @Override
+  public int getModifiersEx(MouseEvent e)
+  {
+    return e.getModifiers();
+  }
+
+}
diff --git a/src/jalview/util/ShortcutKeyMaskExWrapperI.java b/src/jalview/util/ShortcutKeyMaskExWrapperI.java
new file mode 100644 (file)
index 0000000..bf17259
--- /dev/null
@@ -0,0 +1,14 @@
+package jalview.util;
+
+import java.awt.event.MouseEvent;
+
+public interface ShortcutKeyMaskExWrapperI
+{
+  public static int SHIFT_DOWN_MASK = 0;
+
+  public static int ALT_DOWN_MASK = 0;
+
+  public int getMenuShortcutKeyMaskEx();
+
+  public int getModifiersEx(MouseEvent e);
+}