2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.FlowLayout;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
27 import javax.swing.JCheckBoxMenuItem;
28 import javax.swing.JFrame;
29 import javax.swing.JMenu;
30 import javax.swing.JMenuBar;
31 import javax.swing.JMenuItem;
33 import jalview.api.AlignmentViewPanel;
34 import jalview.bin.Cache;
35 import jalview.io.FileFormatException;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
45 @SuppressWarnings("serial")
46 public class GDesktop extends JFrame
49 protected static JMenu windowMenu = new JMenu();
51 JMenuBar desktopMenubar = new JMenuBar();
53 JMenu FileMenu = new JMenu();
55 JMenu HelpMenu = new JMenu();
57 JMenuItem inputLocalFileMenuItem = new JMenuItem();
59 JMenuItem inputURLMenuItem = new JMenuItem();
61 JMenuItem inputTextboxMenuItem = new JMenuItem();
63 JMenuItem quit = new JMenuItem();
65 JMenuItem aboutMenuItem = new JMenuItem();
67 JMenuItem documentationMenuItem = new JMenuItem();
69 FlowLayout flowLayout1 = new FlowLayout();
71 protected JMenu toolsMenu = new JMenu();
73 JMenuItem preferences = new JMenuItem();
75 JMenuItem saveState = new JMenuItem();
77 JMenuItem saveAsState = new JMenuItem();
79 JMenuItem loadState = new JMenuItem();
81 JMenu inputMenu = new JMenu();
83 JMenuItem inputSequence = new JMenuItem();
85 JMenuItem closeAll = new JMenuItem();
87 JMenuItem raiseRelated = new JMenuItem();
89 JMenuItem minimizeAssociated = new JMenuItem();
91 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
93 JMenuItem garbageCollect = new JMenuItem();
95 protected JMenuItem groovyShell;
97 protected JCheckBoxMenuItem experimentalFeatures;
99 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
101 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
103 protected JMenuItem snapShotWindow = new JMenuItem();
106 * Creates a new GDesktop object.
114 this.setJMenuBar(desktopMenubar);
115 } catch (Exception e)
120 if (Platform.allowMnemonics())
122 // BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
123 // but here we want just not a Mac, period, right?
124 FileMenu.setMnemonic('F');
125 inputLocalFileMenuItem.setMnemonic('L');
126 inputURLMenuItem.setMnemonic('U');
127 inputTextboxMenuItem.setMnemonic('C');
128 quit.setMnemonic('Q');
129 saveState.setMnemonic('S');
130 loadState.setMnemonic('L');
131 inputMenu.setMnemonic('I');
141 private void jbInit() throws Exception
144 * APQHandlers sets handlers for About, Preferences and Quit actions
145 * peculiar to macOS's application menu. APQHandlers will check to see if a
146 * handler is supported before setting it.
150 APQHandlers.setAPQHandlers(this);
151 } catch (Exception e)
153 System.out.println("Cannot set APQHandlers");
154 // e.printStackTrace();
155 } catch (Throwable t)
158 .warn("Error setting APQHandlers: " + t.toString());
159 jalview.bin.Console.trace(Cache.getStackTraceString(t));
162 setName("jalview-desktop");
163 FileMenu.setText(MessageManager.getString("action.file"));
164 HelpMenu.setText(MessageManager.getString("action.help"));
165 inputLocalFileMenuItem
166 .setText(MessageManager.getString("label.load_tree_from_file"));
167 inputLocalFileMenuItem
169 javax.swing.KeyStroke
170 .getKeyStroke(java.awt.event.KeyEvent.VK_O,
171 jalview.util.ShortcutKeyMaskExWrapper
172 .getMenuShortcutKeyMaskEx(),
174 inputLocalFileMenuItem
175 .addActionListener(new java.awt.event.ActionListener()
178 public void actionPerformed(ActionEvent e)
180 inputLocalFileMenuItem_actionPerformed(null);
183 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
184 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
187 public void actionPerformed(ActionEvent e)
191 inputURLMenuItem_actionPerformed(null);
192 } catch (FileFormatException e1)
194 System.err.println("Error loading from URL: " + e1.getMessage());
199 .setText(MessageManager.getString("label.from_textbox"));
201 .addActionListener(new java.awt.event.ActionListener()
204 public void actionPerformed(ActionEvent e)
206 inputTextboxMenuItem_actionPerformed(null);
209 quit.setText(MessageManager.getString("action.quit"));
210 quit.addActionListener(new java.awt.event.ActionListener()
213 public void actionPerformed(ActionEvent e)
218 aboutMenuItem.setText(MessageManager.getString("label.about"));
219 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
222 public void actionPerformed(ActionEvent e)
224 aboutMenuItem_actionPerformed(e);
227 documentationMenuItem
228 .setText(MessageManager.getString("label.documentation"));
229 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
230 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
231 documentationMenuItem
232 .addActionListener(new java.awt.event.ActionListener()
235 public void actionPerformed(ActionEvent e)
237 documentationMenuItem_actionPerformed();
240 this.getContentPane().setLayout(flowLayout1);
241 windowMenu.setText(MessageManager.getString("label.window"));
242 preferences.setText(MessageManager.getString("label.preferences"));
243 preferences.addActionListener(new ActionListener()
246 public void actionPerformed(ActionEvent e)
248 preferences_actionPerformed(e);
251 toolsMenu.setText(MessageManager.getString("label.tools"));
252 saveState.setText(MessageManager.getString("action.save_project"));
253 saveState.addActionListener(new ActionListener()
256 public void actionPerformed(ActionEvent e)
258 saveState_actionPerformed();
261 saveAsState.setText(MessageManager.getString("action.save_project_as"));
262 saveAsState.addActionListener(new ActionListener()
265 public void actionPerformed(ActionEvent e)
267 saveAsState_actionPerformed(e);
270 loadState.setText(MessageManager.getString("action.load_project"));
271 loadState.addActionListener(new ActionListener()
274 public void actionPerformed(ActionEvent e)
276 loadState_actionPerformed();
279 inputMenu.setText(MessageManager.getString("label.input_alignment"));
281 .setText(MessageManager.getString("action.fetch_sequences"));
282 inputSequence.addActionListener(new ActionListener()
285 public void actionPerformed(ActionEvent e)
287 inputSequence_actionPerformed(e);
290 closeAll.setText(MessageManager.getString("action.close_all"));
291 closeAll.addActionListener(new ActionListener()
294 public void actionPerformed(ActionEvent e)
296 closeAll_actionPerformed(e);
299 raiseRelated.setText(
300 MessageManager.getString("action.raise_associated_windows"));
301 raiseRelated.addActionListener(new ActionListener()
304 public void actionPerformed(ActionEvent e)
306 raiseRelated_actionPerformed(e);
309 minimizeAssociated.setText(
310 MessageManager.getString("action.minimize_associated_windows"));
311 minimizeAssociated.addActionListener(new ActionListener()
314 public void actionPerformed(ActionEvent e)
316 minimizeAssociated_actionPerformed(e);
320 .setText(MessageManager.getString("label.collect_garbage"));
321 garbageCollect.addActionListener(new ActionListener()
324 public void actionPerformed(ActionEvent e)
326 garbageCollect_actionPerformed(e);
330 .setText(MessageManager.getString("label.show_memory_usage"));
331 showMemusage.addActionListener(new ActionListener()
334 public void actionPerformed(ActionEvent e)
336 showMemusage_actionPerformed(e);
340 .setText(MessageManager.getString("label.show_java_console"));
341 showConsole.addActionListener(new ActionListener()
344 public void actionPerformed(ActionEvent e)
346 showConsole_actionPerformed(e);
349 showNews.setText(MessageManager.getString("label.show_jalview_news"));
350 showNews.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
355 showNews_actionPerformed(e);
358 groovyShell = new JMenuItem();
359 groovyShell.setText(MessageManager.getString("label.groovy_console"));
360 groovyShell.addActionListener(new ActionListener()
363 public void actionPerformed(ActionEvent e)
365 groovyShell_actionPerformed();
368 experimentalFeatures = new JCheckBoxMenuItem();
370 .setText(MessageManager.getString("label.show_experimental"));
371 experimentalFeatures.setToolTipText(
372 MessageManager.getString("label.show_experimental_tip"));
373 experimentalFeatures.addActionListener(new ActionListener()
376 public void actionPerformed(ActionEvent e)
378 showExperimental_actionPerformed(experimentalFeatures.isSelected());
382 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
383 snapShotWindow.addActionListener(new ActionListener()
386 public void actionPerformed(ActionEvent e)
388 snapShotWindow_actionPerformed(e);
392 desktopMenubar.add(FileMenu);
393 desktopMenubar.add(toolsMenu);
394 desktopMenubar.add(HelpMenu);
395 desktopMenubar.add(windowMenu);
396 FileMenu.add(inputMenu);
397 FileMenu.add(inputSequence);
398 FileMenu.addSeparator();
399 // FileMenu.add(saveState);
400 FileMenu.add(saveAsState);
401 FileMenu.add(loadState);
402 FileMenu.addSeparator();
404 if (!APQHandlers.setAPQHandlers)
406 HelpMenu.add(aboutMenuItem);
408 HelpMenu.add(documentationMenuItem);
409 if (!APQHandlers.setAPQHandlers)
411 toolsMenu.add(preferences);
413 if (!Platform.isJS())
415 toolsMenu.add(showMemusage);
416 toolsMenu.add(showConsole);
417 toolsMenu.add(showNews);
418 toolsMenu.add(garbageCollect);
419 toolsMenu.add(groovyShell);
421 toolsMenu.add(experimentalFeatures);
422 // toolsMenu.add(snapShotWindow);
423 inputMenu.add(inputLocalFileMenuItem);
424 inputMenu.add(inputURLMenuItem);
425 inputMenu.add(inputTextboxMenuItem);
426 windowMenu.add(closeAll);
427 windowMenu.add(raiseRelated);
428 windowMenu.add(minimizeAssociated);
429 windowMenu.addSeparator();
430 // inputMenu.add(vamsasLoad);
433 protected void showExperimental_actionPerformed(boolean selected)
437 protected void groovyShell_actionPerformed()
441 protected void snapShotWindow_actionPerformed(ActionEvent e)
443 // TODO Auto-generated method stub
447 protected void showConsole_actionPerformed(ActionEvent e)
449 // TODO Auto-generated method stub
453 protected void showNews_actionPerformed(ActionEvent e)
455 // TODO Auto-generated method stub
459 protected void showMemusage_actionPerformed(ActionEvent e)
461 // TODO Auto-generated method stub
465 protected void garbageCollect_actionPerformed(ActionEvent e)
467 // TODO Auto-generated method stub
471 protected void vamsasStMenu_actionPerformed()
475 public void vamsasSave_actionPerformed(ActionEvent e)
485 protected void inputLocalFileMenuItem_actionPerformed(
486 jalview.gui.AlignViewport av)
495 * @throws FileFormatException
497 protected void inputURLMenuItem_actionPerformed(
498 jalview.gui.AlignViewport av) throws FileFormatException
508 protected void inputTextboxMenuItem_actionPerformed(
509 AlignmentViewPanel avp)
516 protected void quit()
518 // System.out.println("********** GDesktop.quit()");
527 protected void aboutMenuItem_actionPerformed(ActionEvent e)
531 protected void documentationMenuItem_actionPerformed()
541 protected void preferences_actionPerformed(ActionEvent e)
551 public void saveState_actionPerformed()
555 public void saveAsState_actionPerformed(ActionEvent e)
565 public void loadState_actionPerformed()
575 public void loadJalviewAlign_actionPerformed(ActionEvent e)
579 public void vamsasStart_actionPerformed(ActionEvent e)
584 public void inputSequence_actionPerformed(ActionEvent e)
589 public void vamsasStop_actionPerformed(ActionEvent e)
594 public void closeAll_actionPerformed(ActionEvent e)
599 public void raiseRelated_actionPerformed(ActionEvent e)
604 public void minimizeAssociated_actionPerformed(ActionEvent e)
609 public void vamsasImport_actionPerformed(ActionEvent e)