Debian Codegraph @

src/dr/app/treespace/MacFileMenuFactory.java

raw symbols SCIP
1 /*
2 * MacFileMenuFactory.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.treespace;
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.ActionEvent;
35 import java.awt.event.KeyEvent;
36
37 /**
38 * @author Andrew Rambaut
39 * @version $Id$
40 */
41 public class MacFileMenuFactory implements MenuFactory {
42
43 public MacFileMenuFactory() {
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 if (frame instanceof TreeSpaceFrame) {
60 item = new JMenuItem(frame.getImportAction());
61 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
62 menu.add(item);
63
64 // menu.addSeparator();
65 //
66 // item = new JMenuItem(((BeautiFrame)frame).getOpenAction());
67 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
68 // menu.add(item);
69 //
70 // item = new JMenuItem(frame.getSaveAsAction());
71 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
72 // menu.add(item);
73
74 menu.addSeparator();
75
76 item = new JMenuItem(frame.getExportAction());
77 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
78 menu.add(item);
79 } else {
80 // If the frame is not a BeautiFrame then create a dummy set of disabled menu options.
81 // At present the only situation where this may happen is in Mac OS X when no windows
82 // are open and the menubar is created by the hidden frame.
83
84 item = new JMenuItem("Import Alignment...");
85 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MenuBarFactory.MENU_MASK));
86 item.setEnabled(false);
87 menu.add(item);
88
89 // menu.addSeparator();
90 //
91 // item = new JMenuItem("Apply Template...");
92 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MenuBarFactory.MENU_MASK));
93 // item.setEnabled(false);
94 // menu.add(item);
95 //
96 // item = new JMenuItem("Save Template As...");
97 // item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MenuBarFactory.MENU_MASK));
98 // item.setEnabled(false);
99 // menu.add(item);
100
101 menu.addSeparator();
102
103 item = new JMenuItem("Generate Map File...");
104 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MenuBarFactory.MENU_MASK));
105 item.setEnabled(false);
106 menu.add(item);
107 }
108
109 menu.addSeparator();
110
111 item = new JMenuItem(frame.getCloseWindowAction());
112 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, MenuBarFactory.MENU_MASK));
113 menu.add(item);
114
115 menu.addSeparator();
116
117 item = new JMenuItem(frame.getPrintAction());
118 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK));
119 menu.add(item);
120
121 item = new JMenuItem(application.getPageSetupAction());
122 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, MenuBarFactory.MENU_MASK + ActionEvent.SHIFT_MASK));
123 menu.add(item);
124
125 }
126
127 public int getPreferredAlignment() {
128 return LEFT;
129 }
130 }