Debian Codegraph @

src/dr/app/mapper/application/menus/MapperMacFileMenuFactory.java

raw symbols SCIP
1 /*
2 * MapperMacFileMenuFactory.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.mapper.application.menus;
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 Andrew Rambaut
39 * @version $Id$
40 */
41 public class MapperMacFileMenuFactory implements MenuFactory {
42
43 public MapperMacFileMenuFactory() {
44 }
45
46 public String getMenuName() {
47 return "File";
48 }
49
50 public void populateMenu(JMenu menu, AbstractFrame frame) {
51
52 Application application = Application.getApplication();
53 JMenuItem item;
54
55 item = new JMenuItem(application.getNewAction());
56 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MenuBarFactory.MENU_MASK));
57 menu.add(item);
58
59 item = new JMenuItem(application.getOpenAction());
60 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
61 menu.add(item);
62
63 if (application.getRecentFileMenu() != null) {
64 JMenu subMenu = application.getRecentFileMenu();
65 menu.add(subMenu);
66 }
67
68 if (frame instanceof MapperFileMenuHandler) {
69 menu.addSeparator();
70
71 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportMeasurementsAction());
72 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
73 menu.add(item);
74
75 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportLocationsAction());
76 menu.add(item);
77
78 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportTreesAction());
79 menu.add(item);
80
81 menu.addSeparator();
82
83 item = new JMenuItem(((MapperFileMenuHandler)frame).getExportDataAction());
84 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
85 menu.add(item);
86
87 item = new JMenuItem(((MapperFileMenuHandler)frame).getExportPDFAction());
88 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
89 menu.add(item);
90 } else {
91 // If the frame is not a BeautiFrame then create a dummy set of disabled menu options.
92 // At present the only situation where this may happen is in Mac OS X when no windows
93 // are open and the menubar is created by the hidden frame.
94
95 menu.addSeparator();
96
97 item = new JMenuItem("Import Strains...");
98 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
99 item.setEnabled(false);
100 menu.add(item);
101
102 item = new JMenuItem("Import Measurements...");
103 item.setEnabled(false);
104 menu.add(item);
105
106 item = new JMenuItem("Import Locations...");
107 item.setEnabled(false);
108 menu.add(item);
109
110 item = new JMenuItem("Import Trees...");
111 item.setEnabled(false);
112 menu.add(item);
113
114 menu.addSeparator();
115
116 item = new JMenuItem("Export Data...");
117 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
118 item.setEnabled(false);
119 menu.add(item);
120
121 item = new JMenuItem("Export PDF...");
122 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
123 item.setEnabled(false);
124 menu.add(item);
125 }
126
127 menu.addSeparator();
128
129 item = new JMenuItem(frame.getCloseWindowAction());
130 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
131 menu.add(item);
132
133 item = new JMenuItem(frame.getSaveAction());
134 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
135 menu.add(item);
136
137 item = new JMenuItem(frame.getSaveAsAction());
138 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
139 menu.add(item);
140
141 menu.addSeparator();
142
143 item = new JMenuItem(frame.getPrintAction());
144 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
145 menu.add(item);
146
147 item = new JMenuItem(application.getPageSetupAction());
148 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
149 menu.add(item);
150
151 }
152
153 public int getPreferredAlignment() {
154 return LEFT;
155 }
156 }