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 loadState = new JMenuItem();
81 JMenu inputMenu = new JMenu();
83 protected JMenuItem vamsasStart = new JMenuItem();
85 protected JMenuItem vamsasImport = new JMenuItem();
87 protected JMenuItem vamsasSave = new JMenuItem();
89 JMenuItem inputSequence = new JMenuItem();
91 protected JMenuItem vamsasStop = new JMenuItem();
93 JMenuItem closeAll = new JMenuItem();
95 JMenuItem raiseRelated = new JMenuItem();
97 JMenuItem minimizeAssociated = new JMenuItem();
99 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
101 JMenuItem garbageCollect = new JMenuItem();
103 protected JMenuItem groovyShell;
105 protected JCheckBoxMenuItem experimentalFeatures;
107 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
109 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
111 protected JMenuItem snapShotWindow = new JMenuItem();
114 * Creates a new GDesktop object.
121 this.setJMenuBar(desktopMenubar);
122 } catch (Exception e)
127 if (!Platform.isAMac())
129 FileMenu.setMnemonic('F');
130 inputLocalFileMenuItem.setMnemonic('L');
131 VamsasMenu.setMnemonic('V');
132 inputURLMenuItem.setMnemonic('U');
133 inputTextboxMenuItem.setMnemonic('C');
134 quit.setMnemonic('Q');
135 saveState.setMnemonic('S');
136 loadState.setMnemonic('L');
137 inputMenu.setMnemonic('I');
147 private void jbInit() throws Exception
150 FileMenu.setText(MessageManager.getString("action.file"));
151 HelpMenu.setText(MessageManager.getString("action.help"));
152 VamsasMenu.setText("Vamsas");
153 VamsasMenu.setToolTipText(MessageManager
154 .getString("label.share_data_vamsas_applications"));
155 VamsasStMenu.setText(MessageManager.getString("label.connect_to"));
156 VamsasStMenu.setToolTipText(
157 MessageManager.getString("label.join_existing_vamsas_session"));
158 inputLocalFileMenuItem
159 .setText(MessageManager.getString("label.load_tree_from_file"));
160 inputLocalFileMenuItem.setAccelerator(
161 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
162 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
164 inputLocalFileMenuItem
165 .addActionListener(new java.awt.event.ActionListener()
168 public void actionPerformed(ActionEvent e)
170 inputLocalFileMenuItem_actionPerformed(null);
173 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
174 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
177 public void actionPerformed(ActionEvent e)
181 inputURLMenuItem_actionPerformed(null);
182 } catch (FileFormatException e1)
184 System.err.println("Error loading from URL: " + e1.getMessage());
189 .setText(MessageManager.getString("label.from_textbox"));
191 .addActionListener(new java.awt.event.ActionListener()
194 public void actionPerformed(ActionEvent e)
196 inputTextboxMenuItem_actionPerformed(null);
199 quit.setText(MessageManager.getString("action.quit"));
200 quit.addActionListener(new java.awt.event.ActionListener()
203 public void actionPerformed(ActionEvent e)
208 aboutMenuItem.setText(MessageManager.getString("label.about"));
209 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
212 public void actionPerformed(ActionEvent e)
214 aboutMenuItem_actionPerformed(e);
217 documentationMenuItem
218 .setText(MessageManager.getString("label.documentation"));
219 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
220 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
221 documentationMenuItem
222 .addActionListener(new java.awt.event.ActionListener()
225 public void actionPerformed(ActionEvent e)
227 documentationMenuItem_actionPerformed(e);
230 this.getContentPane().setLayout(flowLayout1);
231 windowMenu.setText(MessageManager.getString("label.window"));
232 preferences.setText(MessageManager.getString("label.preferences"));
233 preferences.addActionListener(new ActionListener()
236 public void actionPerformed(ActionEvent e)
238 preferences_actionPerformed(e);
241 toolsMenu.setText(MessageManager.getString("label.tools"));
242 saveState.setText(MessageManager.getString("action.save_project"));
243 saveState.addActionListener(new ActionListener()
246 public void actionPerformed(ActionEvent e)
248 saveState_actionPerformed(e);
251 loadState.setText(MessageManager.getString("action.load_project"));
252 loadState.addActionListener(new ActionListener()
255 public void actionPerformed(ActionEvent e)
257 loadState_actionPerformed(e);
260 inputMenu.setText(MessageManager.getString("label.input_alignment"));
262 .setText(MessageManager.getString("label.new_vamsas_session"));
263 vamsasStart.setVisible(false);
264 vamsasStart.addActionListener(new ActionListener()
267 public void actionPerformed(ActionEvent e)
269 vamsasStart_actionPerformed(e);
272 vamsasImport.setText(
273 MessageManager.getString("action.load_vamsas_session"));
274 vamsasImport.setVisible(false);
275 vamsasImport.addActionListener(new ActionListener()
278 public void actionPerformed(ActionEvent e)
280 vamsasImport_actionPerformed(e);
284 MessageManager.getString("action.save_vamsas_session"));
285 vamsasSave.setVisible(false);
286 vamsasSave.addActionListener(new ActionListener()
289 public void actionPerformed(ActionEvent e)
291 vamsasSave_actionPerformed(e);
295 .setText(MessageManager.getString("action.fetch_sequences"));
296 inputSequence.addActionListener(new ActionListener()
299 public void actionPerformed(ActionEvent e)
301 inputSequence_actionPerformed(e);
305 .setText(MessageManager.getString("label.stop_vamsas_session"));
306 vamsasStop.setVisible(false);
307 vamsasStop.addActionListener(new ActionListener()
310 public void actionPerformed(ActionEvent e)
312 vamsasStop_actionPerformed(e);
315 closeAll.setText(MessageManager.getString("action.close_all"));
316 closeAll.addActionListener(new ActionListener()
319 public void actionPerformed(ActionEvent e)
321 closeAll_actionPerformed(e);
324 raiseRelated.setText(
325 MessageManager.getString("action.raise_associated_windows"));
326 raiseRelated.addActionListener(new ActionListener()
329 public void actionPerformed(ActionEvent e)
331 raiseRelated_actionPerformed(e);
334 minimizeAssociated.setText(
335 MessageManager.getString("action.minimize_associated_windows"));
336 minimizeAssociated.addActionListener(new ActionListener()
339 public void actionPerformed(ActionEvent e)
341 minimizeAssociated_actionPerformed(e);
345 .setText(MessageManager.getString("label.collect_garbage"));
346 garbageCollect.addActionListener(new ActionListener()
349 public void actionPerformed(ActionEvent e)
351 garbageCollect_actionPerformed(e);
355 .setText(MessageManager.getString("label.show_memory_usage"));
356 showMemusage.addActionListener(new ActionListener()
359 public void actionPerformed(ActionEvent e)
361 showMemusage_actionPerformed(e);
365 .setText(MessageManager.getString("label.show_java_console"));
366 showConsole.addActionListener(new ActionListener()
369 public void actionPerformed(ActionEvent e)
371 showConsole_actionPerformed(e);
374 showNews.setText(MessageManager.getString("label.show_jalview_news"));
375 showNews.addActionListener(new ActionListener()
378 public void actionPerformed(ActionEvent e)
380 showNews_actionPerformed(e);
383 groovyShell = new JMenuItem();
384 groovyShell.setText(MessageManager.getString("label.groovy_console"));
385 groovyShell.addActionListener(new ActionListener()
388 public void actionPerformed(ActionEvent e)
390 groovyShell_actionPerformed();
393 experimentalFeatures = new JCheckBoxMenuItem();
395 .setText(MessageManager.getString("label.show_experimental"));
396 experimentalFeatures.setToolTipText(
397 MessageManager.getString("label.show_experimental_tip"));
398 experimentalFeatures.addActionListener(new ActionListener()
401 public void actionPerformed(ActionEvent e)
403 showExperimental_actionPerformed(experimentalFeatures.isSelected());
407 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
408 snapShotWindow.addActionListener(new ActionListener()
411 public void actionPerformed(ActionEvent e)
413 snapShotWindow_actionPerformed(e);
417 desktopMenubar.add(FileMenu);
418 desktopMenubar.add(toolsMenu);
419 VamsasMenu.setVisible(false);
420 desktopMenubar.add(VamsasMenu);
421 desktopMenubar.add(HelpMenu);
422 desktopMenubar.add(windowMenu);
423 FileMenu.add(inputMenu);
424 FileMenu.add(inputSequence);
425 FileMenu.addSeparator();
426 FileMenu.add(saveState);
427 FileMenu.add(loadState);
428 FileMenu.addSeparator();
430 HelpMenu.add(aboutMenuItem);
431 HelpMenu.add(documentationMenuItem);
432 VamsasMenu.add(VamsasStMenu);
433 VamsasStMenu.setVisible(false);
434 VamsasMenu.add(vamsasStart);
435 VamsasMenu.add(vamsasImport);
436 VamsasMenu.add(vamsasSave);
437 VamsasMenu.add(vamsasStop);
438 toolsMenu.add(preferences);
439 toolsMenu.add(showMemusage);
440 toolsMenu.add(showConsole);
441 toolsMenu.add(showNews);
442 toolsMenu.add(garbageCollect);
443 toolsMenu.add(groovyShell);
444 toolsMenu.add(experimentalFeatures);
445 // toolsMenu.add(snapShotWindow);
446 inputMenu.add(inputLocalFileMenuItem);
447 inputMenu.add(inputURLMenuItem);
448 inputMenu.add(inputTextboxMenuItem);
449 windowMenu.add(closeAll);
450 windowMenu.add(raiseRelated);
451 windowMenu.add(minimizeAssociated);
452 windowMenu.addSeparator();
453 // inputMenu.add(vamsasLoad);
456 protected void showExperimental_actionPerformed(boolean selected)
460 protected void groovyShell_actionPerformed()
464 protected void snapShotWindow_actionPerformed(ActionEvent e)
466 // TODO Auto-generated method stub
470 protected void showConsole_actionPerformed(ActionEvent e)
472 // TODO Auto-generated method stub
476 protected void showNews_actionPerformed(ActionEvent e)
478 // TODO Auto-generated method stub
482 protected void showMemusage_actionPerformed(ActionEvent e)
484 // TODO Auto-generated method stub
488 protected void garbageCollect_actionPerformed(ActionEvent e)
490 // TODO Auto-generated method stub
494 protected void vamsasStMenu_actionPerformed()
498 public void vamsasSave_actionPerformed(ActionEvent e)
508 protected void inputLocalFileMenuItem_actionPerformed(
509 jalview.gui.AlignViewport av)
518 * @throws FileFormatException
520 protected void inputURLMenuItem_actionPerformed(
521 jalview.gui.AlignViewport av) throws FileFormatException
531 protected void inputTextboxMenuItem_actionPerformed(
532 AlignmentViewPanel avp)
539 protected void quit()
549 protected void aboutMenuItem_actionPerformed(ActionEvent e)
559 protected void documentationMenuItem_actionPerformed(ActionEvent e)
569 public void SaveState_actionPerformed(ActionEvent e)
579 protected void preferences_actionPerformed(ActionEvent e)
589 public void saveState_actionPerformed(ActionEvent e)
599 public void loadState_actionPerformed(ActionEvent e)
609 public void loadJalviewAlign_actionPerformed(ActionEvent e)
613 public void vamsasStart_actionPerformed(ActionEvent e)
618 public void inputSequence_actionPerformed(ActionEvent e)
623 public void vamsasStop_actionPerformed(ActionEvent e)
628 public void closeAll_actionPerformed(ActionEvent e)
633 public void raiseRelated_actionPerformed(ActionEvent e)
638 public void minimizeAssociated_actionPerformed(ActionEvent e)
643 public void vamsasImport_actionPerformed(ActionEvent e)