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 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
143 setName(Platform.getAppID("desktop"));
144 FileMenu.setText(MessageManager.getString("action.file"));
145 HelpMenu.setText(MessageManager.getString("action.help"));
146 inputLocalFileMenuItem
147 .setText(MessageManager.getString("label.load_tree_from_file"));
148 inputLocalFileMenuItem.setAccelerator(
149 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
150 Platform.SHORTCUT_KEY_MASK,
152 inputLocalFileMenuItem
153 .addActionListener(new java.awt.event.ActionListener()
156 public void actionPerformed(ActionEvent e)
158 inputLocalFileMenuItem_actionPerformed(null);
161 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
162 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
165 public void actionPerformed(ActionEvent e)
169 inputURLMenuItem_actionPerformed(null);
170 } catch (FileFormatException e1)
172 System.err.println("Error loading from URL: " + e1.getMessage());
177 .setText(MessageManager.getString("label.from_textbox"));
179 .addActionListener(new java.awt.event.ActionListener()
182 public void actionPerformed(ActionEvent e)
184 inputTextboxMenuItem_actionPerformed(null);
187 quit.setText(MessageManager.getString("action.quit"));
188 quit.addActionListener(new java.awt.event.ActionListener()
191 public void actionPerformed(ActionEvent e)
196 aboutMenuItem.setText(MessageManager.getString("label.about"));
197 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
200 public void actionPerformed(ActionEvent e)
202 aboutMenuItem_actionPerformed(e);
205 documentationMenuItem
206 .setText(MessageManager.getString("label.documentation"));
207 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
208 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
209 documentationMenuItem
210 .addActionListener(new java.awt.event.ActionListener()
213 public void actionPerformed(ActionEvent e)
215 documentationMenuItem_actionPerformed();
218 this.getContentPane().setLayout(flowLayout1);
219 windowMenu.setText(MessageManager.getString("label.window"));
220 preferences.setText(MessageManager.getString("label.preferences"));
221 preferences.addActionListener(new ActionListener()
224 public void actionPerformed(ActionEvent e)
226 preferences_actionPerformed(e);
229 toolsMenu.setText(MessageManager.getString("label.tools"));
230 saveState.setText(MessageManager.getString("action.save_project"));
231 saveState.addActionListener(new ActionListener()
234 public void actionPerformed(ActionEvent e)
236 saveState_actionPerformed();
239 saveAsState.setText(MessageManager.getString("action.save_project_as"));
240 saveAsState.addActionListener(new ActionListener()
243 public void actionPerformed(ActionEvent e)
245 saveAsState_actionPerformed(e);
248 loadState.setText(MessageManager.getString("action.load_project"));
249 loadState.addActionListener(new ActionListener()
252 public void actionPerformed(ActionEvent e)
254 loadState_actionPerformed();
257 inputMenu.setText(MessageManager.getString("label.input_alignment"));
259 .setText(MessageManager.getString("action.fetch_sequences"));
260 inputSequence.addActionListener(new ActionListener()
263 public void actionPerformed(ActionEvent e)
265 inputSequence_actionPerformed(e);
268 closeAll.setText(MessageManager.getString("action.close_all"));
269 closeAll.addActionListener(new ActionListener()
272 public void actionPerformed(ActionEvent e)
274 closeAll_actionPerformed(e);
277 raiseRelated.setText(
278 MessageManager.getString("action.raise_associated_windows"));
279 raiseRelated.addActionListener(new ActionListener()
282 public void actionPerformed(ActionEvent e)
284 raiseRelated_actionPerformed(e);
287 minimizeAssociated.setText(
288 MessageManager.getString("action.minimize_associated_windows"));
289 minimizeAssociated.addActionListener(new ActionListener()
292 public void actionPerformed(ActionEvent e)
294 minimizeAssociated_actionPerformed(e);
298 .setText(MessageManager.getString("label.collect_garbage"));
299 garbageCollect.addActionListener(new ActionListener()
302 public void actionPerformed(ActionEvent e)
304 garbageCollect_actionPerformed(e);
308 .setText(MessageManager.getString("label.show_memory_usage"));
309 showMemusage.addActionListener(new ActionListener()
312 public void actionPerformed(ActionEvent e)
314 showMemusage_actionPerformed(e);
318 .setText(MessageManager.getString("label.show_java_console"));
319 showConsole.addActionListener(new ActionListener()
322 public void actionPerformed(ActionEvent e)
324 showConsole_actionPerformed(e);
327 showNews.setText(MessageManager.getString("label.show_jalview_news"));
328 showNews.addActionListener(new ActionListener()
331 public void actionPerformed(ActionEvent e)
333 showNews_actionPerformed(e);
336 groovyShell = new JMenuItem();
337 groovyShell.setText(MessageManager.getString("label.groovy_console"));
338 groovyShell.addActionListener(new ActionListener()
341 public void actionPerformed(ActionEvent e)
343 groovyShell_actionPerformed();
346 experimentalFeatures = new JCheckBoxMenuItem();
348 .setText(MessageManager.getString("label.show_experimental"));
349 experimentalFeatures.setToolTipText(
350 MessageManager.getString("label.show_experimental_tip"));
351 experimentalFeatures.addActionListener(new ActionListener()
354 public void actionPerformed(ActionEvent e)
356 showExperimental_actionPerformed(experimentalFeatures.isSelected());
360 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
361 snapShotWindow.addActionListener(new ActionListener()
364 public void actionPerformed(ActionEvent e)
366 snapShotWindow_actionPerformed(e);
370 Float specversion = Platform.isJS() ? Float.valueOf(8)
372 System.getProperty("java.specification.version"));
374 desktopMenubar.add(FileMenu);
375 desktopMenubar.add(toolsMenu);
376 desktopMenubar.add(HelpMenu);
377 desktopMenubar.add(windowMenu);
378 FileMenu.add(inputMenu);
379 FileMenu.add(inputSequence);
380 FileMenu.addSeparator();
381 //FileMenu.add(saveState);
382 FileMenu.add(saveAsState);
383 FileMenu.add(loadState);
384 FileMenu.addSeparator();
386 HelpMenu.add(aboutMenuItem);
387 HelpMenu.add(documentationMenuItem);
388 if (!Platform.isAMacAndNotJS() || specversion < 11)
390 toolsMenu.add(preferences);
392 if (!Platform.isJS())
394 toolsMenu.add(showMemusage);
395 toolsMenu.add(showConsole);
396 toolsMenu.add(showNews);
397 toolsMenu.add(garbageCollect);
398 toolsMenu.add(groovyShell);
400 toolsMenu.add(experimentalFeatures);
401 // toolsMenu.add(snapShotWindow);
402 inputMenu.add(inputLocalFileMenuItem);
403 inputMenu.add(inputURLMenuItem);
404 inputMenu.add(inputTextboxMenuItem);
405 windowMenu.add(closeAll);
406 windowMenu.add(raiseRelated);
407 windowMenu.add(minimizeAssociated);
408 windowMenu.addSeparator();
409 // inputMenu.add(vamsasLoad);
412 protected void showExperimental_actionPerformed(boolean selected)
416 protected void groovyShell_actionPerformed()
420 protected void snapShotWindow_actionPerformed(ActionEvent e)
422 // TODO Auto-generated method stub
426 protected void showConsole_actionPerformed(ActionEvent e)
428 // TODO Auto-generated method stub
432 protected void showNews_actionPerformed(ActionEvent e)
434 // TODO Auto-generated method stub
438 protected void showMemusage_actionPerformed(ActionEvent e)
440 // TODO Auto-generated method stub
444 protected void garbageCollect_actionPerformed(ActionEvent e)
446 // TODO Auto-generated method stub
450 protected void vamsasStMenu_actionPerformed()
454 public void vamsasSave_actionPerformed(ActionEvent e)
464 protected void inputLocalFileMenuItem_actionPerformed(
465 jalview.gui.AlignViewport av)
474 * @throws FileFormatException
476 protected void inputURLMenuItem_actionPerformed(
477 jalview.gui.AlignViewport av) throws FileFormatException
487 protected void inputTextboxMenuItem_actionPerformed(
488 AlignmentViewPanel avp)
495 protected void quit()
497 //System.out.println("********** GDesktop.quit()");
506 protected void aboutMenuItem_actionPerformed(ActionEvent e)
510 protected void documentationMenuItem_actionPerformed()
520 protected void preferences_actionPerformed(ActionEvent e)
530 public void saveState_actionPerformed()
534 public void saveAsState_actionPerformed(ActionEvent e)
544 public void loadState_actionPerformed()
554 public void loadJalviewAlign_actionPerformed(ActionEvent e)
558 public void vamsasStart_actionPerformed(ActionEvent e)
563 public void inputSequence_actionPerformed(ActionEvent e)
568 public void vamsasStop_actionPerformed(ActionEvent e)
573 public void closeAll_actionPerformed(ActionEvent e)
578 public void raiseRelated_actionPerformed(ActionEvent e)
583 public void minimizeAssociated_actionPerformed(ActionEvent e)
588 public void vamsasImport_actionPerformed(ActionEvent e)