Debian Codegraph @

src/dr/app/tempest/TempestDefaultFileMenuFactory.java

raw symbols SCIP
1 /*
2 * TempestDefaultFileMenuFactory.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.AbstractFrame;
29 import jam.framework.Application;
30 import jam.framework.MenuBarFactory;
31 import jam.framework.MenuFactory;
32
33 import javax.swing.*;
34 import java.awt.event.KeyEvent;
35
36 /**
37 * @author rambaut
38 * Date: Dec 26, 2004
39 * Time: 11:01:06 AM
40 */
41 public class TempestDefaultFileMenuFactory implements MenuFactory {
42
43
44 public TempestDefaultFileMenuFactory() {
45 }
46
47 public String getMenuName() {
48 return "File";
49 }
50
51 public void populateMenu(JMenu menu, AbstractFrame frame) {
52
53 JMenuItem item;
54
55 Application application = Application.getApplication();
56 menu.setMnemonic('F');
57
58 item = new JMenuItem(application.getNewAction());
59 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MenuBarFactory.MENU_MASK));
60 menu.add(item);
61
62 item = new JMenuItem(application.getOpenAction());
63 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
64 menu.add(item);
65
66 item = new JMenuItem(frame.getSaveAction());
67 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
68 menu.add(item);
69
70 item = new JMenuItem(frame.getSaveAsAction());
71 menu.add(item);
72
73 menu.addSeparator();
74
75 // On Windows and Linux platforms, each window has its own menu so items which are not needed
76 // are simply missing. In contrast, on Mac, the menu is for the application so items should
77 // be enabled/disabled as frames come to the front.
78 if (frame instanceof TempestFrame) {
79 Action action = frame.getImportAction();
80 if (action != null) {
81 item = new JMenuItem(action);
82 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
83 menu.add(item);
84
85 menu.addSeparator();
86 }
87
88 item = new JMenuItem(((TempestFrame)frame).getExportTreeAction());
89 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
90 menu.add(item);
91
92 // item = new JMenuItem(((TemporalSamplerFrame)frame).getExportGraphicAction());
93 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK + KeyEvent.ALT_MASK));
94 // menu.add(item);
95
96 item = new JMenuItem(((TempestFrame)frame).getExportDataAction());
97 menu.add(item);
98
99 } else {
100 // do nothing
101 }
102
103 menu.addSeparator();
104
105 item = new JMenuItem(frame.getPrintAction());
106 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
107 menu.add(item);
108
109 item = new JMenuItem(application.getPageSetupAction());
110 menu.add(item);
111
112 menu.addSeparator();
113
114 if (application.getRecentFileMenu() != null) {
115 JMenu subMenu = application.getRecentFileMenu();
116 menu.add(subMenu);
117
118 menu.addSeparator();
119 }
120
121 item = new JMenuItem(application.getExitAction());
122 menu.add(item);
123 }
124
125 public int getPreferredAlignment() {
126 return LEFT;
127 }
128 }