Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * MapperDefaultFileMenuFactory.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
36 /**
37 * @author Andrew Rambaut
38 * @version $Id$
39 */
40 public class MapperDefaultFileMenuFactory implements MenuFactory {
41
42
43 public MapperDefaultFileMenuFactory() {
44 }
45
46 public String getMenuName() {
47 return "File";
48 }
49
50 public void populateMenu(JMenu menu, AbstractFrame frame) {
51
52 JMenuItem item;
53
54 Application application = Application.getApplication();
55 menu.setMnemonic('F');
56
57 item = new JMenuItem(application.getNewAction());
58 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MenuBarFactory.MENU_MASK));
59 menu.add(item);
60
61 item = new JMenuItem(frame.getOpenAction());
62 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
63 menu.add(item);
64
65 item = new JMenuItem(frame.getSaveAction());
66 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
67 menu.add(item);
68
69 item = new JMenuItem(frame.getSaveAsAction());
70 menu.add(item);
71
72 menu.addSeparator();
73
74 // On Windows and Linux platforms, each window has its own menu so items which are not needed
75 // are simply missing. In contrast, on Mac, the menu is for the application so items should
76 // be enabled/disabled as frames come to the front.
77 if (frame instanceof MapperFileMenuHandler) {
78 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportMeasurementsAction());
79 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
80 menu.add(item);
81
82 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportLocationsAction());
83 menu.add(item);
84
85 item = new JMenuItem(((MapperFileMenuHandler)frame).getImportTreesAction());
86 menu.add(item);
87
88 item = new JMenuItem(((MapperFileMenuHandler)frame).getExportDataAction());
89 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
90 menu.add(item);
91
92 item = new JMenuItem(((MapperFileMenuHandler)frame).getExportPDFAction());
93 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
94 menu.add(item);
95 } else {
96 // If the frame is not a TracerFileMenuHandler then leave out the import/export options.
97 }
98
99 menu.addSeparator();
100
101 item = new JMenuItem(frame.getPrintAction());
102 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
103 menu.add(item);
104
105 item = new JMenuItem(application.getPageSetupAction());
106 menu.add(item);
107
108 menu.addSeparator();
109
110 item = new JMenuItem(application.getExitAction());
111 menu.add(item);
112
113 }
114
115 public int getPreferredAlignment() {
116 return LEFT;
117 }
118 }