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
48 public static javax.swing.JTabbedPane createTabbedPane()
50 // now just always return JTabbedPane
51 return new javax.swing.JTabbedPane();
52 // // BH 2018 coercing jalview.jbgui.swing.JTabbedPane() for now
53 // if (/** @j2sNative false && */
57 // return new javax.swing.JTabbedPane();
60 // return (javax.swing.JTabbedPane) (Object) new jalview.jbgui.swing.JTabbedPane();
64 protected static JMenu windowMenu = new JMenu();
66 JMenuBar desktopMenubar = new JMenuBar();
68 JMenu FileMenu = new JMenu();
70 JMenu HelpMenu = new JMenu();
72 protected JMenu VamsasMenu = new JMenu();
74 protected JMenu VamsasStMenu = new JMenu();
76 JMenuItem inputLocalFileMenuItem = new JMenuItem();
78 JMenuItem inputURLMenuItem = new JMenuItem();
80 JMenuItem inputTextboxMenuItem = new JMenuItem();
82 JMenuItem quit = new JMenuItem();
84 JMenuItem aboutMenuItem = new JMenuItem();
86 JMenuItem documentationMenuItem = new JMenuItem();
88 FlowLayout flowLayout1 = new FlowLayout();
90 protected JMenu toolsMenu = new JMenu();
92 JMenuItem preferences = new JMenuItem();
94 JMenuItem saveState = new JMenuItem();
96 JMenuItem loadState = new JMenuItem();
98 JMenu inputMenu = new JMenu();
100 protected JMenuItem vamsasStart = new JMenuItem();
102 protected JMenuItem vamsasImport = new JMenuItem();
104 protected JMenuItem vamsasSave = new JMenuItem();
106 JMenuItem inputSequence = new JMenuItem();
108 protected JMenuItem vamsasStop = new JMenuItem();
110 JMenuItem closeAll = new JMenuItem();
112 JMenuItem raiseRelated = new JMenuItem();
114 JMenuItem minimizeAssociated = new JMenuItem();
116 protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
118 JMenuItem garbageCollect = new JMenuItem();
120 protected JMenuItem groovyShell;
122 protected JCheckBoxMenuItem experimentalFeatures;
124 protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
126 protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
128 protected JMenuItem snapShotWindow = new JMenuItem();
131 * Creates a new GDesktop object.
139 this.setJMenuBar(desktopMenubar);
140 } catch (Exception e)
145 if (Platform.allowMnemonics())
147 //BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
148 // but here we want just not a Mac, period, right?
149 FileMenu.setMnemonic('F');
150 inputLocalFileMenuItem.setMnemonic('L');
151 VamsasMenu.setMnemonic('V');
152 inputURLMenuItem.setMnemonic('U');
153 inputTextboxMenuItem.setMnemonic('C');
154 quit.setMnemonic('Q');
155 saveState.setMnemonic('S');
156 loadState.setMnemonic('L');
157 inputMenu.setMnemonic('I');
167 private void jbInit() throws Exception
170 FileMenu.setText(MessageManager.getString("action.file"));
171 HelpMenu.setText(MessageManager.getString("action.help"));
172 VamsasMenu.setText("Vamsas");
173 VamsasMenu.setToolTipText(MessageManager
174 .getString("label.share_data_vamsas_applications"));
175 VamsasStMenu.setText(MessageManager.getString("label.connect_to"));
176 VamsasStMenu.setToolTipText(
177 MessageManager.getString("label.join_existing_vamsas_session"));
178 inputLocalFileMenuItem
179 .setText(MessageManager.getString("label.load_tree_from_file"));
180 inputLocalFileMenuItem.setAccelerator(
181 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
182 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
184 inputLocalFileMenuItem
185 .addActionListener(new java.awt.event.ActionListener()
188 public void actionPerformed(ActionEvent e)
190 inputLocalFileMenuItem_actionPerformed(null);
193 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
194 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
197 public void actionPerformed(ActionEvent e)
201 inputURLMenuItem_actionPerformed(null);
202 } catch (FileFormatException e1)
204 System.err.println("Error loading from URL: " + e1.getMessage());
209 .setText(MessageManager.getString("label.from_textbox"));
211 .addActionListener(new java.awt.event.ActionListener()
214 public void actionPerformed(ActionEvent e)
216 inputTextboxMenuItem_actionPerformed(null);
219 quit.setText(MessageManager.getString("action.quit"));
220 quit.addActionListener(new java.awt.event.ActionListener()
223 public void actionPerformed(ActionEvent e)
228 aboutMenuItem.setText(MessageManager.getString("label.about"));
229 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
232 public void actionPerformed(ActionEvent e)
234 aboutMenuItem_actionPerformed(e);
237 documentationMenuItem
238 .setText(MessageManager.getString("label.documentation"));
239 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
240 .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
241 documentationMenuItem
242 .addActionListener(new java.awt.event.ActionListener()
245 public void actionPerformed(ActionEvent e)
247 documentationMenuItem_actionPerformed();
250 this.getContentPane().setLayout(flowLayout1);
251 windowMenu.setText(MessageManager.getString("label.window"));
252 preferences.setText(MessageManager.getString("label.preferences"));
253 preferences.addActionListener(new ActionListener()
256 public void actionPerformed(ActionEvent e)
258 preferences_actionPerformed(e);
261 toolsMenu.setText(MessageManager.getString("label.tools"));
262 saveState.setText(MessageManager.getString("action.save_project"));
263 saveState.addActionListener(new ActionListener()
266 public void actionPerformed(ActionEvent e)
268 saveState_actionPerformed(true);
271 JMenuItem saveAsJaxb = new JMenuItem("Save Project as JAXB");
272 saveAsJaxb.addActionListener(new ActionListener()
275 public void actionPerformed(ActionEvent e)
277 saveState_actionPerformed(false);
280 loadState.setText(MessageManager.getString("action.load_project"));
281 loadState.addActionListener(new ActionListener()
284 public void actionPerformed(ActionEvent e)
286 loadState_actionPerformed(true);
289 JMenuItem loadAsJaxb = new JMenuItem("Load Project as JAXB");
290 loadAsJaxb.addActionListener(new ActionListener()
293 public void actionPerformed(ActionEvent e)
295 loadState_actionPerformed(false);
298 inputMenu.setText(MessageManager.getString("label.input_alignment"));
300 .setText(MessageManager.getString("label.new_vamsas_session"));
301 vamsasStart.setVisible(false);
302 vamsasStart.addActionListener(new ActionListener()
305 public void actionPerformed(ActionEvent e)
307 vamsasStart_actionPerformed(e);
310 vamsasImport.setText(
311 MessageManager.getString("action.load_vamsas_session"));
312 vamsasImport.setVisible(false);
313 vamsasImport.addActionListener(new ActionListener()
316 public void actionPerformed(ActionEvent e)
318 vamsasImport_actionPerformed(e);
322 MessageManager.getString("action.save_vamsas_session"));
323 vamsasSave.setVisible(false);
324 vamsasSave.addActionListener(new ActionListener()
327 public void actionPerformed(ActionEvent e)
329 vamsasSave_actionPerformed(e);
333 .setText(MessageManager.getString("action.fetch_sequences"));
334 inputSequence.addActionListener(new ActionListener()
337 public void actionPerformed(ActionEvent e)
339 inputSequence_actionPerformed(e);
343 .setText(MessageManager.getString("label.stop_vamsas_session"));
344 vamsasStop.setVisible(false);
345 vamsasStop.addActionListener(new ActionListener()
348 public void actionPerformed(ActionEvent e)
350 vamsasStop_actionPerformed(e);
353 closeAll.setText(MessageManager.getString("action.close_all"));
354 closeAll.addActionListener(new ActionListener()
357 public void actionPerformed(ActionEvent e)
359 closeAll_actionPerformed(e);
362 raiseRelated.setText(
363 MessageManager.getString("action.raise_associated_windows"));
364 raiseRelated.addActionListener(new ActionListener()
367 public void actionPerformed(ActionEvent e)
369 raiseRelated_actionPerformed(e);
372 minimizeAssociated.setText(
373 MessageManager.getString("action.minimize_associated_windows"));
374 minimizeAssociated.addActionListener(new ActionListener()
377 public void actionPerformed(ActionEvent e)
379 minimizeAssociated_actionPerformed(e);
383 .setText(MessageManager.getString("label.collect_garbage"));
384 garbageCollect.addActionListener(new ActionListener()
387 public void actionPerformed(ActionEvent e)
389 garbageCollect_actionPerformed(e);
393 .setText(MessageManager.getString("label.show_memory_usage"));
394 showMemusage.addActionListener(new ActionListener()
397 public void actionPerformed(ActionEvent e)
399 showMemusage_actionPerformed(e);
403 .setText(MessageManager.getString("label.show_java_console"));
404 showConsole.addActionListener(new ActionListener()
407 public void actionPerformed(ActionEvent e)
409 showConsole_actionPerformed(e);
412 showNews.setText(MessageManager.getString("label.show_jalview_news"));
413 showNews.addActionListener(new ActionListener()
416 public void actionPerformed(ActionEvent e)
418 showNews_actionPerformed(e);
421 groovyShell = new JMenuItem();
422 groovyShell.setText(MessageManager.getString("label.groovy_console"));
423 groovyShell.addActionListener(new ActionListener()
426 public void actionPerformed(ActionEvent e)
428 groovyShell_actionPerformed();
431 experimentalFeatures = new JCheckBoxMenuItem();
433 .setText(MessageManager.getString("label.show_experimental"));
434 experimentalFeatures.setToolTipText(
435 MessageManager.getString("label.show_experimental_tip"));
436 experimentalFeatures.addActionListener(new ActionListener()
439 public void actionPerformed(ActionEvent e)
441 showExperimental_actionPerformed(experimentalFeatures.isSelected());
445 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
446 snapShotWindow.addActionListener(new ActionListener()
449 public void actionPerformed(ActionEvent e)
451 snapShotWindow_actionPerformed(e);
455 desktopMenubar.add(FileMenu);
456 desktopMenubar.add(toolsMenu);
457 VamsasMenu.setVisible(false);
458 desktopMenubar.add(VamsasMenu);
459 desktopMenubar.add(HelpMenu);
460 desktopMenubar.add(windowMenu);
461 FileMenu.add(inputMenu);
462 FileMenu.add(inputSequence);
463 FileMenu.addSeparator();
464 FileMenu.add(saveAsJaxb);
465 FileMenu.add(loadAsJaxb);
466 if (!Platform.isJS())
468 FileMenu.add(saveState);
469 FileMenu.add(loadState);
471 FileMenu.addSeparator();
473 HelpMenu.add(aboutMenuItem);
474 HelpMenu.add(documentationMenuItem);
475 VamsasMenu.add(VamsasStMenu);
476 VamsasStMenu.setVisible(false);
477 VamsasMenu.add(vamsasStart);
478 VamsasMenu.add(vamsasImport);
479 VamsasMenu.add(vamsasSave);
480 VamsasMenu.add(vamsasStop);
481 toolsMenu.add(preferences);
482 if (!Platform.isJS())
484 toolsMenu.add(showMemusage);
485 toolsMenu.add(showConsole);
487 if (!Platform.isJS())
489 toolsMenu.add(showNews);
490 toolsMenu.add(garbageCollect);
491 toolsMenu.add(groovyShell);
493 toolsMenu.add(experimentalFeatures);
494 // toolsMenu.add(snapShotWindow);
495 inputMenu.add(inputLocalFileMenuItem);
496 inputMenu.add(inputURLMenuItem);
497 inputMenu.add(inputTextboxMenuItem);
498 windowMenu.add(closeAll);
499 windowMenu.add(raiseRelated);
500 windowMenu.add(minimizeAssociated);
501 windowMenu.addSeparator();
502 // inputMenu.add(vamsasLoad);
505 protected void showExperimental_actionPerformed(boolean selected)
509 protected void groovyShell_actionPerformed()
513 protected void snapShotWindow_actionPerformed(ActionEvent e)
515 // TODO Auto-generated method stub
519 protected void showConsole_actionPerformed(ActionEvent e)
521 // TODO Auto-generated method stub
525 protected void showNews_actionPerformed(ActionEvent e)
527 // TODO Auto-generated method stub
531 protected void showMemusage_actionPerformed(ActionEvent e)
533 // TODO Auto-generated method stub
537 protected void garbageCollect_actionPerformed(ActionEvent e)
539 // TODO Auto-generated method stub
543 protected void vamsasStMenu_actionPerformed()
547 public void vamsasSave_actionPerformed(ActionEvent e)
557 protected void inputLocalFileMenuItem_actionPerformed(
558 jalview.gui.AlignViewport av)
567 * @throws FileFormatException
569 protected void inputURLMenuItem_actionPerformed(
570 jalview.gui.AlignViewport av) throws FileFormatException
580 protected void inputTextboxMenuItem_actionPerformed(
581 AlignmentViewPanel avp)
588 protected void quit()
598 protected void aboutMenuItem_actionPerformed(ActionEvent e)
602 protected void documentationMenuItem_actionPerformed()
612 public void SaveState_actionPerformed(ActionEvent e)
622 protected void preferences_actionPerformed(ActionEvent e)
632 public void saveState_actionPerformed(boolean asCastor)
642 public void loadState_actionPerformed(boolean asCastor)
652 public void loadJalviewAlign_actionPerformed(ActionEvent e)
656 public void vamsasStart_actionPerformed(ActionEvent e)
661 public void inputSequence_actionPerformed(ActionEvent e)
666 public void vamsasStop_actionPerformed(ActionEvent e)
671 public void closeAll_actionPerformed(ActionEvent e)
676 public void raiseRelated_actionPerformed(ActionEvent e)
681 public void minimizeAssociated_actionPerformed(ActionEvent e)
686 public void vamsasImport_actionPerformed(ActionEvent e)