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.bin.Jalview;
25 import jalview.io.FileFormatException;
26 import jalview.util.MessageManager;
27 import jalview.util.Platform;
29 import java.awt.FlowLayout;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
33 import javax.swing.JCheckBoxMenuItem;
34 import javax.swing.JFrame;
35 import javax.swing.JMenu;
36 import javax.swing.JMenuBar;
37 import javax.swing.JMenuItem;
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 setName(Jalview.getAppID("desktop"));
145 FileMenu.setText(MessageManager.getString("action.file"));
146 HelpMenu.setText(MessageManager.getString("action.help"));
147 inputLocalFileMenuItem
148 .setText(MessageManager.getString("label.load_tree_from_file"));
149 inputLocalFileMenuItem.setAccelerator(
150 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
151 jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(),
153 inputLocalFileMenuItem
154 .addActionListener(new java.awt.event.ActionListener()
157 public void actionPerformed(ActionEvent e)
159 inputLocalFileMenuItem_actionPerformed(null);
162 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
163 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
166 public void actionPerformed(ActionEvent e)
170 inputURLMenuItem_actionPerformed(null);
171 } catch (FileFormatException e1)
173 System.err.println("Error loading from URL: " + e1.getMessage());
178 .setText(MessageManager.getString("label.from_textbox"));
180 .addActionListener(new java.awt.event.ActionListener()
183 public void actionPerformed(ActionEvent e)
185 inputTextboxMenuItem_actionPerformed(null);
188 quit.setText(MessageManager.getString("action.quit"));
189 quit.addActionListener(new java.awt.event.ActionListener()
192 public void actionPerformed(ActionEvent e)
197 aboutMenuItem.setText(MessageManager.getString("label.about"));
198 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
201 public void actionPerformed(ActionEvent e)
203 aboutMenuItem_actionPerformed(e);
206 documentationMenuItem
207 .setText(MessageManager.getString("label.documentation"));
208 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
209 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
210 documentationMenuItem
211 .addActionListener(new java.awt.event.ActionListener()
214 public void actionPerformed(ActionEvent e)
216 documentationMenuItem_actionPerformed();
219 this.getContentPane().setLayout(flowLayout1);
220 windowMenu.setText(MessageManager.getString("label.window"));
221 preferences.setText(MessageManager.getString("label.preferences"));
222 preferences.addActionListener(new ActionListener()
225 public void actionPerformed(ActionEvent e)
227 preferences_actionPerformed(e);
230 toolsMenu.setText(MessageManager.getString("label.tools"));
231 saveState.setText(MessageManager.getString("action.save_project"));
232 saveState.addActionListener(new ActionListener()
235 public void actionPerformed(ActionEvent e)
237 saveState_actionPerformed();
240 saveAsState.setText(MessageManager.getString("action.save_project_as"));
241 saveAsState.addActionListener(new ActionListener()
244 public void actionPerformed(ActionEvent e)
246 saveAsState_actionPerformed(e);
249 loadState.setText(MessageManager.getString("action.load_project"));
250 loadState.addActionListener(new ActionListener()
253 public void actionPerformed(ActionEvent e)
255 loadState_actionPerformed();
258 inputMenu.setText(MessageManager.getString("label.input_alignment"));
260 .setText(MessageManager.getString("action.fetch_sequences"));
261 inputSequence.addActionListener(new ActionListener()
264 public void actionPerformed(ActionEvent e)
266 inputSequence_actionPerformed(e);
269 closeAll.setText(MessageManager.getString("action.close_all"));
270 closeAll.addActionListener(new ActionListener()
273 public void actionPerformed(ActionEvent e)
275 closeAll_actionPerformed(e);
278 raiseRelated.setText(
279 MessageManager.getString("action.raise_associated_windows"));
280 raiseRelated.addActionListener(new ActionListener()
283 public void actionPerformed(ActionEvent e)
285 raiseRelated_actionPerformed(e);
288 minimizeAssociated.setText(
289 MessageManager.getString("action.minimize_associated_windows"));
290 minimizeAssociated.addActionListener(new ActionListener()
293 public void actionPerformed(ActionEvent e)
295 minimizeAssociated_actionPerformed(e);
299 .setText(MessageManager.getString("label.collect_garbage"));
300 garbageCollect.addActionListener(new ActionListener()
303 public void actionPerformed(ActionEvent e)
305 garbageCollect_actionPerformed(e);
309 .setText(MessageManager.getString("label.show_memory_usage"));
310 showMemusage.addActionListener(new ActionListener()
313 public void actionPerformed(ActionEvent e)
315 showMemusage_actionPerformed(e);
319 .setText(MessageManager.getString("label.show_java_console"));
320 showConsole.addActionListener(new ActionListener()
323 public void actionPerformed(ActionEvent e)
325 showConsole_actionPerformed(e);
328 showNews.setText(MessageManager.getString("label.show_jalview_news"));
329 showNews.addActionListener(new ActionListener()
332 public void actionPerformed(ActionEvent e)
334 showNews_actionPerformed(e);
337 groovyShell = new JMenuItem();
338 groovyShell.setText(MessageManager.getString("label.groovy_console"));
339 groovyShell.addActionListener(new ActionListener()
342 public void actionPerformed(ActionEvent e)
344 groovyShell_actionPerformed();
347 experimentalFeatures = new JCheckBoxMenuItem();
349 .setText(MessageManager.getString("label.show_experimental"));
350 experimentalFeatures.setToolTipText(
351 MessageManager.getString("label.show_experimental_tip"));
352 experimentalFeatures.addActionListener(new ActionListener()
355 public void actionPerformed(ActionEvent e)
357 showExperimental_actionPerformed(experimentalFeatures.isSelected());
361 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
362 snapShotWindow.addActionListener(new ActionListener()
365 public void actionPerformed(ActionEvent e)
367 snapShotWindow_actionPerformed(e);
371 Float specversion = Platform.isJS() ? Float.valueOf(8)
373 System.getProperty("java.specification.version"));
375 desktopMenubar.add(FileMenu);
376 desktopMenubar.add(toolsMenu);
377 desktopMenubar.add(HelpMenu);
378 desktopMenubar.add(windowMenu);
379 FileMenu.add(inputMenu);
380 FileMenu.add(inputSequence);
381 FileMenu.addSeparator();
382 //FileMenu.add(saveState);
383 FileMenu.add(saveAsState);
384 FileMenu.add(loadState);
385 FileMenu.addSeparator();
387 HelpMenu.add(aboutMenuItem);
388 HelpMenu.add(documentationMenuItem);
389 if (!Platform.isAMacAndNotJS() || specversion < 11)
391 toolsMenu.add(preferences);
393 if (!Platform.isJS())
395 toolsMenu.add(showMemusage);
396 toolsMenu.add(showConsole);
397 toolsMenu.add(showNews);
398 toolsMenu.add(garbageCollect);
399 toolsMenu.add(groovyShell);
401 toolsMenu.add(experimentalFeatures);
402 // toolsMenu.add(snapShotWindow);
403 inputMenu.add(inputLocalFileMenuItem);
404 inputMenu.add(inputURLMenuItem);
405 inputMenu.add(inputTextboxMenuItem);
406 windowMenu.add(closeAll);
407 windowMenu.add(raiseRelated);
408 windowMenu.add(minimizeAssociated);
409 windowMenu.addSeparator();
410 // inputMenu.add(vamsasLoad);
413 protected void showExperimental_actionPerformed(boolean selected)
417 protected void groovyShell_actionPerformed()
421 protected void snapShotWindow_actionPerformed(ActionEvent e)
423 // TODO Auto-generated method stub
427 protected void showConsole_actionPerformed(ActionEvent e)
429 // TODO Auto-generated method stub
433 protected void showNews_actionPerformed(ActionEvent e)
435 // TODO Auto-generated method stub
439 protected void showMemusage_actionPerformed(ActionEvent e)
441 // TODO Auto-generated method stub
445 protected void garbageCollect_actionPerformed(ActionEvent e)
447 // TODO Auto-generated method stub
451 protected void vamsasStMenu_actionPerformed()
455 public void vamsasSave_actionPerformed(ActionEvent e)
465 protected void inputLocalFileMenuItem_actionPerformed(
466 jalview.gui.AlignViewport av)
475 * @throws FileFormatException
477 protected void inputURLMenuItem_actionPerformed(
478 jalview.gui.AlignViewport av) throws FileFormatException
488 protected void inputTextboxMenuItem_actionPerformed(
489 AlignmentViewPanel avp)
496 protected void quit()
498 //System.out.println("********** GDesktop.quit()");
507 protected void aboutMenuItem_actionPerformed(ActionEvent e)
511 protected void documentationMenuItem_actionPerformed()
521 protected void preferences_actionPerformed(ActionEvent e)
531 public void saveState_actionPerformed()
535 public void saveAsState_actionPerformed(ActionEvent e)
545 public void loadState_actionPerformed()
555 public void loadJalviewAlign_actionPerformed(ActionEvent e)
559 public void vamsasStart_actionPerformed(ActionEvent e)
564 public void inputSequence_actionPerformed(ActionEvent e)
569 public void vamsasStop_actionPerformed(ActionEvent e)
574 public void closeAll_actionPerformed(ActionEvent e)
579 public void raiseRelated_actionPerformed(ActionEvent e)
584 public void minimizeAssociated_actionPerformed(ActionEvent e)
589 public void vamsasImport_actionPerformed(ActionEvent e)