Debian Codegraph @

src/dr/app/pathogen/PathogenMacFileMenuFactory.java

raw symbols SCIP
1 /*
2 * PathogenMacFileMenuFactory.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.pathogen;
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 PathogenMacFileMenuFactory implements MenuFactory {
43
44 public PathogenMacFileMenuFactory() {
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 item = new JMenuItem(frame.getCloseWindowAction());
66 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
67 menu.add(item);
68
69 item = new JMenuItem(frame.getSaveAction());
70 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
71 menu.add(item);
72
73 item = new JMenuItem(frame.getSaveAsAction());
74 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
75 menu.add(item);
76 } else {
77 // No frame available so create a disabled menu for the default menu bar
78 item = new JMenuItem("Close");
79 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
80 item.setEnabled(false);
81 menu.add(item);
82
83 item = new JMenuItem("Save");
84 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
85 item.setEnabled(false);
86 menu.add(item);
87
88 item = new JMenuItem("Save As...");
89 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
90 item.setEnabled(false);
91 menu.add(item);
92 }
93
94 menu.addSeparator();
95
96 if (frame instanceof PathogenFrame) {
97
98 item = new JMenuItem(((PathogenFrame)frame).getExportTreeAction());
99 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
100 menu.add(item);
101
102 // item = new JMenuItem(((TemporalSamplerFrame)frame).getExportGraphicAction());
103 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
104 // menu.add(item);
105
106 item = new JMenuItem(((PathogenFrame)frame).getExportDataAction());
107 menu.add(item);
108
109 item = new JMenuItem(((PathogenFrame)frame).getExportTimeTreeAction());
110 menu.add(item);
111
112 } else {
113 // If the frame is not a BeautiFrame then create a dummy set of disabled menu options.
114 // At present the only situation where this may happen is in Mac OS X when no windows
115 // are open and the menubar is created by the hidden frame.
116
117 item = new JMenuItem("Export Tree...");
118 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
119 item.setEnabled(false);
120 menu.add(item);
121
122 // item = new JMenuItem("Export Graphic...");
123 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
124 // item.setEnabled(false);
125 // menu.add(item);
126
127 item = new JMenuItem("Export Data...");
128 item.setEnabled(false);
129 menu.add(item);
130 }
131
132 menu.addSeparator();
133
134 if (frame != null) {
135 item = new JMenuItem(frame.getPrintAction());
136 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
137 menu.add(item);
138
139 item = new JMenuItem(application.getPageSetupAction());
140 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
141 menu.add(item);
142
143 } else {
144 // No frame available so create a disabled menu for the default menu bar
145 item = new JMenuItem("Print...");
146 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
147 item.setEnabled(false);
148 menu.add(item);
149
150 item = new JMenuItem("Page Setup...");
151 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
152 item.setEnabled(false);
153 menu.add(item);
154 }
155
156 }
157
158 public int getPreferredAlignment() {
159 return LEFT;
160 }
161 }