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 jalview.api.AlignmentViewPanel;
24 import jalview.io.FileFormatException;
25 import jalview.util.MessageManager;
26 import jalview.util.Platform;
28 import java.awt.FlowLayout;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
32 import javax.swing.JCheckBoxMenuItem;
33 import javax.swing.JFrame;
34 import javax.swing.JMenu;
35 import javax.swing.JMenuBar;
36 import javax.swing.JMenuItem;
44 @SuppressWarnings("serial")
45 public class GDesktop extends JFrame
48 protected static JMenu windowMenu = new JMenu();
50 JMenuBar desktopMenubar = new JMenuBar();
52 JMenu FileMenu = new JMenu();
54 JMenu HelpMenu = new JMenu();
56 JMenuItem inputLocalFileMenuItem = new JMenuItem();
58 JMenuItem inputURLMenuItem = new JMenuItem();
60 JMenuItem inputTextboxMenuItem = new JMenuItem();
62 JMenuItem quit = new JMenuItem();
64 JMenuItem aboutMenuItem = new JMenuItem();
66 JMenuItem documentationMenuItem = new JMenuItem();
68 FlowLayout flowLayout1 = new FlowLayout();
70 protected JMenu toolsMenu = new JMenu();
72 JMenuItem preferences = new JMenuItem();
74 JMenuItem saveState = new JMenuItem();
76 JMenuItem saveAsState = new JMenuItem();
78 JMenuItem loadState = new JMenuItem();
80 JMenu inputMenu = new JMenu();
82 JMenuItem inputSequence = new JMenuItem();
84 JMenuItem closeAll = new JMenuItem();
86 JMenuItem raiseRelated = new JMenuItem();
88 JMenuItem minimizeAssociated = new JMenuItem();
90 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
92 JMenuItem garbageCollect = new JMenuItem();
94 protected JMenuItem groovyShell;
96 protected JCheckBoxMenuItem experimentalFeatures;
98 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
100 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
102 protected JMenuItem snapShotWindow = new JMenuItem();
105 * Creates a new GDesktop object.
113 this.setJMenuBar(desktopMenubar);
114 } catch (Exception e)
119 if (Platform.allowMnemonics())
121 // BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
122 // but here we want just not a Mac, period, right?
123 FileMenu.setMnemonic('F');
124 inputLocalFileMenuItem.setMnemonic('L');
125 inputURLMenuItem.setMnemonic('U');
126 inputTextboxMenuItem.setMnemonic('C');
127 quit.setMnemonic('Q');
128 saveState.setMnemonic('S');
129 loadState.setMnemonic('L');
130 inputMenu.setMnemonic('I');
140 private void jbInit() throws Exception
142 setName("jalview-desktop");
143 FileMenu.setText(MessageManager.getString("action.file"));
144 HelpMenu.setText(MessageManager.getString("action.help"));
145 inputLocalFileMenuItem
146 .setText(MessageManager.getString("label.load_tree_from_file"));
147 inputLocalFileMenuItem
149 javax.swing.KeyStroke
150 .getKeyStroke(java.awt.event.KeyEvent.VK_O,
151 jalview.util.ShortcutKeyMaskExWrapper
152 .getMenuShortcutKeyMaskEx(),
154 inputLocalFileMenuItem
155 .addActionListener(new java.awt.event.ActionListener()
158 public void actionPerformed(ActionEvent e)
160 inputLocalFileMenuItem_actionPerformed(null);
163 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
164 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
167 public void actionPerformed(ActionEvent e)
171 inputURLMenuItem_actionPerformed(null);
172 } catch (FileFormatException e1)
174 System.err.println("Error loading from URL: " + e1.getMessage());
179 .setText(MessageManager.getString("label.from_textbox"));
181 .addActionListener(new java.awt.event.ActionListener()
184 public void actionPerformed(ActionEvent e)
186 inputTextboxMenuItem_actionPerformed(null);
189 quit.setText(MessageManager.getString("action.quit"));
190 quit.addActionListener(new java.awt.event.ActionListener()
193 public void actionPerformed(ActionEvent e)
198 aboutMenuItem.setText(MessageManager.getString("label.about"));
199 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
202 public void actionPerformed(ActionEvent e)
204 aboutMenuItem_actionPerformed(e);
207 documentationMenuItem
208 .setText(MessageManager.getString("label.documentation"));
209 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
210 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
211 documentationMenuItem
212 .addActionListener(new java.awt.event.ActionListener()
215 public void actionPerformed(ActionEvent e)
217 documentationMenuItem_actionPerformed();
220 this.getContentPane().setLayout(flowLayout1);
221 windowMenu.setText(MessageManager.getString("label.window"));
222 preferences.setText(MessageManager.getString("label.preferences"));
223 preferences.addActionListener(new ActionListener()
226 public void actionPerformed(ActionEvent e)
228 preferences_actionPerformed(e);
231 toolsMenu.setText(MessageManager.getString("label.tools"));
232 saveState.setText(MessageManager.getString("action.save_project"));
233 saveState.addActionListener(new ActionListener()
236 public void actionPerformed(ActionEvent e)
238 saveState_actionPerformed();
241 saveAsState.setText(MessageManager.getString("action.save_project_as"));
242 saveAsState.addActionListener(new ActionListener()
245 public void actionPerformed(ActionEvent e)
247 saveAsState_actionPerformed(e);
250 loadState.setText(MessageManager.getString("action.load_project"));
251 loadState.addActionListener(new ActionListener()
254 public void actionPerformed(ActionEvent e)
256 loadState_actionPerformed();
259 inputMenu.setText(MessageManager.getString("label.input_alignment"));
261 .setText(MessageManager.getString("action.fetch_sequences"));
262 inputSequence.addActionListener(new ActionListener()
265 public void actionPerformed(ActionEvent e)
267 inputSequence_actionPerformed(e);
270 closeAll.setText(MessageManager.getString("action.close_all"));
271 closeAll.addActionListener(new ActionListener()
274 public void actionPerformed(ActionEvent e)
276 closeAll_actionPerformed(e);
279 raiseRelated.setText(
280 MessageManager.getString("action.raise_associated_windows"));
281 raiseRelated.addActionListener(new ActionListener()
284 public void actionPerformed(ActionEvent e)
286 raiseRelated_actionPerformed(e);
289 minimizeAssociated.setText(
290 MessageManager.getString("action.minimize_associated_windows"));
291 minimizeAssociated.addActionListener(new ActionListener()
294 public void actionPerformed(ActionEvent e)
296 minimizeAssociated_actionPerformed(e);
300 .setText(MessageManager.getString("label.collect_garbage"));
301 garbageCollect.addActionListener(new ActionListener()
304 public void actionPerformed(ActionEvent e)
306 garbageCollect_actionPerformed(e);
310 .setText(MessageManager.getString("label.show_memory_usage"));
311 showMemusage.addActionListener(new ActionListener()
314 public void actionPerformed(ActionEvent e)
316 showMemusage_actionPerformed(e);
320 .setText(MessageManager.getString("label.show_java_console"));
321 showConsole.addActionListener(new ActionListener()
324 public void actionPerformed(ActionEvent e)
326 showConsole_actionPerformed(e);
329 showNews.setText(MessageManager.getString("label.show_jalview_news"));
330 showNews.addActionListener(new ActionListener()
333 public void actionPerformed(ActionEvent e)
335 showNews_actionPerformed(e);
338 groovyShell = new JMenuItem();
339 groovyShell.setText(MessageManager.getString("label.groovy_console"));
340 groovyShell.addActionListener(new ActionListener()
343 public void actionPerformed(ActionEvent e)
345 groovyShell_actionPerformed();
348 experimentalFeatures = new JCheckBoxMenuItem();
350 .setText(MessageManager.getString("label.show_experimental"));
351 experimentalFeatures.setToolTipText(
352 MessageManager.getString("label.show_experimental_tip"));
353 experimentalFeatures.addActionListener(new ActionListener()
356 public void actionPerformed(ActionEvent e)
358 showExperimental_actionPerformed(experimentalFeatures.isSelected());
362 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
363 snapShotWindow.addActionListener(new ActionListener()
366 public void actionPerformed(ActionEvent e)
368 snapShotWindow_actionPerformed(e);
372 Float specversion = Platform.isJS() ? Float.valueOf(8)
374 System.getProperty("java.specification.version"));
376 desktopMenubar.add(FileMenu);
377 desktopMenubar.add(toolsMenu);
378 desktopMenubar.add(HelpMenu);
379 desktopMenubar.add(windowMenu);
380 FileMenu.add(inputMenu);
381 FileMenu.add(inputSequence);
382 FileMenu.addSeparator();
383 // FileMenu.add(saveState);
384 FileMenu.add(saveAsState);
385 FileMenu.add(loadState);
386 FileMenu.addSeparator();
388 HelpMenu.add(aboutMenuItem);
389 HelpMenu.add(documentationMenuItem);
390 if (!Platform.isAMacAndNotJS() || specversion < 11)
392 toolsMenu.add(preferences);
394 if (!Platform.isJS())
396 toolsMenu.add(showMemusage);
397 toolsMenu.add(showConsole);
398 toolsMenu.add(showNews);
399 toolsMenu.add(garbageCollect);
400 toolsMenu.add(groovyShell);
402 toolsMenu.add(experimentalFeatures);
403 // toolsMenu.add(snapShotWindow);
404 inputMenu.add(inputLocalFileMenuItem);
405 inputMenu.add(inputURLMenuItem);
406 inputMenu.add(inputTextboxMenuItem);
407 windowMenu.add(closeAll);
408 windowMenu.add(raiseRelated);
409 windowMenu.add(minimizeAssociated);
410 windowMenu.addSeparator();
411 // inputMenu.add(vamsasLoad);
414 protected void showExperimental_actionPerformed(boolean selected)
418 protected void groovyShell_actionPerformed()
422 protected void snapShotWindow_actionPerformed(ActionEvent e)
424 // TODO Auto-generated method stub
428 protected void showConsole_actionPerformed(ActionEvent e)
430 // TODO Auto-generated method stub
434 protected void showNews_actionPerformed(ActionEvent e)
436 // TODO Auto-generated method stub
440 protected void showMemusage_actionPerformed(ActionEvent e)
442 // TODO Auto-generated method stub
446 protected void garbageCollect_actionPerformed(ActionEvent e)
448 // TODO Auto-generated method stub
452 protected void vamsasStMenu_actionPerformed()
456 public void vamsasSave_actionPerformed(ActionEvent e)
466 protected void inputLocalFileMenuItem_actionPerformed(
467 jalview.gui.AlignViewport av)
476 * @throws FileFormatException
478 protected void inputURLMenuItem_actionPerformed(
479 jalview.gui.AlignViewport av) throws FileFormatException
489 protected void inputTextboxMenuItem_actionPerformed(
490 AlignmentViewPanel avp)
497 protected void quit()
499 // System.out.println("********** GDesktop.quit()");
508 protected void aboutMenuItem_actionPerformed(ActionEvent e)
512 protected void documentationMenuItem_actionPerformed()
522 protected void preferences_actionPerformed(ActionEvent e)
532 public void saveState_actionPerformed()
536 public void saveAsState_actionPerformed(ActionEvent e)
546 public void loadState_actionPerformed()
556 public void loadJalviewAlign_actionPerformed(ActionEvent e)
560 public void vamsasStart_actionPerformed(ActionEvent e)
565 public void inputSequence_actionPerformed(ActionEvent e)
570 public void vamsasStop_actionPerformed(ActionEvent e)
575 public void closeAll_actionPerformed(ActionEvent e)
580 public void raiseRelated_actionPerformed(ActionEvent e)
585 public void minimizeAssociated_actionPerformed(ActionEvent e)
590 public void vamsasImport_actionPerformed(ActionEvent e)