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
47 protected static JMenu windowMenu = new JMenu();
49 JMenuBar desktopMenubar = new JMenuBar();
51 JMenu FileMenu = new JMenu();
53 JMenu HelpMenu = new JMenu();
55 protected JMenu VamsasMenu = new JMenu();
57 protected JMenu VamsasStMenu = new JMenu();
59 JMenuItem inputLocalFileMenuItem = new JMenuItem();
61 JMenuItem inputURLMenuItem = new JMenuItem();
63 JMenuItem inputTextboxMenuItem = new JMenuItem();
65 JMenuItem quit = new JMenuItem();
67 JMenuItem aboutMenuItem = new JMenuItem();
69 JMenuItem documentationMenuItem = new JMenuItem();
71 FlowLayout flowLayout1 = new FlowLayout();
73 protected JMenu toolsMenu = new JMenu();
75 JMenuItem preferences = new JMenuItem();
77 JMenuItem saveState = new JMenuItem();
79 JMenuItem saveAsState = new JMenuItem();
81 JMenuItem loadState = new JMenuItem();
83 JMenu inputMenu = new JMenu();
85 protected JMenuItem vamsasStart = new JMenuItem();
87 protected JMenuItem vamsasImport = new JMenuItem();
89 protected JMenuItem vamsasSave = new JMenuItem();
91 JMenuItem inputSequence = new JMenuItem();
93 protected JMenuItem vamsasStop = new JMenuItem();
95 JMenuItem closeAll = new JMenuItem();
97 JMenuItem raiseRelated = new JMenuItem();
99 JMenuItem minimizeAssociated = new JMenuItem();
101 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
103 JMenuItem garbageCollect = new JMenuItem();
105 protected JMenuItem groovyShell;
107 protected JCheckBoxMenuItem experimentalFeatures;
109 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
111 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
113 protected JMenuItem snapShotWindow = new JMenuItem();
116 * Creates a new GDesktop object.
123 this.setJMenuBar(desktopMenubar);
124 } catch (Exception e)
129 if (!Platform.isAMac())
131 FileMenu.setMnemonic('F');
132 inputLocalFileMenuItem.setMnemonic('L');
133 VamsasMenu.setMnemonic('V');
134 inputURLMenuItem.setMnemonic('U');
135 inputTextboxMenuItem.setMnemonic('C');
136 quit.setMnemonic('Q');
137 saveState.setMnemonic('S');
138 loadState.setMnemonic('L');
139 inputMenu.setMnemonic('I');
149 private void jbInit() throws Exception
152 FileMenu.setText(MessageManager.getString("action.file"));
153 HelpMenu.setText(MessageManager.getString("action.help"));
154 VamsasMenu.setText("Vamsas");
155 VamsasMenu.setToolTipText(MessageManager
156 .getString("label.share_data_vamsas_applications"));
157 VamsasStMenu.setText(MessageManager.getString("label.connect_to"));
158 VamsasStMenu.setToolTipText(
159 MessageManager.getString("label.join_existing_vamsas_session"));
160 inputLocalFileMenuItem
161 .setText(MessageManager.getString("label.load_tree_from_file"));
162 inputLocalFileMenuItem.setAccelerator(
163 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
164 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
166 inputLocalFileMenuItem
167 .addActionListener(new java.awt.event.ActionListener()
170 public void actionPerformed(ActionEvent e)
172 inputLocalFileMenuItem_actionPerformed(null);
175 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
176 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
179 public void actionPerformed(ActionEvent e)
183 inputURLMenuItem_actionPerformed(null);
184 } catch (FileFormatException e1)
186 System.err.println("Error loading from URL: " + e1.getMessage());
191 .setText(MessageManager.getString("label.from_textbox"));
193 .addActionListener(new java.awt.event.ActionListener()
196 public void actionPerformed(ActionEvent e)
198 inputTextboxMenuItem_actionPerformed(null);
201 quit.setText(MessageManager.getString("action.quit"));
202 quit.addActionListener(new java.awt.event.ActionListener()
205 public void actionPerformed(ActionEvent e)
210 aboutMenuItem.setText(MessageManager.getString("label.about"));
211 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
214 public void actionPerformed(ActionEvent e)
216 aboutMenuItem_actionPerformed(e);
219 documentationMenuItem
220 .setText(MessageManager.getString("label.documentation"));
221 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
222 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
223 documentationMenuItem
224 .addActionListener(new java.awt.event.ActionListener()
227 public void actionPerformed(ActionEvent e)
229 documentationMenuItem_actionPerformed(e);
232 this.getContentPane().setLayout(flowLayout1);
233 windowMenu.setText(MessageManager.getString("label.window"));
234 preferences.setText(MessageManager.getString("label.preferences"));
235 preferences.addActionListener(new ActionListener()
238 public void actionPerformed(ActionEvent e)
240 preferences_actionPerformed(e);
243 toolsMenu.setText(MessageManager.getString("label.tools"));
244 saveState.setText(MessageManager.getString("action.save_project"));
245 saveState.addActionListener(new ActionListener()
248 public void actionPerformed(ActionEvent e)
250 saveState_actionPerformed();
253 saveAsState.setText(MessageManager.getString("action.save_project_as"));
254 saveAsState.addActionListener(new ActionListener()
257 public void actionPerformed(ActionEvent e)
259 saveAsState_actionPerformed(e);
262 loadState.setText(MessageManager.getString("action.load_project"));
263 loadState.addActionListener(new ActionListener()
266 public void actionPerformed(ActionEvent e)
268 loadState_actionPerformed();
271 inputMenu.setText(MessageManager.getString("label.input_alignment"));
273 .setText(MessageManager.getString("label.new_vamsas_session"));
274 vamsasStart.setVisible(false);
275 vamsasStart.addActionListener(new ActionListener()
278 public void actionPerformed(ActionEvent e)
280 vamsasStart_actionPerformed(e);
283 vamsasImport.setText(
284 MessageManager.getString("action.load_vamsas_session"));
285 vamsasImport.setVisible(false);
286 vamsasImport.addActionListener(new ActionListener()
289 public void actionPerformed(ActionEvent e)
291 vamsasImport_actionPerformed(e);
295 MessageManager.getString("action.save_vamsas_session"));
296 vamsasSave.setVisible(false);
297 vamsasSave.addActionListener(new ActionListener()
300 public void actionPerformed(ActionEvent e)
302 vamsasSave_actionPerformed(e);
306 .setText(MessageManager.getString("action.fetch_sequences"));
307 inputSequence.addActionListener(new ActionListener()
310 public void actionPerformed(ActionEvent e)
312 inputSequence_actionPerformed(e);
316 .setText(MessageManager.getString("label.stop_vamsas_session"));
317 vamsasStop.setVisible(false);
318 vamsasStop.addActionListener(new ActionListener()
321 public void actionPerformed(ActionEvent e)
323 vamsasStop_actionPerformed(e);
326 closeAll.setText(MessageManager.getString("action.close_all"));
327 closeAll.addActionListener(new ActionListener()
330 public void actionPerformed(ActionEvent e)
332 closeAll_actionPerformed(e);
335 raiseRelated.setText(
336 MessageManager.getString("action.raise_associated_windows"));
337 raiseRelated.addActionListener(new ActionListener()
340 public void actionPerformed(ActionEvent e)
342 raiseRelated_actionPerformed(e);
345 minimizeAssociated.setText(
346 MessageManager.getString("action.minimize_associated_windows"));
347 minimizeAssociated.addActionListener(new ActionListener()
350 public void actionPerformed(ActionEvent e)
352 minimizeAssociated_actionPerformed(e);
356 .setText(MessageManager.getString("label.collect_garbage"));
357 garbageCollect.addActionListener(new ActionListener()
360 public void actionPerformed(ActionEvent e)
362 garbageCollect_actionPerformed(e);
366 .setText(MessageManager.getString("label.show_memory_usage"));
367 showMemusage.addActionListener(new ActionListener()
370 public void actionPerformed(ActionEvent e)
372 showMemusage_actionPerformed(e);
376 .setText(MessageManager.getString("label.show_java_console"));
377 showConsole.addActionListener(new ActionListener()
380 public void actionPerformed(ActionEvent e)
382 showConsole_actionPerformed(e);
385 showNews.setText(MessageManager.getString("label.show_jalview_news"));
386 showNews.addActionListener(new ActionListener()
389 public void actionPerformed(ActionEvent e)
391 showNews_actionPerformed(e);
394 groovyShell = new JMenuItem();
395 groovyShell.setText(MessageManager.getString("label.groovy_console"));
396 groovyShell.addActionListener(new ActionListener()
399 public void actionPerformed(ActionEvent e)
401 groovyShell_actionPerformed();
404 experimentalFeatures = new JCheckBoxMenuItem();
406 .setText(MessageManager.getString("label.show_experimental"));
407 experimentalFeatures.setToolTipText(
408 MessageManager.getString("label.show_experimental_tip"));
409 experimentalFeatures.addActionListener(new ActionListener()
412 public void actionPerformed(ActionEvent e)
414 showExperimental_actionPerformed(experimentalFeatures.isSelected());
418 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
419 snapShotWindow.addActionListener(new ActionListener()
422 public void actionPerformed(ActionEvent e)
424 snapShotWindow_actionPerformed(e);
428 desktopMenubar.add(FileMenu);
429 desktopMenubar.add(toolsMenu);
430 VamsasMenu.setVisible(false);
431 desktopMenubar.add(VamsasMenu);
432 desktopMenubar.add(HelpMenu);
433 desktopMenubar.add(windowMenu);
434 FileMenu.add(inputMenu);
435 FileMenu.add(inputSequence);
436 FileMenu.addSeparator();
437 FileMenu.add(saveState);
438 FileMenu.add(saveAsState);
439 FileMenu.add(loadState);
440 FileMenu.addSeparator();
442 HelpMenu.add(aboutMenuItem);
443 HelpMenu.add(documentationMenuItem);
444 VamsasMenu.add(VamsasStMenu);
445 VamsasStMenu.setVisible(false);
446 VamsasMenu.add(vamsasStart);
447 VamsasMenu.add(vamsasImport);
448 VamsasMenu.add(vamsasSave);
449 VamsasMenu.add(vamsasStop);
450 toolsMenu.add(preferences);
451 toolsMenu.add(showMemusage);
452 toolsMenu.add(showConsole);
453 toolsMenu.add(showNews);
454 toolsMenu.add(garbageCollect);
455 toolsMenu.add(groovyShell);
456 toolsMenu.add(experimentalFeatures);
457 // toolsMenu.add(snapShotWindow);
458 inputMenu.add(inputLocalFileMenuItem);
459 inputMenu.add(inputURLMenuItem);
460 inputMenu.add(inputTextboxMenuItem);
461 windowMenu.add(closeAll);
462 windowMenu.add(raiseRelated);
463 windowMenu.add(minimizeAssociated);
464 windowMenu.addSeparator();
465 // inputMenu.add(vamsasLoad);
468 protected void showExperimental_actionPerformed(boolean selected)
472 protected void groovyShell_actionPerformed()
476 protected void snapShotWindow_actionPerformed(ActionEvent e)
478 // TODO Auto-generated method stub
482 protected void showConsole_actionPerformed(ActionEvent e)
484 // TODO Auto-generated method stub
488 protected void showNews_actionPerformed(ActionEvent e)
490 // TODO Auto-generated method stub
494 protected void showMemusage_actionPerformed(ActionEvent e)
496 // TODO Auto-generated method stub
500 protected void garbageCollect_actionPerformed(ActionEvent e)
502 // TODO Auto-generated method stub
506 protected void vamsasStMenu_actionPerformed()
510 public void vamsasSave_actionPerformed(ActionEvent e)
520 protected void inputLocalFileMenuItem_actionPerformed(
521 jalview.gui.AlignViewport av)
530 * @throws FileFormatException
532 protected void inputURLMenuItem_actionPerformed(
533 jalview.gui.AlignViewport av) throws FileFormatException
543 protected void inputTextboxMenuItem_actionPerformed(
544 AlignmentViewPanel avp)
551 protected void quit()
561 protected void aboutMenuItem_actionPerformed(ActionEvent e)
571 protected void documentationMenuItem_actionPerformed(ActionEvent e)
581 protected void preferences_actionPerformed(ActionEvent e)
591 public void saveState_actionPerformed()
595 public void saveAsState_actionPerformed(ActionEvent e)
605 public void loadState_actionPerformed()
615 public void loadJalviewAlign_actionPerformed(ActionEvent e)
619 public void vamsasStart_actionPerformed(ActionEvent e)
624 public void inputSequence_actionPerformed(ActionEvent e)
629 public void vamsasStop_actionPerformed(ActionEvent e)
634 public void closeAll_actionPerformed(ActionEvent e)
639 public void raiseRelated_actionPerformed(ActionEvent e)
644 public void minimizeAssociated_actionPerformed(ActionEvent e)
649 public void vamsasImport_actionPerformed(ActionEvent e)