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.Toolkit;
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 public class GDesktop extends JFrame
48 public static javax.swing.JTabbedPane createTabbedPane()
50 return new javax.swing.JTabbedPane();
54 protected static JMenu windowMenu = new JMenu();
56 JMenuBar desktopMenubar = new JMenuBar();
58 JMenu FileMenu = new JMenu();
60 JMenu HelpMenu = new JMenu();
62 protected JMenu VamsasMenu = new JMenu();
64 protected JMenu VamsasStMenu = new JMenu();
66 JMenuItem inputLocalFileMenuItem = new JMenuItem();
68 JMenuItem inputURLMenuItem = new JMenuItem();
70 JMenuItem inputTextboxMenuItem = new JMenuItem();
72 JMenuItem quit = new JMenuItem();
74 JMenuItem aboutMenuItem = new JMenuItem();
76 JMenuItem documentationMenuItem = new JMenuItem();
78 FlowLayout flowLayout1 = new FlowLayout();
80 protected JMenu toolsMenu = new JMenu();
82 JMenuItem preferences = new JMenuItem();
84 JMenuItem saveState = new JMenuItem();
86 JMenuItem loadState = new JMenuItem();
88 JMenu inputMenu = new JMenu();
90 protected JMenuItem vamsasStart = new JMenuItem();
92 protected JMenuItem vamsasImport = new JMenuItem();
94 protected JMenuItem vamsasSave = new JMenuItem();
96 JMenuItem inputSequence = new JMenuItem();
98 protected JMenuItem vamsasStop = new JMenuItem();
100 JMenuItem closeAll = new JMenuItem();
102 JMenuItem raiseRelated = new JMenuItem();
104 JMenuItem minimizeAssociated = new JMenuItem();
106 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
108 JMenuItem garbageCollect = new JMenuItem();
110 protected JMenuItem groovyShell;
112 protected JCheckBoxMenuItem experimentalFeatures;
114 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
116 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
118 protected JMenuItem snapShotWindow = new JMenuItem();
121 * Creates a new GDesktop object.
129 this.setJMenuBar(desktopMenubar);
130 } catch (Exception e)
135 if (Platform.allowMnemonics())
137 //BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
138 // but here we want just not a Mac, period, right?
139 FileMenu.setMnemonic('F');
140 inputLocalFileMenuItem.setMnemonic('L');
141 VamsasMenu.setMnemonic('V');
142 inputURLMenuItem.setMnemonic('U');
143 inputTextboxMenuItem.setMnemonic('C');
144 quit.setMnemonic('Q');
145 saveState.setMnemonic('S');
146 loadState.setMnemonic('L');
147 inputMenu.setMnemonic('I');
157 private void jbInit() throws Exception
160 FileMenu.setText(MessageManager.getString("action.file"));
161 HelpMenu.setText(MessageManager.getString("action.help"));
162 VamsasMenu.setText("Vamsas");
163 VamsasMenu.setToolTipText(MessageManager
164 .getString("label.share_data_vamsas_applications"));
165 VamsasStMenu.setText(MessageManager.getString("label.connect_to"));
166 VamsasStMenu.setToolTipText(
167 MessageManager.getString("label.join_existing_vamsas_session"));
168 inputLocalFileMenuItem
169 .setText(MessageManager.getString("label.load_tree_from_file"));
170 inputLocalFileMenuItem.setAccelerator(
171 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
172 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
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(true);
261 JMenuItem saveAsJaxb = new JMenuItem("Save Project as JAXB");
262 saveAsJaxb.addActionListener(new ActionListener()
265 public void actionPerformed(ActionEvent e)
267 saveState_actionPerformed(false);
270 loadState.setText(MessageManager.getString("action.load_project"));
271 loadState.addActionListener(new ActionListener()
274 public void actionPerformed(ActionEvent e)
276 loadState_actionPerformed(true);
279 JMenuItem loadAsJaxb = new JMenuItem("Load Project as JAXB");
280 loadAsJaxb.addActionListener(new ActionListener()
283 public void actionPerformed(ActionEvent e)
285 loadState_actionPerformed(false);
288 inputMenu.setText(MessageManager.getString("label.input_alignment"));
290 .setText(MessageManager.getString("label.new_vamsas_session"));
291 vamsasStart.setVisible(false);
292 vamsasStart.addActionListener(new ActionListener()
295 public void actionPerformed(ActionEvent e)
297 vamsasStart_actionPerformed(e);
300 vamsasImport.setText(
301 MessageManager.getString("action.load_vamsas_session"));
302 vamsasImport.setVisible(false);
303 vamsasImport.addActionListener(new ActionListener()
306 public void actionPerformed(ActionEvent e)
308 vamsasImport_actionPerformed(e);
312 MessageManager.getString("action.save_vamsas_session"));
313 vamsasSave.setVisible(false);
314 vamsasSave.addActionListener(new ActionListener()
317 public void actionPerformed(ActionEvent e)
319 vamsasSave_actionPerformed(e);
323 .setText(MessageManager.getString("action.fetch_sequences"));
324 inputSequence.addActionListener(new ActionListener()
327 public void actionPerformed(ActionEvent e)
329 inputSequence_actionPerformed(e);
333 .setText(MessageManager.getString("label.stop_vamsas_session"));
334 vamsasStop.setVisible(false);
335 vamsasStop.addActionListener(new ActionListener()
338 public void actionPerformed(ActionEvent e)
340 vamsasStop_actionPerformed(e);
343 closeAll.setText(MessageManager.getString("action.close_all"));
344 closeAll.addActionListener(new ActionListener()
347 public void actionPerformed(ActionEvent e)
349 closeAll_actionPerformed(e);
352 raiseRelated.setText(
353 MessageManager.getString("action.raise_associated_windows"));
354 raiseRelated.addActionListener(new ActionListener()
357 public void actionPerformed(ActionEvent e)
359 raiseRelated_actionPerformed(e);
362 minimizeAssociated.setText(
363 MessageManager.getString("action.minimize_associated_windows"));
364 minimizeAssociated.addActionListener(new ActionListener()
367 public void actionPerformed(ActionEvent e)
369 minimizeAssociated_actionPerformed(e);
373 .setText(MessageManager.getString("label.collect_garbage"));
374 garbageCollect.addActionListener(new ActionListener()
377 public void actionPerformed(ActionEvent e)
379 garbageCollect_actionPerformed(e);
383 .setText(MessageManager.getString("label.show_memory_usage"));
384 showMemusage.addActionListener(new ActionListener()
387 public void actionPerformed(ActionEvent e)
389 showMemusage_actionPerformed(e);
393 .setText(MessageManager.getString("label.show_java_console"));
394 showConsole.addActionListener(new ActionListener()
397 public void actionPerformed(ActionEvent e)
399 showConsole_actionPerformed(e);
402 showNews.setText(MessageManager.getString("label.show_jalview_news"));
403 showNews.addActionListener(new ActionListener()
406 public void actionPerformed(ActionEvent e)
408 showNews_actionPerformed(e);
411 groovyShell = new JMenuItem();
412 groovyShell.setText(MessageManager.getString("label.groovy_console"));
413 groovyShell.addActionListener(new ActionListener()
416 public void actionPerformed(ActionEvent e)
418 groovyShell_actionPerformed();
421 experimentalFeatures = new JCheckBoxMenuItem();
423 .setText(MessageManager.getString("label.show_experimental"));
424 experimentalFeatures.setToolTipText(
425 MessageManager.getString("label.show_experimental_tip"));
426 experimentalFeatures.addActionListener(new ActionListener()
429 public void actionPerformed(ActionEvent e)
431 showExperimental_actionPerformed(experimentalFeatures.isSelected());
435 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
436 snapShotWindow.addActionListener(new ActionListener()
439 public void actionPerformed(ActionEvent e)
441 snapShotWindow_actionPerformed(e);
445 desktopMenubar.add(FileMenu);
446 desktopMenubar.add(toolsMenu);
447 VamsasMenu.setVisible(false);
448 desktopMenubar.add(VamsasMenu);
449 desktopMenubar.add(HelpMenu);
450 desktopMenubar.add(windowMenu);
451 FileMenu.add(inputMenu);
452 FileMenu.add(inputSequence);
453 FileMenu.addSeparator();
454 FileMenu.add(saveAsJaxb);
455 FileMenu.add(loadAsJaxb);
456 if (!Platform.isJS())
458 FileMenu.add(saveState);
459 FileMenu.add(loadState);
461 FileMenu.addSeparator();
463 HelpMenu.add(aboutMenuItem);
464 HelpMenu.add(documentationMenuItem);
465 VamsasMenu.add(VamsasStMenu);
466 VamsasStMenu.setVisible(false);
467 VamsasMenu.add(vamsasStart);
468 VamsasMenu.add(vamsasImport);
469 VamsasMenu.add(vamsasSave);
470 VamsasMenu.add(vamsasStop);
471 toolsMenu.add(preferences);
472 if (!Platform.isJS())
474 toolsMenu.add(showMemusage);
475 toolsMenu.add(showConsole);
477 if (!Platform.isJS())
479 toolsMenu.add(showNews);
480 toolsMenu.add(garbageCollect);
481 toolsMenu.add(groovyShell);
483 toolsMenu.add(experimentalFeatures);
484 // toolsMenu.add(snapShotWindow);
485 inputMenu.add(inputLocalFileMenuItem);
486 inputMenu.add(inputURLMenuItem);
487 inputMenu.add(inputTextboxMenuItem);
488 windowMenu.add(closeAll);
489 windowMenu.add(raiseRelated);
490 windowMenu.add(minimizeAssociated);
491 windowMenu.addSeparator();
492 // inputMenu.add(vamsasLoad);
495 protected void showExperimental_actionPerformed(boolean selected)
499 protected void groovyShell_actionPerformed()
503 protected void snapShotWindow_actionPerformed(ActionEvent e)
505 // TODO Auto-generated method stub
509 protected void showConsole_actionPerformed(ActionEvent e)
511 // TODO Auto-generated method stub
515 protected void showNews_actionPerformed(ActionEvent e)
517 // TODO Auto-generated method stub
521 protected void showMemusage_actionPerformed(ActionEvent e)
523 // TODO Auto-generated method stub
527 protected void garbageCollect_actionPerformed(ActionEvent e)
529 // TODO Auto-generated method stub
533 protected void vamsasStMenu_actionPerformed()
537 public void vamsasSave_actionPerformed(ActionEvent e)
547 protected void inputLocalFileMenuItem_actionPerformed(
548 jalview.gui.AlignViewport av)
557 * @throws FileFormatException
559 protected void inputURLMenuItem_actionPerformed(
560 jalview.gui.AlignViewport av) throws FileFormatException
570 protected void inputTextboxMenuItem_actionPerformed(
571 AlignmentViewPanel avp)
578 protected void quit()
588 protected void aboutMenuItem_actionPerformed(ActionEvent e)
592 protected void documentationMenuItem_actionPerformed()
602 public void SaveState_actionPerformed(ActionEvent e)
612 protected void preferences_actionPerformed(ActionEvent e)
622 public void saveState_actionPerformed(boolean asCastor)
632 public void loadState_actionPerformed(boolean asCastor)
642 public void loadJalviewAlign_actionPerformed(ActionEvent e)
646 public void vamsasStart_actionPerformed(ActionEvent e)
651 public void inputSequence_actionPerformed(ActionEvent e)
656 public void vamsasStop_actionPerformed(ActionEvent e)
661 public void closeAll_actionPerformed(ActionEvent e)
666 public void raiseRelated_actionPerformed(ActionEvent e)
671 public void minimizeAssociated_actionPerformed(ActionEvent e)
676 public void vamsasImport_actionPerformed(ActionEvent e)