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(MessageManager
157 .getString("label.join_existing_vamsas_session"));
158 inputLocalFileMenuItem.setText(MessageManager
159 .getString("label.load_tree_from_file"));
160 inputLocalFileMenuItem.setAccelerator(javax.swing.KeyStroke
161 .getKeyStroke(java.awt.event.KeyEvent.VK_O, Toolkit
162 .getDefaultToolkit().getMenuShortcutKeyMask(), false));
163 inputLocalFileMenuItem
164 .addActionListener(new java.awt.event.ActionListener()
167 public void actionPerformed(ActionEvent e)
169 inputLocalFileMenuItem_actionPerformed(null);
172 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
173 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
176 public void actionPerformed(ActionEvent e)
180 inputURLMenuItem_actionPerformed(null);
181 } catch (FileFormatException e1)
183 System.err.println("Error loading from URL: " + e1.getMessage());
187 inputTextboxMenuItem.setText(MessageManager
188 .getString("label.from_textbox"));
190 .addActionListener(new java.awt.event.ActionListener()
193 public void actionPerformed(ActionEvent e)
195 inputTextboxMenuItem_actionPerformed(null);
198 quit.setText(MessageManager.getString("action.quit"));
199 quit.addActionListener(new java.awt.event.ActionListener()
202 public void actionPerformed(ActionEvent e)
207 aboutMenuItem.setText(MessageManager.getString("label.about"));
208 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
211 public void actionPerformed(ActionEvent e)
213 aboutMenuItem_actionPerformed(e);
216 documentationMenuItem.setText(MessageManager
217 .getString("label.documentation"));
218 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
219 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
220 documentationMenuItem
221 .addActionListener(new java.awt.event.ActionListener()
224 public void actionPerformed(ActionEvent e)
226 documentationMenuItem_actionPerformed(e);
229 this.getContentPane().setLayout(flowLayout1);
230 windowMenu.setText(MessageManager.getString("label.window"));
231 preferences.setText(MessageManager.getString("label.preferences"));
232 preferences.addActionListener(new ActionListener()
235 public void actionPerformed(ActionEvent e)
237 preferences_actionPerformed(e);
240 toolsMenu.setText(MessageManager.getString("label.tools"));
241 saveState.setText(MessageManager.getString("action.save_project"));
242 saveState.addActionListener(new ActionListener()
245 public void actionPerformed(ActionEvent e)
247 saveState_actionPerformed(e);
250 loadState.setText(MessageManager.getString("action.load_project"));
251 loadState.addActionListener(new ActionListener()
254 public void actionPerformed(ActionEvent e)
256 loadState_actionPerformed(e);
259 inputMenu.setText(MessageManager.getString("label.input_alignment"));
260 vamsasStart.setText(MessageManager
261 .getString("label.new_vamsas_session"));
262 vamsasStart.setVisible(false);
263 vamsasStart.addActionListener(new ActionListener()
266 public void actionPerformed(ActionEvent e)
268 vamsasStart_actionPerformed(e);
271 vamsasImport.setText(MessageManager
272 .getString("action.load_vamsas_session"));
273 vamsasImport.setVisible(false);
274 vamsasImport.addActionListener(new ActionListener()
277 public void actionPerformed(ActionEvent e)
279 vamsasImport_actionPerformed(e);
282 vamsasSave.setText(MessageManager
283 .getString("action.save_vamsas_session"));
284 vamsasSave.setVisible(false);
285 vamsasSave.addActionListener(new ActionListener()
288 public void actionPerformed(ActionEvent e)
290 vamsasSave_actionPerformed(e);
293 inputSequence.setText(MessageManager
294 .getString("action.fetch_sequences"));
295 inputSequence.addActionListener(new ActionListener()
298 public void actionPerformed(ActionEvent e)
300 inputSequence_actionPerformed(e);
303 vamsasStop.setText(MessageManager
304 .getString("label.stop_vamsas_session"));
305 vamsasStop.setVisible(false);
306 vamsasStop.addActionListener(new ActionListener()
309 public void actionPerformed(ActionEvent e)
311 vamsasStop_actionPerformed(e);
314 closeAll.setText(MessageManager.getString("action.close_all"));
315 closeAll.addActionListener(new ActionListener()
318 public void actionPerformed(ActionEvent e)
320 closeAll_actionPerformed(e);
323 raiseRelated.setText(MessageManager
324 .getString("action.raise_associated_windows"));
325 raiseRelated.addActionListener(new ActionListener()
328 public void actionPerformed(ActionEvent e)
330 raiseRelated_actionPerformed(e);
333 minimizeAssociated.setText(MessageManager
334 .getString("action.minimize_associated_windows"));
335 minimizeAssociated.addActionListener(new ActionListener()
338 public void actionPerformed(ActionEvent e)
340 minimizeAssociated_actionPerformed(e);
343 garbageCollect.setText(MessageManager
344 .getString("label.collect_garbage"));
345 garbageCollect.addActionListener(new ActionListener()
348 public void actionPerformed(ActionEvent e)
350 garbageCollect_actionPerformed(e);
353 showMemusage.setText(MessageManager
354 .getString("label.show_memory_usage"));
355 showMemusage.addActionListener(new ActionListener()
358 public void actionPerformed(ActionEvent e)
360 showMemusage_actionPerformed(e);
364 .setText(MessageManager.getString("label.show_java_console"));
365 showConsole.addActionListener(new ActionListener()
368 public void actionPerformed(ActionEvent e)
370 showConsole_actionPerformed(e);
373 showNews.setText(MessageManager.getString("label.show_jalview_news"));
374 showNews.addActionListener(new ActionListener()
377 public void actionPerformed(ActionEvent e)
379 showNews_actionPerformed(e);
382 groovyShell = new JMenuItem();
383 groovyShell.setText(MessageManager.getString("label.groovy_console"));
384 groovyShell.addActionListener(new ActionListener()
387 public void actionPerformed(ActionEvent e)
389 groovyShell_actionPerformed();
392 experimentalFeatures = new JCheckBoxMenuItem();
393 experimentalFeatures.setText(MessageManager
394 .getString("label.show_experimental"));
395 experimentalFeatures.setToolTipText(MessageManager
396 .getString("label.show_experimental_tip"));
397 experimentalFeatures.addActionListener(new ActionListener()
400 public void actionPerformed(ActionEvent e)
402 showExperimental_actionPerformed(experimentalFeatures.isSelected());
406 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
407 snapShotWindow.addActionListener(new ActionListener()
410 public void actionPerformed(ActionEvent e)
412 snapShotWindow_actionPerformed(e);
416 desktopMenubar.add(FileMenu);
417 desktopMenubar.add(toolsMenu);
418 VamsasMenu.setVisible(false);
419 desktopMenubar.add(VamsasMenu);
420 desktopMenubar.add(HelpMenu);
421 desktopMenubar.add(windowMenu);
422 FileMenu.add(inputMenu);
423 FileMenu.add(inputSequence);
424 FileMenu.addSeparator();
425 FileMenu.add(saveState);
426 FileMenu.add(loadState);
427 FileMenu.addSeparator();
429 HelpMenu.add(aboutMenuItem);
430 HelpMenu.add(documentationMenuItem);
431 VamsasMenu.add(VamsasStMenu);
432 VamsasStMenu.setVisible(false);
433 VamsasMenu.add(vamsasStart);
434 VamsasMenu.add(vamsasImport);
435 VamsasMenu.add(vamsasSave);
436 VamsasMenu.add(vamsasStop);
437 toolsMenu.add(preferences);
438 toolsMenu.add(showMemusage);
439 toolsMenu.add(showConsole);
440 toolsMenu.add(showNews);
441 toolsMenu.add(garbageCollect);
442 toolsMenu.add(groovyShell);
443 toolsMenu.add(experimentalFeatures);
444 // toolsMenu.add(snapShotWindow);
445 inputMenu.add(inputLocalFileMenuItem);
446 inputMenu.add(inputURLMenuItem);
447 inputMenu.add(inputTextboxMenuItem);
448 windowMenu.add(closeAll);
449 windowMenu.add(raiseRelated);
450 windowMenu.add(minimizeAssociated);
451 windowMenu.addSeparator();
452 // inputMenu.add(vamsasLoad);
455 protected void showExperimental_actionPerformed(boolean selected)
459 protected void groovyShell_actionPerformed()
463 protected void snapShotWindow_actionPerformed(ActionEvent e)
465 // TODO Auto-generated method stub
469 protected void showConsole_actionPerformed(ActionEvent e)
471 // TODO Auto-generated method stub
475 protected void showNews_actionPerformed(ActionEvent e)
477 // TODO Auto-generated method stub
481 protected void showMemusage_actionPerformed(ActionEvent e)
483 // TODO Auto-generated method stub
487 protected void garbageCollect_actionPerformed(ActionEvent e)
489 // TODO Auto-generated method stub
493 protected void vamsasStMenu_actionPerformed()
497 public void vamsasSave_actionPerformed(ActionEvent e)
507 protected void inputLocalFileMenuItem_actionPerformed(
508 jalview.gui.AlignViewport av)
517 * @throws FileFormatException
519 protected void inputURLMenuItem_actionPerformed(
520 jalview.gui.AlignViewport av) throws FileFormatException
530 protected void inputTextboxMenuItem_actionPerformed(AlignmentViewPanel avp)
537 protected void quit()
547 protected void aboutMenuItem_actionPerformed(ActionEvent e)
557 protected void documentationMenuItem_actionPerformed(ActionEvent e)
567 public void SaveState_actionPerformed(ActionEvent e)
577 protected void preferences_actionPerformed(ActionEvent e)
587 public void saveState_actionPerformed(ActionEvent e)
597 public void loadState_actionPerformed(ActionEvent e)
607 public void loadJalviewAlign_actionPerformed(ActionEvent e)
611 public void vamsasStart_actionPerformed(ActionEvent e)
616 public void inputSequence_actionPerformed(ActionEvent e)
621 public void vamsasStop_actionPerformed(ActionEvent e)
626 public void closeAll_actionPerformed(ActionEvent e)
631 public void raiseRelated_actionPerformed(ActionEvent e)
636 public void minimizeAssociated_actionPerformed(ActionEvent e)
641 public void vamsasImport_actionPerformed(ActionEvent e)