Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 17:27:16 GMT
  2. Package jalview.jbgui

File GDesktop.java

 

Coverage histogram

../../img/srcFileCovDistChart6.png
36% of files have more coverage

Code metrics

14
130
50
1
626
443
61
0.47
2.6
50
1.22

Classes

Class Line # Actions
GDesktop 48 130 61
0.5721649557.2%
 

Contributing tests

This file is covered by 45 tests. .

Source view

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 java.awt.FlowLayout;
24    import java.awt.event.ActionEvent;
25    import java.awt.event.ActionListener;
26   
27    import javax.swing.JCheckBoxMenuItem;
28    import javax.swing.JFrame;
29    import javax.swing.JMenu;
30    import javax.swing.JMenuBar;
31    import javax.swing.JMenuItem;
32   
33    import jalview.api.AlignmentViewPanel;
34    import jalview.bin.Cache;
35    import jalview.gui.APQHandlers;
36    import jalview.gui.Desktop;
37    import jalview.io.FileFormatException;
38    import jalview.util.MessageManager;
39    import jalview.util.Platform;
40   
41    /**
42    * DOCUMENT ME!
43    *
44    * @author $author$
45    * @version $Revision$
46    */
47    @SuppressWarnings("serial")
 
48    public class GDesktop extends JFrame
49    {
50   
51    protected static JMenu windowMenu = null;
52   
53    JMenuBar desktopMenubar = new JMenuBar();
54   
55    JMenu FileMenu = new JMenu();
56   
57    JMenu HelpMenu = new JMenu();
58   
59    JMenuItem inputLocalFileMenuItem = new JMenuItem();
60   
61    JMenuItem inputURLMenuItem = new JMenuItem();
62   
63    JMenuItem inputTextboxMenuItem = new JMenuItem();
64   
65    JMenuItem quit = new JMenuItem();
66   
67    JMenuItem aboutMenuItem = new JMenuItem();
68   
69    JMenuItem documentationMenuItem = new JMenuItem();
70   
71    FlowLayout flowLayout1 = new FlowLayout();
72   
73    protected JMenu toolsMenu = new JMenu();
74   
75    JMenuItem preferences = new JMenuItem();
76   
77    JMenuItem saveState = new JMenuItem();
78   
79    JMenuItem saveAsState = new JMenuItem();
80   
81    JMenuItem loadState = new JMenuItem();
82   
83    JMenu inputMenu = new JMenu();
84   
85    JMenuItem inputSequence = new JMenuItem();
86   
87    JMenuItem closeAll = new JMenuItem();
88   
89    JMenuItem raiseRelated = new JMenuItem();
90   
91    JMenuItem minimizeAssociated = new JMenuItem();
92   
93    protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
94   
95    JMenuItem garbageCollect = new JMenuItem();
96   
97    protected JMenuItem groovyShell;
98   
99    protected JCheckBoxMenuItem experimentalFeatures;
100   
101    protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
102   
103    protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
104   
105    protected JMenuItem snapShotWindow = new JMenuItem();
106   
107    /**
108    * Creates a new GDesktop object.
109    */
 
110  74 toggle public GDesktop()
111    {
112  74 super();
113   
114    // instantiate here to set same context (e.g. font) as other menus
115  74 if (windowMenu == null)
116    {
117  10 windowMenu = new JMenu();
118    }
119   
120  74 try
121    {
122  74 jbInit();
123  74 this.setJMenuBar(desktopMenubar);
124    } catch (Exception e)
125    {
126  0 e.printStackTrace();
127    }
128   
129  74 if (Platform.allowMnemonics())
130    {
131    // BH was !Platform.isAMacAndNotJS()) i.e. "JS or not Mac"
132    // but here we want just not a Mac, period, right?
133  74 FileMenu.setMnemonic('F');
134  74 inputLocalFileMenuItem.setMnemonic('L');
135  74 inputURLMenuItem.setMnemonic('U');
136  74 inputTextboxMenuItem.setMnemonic('C');
137  74 quit.setMnemonic('Q');
138  74 saveState.setMnemonic('S');
139  74 loadState.setMnemonic('L');
140  74 inputMenu.setMnemonic('I');
141    }
142    }
143   
144    /**
145    * DOCUMENT ME!
146    *
147    * @throws Exception
148    * DOCUMENT ME!
149    */
 
150  74 toggle private void jbInit() throws Exception
151    {
152    /**
153    * APQHandlers sets handlers for About, Preferences and Quit actions
154    * peculiar to macOS's application menu. APQHandlers will check to see if a
155    * handler is supported before setting it.
156    */
157  74 try
158    {
159  74 APQHandlers.setAPQHandlers((Desktop) this);
160    } catch (Exception e)
161    {
162  0 jalview.bin.Console.outPrintln("Cannot set APQHandlers");
163    // e.printStackTrace();
164    } catch (Throwable t)
165    {
166  0 jalview.bin.Console
167    .warn("Error setting APQHandlers: " + t.toString());
168  0 jalview.bin.Console.trace(Cache.getStackTraceString(t));
169    }
170   
171  74 setName("jalview-desktop");
172  74 FileMenu.setText(MessageManager.getString("action.file"));
173  74 HelpMenu.setText(MessageManager.getString("action.help"));
174  74 inputLocalFileMenuItem
175    .setText(MessageManager.getString("label.load_tree_from_file"));
176  74 inputLocalFileMenuItem
177    .setAccelerator(
178    javax.swing.KeyStroke
179    .getKeyStroke(java.awt.event.KeyEvent.VK_O,
180    jalview.util.ShortcutKeyMaskExWrapper
181    .getMenuShortcutKeyMaskEx(),
182    false));
183  74 inputLocalFileMenuItem
184    .addActionListener(new java.awt.event.ActionListener()
185    {
 
186  0 toggle @Override
187    public void actionPerformed(ActionEvent e)
188    {
189  0 inputLocalFileMenuItem_actionPerformed(null);
190    }
191    });
192  74 inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
193  74 inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
194    {
 
195  0 toggle @Override
196    public void actionPerformed(ActionEvent e)
197    {
198  0 try
199    {
200  0 inputURLMenuItem_actionPerformed(null);
201    } catch (FileFormatException e1)
202    {
203  0 jalview.bin.Console
204    .errPrintln("Error loading from URL: " + e1.getMessage());
205    }
206    }
207    });
208  74 inputTextboxMenuItem
209    .setText(MessageManager.getString("label.from_textbox"));
210  74 inputTextboxMenuItem
211    .addActionListener(new java.awt.event.ActionListener()
212    {
 
213  0 toggle @Override
214    public void actionPerformed(ActionEvent e)
215    {
216  0 inputTextboxMenuItem_actionPerformed(null);
217    }
218    });
219  74 quit.setText(MessageManager.getString("action.quit"));
220  74 quit.addActionListener(new java.awt.event.ActionListener()
221    {
 
222  0 toggle @Override
223    public void actionPerformed(ActionEvent e)
224    {
225  0 if (Desktop.instance != null)
226  0 Desktop.instance.desktopQuit();
227    }
228    });
229  74 aboutMenuItem.setText(MessageManager.getString("label.about"));
230  74 aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
231    {
 
232  0 toggle @Override
233    public void actionPerformed(ActionEvent e)
234    {
235  0 aboutMenuItem_actionPerformed(e);
236    }
237    });
238  74 documentationMenuItem
239    .setText(MessageManager.getString("label.documentation"));
240  74 documentationMenuItem.setAccelerator(javax.swing.KeyStroke
241    .getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0, false));
242  74 documentationMenuItem
243    .addActionListener(new java.awt.event.ActionListener()
244    {
 
245  0 toggle @Override
246    public void actionPerformed(ActionEvent e)
247    {
248  0 documentationMenuItem_actionPerformed();
249    }
250    });
251  74 this.getContentPane().setLayout(flowLayout1);
252  74 windowMenu.setText(MessageManager.getString("label.window"));
253  74 preferences.setText(MessageManager.getString("label.preferences"));
254  74 preferences.addActionListener(new ActionListener()
255    {
 
256  0 toggle @Override
257    public void actionPerformed(ActionEvent e)
258    {
259  0 preferences_actionPerformed(e);
260    }
261    });
262  74 toolsMenu.setText(MessageManager.getString("label.tools"));
263  74 saveState.setText(MessageManager.getString("action.save_project"));
264  74 saveState.addActionListener(new ActionListener()
265    {
 
266  0 toggle @Override
267    public void actionPerformed(ActionEvent e)
268    {
269  0 saveState_actionPerformed();
270    }
271    });
272  74 saveAsState.setText(MessageManager.getString("action.save_project_as"));
273  74 saveAsState.addActionListener(new ActionListener()
274    {
 
275  0 toggle @Override
276    public void actionPerformed(ActionEvent e)
277    {
278  0 saveAsState_actionPerformed(e);
279    }
280    });
281  74 loadState.setText(MessageManager.getString("action.load_project"));
282  74 loadState.addActionListener(new ActionListener()
283    {
 
284  0 toggle @Override
285    public void actionPerformed(ActionEvent e)
286    {
287  0 loadState_actionPerformed();
288    }
289    });
290  74 inputMenu.setText(MessageManager.getString("label.input_alignment"));
291  74 inputSequence
292    .setText(MessageManager.getString("action.fetch_sequences"));
293  74 inputSequence.addActionListener(new ActionListener()
294    {
 
295  0 toggle @Override
296    public void actionPerformed(ActionEvent e)
297    {
298  0 inputSequence_actionPerformed(e);
299    }
300    });
301  74 closeAll.setText(MessageManager.getString("action.close_all"));
302  74 closeAll.addActionListener(new ActionListener()
303    {
 
304  0 toggle @Override
305    public void actionPerformed(ActionEvent e)
306    {
307  0 closeAll_actionPerformed(e);
308    }
309    });
310  74 raiseRelated.setText(
311    MessageManager.getString("action.raise_associated_windows"));
312  74 raiseRelated.addActionListener(new ActionListener()
313    {
 
314  0 toggle @Override
315    public void actionPerformed(ActionEvent e)
316    {
317  0 raiseRelated_actionPerformed(e);
318    }
319    });
320  74 minimizeAssociated.setText(
321    MessageManager.getString("action.minimize_associated_windows"));
322  74 minimizeAssociated.addActionListener(new ActionListener()
323    {
 
324  0 toggle @Override
325    public void actionPerformed(ActionEvent e)
326    {
327  0 minimizeAssociated_actionPerformed(e);
328    }
329    });
330  74 garbageCollect
331    .setText(MessageManager.getString("label.collect_garbage"));
332  74 garbageCollect.addActionListener(new ActionListener()
333    {
 
334  0 toggle @Override
335    public void actionPerformed(ActionEvent e)
336    {
337  0 garbageCollect_actionPerformed(e);
338    }
339    });
340  74 showMemusage
341    .setText(MessageManager.getString("label.show_memory_usage"));
342  74 showMemusage.addActionListener(new ActionListener()
343    {
 
344  0 toggle @Override
345    public void actionPerformed(ActionEvent e)
346    {
347  0 showMemusage_actionPerformed(e);
348    }
349    });
350  74 showConsole
351    .setText(MessageManager.getString("label.show_java_console"));
352  74 showConsole.addActionListener(new ActionListener()
353    {
 
354  0 toggle @Override
355    public void actionPerformed(ActionEvent e)
356    {
357  0 showConsole_actionPerformed(e);
358    }
359    });
360  74 showNews.setText(MessageManager.getString("label.show_jalview_news"));
361  74 showNews.addActionListener(new ActionListener()
362    {
 
363  0 toggle @Override
364    public void actionPerformed(ActionEvent e)
365    {
366  0 showNews_actionPerformed(e);
367    }
368    });
369  74 groovyShell = new JMenuItem();
370  74 groovyShell.setText(MessageManager.getString("label.groovy_console"));
371  74 groovyShell.addActionListener(new ActionListener()
372    {
 
373  0 toggle @Override
374    public void actionPerformed(ActionEvent e)
375    {
376  0 groovyShell_actionPerformed();
377    }
378    });
379  74 experimentalFeatures = new JCheckBoxMenuItem();
380  74 experimentalFeatures
381    .setText(MessageManager.getString("label.show_experimental"));
382  74 experimentalFeatures.setToolTipText(
383    MessageManager.getString("label.show_experimental_tip"));
384  74 experimentalFeatures.addActionListener(new ActionListener()
385    {
 
386  0 toggle @Override
387    public void actionPerformed(ActionEvent e)
388    {
389  0 showExperimental_actionPerformed(experimentalFeatures.isSelected());
390    }
391    });
392   
393  74 snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
394  74 snapShotWindow.addActionListener(new ActionListener()
395    {
 
396  0 toggle @Override
397    public void actionPerformed(ActionEvent e)
398    {
399  0 snapShotWindow_actionPerformed(e);
400    }
401    });
402   
403  74 desktopMenubar.add(FileMenu);
404  74 desktopMenubar.add(toolsMenu);
405  74 desktopMenubar.add(HelpMenu);
406  74 desktopMenubar.add(windowMenu);
407  74 FileMenu.add(inputMenu);
408  74 FileMenu.add(inputSequence);
409  74 FileMenu.addSeparator();
410    // FileMenu.add(saveState);
411  74 FileMenu.add(saveAsState);
412  74 FileMenu.add(loadState);
413  74 FileMenu.addSeparator();
414  74 if (!APQHandlers.setQuit)
415    {
416  74 FileMenu.add(quit);
417    }
418  74 if (!APQHandlers.setAbout)
419    {
420  74 HelpMenu.add(aboutMenuItem);
421    }
422  74 HelpMenu.add(documentationMenuItem);
423  74 if (!APQHandlers.setPreferences)
424    {
425  74 toolsMenu.add(preferences);
426    }
427  74 if (!Platform.isJS())
428    {
429  74 toolsMenu.add(showMemusage);
430  74 toolsMenu.add(showConsole);
431  74 toolsMenu.add(showNews);
432  74 toolsMenu.add(garbageCollect);
433  74 toolsMenu.add(groovyShell);
434    }
435  74 toolsMenu.add(experimentalFeatures);
436    // toolsMenu.add(snapShotWindow);
437  74 inputMenu.add(inputLocalFileMenuItem);
438  74 inputMenu.add(inputURLMenuItem);
439  74 inputMenu.add(inputTextboxMenuItem);
440  74 windowMenu.add(closeAll);
441  74 windowMenu.add(raiseRelated);
442  74 windowMenu.add(minimizeAssociated);
443  74 windowMenu.addSeparator();
444    // inputMenu.add(vamsasLoad);
445    }
446   
 
447  0 toggle protected void showExperimental_actionPerformed(boolean selected)
448    {
449    }
450   
 
451  0 toggle protected void groovyShell_actionPerformed()
452    {
453    }
454   
 
455  0 toggle protected void snapShotWindow_actionPerformed(ActionEvent e)
456    {
457    // TODO Auto-generated method stub
458   
459    }
460   
 
461  0 toggle protected void showConsole_actionPerformed(ActionEvent e)
462    {
463    // TODO Auto-generated method stub
464   
465    }
466   
 
467  0 toggle protected void showNews_actionPerformed(ActionEvent e)
468    {
469    // TODO Auto-generated method stub
470   
471    }
472   
 
473  0 toggle protected void showMemusage_actionPerformed(ActionEvent e)
474    {
475    // TODO Auto-generated method stub
476   
477    }
478   
 
479  0 toggle protected void garbageCollect_actionPerformed(ActionEvent e)
480    {
481    // TODO Auto-generated method stub
482   
483    }
484   
 
485  0 toggle protected void vamsasStMenu_actionPerformed()
486    {
487    }
488   
 
489  0 toggle public void vamsasSave_actionPerformed(ActionEvent e)
490    {
491    }
492   
493    /**
494    * DOCUMENT ME!
495    *
496    * @param e
497    * DOCUMENT ME!
498    */
 
499  0 toggle protected void inputLocalFileMenuItem_actionPerformed(
500    jalview.gui.AlignViewport av)
501    {
502    }
503   
504    /**
505    * DOCUMENT ME!
506    *
507    * @param e
508    * DOCUMENT ME!
509    * @throws FileFormatException
510    */
 
511  0 toggle protected void inputURLMenuItem_actionPerformed(
512    jalview.gui.AlignViewport av) throws FileFormatException
513    {
514    }
515   
516    /**
517    * DOCUMENT ME!
518    *
519    * @param e
520    * DOCUMENT ME!
521    */
 
522  0 toggle protected void inputTextboxMenuItem_actionPerformed(
523    AlignmentViewPanel avp)
524    {
525    }
526   
527    /**
528    * DOCUMENT ME!
529    */
 
530  0 toggle protected void quit()
531    {
532    // jalview.bin.Console.outPrintln("********** GDesktop.quit()");
533    }
534   
535    /**
536    * DOCUMENT ME!
537    *
538    * @param e
539    * DOCUMENT ME!
540    */
 
541  0 toggle protected void aboutMenuItem_actionPerformed(ActionEvent e)
542    {
543    }
544   
 
545  0 toggle protected void documentationMenuItem_actionPerformed()
546    {
547    }
548   
549    /**
550    * DOCUMENT ME!
551    *
552    * @param e
553    * DOCUMENT ME!
554    */
 
555  0 toggle protected void preferences_actionPerformed(ActionEvent e)
556    {
557    }
558   
559    /**
560    * DOCUMENT ME!
561    *
562    * @param e
563    * DOCUMENT ME!
564    */
 
565  0 toggle public void saveState_actionPerformed()
566    {
567    }
568   
 
569  0 toggle public void saveAsState_actionPerformed(ActionEvent e)
570    {
571    }
572   
573    /**
574    * DOCUMENT ME!
575    *
576    * @param e
577    * DOCUMENT ME!
578    */
 
579  0 toggle public void loadState_actionPerformed()
580    {
581    }
582   
583    /**
584    * DOCUMENT ME!
585    *
586    * @param e
587    * DOCUMENT ME!
588    */
 
589  0 toggle public void loadJalviewAlign_actionPerformed(ActionEvent e)
590    {
591    }
592   
 
593  0 toggle public void vamsasStart_actionPerformed(ActionEvent e)
594    {
595   
596    }
597   
 
598  0 toggle public void inputSequence_actionPerformed(ActionEvent e)
599    {
600   
601    }
602   
 
603  0 toggle public void vamsasStop_actionPerformed(ActionEvent e)
604    {
605   
606    }
607   
 
608  0 toggle public void closeAll_actionPerformed(ActionEvent e)
609    {
610   
611    }
612   
 
613  0 toggle public void raiseRelated_actionPerformed(ActionEvent e)
614    {
615   
616    }
617   
 
618  0 toggle public void minimizeAssociated_actionPerformed(ActionEvent e)
619    {
620   
621    }
622   
 
623  0 toggle public void vamsasImport_actionPerformed(ActionEvent e)
624    {
625    }
626    }