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 @SuppressWarnings("serial")
45 public class GDesktop extends JFrame
48 protected static JMenu windowMenu = new JMenu();
50 JMenuBar desktopMenubar = new JMenuBar();
52 JMenu FileMenu = new JMenu();
54 JMenu HelpMenu = new JMenu();
56 JMenuItem inputLocalFileMenuItem = new JMenuItem();
58 JMenuItem inputURLMenuItem = new JMenuItem();
60 JMenuItem inputTextboxMenuItem = new JMenuItem();
62 JMenuItem quit = new JMenuItem();
64 JMenuItem aboutMenuItem = new JMenuItem();
66 JMenuItem documentationMenuItem = new JMenuItem();
68 FlowLayout flowLayout1 = new FlowLayout();
70 protected JMenu toolsMenu = new JMenu();
72 JMenuItem preferences = new JMenuItem();
74 JMenuItem saveState = new JMenuItem();
76 JMenuItem saveAsState = new JMenuItem();
78 JMenuItem loadState = new JMenuItem();
80 JMenu inputMenu = new JMenu();
82 JMenuItem inputSequence = new JMenuItem();
84 JMenuItem closeAll = new JMenuItem();
86 JMenuItem raiseRelated = new JMenuItem();
88 JMenuItem minimizeAssociated = new JMenuItem();
90 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
92 JMenuItem garbageCollect = new JMenuItem();
94 protected JMenuItem groovyShell;
96 protected JCheckBoxMenuItem experimentalFeatures;
98 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
100 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
102 protected JMenuItem snapShotWindow = new JMenuItem();
105 * Creates a new GDesktop object.
113 this.setJMenuBar(desktopMenubar);
114 } catch (Exception e)
119 if (Platform.allowMnemonics())
121 //BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
122 // but here we want just not a Mac, period, right?
123 FileMenu.setMnemonic('F');
124 inputLocalFileMenuItem.setMnemonic('L');
125 inputURLMenuItem.setMnemonic('U');
126 inputTextboxMenuItem.setMnemonic('C');
127 quit.setMnemonic('Q');
128 saveState.setMnemonic('S');
129 loadState.setMnemonic('L');
130 inputMenu.setMnemonic('I');
140 private void jbInit() throws Exception
142 setName("jalview-desktop");
143 FileMenu.setText(MessageManager.getString("action.file"));
144 HelpMenu.setText(MessageManager.getString("action.help"));
145 inputLocalFileMenuItem
146 .setText(MessageManager.getString("label.load_tree_from_file"));
147 inputLocalFileMenuItem.setAccelerator(
148 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
149 jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(),
151 inputLocalFileMenuItem
152 .addActionListener(new java.awt.event.ActionListener()
155 public void actionPerformed(ActionEvent e)
157 inputLocalFileMenuItem_actionPerformed(null);
160 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
161 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
164 public void actionPerformed(ActionEvent e)
168 inputURLMenuItem_actionPerformed(null);
169 } catch (FileFormatException e1)
171 System.err.println("Error loading from URL: " + e1.getMessage());
176 .setText(MessageManager.getString("label.from_textbox"));
178 .addActionListener(new java.awt.event.ActionListener()
181 public void actionPerformed(ActionEvent e)
183 inputTextboxMenuItem_actionPerformed(null);
186 quit.setText(MessageManager.getString("action.quit"));
187 quit.addActionListener(new java.awt.event.ActionListener()
190 public void actionPerformed(ActionEvent e)
195 aboutMenuItem.setText(MessageManager.getString("label.about"));
196 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
199 public void actionPerformed(ActionEvent e)
201 aboutMenuItem_actionPerformed(e);
204 documentationMenuItem
205 .setText(MessageManager.getString("label.documentation"));
206 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
207 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
208 documentationMenuItem
209 .addActionListener(new java.awt.event.ActionListener()
212 public void actionPerformed(ActionEvent e)
214 documentationMenuItem_actionPerformed();
217 this.getContentPane().setLayout(flowLayout1);
218 windowMenu.setText(MessageManager.getString("label.window"));
219 preferences.setText(MessageManager.getString("label.preferences"));
220 preferences.addActionListener(new ActionListener()
223 public void actionPerformed(ActionEvent e)
225 preferences_actionPerformed(e);
228 toolsMenu.setText(MessageManager.getString("label.tools"));
229 saveState.setText(MessageManager.getString("action.save_project"));
230 saveState.addActionListener(new ActionListener()
233 public void actionPerformed(ActionEvent e)
235 saveState_actionPerformed();
238 saveAsState.setText(MessageManager.getString("action.save_project_as"));
239 saveAsState.addActionListener(new ActionListener()
242 public void actionPerformed(ActionEvent e)
244 saveAsState_actionPerformed(e);
247 loadState.setText(MessageManager.getString("action.load_project"));
248 loadState.addActionListener(new ActionListener()
251 public void actionPerformed(ActionEvent e)
253 loadState_actionPerformed();
256 inputMenu.setText(MessageManager.getString("label.input_alignment"));
258 .setText(MessageManager.getString("action.fetch_sequences"));
259 inputSequence.addActionListener(new ActionListener()
262 public void actionPerformed(ActionEvent e)
264 inputSequence_actionPerformed(e);
267 closeAll.setText(MessageManager.getString("action.close_all"));
268 closeAll.addActionListener(new ActionListener()
271 public void actionPerformed(ActionEvent e)
273 closeAll_actionPerformed(e);
276 raiseRelated.setText(
277 MessageManager.getString("action.raise_associated_windows"));
278 raiseRelated.addActionListener(new ActionListener()
281 public void actionPerformed(ActionEvent e)
283 raiseRelated_actionPerformed(e);
286 minimizeAssociated.setText(
287 MessageManager.getString("action.minimize_associated_windows"));
288 minimizeAssociated.addActionListener(new ActionListener()
291 public void actionPerformed(ActionEvent e)
293 minimizeAssociated_actionPerformed(e);
297 .setText(MessageManager.getString("label.collect_garbage"));
298 garbageCollect.addActionListener(new ActionListener()
301 public void actionPerformed(ActionEvent e)
303 garbageCollect_actionPerformed(e);
307 .setText(MessageManager.getString("label.show_memory_usage"));
308 showMemusage.addActionListener(new ActionListener()
311 public void actionPerformed(ActionEvent e)
313 showMemusage_actionPerformed(e);
317 .setText(MessageManager.getString("label.show_java_console"));
318 showConsole.addActionListener(new ActionListener()
321 public void actionPerformed(ActionEvent e)
323 showConsole_actionPerformed(e);
326 showNews.setText(MessageManager.getString("label.show_jalview_news"));
327 showNews.addActionListener(new ActionListener()
330 public void actionPerformed(ActionEvent e)
332 showNews_actionPerformed(e);
335 groovyShell = new JMenuItem();
336 groovyShell.setText(MessageManager.getString("label.groovy_console"));
337 groovyShell.addActionListener(new ActionListener()
340 public void actionPerformed(ActionEvent e)
342 groovyShell_actionPerformed();
345 experimentalFeatures = new JCheckBoxMenuItem();
347 .setText(MessageManager.getString("label.show_experimental"));
348 experimentalFeatures.setToolTipText(
349 MessageManager.getString("label.show_experimental_tip"));
350 experimentalFeatures.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
355 showExperimental_actionPerformed(experimentalFeatures.isSelected());
359 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
360 snapShotWindow.addActionListener(new ActionListener()
363 public void actionPerformed(ActionEvent e)
365 snapShotWindow_actionPerformed(e);
369 Float specversion = Platform.isJS() ? Float.valueOf(8)
371 System.getProperty("java.specification.version"));
373 desktopMenubar.add(FileMenu);
374 desktopMenubar.add(toolsMenu);
375 desktopMenubar.add(HelpMenu);
376 desktopMenubar.add(windowMenu);
377 FileMenu.add(inputMenu);
378 FileMenu.add(inputSequence);
379 FileMenu.addSeparator();
380 //FileMenu.add(saveState);
381 FileMenu.add(saveAsState);
382 FileMenu.add(loadState);
383 FileMenu.addSeparator();
385 HelpMenu.add(aboutMenuItem);
386 HelpMenu.add(documentationMenuItem);
387 if (!Platform.isAMacAndNotJS() || specversion < 11)
389 toolsMenu.add(preferences);
391 if (!Platform.isJS())
393 toolsMenu.add(showMemusage);
394 toolsMenu.add(showConsole);
395 toolsMenu.add(showNews);
396 toolsMenu.add(garbageCollect);
397 toolsMenu.add(groovyShell);
399 toolsMenu.add(experimentalFeatures);
400 // toolsMenu.add(snapShotWindow);
401 inputMenu.add(inputLocalFileMenuItem);
402 inputMenu.add(inputURLMenuItem);
403 inputMenu.add(inputTextboxMenuItem);
404 windowMenu.add(closeAll);
405 windowMenu.add(raiseRelated);
406 windowMenu.add(minimizeAssociated);
407 windowMenu.addSeparator();
408 // inputMenu.add(vamsasLoad);
411 protected void showExperimental_actionPerformed(boolean selected)
415 protected void groovyShell_actionPerformed()
419 protected void snapShotWindow_actionPerformed(ActionEvent e)
421 // TODO Auto-generated method stub
425 protected void showConsole_actionPerformed(ActionEvent e)
427 // TODO Auto-generated method stub
431 protected void showNews_actionPerformed(ActionEvent e)
433 // TODO Auto-generated method stub
437 protected void showMemusage_actionPerformed(ActionEvent e)
439 // TODO Auto-generated method stub
443 protected void garbageCollect_actionPerformed(ActionEvent e)
445 // TODO Auto-generated method stub
449 protected void vamsasStMenu_actionPerformed()
453 public void vamsasSave_actionPerformed(ActionEvent e)
463 protected void inputLocalFileMenuItem_actionPerformed(
464 jalview.gui.AlignViewport av)
473 * @throws FileFormatException
475 protected void inputURLMenuItem_actionPerformed(
476 jalview.gui.AlignViewport av) throws FileFormatException
486 protected void inputTextboxMenuItem_actionPerformed(
487 AlignmentViewPanel avp)
494 protected void quit()
496 //System.out.println("********** GDesktop.quit()");
505 protected void aboutMenuItem_actionPerformed(ActionEvent e)
509 protected void documentationMenuItem_actionPerformed()
519 protected void preferences_actionPerformed(ActionEvent e)
529 public void saveState_actionPerformed()
533 public void saveAsState_actionPerformed(ActionEvent e)
543 public void loadState_actionPerformed()
553 public void loadJalviewAlign_actionPerformed(ActionEvent e)
557 public void vamsasStart_actionPerformed(ActionEvent e)
562 public void inputSequence_actionPerformed(ActionEvent e)
567 public void vamsasStop_actionPerformed(ActionEvent e)
572 public void closeAll_actionPerformed(ActionEvent e)
577 public void raiseRelated_actionPerformed(ActionEvent e)
582 public void minimizeAssociated_actionPerformed(ActionEvent e)
587 public void vamsasImport_actionPerformed(ActionEvent e)