1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2010 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
|
28 |
import javax.swing.JMenu; |
29 |
import javax.swing.JMenuBar; |
30 |
import javax.swing.JMenuItem; |
31 |
|
32 |
import org.jsampler.CC; |
33 |
import org.jsampler.view.std.JSFrame; |
34 |
import org.jsampler.view.std.JSLscpScriptDlg; |
35 |
|
36 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
37 |
|
38 |
/** |
39 |
* |
40 |
* @author Grigor Iliev |
41 |
*/ |
42 |
public class LSConsoleFrame extends JSFrame { |
43 |
private final JMenuBar menuBar = new JMenuBar(); |
44 |
private final LSConsolePane lsConsolePane = new LSConsolePane(this); |
45 |
|
46 |
/** |
47 |
* Creates a new instance of <code>LSConsoleFrame</code> |
48 |
*/ |
49 |
public |
50 |
LSConsoleFrame() { |
51 |
super(i18n.getLabel("LSConsoleFrame.title"), "LSConsoleFrame"); |
52 |
if(Res.iconAppIcon != null) setIconImage(Res.iconLSConsole.getImage()); |
53 |
|
54 |
add(lsConsolePane); |
55 |
addMenu(); |
56 |
} |
57 |
|
58 |
private void |
59 |
addMenu() { |
60 |
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
61 |
((ViewConfig)CC.getViewConfig()).setNativeMenuProperties(); |
62 |
} |
63 |
|
64 |
JMenu m; |
65 |
JMenuItem mi; |
66 |
|
67 |
setJMenuBar(menuBar); |
68 |
|
69 |
// Actions |
70 |
m = new JMenu(i18n.getMenuLabel("lsconsole.actions")); |
71 |
m.setFont(m.getFont().deriveFont(java.awt.Font.BOLD)); |
72 |
menuBar.add(m); |
73 |
|
74 |
JMenu clearMenu = new JMenu(i18n.getMenuLabel("lsconsole.clear")); |
75 |
|
76 |
mi = new JMenuItem(i18n.getMenuLabel("lsconsole.clearConsole")); |
77 |
clearMenu.add(mi); |
78 |
mi.addActionListener(lsConsolePane.clearConsoleAction); |
79 |
|
80 |
mi = new JMenuItem(i18n.getMenuLabel("lsconsole.clearSessionHistory")); |
81 |
clearMenu.add(mi); |
82 |
mi.addActionListener(lsConsolePane.clearSessionHistoryAction); |
83 |
|
84 |
m.add(clearMenu); |
85 |
|
86 |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("lsconsole.export")); |
87 |
|
88 |
mi = new JMenuItem(i18n.getMenuLabel("lsconsole.export.session")); |
89 |
exportMenu.add(mi); |
90 |
mi.addActionListener(new ActionListener() { |
91 |
public void |
92 |
actionPerformed(ActionEvent e) { |
93 |
JSLscpScriptDlg dlg = new JSLscpScriptDlg(); |
94 |
dlg.setCommands(lsConsolePane.getModel().getSessionHistory()); |
95 |
dlg.setVisible(true); |
96 |
} |
97 |
}); |
98 |
|
99 |
mi = new JMenuItem(i18n.getMenuLabel("lsconsole.export.commandHistory")); |
100 |
exportMenu.add(mi); |
101 |
mi.addActionListener(new ActionListener() { |
102 |
public void |
103 |
actionPerformed(ActionEvent e) { |
104 |
JSLscpScriptDlg dlg = new JSLscpScriptDlg(); |
105 |
dlg.setCommands(lsConsolePane.getModel().getCommandHistory()); |
106 |
dlg.setVisible(true); |
107 |
} |
108 |
}); |
109 |
|
110 |
m.add(exportMenu); |
111 |
|
112 |
m.addSeparator(); |
113 |
|
114 |
mi = new JMenuItem(i18n.getMenuLabel("lsconsole.runScript")); |
115 |
m.add(mi); |
116 |
mi.addActionListener(new ActionListener() { |
117 |
public void |
118 |
actionPerformed(ActionEvent e) { |
119 |
((MainFrame)CC.getMainFrame()).runScript(); |
120 |
} |
121 |
}); |
122 |
|
123 |
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
124 |
((ViewConfig)CC.getViewConfig()).restoreMenuProperties(); |
125 |
} |
126 |
} |
127 |
|
128 |
protected LSConsolePane |
129 |
getLSConsolePane() { return lsConsolePane; } |
130 |
} |