1 |
iliev |
1286 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2192 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1286 |
* |
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 |
|
|
|
27 |
|
|
import javax.swing.AbstractAction; |
28 |
|
|
import javax.swing.Action; |
29 |
|
|
|
30 |
|
|
import org.jsampler.CC; |
31 |
iliev |
1818 |
import org.jsampler.view.JSChannel; |
32 |
iliev |
1286 |
import org.jsampler.view.std.JSNewAudioDeviceDlg; |
33 |
|
|
import org.jsampler.view.std.JSNewMidiDeviceDlg; |
34 |
|
|
import org.jsampler.view.std.StdA4n; |
35 |
iliev |
2288 |
import org.jsampler.view.swing.SHF; |
36 |
iliev |
1286 |
|
37 |
iliev |
2288 |
import static org.jsampler.JSPrefs.*; |
38 |
iliev |
1286 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
* |
42 |
|
|
* @author Grigor Iliev |
43 |
|
|
*/ |
44 |
|
|
public class A4n extends StdA4n { |
45 |
|
|
protected static A4n a4n = new A4n(); |
46 |
|
|
|
47 |
|
|
/** Forbids the instantiation of <code>A4n</code> */ |
48 |
|
|
private A4n() { |
49 |
|
|
refresh.putValue(Action.SMALL_ICON, Res.iconReload32); |
50 |
|
|
resetSampler.putValue(Action.SMALL_ICON, Res.iconReset32); |
51 |
|
|
exportSamplerConfig.putValue(Action.SMALL_ICON, Res.iconSave32); |
52 |
|
|
//exportMidiInstrumentMaps.putValue(Action.SMALL_ICON, Res.icon); |
53 |
|
|
} |
54 |
|
|
|
55 |
iliev |
1818 |
@Override |
56 |
iliev |
1286 |
protected FantasiaPrefs |
57 |
iliev |
1818 |
preferences() { return FantasiaPrefs.preferences(); } |
58 |
iliev |
1286 |
|
59 |
|
|
public final Action samplerInfo = new SamplerInfo(); |
60 |
|
|
|
61 |
|
|
private static class SamplerInfo extends AbstractAction { |
62 |
|
|
SamplerInfo() { |
63 |
|
|
super(i18n.getMenuLabel("actions.samplerInfo")); |
64 |
|
|
|
65 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.samplerInfo.tt")); |
66 |
|
|
putValue(Action.SMALL_ICON, Res.iconSamplerInfo32); |
67 |
|
|
} |
68 |
|
|
|
69 |
iliev |
1818 |
@Override |
70 |
iliev |
1286 |
public void |
71 |
|
|
actionPerformed(ActionEvent e) { |
72 |
iliev |
2288 |
new SamplerInfoDlg(SHF.getMainFrame()).setVisible(true); |
73 |
iliev |
1286 |
} |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
public final Action loadScript = new LoadLscpScript(); |
77 |
|
|
|
78 |
|
|
private class LoadLscpScript extends AbstractAction { |
79 |
|
|
LoadLscpScript() { |
80 |
|
|
super(i18n.getMenuLabel("actions.runScript")); |
81 |
|
|
|
82 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.runScript.tt")); |
83 |
|
|
putValue(Action.SMALL_ICON, Res.iconOpen32); |
84 |
|
|
} |
85 |
|
|
|
86 |
iliev |
1818 |
@Override |
87 |
iliev |
1286 |
public void |
88 |
|
|
actionPerformed(ActionEvent e) { |
89 |
iliev |
2288 |
if(!((MainFrame)SHF.getMainFrame()).runScript()) return; |
90 |
iliev |
1286 |
|
91 |
|
|
if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) { |
92 |
|
|
windowLSConsole.actionPerformed(null); |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
public final Action createMidiDevice = new CreateMidiDevice(); |
98 |
|
|
|
99 |
|
|
private class CreateMidiDevice extends AbstractAction { |
100 |
|
|
CreateMidiDevice() { |
101 |
iliev |
1323 |
super(i18n.getMenuLabel("edit.createMidiDevice")); |
102 |
iliev |
1286 |
|
103 |
iliev |
1323 |
String s = i18n.getMenuLabel("edit.createMidiDevice.tt"); |
104 |
iliev |
1286 |
putValue(SHORT_DESCRIPTION, s); |
105 |
|
|
//putValue(Action.SMALL_ICON, Res.iconNew16); |
106 |
|
|
} |
107 |
|
|
|
108 |
iliev |
1818 |
@Override |
109 |
iliev |
1286 |
public void |
110 |
|
|
actionPerformed(ActionEvent e) { |
111 |
iliev |
1688 |
if(!CC.verifyConnection()) return; |
112 |
iliev |
2288 |
new JSNewMidiDeviceDlg(SHF.getMainFrame()).setVisible(true); |
113 |
iliev |
1286 |
} |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
public final Action createAudioDevice = new CreateAudioDevice(); |
117 |
|
|
|
118 |
|
|
private class CreateAudioDevice extends AbstractAction { |
119 |
|
|
CreateAudioDevice() { |
120 |
iliev |
1323 |
super(i18n.getMenuLabel("edit.createAudioDevice")); |
121 |
iliev |
1286 |
|
122 |
iliev |
1323 |
String s = i18n.getMenuLabel("edit.createAudioDevice.tt"); |
123 |
iliev |
1286 |
putValue(SHORT_DESCRIPTION, s); |
124 |
|
|
//putValue(Action.SMALL_ICON, Res.iconNew16); |
125 |
|
|
} |
126 |
|
|
|
127 |
iliev |
1818 |
@Override |
128 |
iliev |
1286 |
public void |
129 |
|
|
actionPerformed(ActionEvent e) { |
130 |
iliev |
1688 |
if(!CC.verifyConnection()) return; |
131 |
iliev |
2288 |
new JSNewAudioDeviceDlg(SHF.getMainFrame()).setVisible(true); |
132 |
iliev |
1286 |
} |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
// EDIT |
136 |
|
|
|
137 |
|
|
public final Action editPreferences = new EditPreferences(); |
138 |
|
|
|
139 |
|
|
private class EditPreferences extends AbstractAction { |
140 |
|
|
EditPreferences() { |
141 |
|
|
super(i18n.getMenuLabel("edit.preferences")); |
142 |
|
|
|
143 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("edit.preferences.tt")); |
144 |
|
|
putValue(Action.SMALL_ICON, Res.iconPreferences32); |
145 |
|
|
} |
146 |
|
|
|
147 |
iliev |
1818 |
@Override |
148 |
iliev |
1286 |
public void |
149 |
iliev |
2288 |
actionPerformed(ActionEvent e) { new PrefsDlg(SHF.getMainFrame()).setVisible(true); } |
150 |
iliev |
1286 |
} |
151 |
|
|
|
152 |
iliev |
1818 |
|
153 |
|
|
// CHANNELS |
154 |
|
|
|
155 |
|
|
public final Action setSmallView = new SetView(ChannelView.Type.SMALL); |
156 |
|
|
public final Action setNormalView = new SetView(ChannelView.Type.NORMAL); |
157 |
|
|
|
158 |
|
|
public static class SetView extends AbstractAction { |
159 |
|
|
private ChannelView.Type type; |
160 |
|
|
|
161 |
|
|
SetView(ChannelView.Type type) { |
162 |
|
|
this.type = type; |
163 |
|
|
|
164 |
|
|
switch(type) { |
165 |
|
|
case SMALL: |
166 |
|
|
putValue(Action.NAME, i18n.getMenuLabel("channels.smallView")); |
167 |
|
|
break; |
168 |
|
|
case NORMAL: |
169 |
|
|
putValue(Action.NAME, i18n.getMenuLabel("channels.normalView")); |
170 |
|
|
break; |
171 |
|
|
} |
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
@Override |
175 |
|
|
public void |
176 |
|
|
actionPerformed(ActionEvent e) { |
177 |
|
|
JSChannel[] channels = |
178 |
|
|
CC.getMainFrame().getSelectedChannelsPane().getSelectedChannels(); |
179 |
|
|
|
180 |
|
|
for(JSChannel c : channels) { |
181 |
|
|
Channel c2 = (Channel)c; |
182 |
|
|
if(c2.getViewTracker().getOriginalView().getType() == type) { |
183 |
|
|
continue; |
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
c2.getViewTracker().setView(createView(type, c2)); |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
MenuManager.getMenuManager().updateChannelViewGroups(); |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
public static int |
193 |
|
|
getViewCount(ChannelView.Type type) { |
194 |
|
|
int count = 0; |
195 |
|
|
|
196 |
|
|
JSChannel[] channels = |
197 |
|
|
CC.getMainFrame().getSelectedChannelsPane().getSelectedChannels(); |
198 |
|
|
|
199 |
|
|
for(JSChannel c : channels) { |
200 |
|
|
Channel c2 = (Channel)c; |
201 |
|
|
if(c2.getViewTracker().getOriginalView().getType() == type) { |
202 |
|
|
count++; |
203 |
|
|
} |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
return count; |
207 |
|
|
} |
208 |
|
|
|
209 |
|
|
public ChannelView |
210 |
|
|
createView(ChannelView.Type type, Channel channel) { |
211 |
|
|
switch(type) { |
212 |
|
|
case SMALL: return new SmallChannelView(channel); |
213 |
|
|
case NORMAL: return new NormalChannelView(channel); |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
throw new IllegalArgumentException("Unknown channel type"); |
217 |
|
|
} |
218 |
|
|
} |
219 |
|
|
|
220 |
iliev |
1286 |
// WINDOW |
221 |
|
|
public final Action windowLSConsole = new WindowLSConsole(); |
222 |
|
|
|
223 |
|
|
private class WindowLSConsole extends AbstractAction { |
224 |
|
|
WindowLSConsole() { |
225 |
|
|
super(i18n.getMenuLabel("window.lsConsole")); |
226 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.lsConsole.tt")); |
227 |
|
|
putValue(Action.SMALL_ICON, Res.iconLSConsole32); |
228 |
|
|
} |
229 |
|
|
|
230 |
iliev |
1818 |
@Override |
231 |
iliev |
1286 |
public void |
232 |
|
|
actionPerformed(ActionEvent e) { |
233 |
iliev |
2288 |
LSConsoleFrame console = ((MainFrame)SHF.getMainFrame()).getLSConsoleFrame(); |
234 |
iliev |
1286 |
|
235 |
|
|
if(console.isVisible()) console.setVisible(false); |
236 |
|
|
|
237 |
|
|
console.setVisible(true); |
238 |
|
|
} |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
public final Action windowInstrumentsDb = new WindowInstrumentsDb(); |
242 |
|
|
|
243 |
|
|
private class WindowInstrumentsDb extends AbstractAction { |
244 |
|
|
InstrumentsDbFrame instrumentsDbFrame = null; |
245 |
|
|
|
246 |
|
|
WindowInstrumentsDb() { |
247 |
|
|
super(i18n.getMenuLabel("window.instrumentsDb")); |
248 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.instrumentsDb.tt")); |
249 |
|
|
putValue(Action.SMALL_ICON, Res.iconDb32); |
250 |
|
|
} |
251 |
|
|
|
252 |
iliev |
1818 |
@Override |
253 |
iliev |
1286 |
public void |
254 |
|
|
actionPerformed(ActionEvent e) { |
255 |
iliev |
1688 |
if(!CC.verifyConnection()) return; |
256 |
|
|
|
257 |
iliev |
2288 |
if(SHF.getInstrumentsDbTreeModel() == null) { |
258 |
iliev |
1286 |
String s = i18n.getMessage("A4n.noInstrumentsDbSupport!"); |
259 |
iliev |
2288 |
SHF.showErrorMessage(s, SHF.getMainFrame()); |
260 |
iliev |
1286 |
return; |
261 |
|
|
} |
262 |
|
|
|
263 |
iliev |
1865 |
if(instrumentsDbFrame != null) { |
264 |
iliev |
1286 |
instrumentsDbFrame.setVisible(false); |
265 |
|
|
instrumentsDbFrame.setVisible(true); |
266 |
|
|
return; |
267 |
|
|
} |
268 |
|
|
|
269 |
iliev |
1865 |
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
270 |
|
|
// fix for moving the menu bar on top of the screen |
271 |
|
|
// when running on Mac OS and third party plugin is used |
272 |
|
|
((ViewConfig)CC.getViewConfig()).setNativeMenuProperties(); |
273 |
|
|
instrumentsDbFrame = new InstrumentsDbFrame(); |
274 |
|
|
((ViewConfig)CC.getViewConfig()).restoreMenuProperties(); |
275 |
|
|
|
276 |
|
|
} else { |
277 |
|
|
instrumentsDbFrame = new InstrumentsDbFrame(); |
278 |
|
|
} |
279 |
|
|
|
280 |
iliev |
1286 |
instrumentsDbFrame.setVisible(true); |
281 |
|
|
} |
282 |
|
|
} |
283 |
|
|
|
284 |
iliev |
2192 |
public final Action windowSamplerBrowser = new WindowSamplerBrowser(); |
285 |
|
|
|
286 |
|
|
private class WindowSamplerBrowser extends AbstractAction { |
287 |
|
|
WindowSamplerBrowser() { |
288 |
|
|
super(i18n.getMenuLabel("window.SamplerBrowser")); |
289 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.SamplerBrowser.tt")); |
290 |
|
|
//putValue(Action.SMALL_ICON, Res.iconLSConsole32); |
291 |
|
|
} |
292 |
|
|
|
293 |
|
|
@Override |
294 |
|
|
public void |
295 |
|
|
actionPerformed(ActionEvent e) { |
296 |
|
|
SamplerBrowserFrame browser = |
297 |
iliev |
2288 |
((MainFrame)SHF.getMainFrame()).getSamplerBrowserFrame(); |
298 |
iliev |
2192 |
|
299 |
|
|
if(browser.isVisible()) browser.setVisible(false); |
300 |
|
|
|
301 |
|
|
browser.setVisible(true); |
302 |
|
|
} |
303 |
|
|
} |
304 |
|
|
|
305 |
iliev |
1286 |
// HELP |
306 |
|
|
public final Action helpAbout = new HelpAbout(); |
307 |
|
|
|
308 |
|
|
private class HelpAbout extends AbstractAction { |
309 |
|
|
HelpAbout() { |
310 |
|
|
super(i18n.getMenuLabel("help.about", "Fantasia")); |
311 |
|
|
} |
312 |
|
|
|
313 |
iliev |
1818 |
@Override |
314 |
iliev |
1286 |
public void |
315 |
|
|
actionPerformed(ActionEvent e) { |
316 |
iliev |
2288 |
new HelpAboutDlg(SHF.getMainFrame()).setVisible(true); |
317 |
iliev |
1286 |
} |
318 |
|
|
} |
319 |
|
|
} |