import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
-import java.awt.Image;
-import java.awt.Taskbar;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
desktop = new Desktop();
desktop.setInBatchMode(true); // indicate we are starting up
- if (Taskbar.isTaskbarSupported())
+ try
{
- Taskbar tb = Taskbar.getTaskbar();
- if (tb.isSupported(Taskbar.Feature.ICON_IMAGE))
- {
- try
- {
- java.net.URL url = getClass()
- .getResource("/images/JalviewLogo_Huge.png");
- if (url != null)
- {
- Image image = java.awt.Toolkit.getDefaultToolkit()
- .createImage(url);
- tb.setIconImage(image);
- }
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- }
+ JalviewTaskbar.setTaskbar(this);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ } catch (Throwable t)
+ {
+ t.printStackTrace();
}
desktop.setVisible(true);
--- /dev/null
+package jalview.bin;
+
+import java.awt.Image;
+import java.awt.Taskbar;
+
+public class JalviewTaskbar
+{
+ public JalviewTaskbar()
+ {
+ }
+
+ protected static void setTaskbar(Jalview jalview)
+ {
+
+ if (Taskbar.isTaskbarSupported())
+ {
+ Taskbar tb = Taskbar.getTaskbar();
+ if (tb.isSupported(Taskbar.Feature.ICON_IMAGE))
+ {
+ try
+ {
+ java.net.URL url = jalview.getClass()
+ .getResource("/images/JalviewLogo_Huge.png");
+ if (url != null)
+ {
+ Image image = java.awt.Toolkit.getDefaultToolkit()
+ .createImage(url);
+ tb.setIconImage(image);
+ }
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+}
--- /dev/null
+package jalview.gui;
+
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+
+import java.awt.Desktop;
+import java.awt.desktop.AboutEvent;
+import java.awt.desktop.AboutHandler;
+import java.awt.desktop.PreferencesEvent;
+import java.awt.desktop.PreferencesHandler;
+import java.awt.desktop.QuitEvent;
+import java.awt.desktop.QuitHandler;
+import java.awt.desktop.QuitResponse;
+import java.awt.desktop.QuitStrategy;
+
+import javax.swing.JOptionPane;
+
+public class APQHandlers
+{
+ private static boolean setAPQHandlers = false;
+
+ public APQHandlers() {
+ }
+
+ protected static boolean setAPQHandlers(jalview.gui.Desktop jalviewDesktop)
+ {
+ // flagging this test to avoid unnecessary reflection
+ if (!setAPQHandlers)
+ {
+ // see if the Quit, About and Preferences handlers are available
+ Class desktopClass = Desktop.class;
+ Desktop hdesktop = Desktop.getDesktop();
+
+ try
+ {
+ Float specversion = Float.parseFloat(
+ System.getProperty("java.specification.version"));
+
+ if (specversion >= 9)
+ {
+ if (Platform.isAMac())
+ {
+ if (desktopClass.getDeclaredMethod("setAboutHandler",
+ new Class[]
+ { AboutHandler.class }) != null)
+ {
+
+ hdesktop.setAboutHandler(new AboutHandler()
+ {
+ @Override
+ public void handleAbout(AboutEvent e)
+ {
+ jalviewDesktop.aboutMenuItem_actionPerformed(null);
+ }
+ });
+
+ }
+
+ if (desktopClass.getDeclaredMethod("setPreferencesHandler",
+ new Class[]
+ { PreferencesHandler.class }) != null)
+ {
+
+ hdesktop.setPreferencesHandler(
+ new PreferencesHandler()
+ {
+ @Override
+ public void handlePreferences(
+ PreferencesEvent e)
+ {
+ jalviewDesktop.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(jalviewDesktop.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");
+ jalviewDesktop.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);
+
+ }
+ }
+ setAPQHandlers = true;
+ }
+ else
+ {
+ System.out.println(
+ "Not going to try setting APQ Handlers as java.spec.version is "
+ + specversion);
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println(
+ "Exception when looking for About, Preferences, Quit Handlers");
+ e.printStackTrace();
+ } catch (Throwable t)
+ {
+ System.out.println(
+ "Throwable when looking for About, Preferences, Quit Handlers");
+ t.printStackTrace();
+ }
+
+ }
+
+ return setAPQHandlers;
+ }
+
+}
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
-import java.awt.desktop.QuitStrategy;
-/* not importing directly. Calling classes with full name in try block to allow Java 1.8 runtime
-import java.awt.desktop.AboutHandler;
-import java.awt.desktop.PreferencesEvent;
-import java.awt.desktop.PreferencesHandler;
-import java.awt.desktop.QuitEvent;
-import java.awt.desktop.QuitHandler;
-import java.awt.desktop.QuitResponse;
-import java.awt.desktop.QuitStrategy;
-*/
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
- private static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
+ protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
public static HashMap<String, FileWriter> savingFiles = new HashMap<>();
private File projectFile;
- private static boolean setAPQHandlers = false;
-
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
}
*/
- // flagging this test to avoid unnecessary reflection
- if (!setAPQHandlers)
+ try
{
- // see if the Quit, About and Preferences handlers are available
- Class desktopClass = java.awt.Desktop.class;
- java.awt.Desktop hdesktop = java.awt.Desktop.getDesktop();
-
- try
- {
- Float specversion = Float.parseFloat(
- System.getProperty("java.specification.version"));
-
- if (specversion >= 9)
- {
- if (Platform.isAMac())
- {
- if (desktopClass.getDeclaredMethod("setAboutHandler",
- new Class[]
- { java.awt.desktop.AboutHandler.class }) != null)
- {
-
- hdesktop.setAboutHandler(new java.awt.desktop.AboutHandler()
- {
- @Override
- public void handleAbout(java.awt.desktop.AboutEvent e)
- {
- aboutMenuItem_actionPerformed(null);
- }
- });
-
- }
-
- if (desktopClass.getDeclaredMethod("setPreferencesHandler",
- new Class[]
- { java.awt.desktop.PreferencesHandler.class }) != null)
- {
-
- hdesktop.setPreferencesHandler(
- new java.awt.desktop.PreferencesHandler()
- {
- @Override
- public void handlePreferences(
- java.awt.desktop.PreferencesEvent e)
- {
- preferences_actionPerformed(null);
- }
- });
-
- }
-
- if (desktopClass.getDeclaredMethod("setQuitHandler",
- new Class[]
- { java.awt.desktop.QuitHandler.class }) != null)
- {
-
- hdesktop.setQuitHandler(new java.awt.desktop.QuitHandler()
- {
- @Override
- public void handleQuitRequestWith(
- java.awt.desktop.QuitEvent e,
- java.awt.desktop.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);
-
- }
- }
- }
- else
- {
- System.out.println(
- "Not going to try setting APQ Handlers as java.spec.version is "
- + specversion);
- }
-
- } catch (Exception e)
- {
- System.out.println(
- "Exception when looking for About, Preferences, Quit Handlers");
- e.printStackTrace();
- } catch (Throwable t)
- {
- System.out.println(
- "Throwable when looking for About, Preferences, Quit Handlers");
- t.printStackTrace();
- }
-
- setAPQHandlers = true;
+ APQHandlers.setAPQHandlers(this);
+ } catch (Exception e)
+ {
+ System.out.println("Exception when trying to set APQHandlers");
+ e.printStackTrace();
+ } catch (Throwable t)
+ {
+ System.out.println("Throwable when trying to set APQHandlers");
+ t.printStackTrace();
}
+
addWindowListener(new WindowAdapter()
{
KeyStroke ctrlWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W,
InputEvent.CTRL_DOWN_MASK);
KeyStroke cmdWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx());
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx());
InputMap inputMap = frame
.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
{
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()),
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()),
"Quit");
getRootPane().getActionMap().put("Quit", new AbstractAction()
{
* Ctrl-W / Cmd-W - close view or window
*/
KeyStroke key_cmdW = KeyStroke.getKeyStroke(KeyEvent.VK_W,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
action = new AbstractAction()
{
@Override
* Ctrl-T / Cmd-T open new view
*/
KeyStroke key_cmdT = KeyStroke.getKeyStroke(KeyEvent.VK_T,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
AbstractAction action = new AbstractAction()
{
@Override
* Ctrl-F / Cmd-F open Finder dialog, 'focused' on the right alignment
*/
KeyStroke key_cmdF = KeyStroke.getKeyStroke(KeyEvent.VK_F,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
AbstractAction action = new AbstractAction()
{
@Override
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
// FIXME getDefaultToolkit throws an exception in Headless mode
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
- | KeyEvent.SHIFT_DOWN_MASK,
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+ | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
false);
addMenuActionAndAccelerator(keyStroke, saveAs, al);
closeMenuItem.setText(MessageManager.getString("action.close"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem selectAllSequenceMenuItem = new JMenuItem(
MessageManager.getString("action.select_all"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem invertSequenceMenuItem = new JMenuItem(
MessageManager.getString("action.invert_sequence_selection"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem remove2LeftMenuItem = new JMenuItem(
MessageManager.getString("action.remove_left"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem remove2RightMenuItem = new JMenuItem(
MessageManager.getString("action.remove_right"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem removeGappedColumnMenuItem = new JMenuItem(
MessageManager.getString("action.remove_empty_columns"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem removeAllGapsMenuItem = new JMenuItem(
MessageManager.getString("action.remove_all_gaps"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
- | KeyEvent.SHIFT_DOWN_MASK,
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+ | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
false);
al = new ActionListener()
{
JMenuItem removeRedundancyMenuItem = new JMenuItem(
MessageManager.getString("action.remove_redundancy"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
undoMenuItem.setEnabled(false);
undoMenuItem.setText(MessageManager.getString("action.undo"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
redoMenuItem.setEnabled(false);
redoMenuItem.setText(MessageManager.getString("action.redo"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem printMenuItem = new JMenuItem(
MessageManager.getString("action.print"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem findMenuItem = new JMenuItem(
MessageManager.getString("action.find"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
findMenuItem.setToolTipText(JvSwingUtils.wrapTooltip(true,
MessageManager.getString("label.find_tip")));
al = new ActionListener()
JMenuItem deleteGroups = new JMenuItem(
MessageManager.getString("action.undefine_groups"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem createGroup = new JMenuItem(
MessageManager.getString("action.create_group"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem unGroup = new JMenuItem(
MessageManager.getString("action.remove_group"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
- | KeyEvent.SHIFT_DOWN_MASK,
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+ | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
false);
al = new ActionListener()
{
copy.setText(MessageManager.getString("action.copy"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
cut.setText(MessageManager.getString("action.cut"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem pasteNew = new JMenuItem(
MessageManager.getString("label.to_new_alignment"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
- | KeyEvent.SHIFT_DOWN_MASK,
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+ | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
false);
al = new ActionListener()
{
JMenuItem pasteThis = new JMenuItem(
MessageManager.getString("label.to_this_alignment"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem invertColSel = new JMenuItem(
MessageManager.getString("action.invert_column_selection"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
- | KeyEvent.ALT_DOWN_MASK,
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+ | jalview.util.ShortcutKeyMaskExWrapper.ALT_DOWN_MASK,
false);
al = new ActionListener()
{
JMenuItem save = new JMenuItem(MessageManager.getString("action.save"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
JMenuItem newView = new JMenuItem(
MessageManager.getString("action.new_view"));
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_T,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false);
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
al = new ActionListener()
{
@Override
import jalview.gui.JvSwingUtils;
import jalview.util.MessageManager;
+import jalview.util.ShortcutKeyMaskExWrapper;
import java.awt.BorderLayout;
import java.awt.Font;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
});
close.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_W,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
selectAll.setText(MessageManager.getString("action.select_all"));
selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_A,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
selectAll.addActionListener(new ActionListener()
{
@Override
save.setText(MessageManager.getString("action.save"));
save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_S,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
save.addActionListener(new ActionListener()
{
@Override
});
copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_C,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
editMenubar.add(jMenu1);
editMenubar.add(editMenu);
selectAll.setText(MessageManager.getString("action.select_all"));
selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_A,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
selectAll.addActionListener(new ActionListener()
{
@Override
save.setText(MessageManager.getString("action.save"));
save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_S,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
save.addActionListener(new ActionListener()
{
@Override
});
copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_C,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
pasteMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_V,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false));
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false));
editMenubar.add(jMenu1);
editMenubar.add(editMenu);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
import jalview.util.Platform;
import java.awt.FlowLayout;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
.setText(MessageManager.getString("label.load_tree_from_file"));
inputLocalFileMenuItem.setAccelerator(
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(),
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(),
false));
inputLocalFileMenuItem
.addActionListener(new java.awt.event.ActionListener()
}
});
+ Float specversion = Float.parseFloat(System.getProperty("java.specification.version"));
+
desktopMenubar.add(FileMenu);
desktopMenubar.add(toolsMenu);
VamsasMenu.setVisible(false);
VamsasMenu.add(vamsasImport);
VamsasMenu.add(vamsasSave);
VamsasMenu.add(vamsasStop);
- if (!Platform.isAMac())
+ if (!Platform.isAMac() || specversion < 11)
{
toolsMenu.add(preferences);
}
{
return false;
}
- return (Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() // .getMenuShortcutKeyMaskEx()
+ return (jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx() // .getMenuShortcutKeyMaskEx()
& e.getModifiersEx()) != 0; // getModifiers()) != 0;
}
return e.isControlDown();
--- /dev/null
+package jalview.util;
+
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
+
+public class ShortcutKeyMaskExWrapper
+{
+
+ private static boolean init = false;
+
+ private static final Float specversion = Float
+ .parseFloat(System.getProperty("java.specification.version"));
+
+ private static final float modern = 11;
+
+ public static int SHIFT_DOWN_MASK = KeyEvent.SHIFT_DOWN_MASK;
+
+ public static int ALT_DOWN_MASK = KeyEvent.ALT_DOWN_MASK;
+
+ public ShortcutKeyMaskExWrapper()
+ {
+ }
+
+ private static void init()
+ {
+ if (init)
+ {
+ return;
+ }
+ if (specversion < modern)
+ {
+ SHIFT_DOWN_MASK = KeyEvent.SHIFT_MASK;
+ ALT_DOWN_MASK = KeyEvent.ALT_MASK;
+ }
+ else
+ {
+ SHIFT_DOWN_MASK = KeyEvent.SHIFT_DOWN_MASK;
+ ALT_DOWN_MASK = KeyEvent.ALT_DOWN_MASK;
+ }
+
+ init = true;
+ }
+
+ public static int getMenuShortcutKeyMaskEx()
+ {
+ init();
+ if (specversion < modern)
+ {
+ return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+ }
+ else
+ {
+ return Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
+ }
+ }
+
+}