From: Ben Soares Date: Wed, 12 Jun 2019 16:16:35 +0000 (+0100) Subject: JAL-3295 Fixed CMD-select of sequences in alignment window X-Git-Tag: Release_2_11_0~10^2^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9d2ac8fe3057585a37586379a3c1cd2ead49aafe;p=jalview.git JAL-3295 Fixed CMD-select of sequences in alignment window --- diff --git a/build.gradle b/build.gradle index 0ae4e5c..1441e7d 100644 --- a/build.gradle +++ b/build.gradle @@ -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() diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index c1d8228..e8558fa 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -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(); } diff --git a/src/jalview/util/ShortcutKeyMaskExWrapper.java b/src/jalview/util/ShortcutKeyMaskExWrapper.java index 7292c80..c9ed231 100644 --- a/src/jalview/util/ShortcutKeyMaskExWrapper.java +++ b/src/jalview/util/ShortcutKeyMaskExWrapper.java @@ -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 index 0000000..41a6aa0 --- /dev/null +++ b/src/jalview/util/ShortcutKeyMaskExWrapper11.java @@ -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 index 0000000..78254b5 --- /dev/null +++ b/src/jalview/util/ShortcutKeyMaskExWrapper8.java @@ -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 index 0000000..bf17259 --- /dev/null +++ b/src/jalview/util/ShortcutKeyMaskExWrapperI.java @@ -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); +}