From: hansonr Date: Mon, 21 Jan 2019 17:38:23 +0000 (-0600) Subject: isAMac() -> isAMacAndNotJS(), isWindows() -> isWindowsAndNotJS() X-Git-Tag: Release_2_11_4_0~45^2~18^2~305 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f5d6c0018555b2c453c2c0354c84cd5d2d81e3b9;p=jalview.git isAMac() -> isAMacAndNotJS(), isWindows() -> isWindowsAndNotJS() Added Platform.isWin[Right|Middle]Button() --- diff --git a/src/jalview/appletgui/EmbmenuFrame.java b/src/jalview/appletgui/EmbmenuFrame.java index b99bc93..af5fec0 100644 --- a/src/jalview/appletgui/EmbmenuFrame.java +++ b/src/jalview/appletgui/EmbmenuFrame.java @@ -97,7 +97,7 @@ public class EmbmenuFrame extends Frame implements MouseListener return false; } // DEBUG Hint: can test embedded menus by inserting true here. - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { // Build the embedded menu panel, allowing override with system font embeddedMenu = makeEmbeddedPopupMenu(topMenuBar, true, false); diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 5081509..1b29ef6 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -44,6 +44,8 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; +import javax.swing.SwingUtilities; + public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener, ViewportListenerI { @@ -142,7 +144,7 @@ public class OverviewPanel extends Panel implements Runnable, if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - if (!Platform.isAMac()) + if (!Platform.isAMacAndNotJS()) { showPopupMenu(evt); } @@ -182,32 +184,32 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mouseDragged(MouseEvent evt) { - if ((evt.getModifiers() - & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if (Platform.isWinRightButton(evt)) { - if (!Platform.isAMac()) - { - showPopupMenu(evt); - } + showPopupMenu(evt); + return; } - else - { - if (draggingBox) - { - // set the mouse position as a fixed point in the box - // and drag relative to that position - od.adjustViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - else - { - od.updateViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - ap.paintAlignment(false, false); + + if (SwingUtilities.isRightMouseButton(evt)) + { + return; } + + if (draggingBox) + { + // set the mouse position as a fixed point in the box + // and drag relative to that position + od.adjustViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + else + { + od.updateViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + ap.paintAlignment(false, false); } /** diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 291ab02..32f0abb 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -500,9 +500,8 @@ public class SeqPanel extends Panel implements MouseMotionListener, // For now, ignore the mouseWheel font resizing on Macs // As the Button2_mask always seems to be true - if ((evt.getModifiers() - & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK - && !Platform.isAMac()) + + if (Platform.isWinMiddleButton(evt)) { mouseWheelPressed = true; return; diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 4684f01..474c707 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -352,7 +352,7 @@ public class Jalview System.err.println("Unexpected Look and Feel Exception"); ex.printStackTrace(); } - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 3212156..bd7d5fb 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1309,7 +1309,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, * hscroll, status bar, insets. */ int stuff = (ap.getViewName() != null ? 30 : 0) - + (Platform.isAMac() ? 120 : 140); + + (Platform.isAMacAndNotJS() ? 120 : 140); int availableHeight = ap.alignFrame.getHeight() - stuff; int rowHeight = av.getCharHeight(); diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 1e373c3..144cdd0 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -385,8 +385,8 @@ public class Desktop extends jalview.jbgui.GDesktop // This line prevents Windows Look&Feel resizing all new windows to maximum // if previous window was maximised desktop.setDesktopManager(new MyDesktopManager( - (Platform.isWindows() ? new DefaultDesktopManager() - : Platform.isAMac() + (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager() + : Platform.isAMacAndNotJS() ? new AquaInternalFrameManager( desktop.getDesktopManager()) : desktop.getDesktopManager()))); @@ -3476,7 +3476,7 @@ public class Desktop extends jalview.jbgui.GDesktop } else { - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { System.err.println( "Please ignore plist error - occurs due to problem with java 8 on OSX"); @@ -3593,8 +3593,7 @@ public class Desktop extends jalview.jbgui.GDesktop } } } - if (Platform.isWindows()) - + if (Platform.isWindowsAndNotJS()) { Cache.log.debug("Scanning dropped content for Windows Link Files"); diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index a6f4a84..f5ae15c 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -403,7 +403,7 @@ public class FeatureSettings extends JPanel frame = new JInternalFrame(); frame.setContentPane(this); - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { Desktop.addInternalFrame(frame, MessageManager.getString("label.sequence_feature_settings"), diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 8290dcf..9ee4750 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -353,7 +353,7 @@ public class IdPanel extends JPanel * (where isPopupTrigger() will answer true) * NB isRightMouseButton is also true for Cmd-click on Mac */ - if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac()) + if (Platform.isWinRightButton(e)) { return; } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index cfbc582..1785e70 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -55,24 +55,25 @@ import javax.swing.SwingUtilities; * @author $author$ * @version $Revision$ */ +@SuppressWarnings("serial") public class OverviewPanel extends JPanel implements Runnable, ViewportListenerI { - private OverviewDimensions od; + protected OverviewDimensions od; private OverviewCanvas oviewCanvas; - private AlignViewport av; + protected AlignViewport av; private AlignmentPanel ap; - private JCheckBoxMenuItem displayToggle; + protected JCheckBoxMenuItem displayToggle; - private boolean showHidden = true; + protected boolean showHidden = true; - private boolean draggingBox = false; + protected boolean draggingBox = false; - private ProgressPanel progressPanel; + protected ProgressPanel progressPanel; /** * Creates a new OverviewPanel object. @@ -195,8 +196,9 @@ public class OverviewPanel extends JPanel { if (SwingUtilities.isRightMouseButton(evt)) { - if (!Platform.isAMac()) + if (!Platform.isAMacAndNotJS()) { + // BH - MAC L&F here - forces popup and cancels any drag operation showPopupMenu(evt); } } @@ -255,7 +257,7 @@ public class OverviewPanel extends JPanel /* * Displays the popup menu and acts on user input */ - private void showPopupMenu(MouseEvent e) + protected void showPopupMenu(MouseEvent e) { JPopupMenu popup = new JPopupMenu(); ActionListener menuListener = new ActionListener() @@ -280,7 +282,7 @@ public class OverviewPanel extends JPanel /* * Toggle overview display between showing hidden columns and hiding hidden columns */ - private void toggleHiddenColumns() + protected void toggleHiddenColumns() { if (showHidden) { diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 92dde1f..6a558d5 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -195,7 +195,7 @@ public class Preferences extends GPreferences wsTab.add(wsPrefs, BorderLayout.CENTER); } int width = 500, height = 450; - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { width = 570; height = 480; diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index f617d0f..6912a02 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -132,8 +132,9 @@ public class ScalePanel extends JPanel if (evt.isPopupTrigger()) // Mac: mousePressed { rightMouseButtonPressed(evt, res); + return; } - else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac()) + if (Platform.isWinRightButton(evt)) { /* * defer right-mouse click handling to mouse up on Windows @@ -142,10 +143,7 @@ public class ScalePanel extends JPanel */ return; } - else - { - leftMouseButtonPressed(evt, res); - } + leftMouseButtonPressed(evt, res); } /** diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 5eb97e0..0a66114 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1767,22 +1767,22 @@ public class SeqPanel extends JPanel } } - if (evt.isPopupTrigger()) // Mac: mousePressed - { - showPopupMenu(evt); - return; - } - /* * defer right-mouse click handling to mouseReleased on Windows * (where isPopupTrigger() will answer true) * NB isRightMouseButton is also true for Cmd-click on Mac */ - if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac()) + if (Platform.isWinRightButton(evt)) { return; } + if (evt.isPopupTrigger()) // Mac: mousePressed + { + showPopupMenu(evt); + return; + } + if (av.cursorMode) { seqCanvas.cursorX = findColumn(evt); diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 51be630..79f25e2 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -145,7 +145,7 @@ public class SequenceFetcher extends JPanel implements Runnable frame = new JInternalFrame(); frame.setContentPane(this); - int height = Platform.isAMac() ? 240 : 180; + int height = Platform.isAMacAndNotJS() ? 240 : 180; Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, height); } diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index a0d31cf..e066c75 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -97,9 +97,9 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI * estimate width and height of SplitFrame; this.getInsets() doesn't seem to * give the full additional size (a few pixels short) */ - int widthFudge = Platform.isAMac() ? MAC_INSETS_WIDTH + int widthFudge = Platform.isAMacAndNotJS() ? MAC_INSETS_WIDTH : WINDOWS_INSETS_WIDTH; - int heightFudge = Platform.isAMac() ? MAC_INSETS_HEIGHT + int heightFudge = Platform.isAMacAndNotJS() ? MAC_INSETS_HEIGHT : WINDOWS_INSETS_HEIGHT; int width = ((AlignFrame) getTopFrame()).getWidth() + widthFudge; int height = ((AlignFrame) getTopFrame()).getHeight() @@ -253,7 +253,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI /* * estimate ratio of (topFrameContent / bottomFrameContent) */ - int insets = Platform.isAMac() ? MAC_INSETS_HEIGHT + int insets = Platform.isAMacAndNotJS() ? MAC_INSETS_HEIGHT : WINDOWS_INSETS_HEIGHT; // allow 3 'rows' for scale, scrollbar, status bar int topHeight = insets + (3 + topCount) * topCharHeight diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 56b8637..f6455bf 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -470,7 +470,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, layout.putConstraint(SpringLayout.NORTH, scroller, 5, SpringLayout.NORTH, this); - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { scroller.setPreferredSize(new Dimension(500, 100)); } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 4fb5a44..d1732cf 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -236,7 +236,7 @@ public class GAlignFrame extends JInternalFrame System.err.println(e.toString()); } - if (!Platform.isAMac()) + if (!Platform.isAMacAndNotJS()) { closeMenuItem.setMnemonic('C'); outputTextboxMenu.setMnemonic('T'); diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 34c7d31..89b8781 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -143,7 +143,7 @@ public class GDesktop extends JFrame e.printStackTrace(); } - if (!Platform.isAMac()) + if (!Platform.isAMacAndNotJS()) { FileMenu.setMnemonic('F'); inputLocalFileMenuItem.setMnemonic('L'); diff --git a/src/jalview/jbgui/GSplitFrame.java b/src/jalview/jbgui/GSplitFrame.java index 0549f17..a40e260 100644 --- a/src/jalview/jbgui/GSplitFrame.java +++ b/src/jalview/jbgui/GSplitFrame.java @@ -109,7 +109,7 @@ public class GSplitFrame extends JInternalFrame */ protected void hideTitleBars() { - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { // this saves some space - but doesn't hide the title bar topFrame.putClientProperty("JInternalFrame.isPalette", true); diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 68dbe4f..4d3445b 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -68,7 +68,7 @@ public class AnnotationRenderer private FontMetrics fm; - private final boolean USE_FILL_ROUND_RECT = Platform.isAMac(); + private final boolean USE_FILL_ROUND_RECT = Platform.isAMacAndNotJS(); boolean av_renderHistogram = true, av_renderProfile = true, av_normaliseProfile = false; diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 2953c97..bb3f7fa 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -21,8 +21,11 @@ package jalview.util; import java.awt.Toolkit; +import java.awt.event.InputEvent; import java.awt.event.MouseEvent; +import javax.swing.SwingUtilities; + /** * System platform information used by Applet and Application * @@ -31,7 +34,7 @@ import java.awt.event.MouseEvent; public class Platform { - private static Boolean isAMac = null, isWindows = null; + private static Boolean isNoJSMac = null, isNoJSWindows = null; private static Boolean isHeadless = null; @@ -42,15 +45,15 @@ public class Platform * * @return true if we do things in a special way. */ - public static boolean isAMac() + public static boolean isAMacAndNotJS() { - if (isAMac == null) + if (isNoJSMac == null) { - isAMac = /** @j2sNative false && */ + isNoJSMac = /** @j2sNative false && */ System.getProperty("os.name").indexOf("Mac") > -1; } - return isAMac.booleanValue(); + return isNoJSMac.booleanValue(); } @@ -59,14 +62,14 @@ public class Platform * * @return true if we have to cope with another platform variation */ - public static boolean isWindows() + public static boolean isWindowsAndNotJS() { - if (isWindows == null) + if (isNoJSWindows == null) { - isWindows = /** @j2sNative false && */ + isNoJSWindows = /** @j2sNative false && */ System.getProperty("os.name").indexOf("Win") > -1; } - return isWindows.booleanValue(); + return isNoJSWindows.booleanValue(); } // BH - preferred: @@ -146,7 +149,7 @@ public class Platform /** * Answers true if the mouse event has Meta-down (Command key on Mac) or * Ctrl-down (on other o/s). Note this answers _false_ if the Ctrl key is - * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-click on Mac, + * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-pressed on Mac, * you can use e.isPopupTrigger(). * * @param e @@ -154,7 +157,7 @@ public class Platform */ public static boolean isControlDown(MouseEvent e) { - boolean aMac = isAMac(); + boolean aMac = isAMacAndNotJS(); return isControlDown(e, aMac); } @@ -182,4 +185,14 @@ public class Platform } return e.isControlDown(); } + + public static boolean isWinRightButton(MouseEvent e) + { + return !isAMacAndNotJS() && SwingUtilities.isRightMouseButton(e); + } + + public static boolean isWinMiddleButton(MouseEvent evt) + { + return !isAMacAndNotJS() && ((evt.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK); + } }