Debian Codegraph @

src/dr/app/tempest/TempestMacFileMenuFactory.java

raw symbols SCIP
1 /*
2 * TempestMacFileMenuFactory.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.tempest;
27
28 import jam.framework.MenuFactory;
29 import jam.framework.AbstractFrame;
30 import jam.framework.Application;
31 import jam.framework.MenuBarFactory;
32
33 import javax.swing.*;
34 import java.awt.event.KeyEvent;
35 import java.awt.event.ActionEvent;
36
37 /**
38 * @author rambaut
39 * Date: Dec 26, 2004
40 * Time: 11:02:45 AM
41 */
42 public class TempestMacFileMenuFactory implements MenuFactory {
43
44 public TempestMacFileMenuFactory() {
45 }
46
47 public String getMenuName() {
48 return "File";
49 }
50
51 public void populateMenu(JMenu menu, AbstractFrame frame) {
52
53 Application application = Application.getApplication();
54 JMenuItem item;
55
56 item = new JMenuItem(application.getNewAction());
57 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MenuBarFactory.MENU_MASK));
58 menu.add(item);
59
60 item = new JMenuItem(application.getOpenAction());
61 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
62 menu.add(item);
63
64 if (frame != null) {
65 menu.addSeparator();
66
67 item = new JMenuItem(frame.getImportAction());
68 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
69 menu.add(item);
70
71 menu.addSeparator();
72
73 item = new JMenuItem(frame.getCloseWindowAction());
74 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
75 menu.add(item);
76
77 item = new JMenuItem(frame.getSaveAction());
78 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
79 menu.add(item);
80
81 item = new JMenuItem(frame.getSaveAsAction());
82 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
83 menu.add(item);
84 } else {
85 menu.addSeparator();
86
87 item = new JMenuItem("Import Dates...");
88 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
89 item.setEnabled(false);
90 menu.add(item);
91
92 menu.addSeparator();
93
94 // No frame available so create a disabled menu for the default menu bar
95 item = new JMenuItem("Close");
96 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
97 item.setEnabled(false);
98 menu.add(item);
99
100 item = new JMenuItem("Save");
101 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
102 item.setEnabled(false);
103 menu.add(item);
104
105 item = new JMenuItem("Save As...");
106 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
107 item.setEnabled(false);
108 menu.add(item);
109 }
110
111 menu.addSeparator();
112
113 if (frame instanceof TempestFrame) {
114
115 item = new JMenuItem(((TempestFrame)frame).getExportTreeAction());
116 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
117 menu.add(item);
118
119 // item = new JMenuItem(((TemporalSamplerFrame)frame).getExportGraphicAction());
120 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
121 // menu.add(item);
122
123 item = new JMenuItem(((TempestFrame)frame).getExportDataAction());
124 menu.add(item);
125
126 item = new JMenuItem(((TempestFrame)frame).getExportTimeTreeAction());
127 menu.add(item);
128
129 } else {
130 // If the frame is not a BeautiFrame then create a dummy set of disabled menu options.
131 // At present the only situation where this may happen is in Mac OS X when no windows
132 // are open and the menubar is created by the hidden frame.
133
134 item = new JMenuItem("Export Tree...");
135 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
136 item.setEnabled(false);
137 menu.add(item);
138
139 // item = new JMenuItem("Export Graphic...");
140 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
141 // item.setEnabled(false);
142 // menu.add(item);
143
144 item = new JMenuItem("Export Data...");
145 item.setEnabled(false);
146 menu.add(item);
147 }
148
149 menu.addSeparator();
150
151 if (frame != null) {
152 item = new JMenuItem(frame.getPrintAction());
153 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
154 menu.add(item);
155
156 item = new JMenuItem(application.getPageSetupAction());
157 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
158 menu.add(item);
159
160 } else {
161 // No frame available so create a disabled menu for the default menu bar
162 item = new JMenuItem("Print...");
163 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
164 item.setEnabled(false);
165 menu.add(item);
166
167 item = new JMenuItem("Page Setup...");
168 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
169 item.setEnabled(false);
170 menu.add(item);
171 }
172
173 }
174
175 public int getPreferredAlignment() {
176 return LEFT;
177 }
178 }