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.event.ActionEvent;
30 import java.awt.event.ActionListener;
32 import javax.swing.JCheckBoxMenuItem;
33 import javax.swing.JFrame;
34 import javax.swing.JMenu;
35 import javax.swing.JMenuBar;
36 import javax.swing.JMenuItem;
44 public class GDesktop extends JFrame
46 protected static JMenu windowMenu = new JMenu();
48 JMenuBar desktopMenubar = new JMenuBar();
50 JMenu FileMenu = new JMenu();
52 JMenu HelpMenu = new JMenu();
54 JMenuItem inputLocalFileMenuItem = new JMenuItem();
56 JMenuItem inputURLMenuItem = new JMenuItem();
58 JMenuItem inputTextboxMenuItem = new JMenuItem();
60 JMenuItem quit = new JMenuItem();
62 JMenuItem aboutMenuItem = new JMenuItem();
64 JMenuItem documentationMenuItem = new JMenuItem();
66 FlowLayout flowLayout1 = new FlowLayout();
68 protected JMenu toolsMenu = new JMenu();
70 JMenuItem preferences = new JMenuItem();
72 JMenuItem saveState = new JMenuItem();
74 JMenuItem saveAsState = new JMenuItem();
76 JMenuItem loadState = new JMenuItem();
78 JMenu inputMenu = new JMenu();
80 JMenuItem inputSequence = new JMenuItem();
82 JMenuItem closeAll = new JMenuItem();
84 JMenuItem raiseRelated = new JMenuItem();
86 JMenuItem minimizeAssociated = new JMenuItem();
88 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
90 JMenuItem garbageCollect = new JMenuItem();
92 protected JMenuItem groovyShell;
94 protected JCheckBoxMenuItem experimentalFeatures;
96 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
98 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
100 protected JMenuItem snapShotWindow = new JMenuItem();
103 * Creates a new GDesktop object.
110 this.setJMenuBar(desktopMenubar);
111 } catch (Exception e)
116 if (!Platform.isAMac())
118 FileMenu.setMnemonic('F');
119 inputLocalFileMenuItem.setMnemonic('L');
120 inputURLMenuItem.setMnemonic('U');
121 inputTextboxMenuItem.setMnemonic('C');
122 quit.setMnemonic('Q');
123 saveState.setMnemonic('S');
124 loadState.setMnemonic('L');
125 inputMenu.setMnemonic('I');
135 private void jbInit() throws Exception
138 FileMenu.setText(MessageManager.getString("action.file"));
139 HelpMenu.setText(MessageManager.getString("action.help"));
140 inputLocalFileMenuItem
141 .setText(MessageManager.getString("label.load_tree_from_file"));
142 inputLocalFileMenuItem.setAccelerator(
143 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
144 jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(),
146 inputLocalFileMenuItem
147 .addActionListener(new java.awt.event.ActionListener()
150 public void actionPerformed(ActionEvent e)
152 inputLocalFileMenuItem_actionPerformed(null);
155 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
156 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
159 public void actionPerformed(ActionEvent e)
163 inputURLMenuItem_actionPerformed(null);
164 } catch (FileFormatException e1)
166 System.err.println("Error loading from URL: " + e1.getMessage());
171 .setText(MessageManager.getString("label.from_textbox"));
173 .addActionListener(new java.awt.event.ActionListener()
176 public void actionPerformed(ActionEvent e)
178 inputTextboxMenuItem_actionPerformed(null);
181 quit.setText(MessageManager.getString("action.quit"));
182 quit.addActionListener(new java.awt.event.ActionListener()
185 public void actionPerformed(ActionEvent e)
190 aboutMenuItem.setText(MessageManager.getString("label.about"));
191 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
194 public void actionPerformed(ActionEvent e)
196 aboutMenuItem_actionPerformed(e);
199 documentationMenuItem
200 .setText(MessageManager.getString("label.documentation"));
201 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
202 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
203 documentationMenuItem
204 .addActionListener(new java.awt.event.ActionListener()
207 public void actionPerformed(ActionEvent e)
209 documentationMenuItem_actionPerformed(e);
212 this.getContentPane().setLayout(flowLayout1);
213 windowMenu.setText(MessageManager.getString("label.window"));
214 preferences.setText(MessageManager.getString("label.preferences"));
215 preferences.addActionListener(new ActionListener()
218 public void actionPerformed(ActionEvent e)
220 preferences_actionPerformed(e);
223 toolsMenu.setText(MessageManager.getString("label.tools"));
224 saveState.setText(MessageManager.getString("action.save_project"));
225 saveState.addActionListener(new ActionListener()
228 public void actionPerformed(ActionEvent e)
230 saveState_actionPerformed();
233 saveAsState.setText(MessageManager.getString("action.save_project_as"));
234 saveAsState.addActionListener(new ActionListener()
237 public void actionPerformed(ActionEvent e)
239 saveAsState_actionPerformed(e);
242 loadState.setText(MessageManager.getString("action.load_project"));
243 loadState.addActionListener(new ActionListener()
246 public void actionPerformed(ActionEvent e)
248 loadState_actionPerformed();
251 inputMenu.setText(MessageManager.getString("label.input_alignment"));
253 .setText(MessageManager.getString("action.fetch_sequences"));
254 inputSequence.addActionListener(new ActionListener()
257 public void actionPerformed(ActionEvent e)
259 inputSequence_actionPerformed(e);
262 closeAll.setText(MessageManager.getString("action.close_all"));
263 closeAll.addActionListener(new ActionListener()
266 public void actionPerformed(ActionEvent e)
268 closeAll_actionPerformed(e);
271 raiseRelated.setText(
272 MessageManager.getString("action.raise_associated_windows"));
273 raiseRelated.addActionListener(new ActionListener()
276 public void actionPerformed(ActionEvent e)
278 raiseRelated_actionPerformed(e);
281 minimizeAssociated.setText(
282 MessageManager.getString("action.minimize_associated_windows"));
283 minimizeAssociated.addActionListener(new ActionListener()
286 public void actionPerformed(ActionEvent e)
288 minimizeAssociated_actionPerformed(e);
292 .setText(MessageManager.getString("label.collect_garbage"));
293 garbageCollect.addActionListener(new ActionListener()
296 public void actionPerformed(ActionEvent e)
298 garbageCollect_actionPerformed(e);
302 .setText(MessageManager.getString("label.show_memory_usage"));
303 showMemusage.addActionListener(new ActionListener()
306 public void actionPerformed(ActionEvent e)
308 showMemusage_actionPerformed(e);
312 .setText(MessageManager.getString("label.show_java_console"));
313 showConsole.addActionListener(new ActionListener()
316 public void actionPerformed(ActionEvent e)
318 showConsole_actionPerformed(e);
321 showNews.setText(MessageManager.getString("label.show_jalview_news"));
322 showNews.addActionListener(new ActionListener()
325 public void actionPerformed(ActionEvent e)
327 showNews_actionPerformed(e);
330 groovyShell = new JMenuItem();
331 groovyShell.setText(MessageManager.getString("label.groovy_console"));
332 groovyShell.addActionListener(new ActionListener()
335 public void actionPerformed(ActionEvent e)
337 groovyShell_actionPerformed();
340 experimentalFeatures = new JCheckBoxMenuItem();
342 .setText(MessageManager.getString("label.show_experimental"));
343 experimentalFeatures.setToolTipText(
344 MessageManager.getString("label.show_experimental_tip"));
345 experimentalFeatures.addActionListener(new ActionListener()
348 public void actionPerformed(ActionEvent e)
350 showExperimental_actionPerformed(experimentalFeatures.isSelected());
354 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
355 snapShotWindow.addActionListener(new ActionListener()
358 public void actionPerformed(ActionEvent e)
360 snapShotWindow_actionPerformed(e);
368 .parseFloat(System.getProperty("java.specification.version"));
369 } catch (Exception e)
374 desktopMenubar.add(FileMenu);
375 desktopMenubar.add(toolsMenu);
376 desktopMenubar.add(HelpMenu);
377 desktopMenubar.add(windowMenu);
378 FileMenu.add(inputMenu);
379 FileMenu.add(inputSequence);
380 FileMenu.addSeparator();
381 //FileMenu.add(saveState);
382 FileMenu.add(saveAsState);
383 FileMenu.add(loadState);
384 FileMenu.addSeparator();
386 HelpMenu.add(aboutMenuItem);
387 HelpMenu.add(documentationMenuItem);
388 if (!Platform.isAMac() || specversion < 11)
390 toolsMenu.add(preferences);
392 toolsMenu.add(showMemusage);
393 toolsMenu.add(showConsole);
394 toolsMenu.add(showNews);
395 toolsMenu.add(garbageCollect);
396 toolsMenu.add(groovyShell);
397 toolsMenu.add(experimentalFeatures);
398 // toolsMenu.add(snapShotWindow);
399 inputMenu.add(inputLocalFileMenuItem);
400 inputMenu.add(inputURLMenuItem);
401 inputMenu.add(inputTextboxMenuItem);
402 windowMenu.add(closeAll);
403 windowMenu.add(raiseRelated);
404 windowMenu.add(minimizeAssociated);
405 windowMenu.addSeparator();
406 // inputMenu.add(vamsasLoad);
409 protected void showExperimental_actionPerformed(boolean selected)
413 protected void groovyShell_actionPerformed()
417 protected void snapShotWindow_actionPerformed(ActionEvent e)
419 // TODO Auto-generated method stub
423 protected void showConsole_actionPerformed(ActionEvent e)
425 // TODO Auto-generated method stub
429 protected void showNews_actionPerformed(ActionEvent e)
431 // TODO Auto-generated method stub
435 protected void showMemusage_actionPerformed(ActionEvent e)
437 // TODO Auto-generated method stub
441 protected void garbageCollect_actionPerformed(ActionEvent e)
443 // TODO Auto-generated method stub
447 protected void vamsasStMenu_actionPerformed()
451 public void vamsasSave_actionPerformed(ActionEvent e)
461 protected void inputLocalFileMenuItem_actionPerformed(
462 jalview.gui.AlignViewport av)
471 * @throws FileFormatException
473 protected void inputURLMenuItem_actionPerformed(
474 jalview.gui.AlignViewport av) throws FileFormatException
484 protected void inputTextboxMenuItem_actionPerformed(
485 AlignmentViewPanel avp)
492 protected void quit()
494 //System.out.println("********** GDesktop.quit()");
503 protected void aboutMenuItem_actionPerformed(ActionEvent e)
513 protected void documentationMenuItem_actionPerformed(ActionEvent e)
523 protected void preferences_actionPerformed(ActionEvent e)
533 public void saveState_actionPerformed()
537 public void saveAsState_actionPerformed(ActionEvent e)
547 public void loadState_actionPerformed()
557 public void loadJalviewAlign_actionPerformed(ActionEvent e)
561 public void vamsasStart_actionPerformed(ActionEvent e)
566 public void inputSequence_actionPerformed(ActionEvent e)
571 public void vamsasStop_actionPerformed(ActionEvent e)
576 public void closeAll_actionPerformed(ActionEvent e)
581 public void raiseRelated_actionPerformed(ActionEvent e)
586 public void minimizeAssociated_actionPerformed(ActionEvent e)
591 public void vamsasImport_actionPerformed(ActionEvent e)