JAL-3311 remove menus and documentation relating to VAMSAS - dead code will be backed...
[jalview.git] / src / jalview / jbgui / GDesktop.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.jbgui;
22
23 import jalview.api.AlignmentViewPanel;
24 import jalview.io.FileFormatException;
25 import jalview.util.MessageManager;
26 import jalview.util.Platform;
27
28 import java.awt.FlowLayout;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31
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;
37
38 /**
39  * DOCUMENT ME!
40  * 
41  * @author $author$
42  * @version $Revision$
43  */
44 public class GDesktop extends JFrame
45 {
46   protected static JMenu windowMenu = new JMenu();
47
48   JMenuBar desktopMenubar = new JMenuBar();
49
50   JMenu FileMenu = new JMenu();
51
52   JMenu HelpMenu = new JMenu();
53
54   JMenuItem inputLocalFileMenuItem = new JMenuItem();
55
56   JMenuItem inputURLMenuItem = new JMenuItem();
57
58   JMenuItem inputTextboxMenuItem = new JMenuItem();
59
60   JMenuItem quit = new JMenuItem();
61
62   JMenuItem aboutMenuItem = new JMenuItem();
63
64   JMenuItem documentationMenuItem = new JMenuItem();
65
66   FlowLayout flowLayout1 = new FlowLayout();
67
68   protected JMenu toolsMenu = new JMenu();
69
70   JMenuItem preferences = new JMenuItem();
71
72   JMenuItem saveState = new JMenuItem();
73
74   JMenuItem saveAsState = new JMenuItem();
75
76   JMenuItem loadState = new JMenuItem();
77
78   JMenu inputMenu = new JMenu();
79
80   JMenuItem inputSequence = new JMenuItem();
81
82   JMenuItem closeAll = new JMenuItem();
83
84   JMenuItem raiseRelated = new JMenuItem();
85
86   JMenuItem minimizeAssociated = new JMenuItem();
87
88   protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
89
90   JMenuItem garbageCollect = new JMenuItem();
91
92   protected JMenuItem groovyShell;
93
94   protected JCheckBoxMenuItem experimentalFeatures;
95
96   protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
97
98   protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
99
100   protected JMenuItem snapShotWindow = new JMenuItem();
101
102   /**
103    * Creates a new GDesktop object.
104    */
105   public GDesktop()
106   {
107     try
108     {
109       jbInit();
110       this.setJMenuBar(desktopMenubar);
111     } catch (Exception e)
112     {
113       e.printStackTrace();
114     }
115
116     if (!Platform.isAMac())
117     {
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');
126     }
127   }
128
129   /**
130    * DOCUMENT ME!
131    * 
132    * @throws Exception
133    *           DOCUMENT ME!
134    */
135   private void jbInit() throws Exception
136   {
137
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(),
145                     false));
146     inputLocalFileMenuItem
147             .addActionListener(new java.awt.event.ActionListener()
148             {
149               @Override
150               public void actionPerformed(ActionEvent e)
151               {
152                 inputLocalFileMenuItem_actionPerformed(null);
153               }
154             });
155     inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
156     inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
157     {
158       @Override
159       public void actionPerformed(ActionEvent e)
160       {
161         try
162         {
163           inputURLMenuItem_actionPerformed(null);
164         } catch (FileFormatException e1)
165         {
166           System.err.println("Error loading from URL: " + e1.getMessage());
167         }
168       }
169     });
170     inputTextboxMenuItem
171             .setText(MessageManager.getString("label.from_textbox"));
172     inputTextboxMenuItem
173             .addActionListener(new java.awt.event.ActionListener()
174             {
175               @Override
176               public void actionPerformed(ActionEvent e)
177               {
178                 inputTextboxMenuItem_actionPerformed(null);
179               }
180             });
181     quit.setText(MessageManager.getString("action.quit"));
182     quit.addActionListener(new java.awt.event.ActionListener()
183     {
184       @Override
185       public void actionPerformed(ActionEvent e)
186       {
187         quit();
188       }
189     });
190     aboutMenuItem.setText(MessageManager.getString("label.about"));
191     aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
192     {
193       @Override
194       public void actionPerformed(ActionEvent e)
195       {
196         aboutMenuItem_actionPerformed(e);
197       }
198     });
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()
205             {
206               @Override
207               public void actionPerformed(ActionEvent e)
208               {
209                 documentationMenuItem_actionPerformed(e);
210               }
211             });
212     this.getContentPane().setLayout(flowLayout1);
213     windowMenu.setText(MessageManager.getString("label.window"));
214     preferences.setText(MessageManager.getString("label.preferences"));
215     preferences.addActionListener(new ActionListener()
216     {
217       @Override
218       public void actionPerformed(ActionEvent e)
219       {
220         preferences_actionPerformed(e);
221       }
222     });
223     toolsMenu.setText(MessageManager.getString("label.tools"));
224     saveState.setText(MessageManager.getString("action.save_project"));
225     saveState.addActionListener(new ActionListener()
226     {
227       @Override
228       public void actionPerformed(ActionEvent e)
229       {
230         saveState_actionPerformed();
231       }
232     });
233     saveAsState.setText(MessageManager.getString("action.save_project_as"));
234     saveAsState.addActionListener(new ActionListener()
235     {
236       @Override
237       public void actionPerformed(ActionEvent e)
238       {
239         saveAsState_actionPerformed(e);
240       }
241     });
242     loadState.setText(MessageManager.getString("action.load_project"));
243     loadState.addActionListener(new ActionListener()
244     {
245       @Override
246       public void actionPerformed(ActionEvent e)
247       {
248         loadState_actionPerformed();
249       }
250     });
251     inputMenu.setText(MessageManager.getString("label.input_alignment"));
252     inputSequence
253             .setText(MessageManager.getString("action.fetch_sequences"));
254     inputSequence.addActionListener(new ActionListener()
255     {
256       @Override
257       public void actionPerformed(ActionEvent e)
258       {
259         inputSequence_actionPerformed(e);
260       }
261     });
262     closeAll.setText(MessageManager.getString("action.close_all"));
263     closeAll.addActionListener(new ActionListener()
264     {
265       @Override
266       public void actionPerformed(ActionEvent e)
267       {
268         closeAll_actionPerformed(e);
269       }
270     });
271     raiseRelated.setText(
272             MessageManager.getString("action.raise_associated_windows"));
273     raiseRelated.addActionListener(new ActionListener()
274     {
275       @Override
276       public void actionPerformed(ActionEvent e)
277       {
278         raiseRelated_actionPerformed(e);
279       }
280     });
281     minimizeAssociated.setText(
282             MessageManager.getString("action.minimize_associated_windows"));
283     minimizeAssociated.addActionListener(new ActionListener()
284     {
285       @Override
286       public void actionPerformed(ActionEvent e)
287       {
288         minimizeAssociated_actionPerformed(e);
289       }
290     });
291     garbageCollect
292             .setText(MessageManager.getString("label.collect_garbage"));
293     garbageCollect.addActionListener(new ActionListener()
294     {
295       @Override
296       public void actionPerformed(ActionEvent e)
297       {
298         garbageCollect_actionPerformed(e);
299       }
300     });
301     showMemusage
302             .setText(MessageManager.getString("label.show_memory_usage"));
303     showMemusage.addActionListener(new ActionListener()
304     {
305       @Override
306       public void actionPerformed(ActionEvent e)
307       {
308         showMemusage_actionPerformed(e);
309       }
310     });
311     showConsole
312             .setText(MessageManager.getString("label.show_java_console"));
313     showConsole.addActionListener(new ActionListener()
314     {
315       @Override
316       public void actionPerformed(ActionEvent e)
317       {
318         showConsole_actionPerformed(e);
319       }
320     });
321     showNews.setText(MessageManager.getString("label.show_jalview_news"));
322     showNews.addActionListener(new ActionListener()
323     {
324       @Override
325       public void actionPerformed(ActionEvent e)
326       {
327         showNews_actionPerformed(e);
328       }
329     });
330     groovyShell = new JMenuItem();
331     groovyShell.setText(MessageManager.getString("label.groovy_console"));
332     groovyShell.addActionListener(new ActionListener()
333     {
334       @Override
335       public void actionPerformed(ActionEvent e)
336       {
337         groovyShell_actionPerformed();
338       }
339     });
340     experimentalFeatures = new JCheckBoxMenuItem();
341     experimentalFeatures
342             .setText(MessageManager.getString("label.show_experimental"));
343     experimentalFeatures.setToolTipText(
344             MessageManager.getString("label.show_experimental_tip"));
345     experimentalFeatures.addActionListener(new ActionListener()
346     {
347       @Override
348       public void actionPerformed(ActionEvent e)
349       {
350         showExperimental_actionPerformed(experimentalFeatures.isSelected());
351       }
352     });
353
354     snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
355     snapShotWindow.addActionListener(new ActionListener()
356     {
357       @Override
358       public void actionPerformed(ActionEvent e)
359       {
360         snapShotWindow_actionPerformed(e);
361       }
362     });
363
364     Float specversion = Float.parseFloat(System.getProperty("java.specification.version"));
365     
366     desktopMenubar.add(FileMenu);
367     desktopMenubar.add(toolsMenu);
368     desktopMenubar.add(HelpMenu);
369     desktopMenubar.add(windowMenu);
370     FileMenu.add(inputMenu);
371     FileMenu.add(inputSequence);
372     FileMenu.addSeparator();
373     //FileMenu.add(saveState);
374     FileMenu.add(saveAsState);
375     FileMenu.add(loadState);
376     FileMenu.addSeparator();
377     FileMenu.add(quit);
378     HelpMenu.add(aboutMenuItem);
379     HelpMenu.add(documentationMenuItem);
380     if (!Platform.isAMac() || specversion < 11)
381     {
382       toolsMenu.add(preferences);
383     }
384     toolsMenu.add(showMemusage);
385     toolsMenu.add(showConsole);
386     toolsMenu.add(showNews);
387     toolsMenu.add(garbageCollect);
388     toolsMenu.add(groovyShell);
389     toolsMenu.add(experimentalFeatures);
390     // toolsMenu.add(snapShotWindow);
391     inputMenu.add(inputLocalFileMenuItem);
392     inputMenu.add(inputURLMenuItem);
393     inputMenu.add(inputTextboxMenuItem);
394     windowMenu.add(closeAll);
395     windowMenu.add(raiseRelated);
396     windowMenu.add(minimizeAssociated);
397     windowMenu.addSeparator();
398     // inputMenu.add(vamsasLoad);
399   }
400
401   protected void showExperimental_actionPerformed(boolean selected)
402   {
403   }
404
405   protected void groovyShell_actionPerformed()
406   {
407   }
408
409   protected void snapShotWindow_actionPerformed(ActionEvent e)
410   {
411     // TODO Auto-generated method stub
412
413   }
414
415   protected void showConsole_actionPerformed(ActionEvent e)
416   {
417     // TODO Auto-generated method stub
418
419   }
420
421   protected void showNews_actionPerformed(ActionEvent e)
422   {
423     // TODO Auto-generated method stub
424
425   }
426
427   protected void showMemusage_actionPerformed(ActionEvent e)
428   {
429     // TODO Auto-generated method stub
430
431   }
432
433   protected void garbageCollect_actionPerformed(ActionEvent e)
434   {
435     // TODO Auto-generated method stub
436
437   }
438
439   protected void vamsasStMenu_actionPerformed()
440   {
441   }
442
443   public void vamsasSave_actionPerformed(ActionEvent e)
444   {
445   }
446
447   /**
448    * DOCUMENT ME!
449    * 
450    * @param e
451    *          DOCUMENT ME!
452    */
453   protected void inputLocalFileMenuItem_actionPerformed(
454           jalview.gui.AlignViewport av)
455   {
456   }
457
458   /**
459    * DOCUMENT ME!
460    * 
461    * @param e
462    *          DOCUMENT ME!
463    * @throws FileFormatException
464    */
465   protected void inputURLMenuItem_actionPerformed(
466           jalview.gui.AlignViewport av) throws FileFormatException
467   {
468   }
469
470   /**
471    * DOCUMENT ME!
472    * 
473    * @param e
474    *          DOCUMENT ME!
475    */
476   protected void inputTextboxMenuItem_actionPerformed(
477           AlignmentViewPanel avp)
478   {
479   }
480
481   /**
482    * DOCUMENT ME!
483    */
484   protected void quit()
485   {
486     //System.out.println("********** GDesktop.quit()");
487   }
488
489   /**
490    * DOCUMENT ME!
491    * 
492    * @param e
493    *          DOCUMENT ME!
494    */
495   protected void aboutMenuItem_actionPerformed(ActionEvent e)
496   {
497   }
498
499   /**
500    * DOCUMENT ME!
501    * 
502    * @param e
503    *          DOCUMENT ME!
504    */
505   protected void documentationMenuItem_actionPerformed(ActionEvent e)
506   {
507   }
508
509   /**
510    * DOCUMENT ME!
511    * 
512    * @param e
513    *          DOCUMENT ME!
514    */
515   protected void preferences_actionPerformed(ActionEvent e)
516   {
517   }
518
519   /**
520    * DOCUMENT ME!
521    * 
522    * @param e
523    *          DOCUMENT ME!
524    */
525   public void saveState_actionPerformed()
526   {
527   }
528
529   public void saveAsState_actionPerformed(ActionEvent e)
530   {
531   }
532
533   /**
534    * DOCUMENT ME!
535    * 
536    * @param e
537    *          DOCUMENT ME!
538    */
539   public void loadState_actionPerformed()
540   {
541   }
542
543   /**
544    * DOCUMENT ME!
545    * 
546    * @param e
547    *          DOCUMENT ME!
548    */
549   public void loadJalviewAlign_actionPerformed(ActionEvent e)
550   {
551   }
552
553   public void vamsasStart_actionPerformed(ActionEvent e)
554   {
555
556   }
557
558   public void inputSequence_actionPerformed(ActionEvent e)
559   {
560
561   }
562
563   public void vamsasStop_actionPerformed(ActionEvent e)
564   {
565
566   }
567
568   public void closeAll_actionPerformed(ActionEvent e)
569   {
570
571   }
572
573   public void raiseRelated_actionPerformed(ActionEvent e)
574   {
575
576   }
577
578   public void minimizeAssociated_actionPerformed(ActionEvent e)
579   {
580
581   }
582
583   public void vamsasImport_actionPerformed(ActionEvent e)
584   {
585   }
586 }