Debian Codegraph @

src/dr/app/bss/DefaultHelpMenuFactory.java

raw symbols SCIP
1 /*
2 * DefaultHelpMenuFactory.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.bss;
27
28 import jam.framework.AbstractFrame;
29 import jam.framework.MenuFactory;
30
31 import java.awt.Desktop;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.io.IOException;
35 import java.net.URI;
36 import java.net.URISyntaxException;
37
38 import javax.swing.JMenu;
39 import javax.swing.JMenuItem;
40
41 /**
42 * @author Filip Bielejec
43 * @version $Id$
44 */
45 public class DefaultHelpMenuFactory implements MenuFactory {
46
47 public DefaultHelpMenuFactory() {
48 }// END: Constructor
49
50 @Override
51 public void populateMenu(JMenu menu, AbstractFrame frame) {
52
53 menu.setMnemonic('H');
54
55 JMenuItem item;
56
57 // Setup About
58 item = new JMenuItem();
59 item.setText("About " + BeagleSequenceSimulatorApp.LONG_NAME + "...");
60 item.addActionListener(new ListenAboutMenuItem());
61 menu.add(item);
62
63 // Setup Help
64 item = new JMenuItem();
65 item.setText("Help...");
66 item.addActionListener(new ListenHelpMenuItem());
67 menu.add(item);
68
69 }// END: populateMenu
70
71 @Override
72 public String getMenuName() {
73 return "Help";
74 }
75
76 @Override
77 public int getPreferredAlignment() {
78 return LEFT;
79 }
80
81 private class ListenAboutMenuItem implements ActionListener {
82 public void actionPerformed(ActionEvent ev) {
83
84 AboutDialog ad = new AboutDialog();
85 ad.setVisible(true);
86
87 }// END: actionPerformed
88 }// END: ListenAboutMenuItem
89
90 private class ListenHelpMenuItem implements ActionListener {
91 public void actionPerformed(ActionEvent ev) {
92
93 try {
94 Desktop.getDesktop()
95 .browse(new URI(
96 "http://rega.kuleuven.be/cev/ecv/software/buss"));
97 } catch (IOException e) {
98 Utils.handleException(
99 e,
100 "Problem occurred while trying to open this link in your system's standard browser.");
101 } catch (URISyntaxException e) {
102 Utils.handleException(
103 e,
104 "Problem occurred while trying to open this link in your system's standard browser.");
105 }
106
107 }// END: actionPerformed
108 }// END: ListenAboutMenuItem
109
110 }// END: class