Debian Codegraph @

src/dr/app/bss/DefaultFileMenuFactory.java

raw symbols SCIP
1 /*
2 * DefaultFileMenuFactory.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.bss;
27
28 import jam.framework.AbstractFrame;
29 import jam.framework.Application;
30 import jam.framework.MenuBarFactory;
31 import jam.framework.MenuFactory;
32
33 import java.awt.event.KeyEvent;
34
35 import javax.swing.Action;
36 import javax.swing.JMenu;
37 import javax.swing.JMenuItem;
38 import javax.swing.KeyStroke;
39
40 /**
41 * @author Filip Bielejec
42 * @version $Id$
43 */
44 public class DefaultFileMenuFactory implements MenuFactory {
45
46 public DefaultFileMenuFactory() {
47 }// END: Constructor
48
49 @Override
50 public void populateMenu(JMenu menu, AbstractFrame frame) {
51
52 JMenuItem item;
53 Action action;
54
55 Application application = Application.getApplication();
56 menu.setMnemonic('F');
57
58 if (frame instanceof FileMenuHandler) {
59
60 // Setup Open
61 action = ((FileMenuHandler) frame).getLoadSettingsAction();
62 if (action != null) {
63 item = new JMenuItem(action);
64 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,
65 MenuBarFactory.MENU_MASK));
66 menu.add(item);
67 }
68
69 // Setup Save As
70 action = ((FileMenuHandler) frame).getSaveSettingsAction();
71 if (action != null) {
72 item = new JMenuItem(action);
73 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
74 MenuBarFactory.MENU_MASK));
75 menu.add(item);
76 }
77
78 }// END: instanceof check
79
80 menu.addSeparator();
81
82 // Setup Exit
83 item = new JMenuItem(application.getExitAction());
84 menu.add(item);
85
86 }// END: populateMenu
87
88 @Override
89 public String getMenuName() {
90 return "File";
91 }// END: getMenuName
92
93 @Override
94 public int getPreferredAlignment() {
95 return LEFT;
96 }// END: getPreferredAlignment
97
98 }// END: class