1 |
iliev |
787 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
1204 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
787 |
* |
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.classic; |
24 |
|
|
|
25 |
|
|
import java.awt.MediaTracker; |
26 |
|
|
|
27 |
|
|
import java.awt.event.ActionEvent; |
28 |
|
|
|
29 |
|
|
import java.beans.PropertyChangeEvent; |
30 |
|
|
import java.beans.PropertyChangeListener; |
31 |
|
|
|
32 |
iliev |
1143 |
import java.io.FileOutputStream; |
33 |
iliev |
787 |
import java.net.URL; |
34 |
|
|
import java.util.logging.Level; |
35 |
|
|
|
36 |
|
|
import javax.swing.AbstractAction; |
37 |
|
|
import javax.swing.Action; |
38 |
|
|
import javax.swing.ImageIcon; |
39 |
iliev |
1143 |
import javax.swing.JFileChooser; |
40 |
iliev |
787 |
|
41 |
iliev |
1143 |
import net.sf.juife.event.TaskEvent; |
42 |
|
|
import net.sf.juife.event.TaskListener; |
43 |
|
|
|
44 |
iliev |
787 |
import org.jsampler.CC; |
45 |
|
|
import org.jsampler.HF; |
46 |
|
|
import org.jsampler.JSampler; |
47 |
|
|
|
48 |
|
|
import org.jsampler.view.JSChannel; |
49 |
|
|
import org.jsampler.view.JSChannelsPane; |
50 |
|
|
import org.jsampler.view.JSMainFrame; |
51 |
iliev |
1143 |
import org.jsampler.view.LscpFileFilter; |
52 |
iliev |
787 |
|
53 |
|
|
import static org.jsampler.view.classic.ClassicI18n.i18n; |
54 |
|
|
|
55 |
|
|
|
56 |
|
|
/** |
57 |
|
|
* This class provides an <code>Action</code> instances performing all needed tasks. |
58 |
|
|
* @author Grigor Iliev |
59 |
|
|
*/ |
60 |
|
|
public class A4n { |
61 |
iliev |
842 |
private static boolean |
62 |
|
|
verifyConnection() { |
63 |
|
|
if(!CC.getClient().isConnected()) { |
64 |
|
|
HF.showErrorMessage(i18n.getError("notConnected")); |
65 |
|
|
return false; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
return true; |
69 |
|
|
} |
70 |
|
|
|
71 |
iliev |
787 |
public final static Action connect = new Connect(); |
72 |
|
|
|
73 |
|
|
private static class Connect extends AbstractAction { |
74 |
|
|
Connect() { |
75 |
|
|
super(i18n.getMenuLabel("actions.connect")); |
76 |
|
|
|
77 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttConnect")); |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
public void |
81 |
iliev |
911 |
actionPerformed(ActionEvent e) { CC.reconnect(); } |
82 |
iliev |
787 |
} |
83 |
|
|
|
84 |
|
|
public final static Action samplerInfo = new SamplerInfo(); |
85 |
|
|
|
86 |
|
|
private static class SamplerInfo extends AbstractAction { |
87 |
|
|
SamplerInfo() { |
88 |
|
|
super(i18n.getMenuLabel("actions.samplerInfo")); |
89 |
|
|
|
90 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttSamplerInfo")); |
91 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconInfo32); |
92 |
iliev |
787 |
} |
93 |
|
|
|
94 |
|
|
public void |
95 |
|
|
actionPerformed(ActionEvent e) { |
96 |
|
|
new SamplerInfoDlg(CC.getMainFrame()).setVisible(true); |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
public final static Action refresh = new Refresh(); |
101 |
|
|
|
102 |
|
|
private static class Refresh extends AbstractAction { |
103 |
|
|
Refresh() { |
104 |
|
|
super(i18n.getMenuLabel("actions.refresh")); |
105 |
|
|
|
106 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttRefresh")); |
107 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconReload32); |
108 |
iliev |
787 |
} |
109 |
|
|
|
110 |
|
|
public void |
111 |
|
|
actionPerformed(ActionEvent e) { CC.initSamplerModel(); } |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
public final static Action resetSampler = new Reset(); |
115 |
|
|
|
116 |
|
|
private static class Reset extends AbstractAction { |
117 |
|
|
Reset() { |
118 |
|
|
super(i18n.getMenuLabel("actions.resetSampler")); |
119 |
|
|
|
120 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttResetSampler")); |
121 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconReset32); |
122 |
iliev |
787 |
} |
123 |
|
|
|
124 |
|
|
public void |
125 |
iliev |
1143 |
actionPerformed(ActionEvent e) { CC.getSamplerModel().resetBackend(); } |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
public final static Action addMidiInstrumentMap = new AddMidiInstrumentMap(); |
129 |
|
|
|
130 |
|
|
private static class AddMidiInstrumentMap extends AbstractAction { |
131 |
|
|
AddMidiInstrumentMap() { |
132 |
|
|
super(i18n.getMenuLabel("actions.midiInstruments.addMap")); |
133 |
|
|
|
134 |
|
|
String s = i18n.getMenuLabel("actions.midiInstruments.addMap.tt"); |
135 |
|
|
putValue(SHORT_DESCRIPTION, s); |
136 |
|
|
putValue(Action.SMALL_ICON, Res.iconNew16); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
public void |
140 |
iliev |
787 |
actionPerformed(ActionEvent e) { |
141 |
iliev |
1143 |
AddMidiInstrumentMapDlg dlg = new AddMidiInstrumentMapDlg(); |
142 |
|
|
dlg.setVisible(true); |
143 |
|
|
if(dlg.isCancelled()) return; |
144 |
|
|
|
145 |
|
|
CC.getSamplerModel().addBackendMidiInstrumentMap(dlg.getMapName()); |
146 |
|
|
LeftPane.getLeftPane().showMidiInstrumentMapsPage(); |
147 |
iliev |
787 |
} |
148 |
|
|
} |
149 |
|
|
|
150 |
iliev |
1143 |
public final static Action removeMidiInstrumentMap = new RemoveMidiInstrumentMap(); |
151 |
|
|
|
152 |
|
|
private static class RemoveMidiInstrumentMap extends AbstractAction { |
153 |
|
|
RemoveMidiInstrumentMap() { |
154 |
|
|
super(i18n.getMenuLabel("actions.midiInstruments.removeMap")); |
155 |
|
|
|
156 |
|
|
String s = i18n.getMenuLabel("actions.midiInstruments.removeMap.tt"); |
157 |
|
|
putValue(SHORT_DESCRIPTION, s); |
158 |
|
|
putValue(Action.SMALL_ICON, Res.iconDelete16); |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
public void |
162 |
|
|
actionPerformed(ActionEvent e) { |
163 |
|
|
RemoveMidiInstrumentMapDlg dlg = new RemoveMidiInstrumentMapDlg(); |
164 |
|
|
dlg.setVisible(true); |
165 |
|
|
if(dlg.isCancelled()) return; |
166 |
|
|
int id = dlg.getSelectedMap().getMapId(); |
167 |
|
|
CC.getSamplerModel().removeBackendMidiInstrumentMap(id); |
168 |
|
|
} |
169 |
|
|
} |
170 |
|
|
|
171 |
|
|
public final static Action addMidiInstrumentWizard = new AddMidiInstrumentWizard(); |
172 |
|
|
|
173 |
|
|
private static class AddMidiInstrumentWizard extends AbstractAction { |
174 |
|
|
AddMidiInstrumentWizard() { |
175 |
|
|
super(i18n.getMenuLabel("actions.midiInstruments.newMidiInstrumentWizard")); |
176 |
|
|
|
177 |
|
|
String s = "actions.midiInstruments.newMidiInstrumentWizard.tt"; |
178 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel(s)); |
179 |
|
|
putValue(Action.SMALL_ICON, Res.iconNew16); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
public void |
183 |
|
|
actionPerformed(ActionEvent e) { |
184 |
|
|
NewMidiInstrumentWizard wizard = new NewMidiInstrumentWizard(); |
185 |
|
|
wizard.getWizardDialog().setResizable(false); |
186 |
|
|
|
187 |
|
|
if(ClassicPrefs.getNewMidiInstrWizardSkip1()) { |
188 |
|
|
if(wizard.getModel().getCurrentPage() == null) { |
189 |
|
|
wizard.getModel().next(); |
190 |
|
|
} |
191 |
|
|
wizard.getModel().next(); |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
wizard.showWizard(); |
195 |
|
|
|
196 |
|
|
} |
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
public final static Action exportMidiInstrumentMaps = new ExportMidiInstrumentMaps(); |
200 |
|
|
|
201 |
|
|
private static class ExportMidiInstrumentMaps extends AbstractAction { |
202 |
|
|
ExportMidiInstrumentMaps() { |
203 |
|
|
super(i18n.getMenuLabel("actions.export.MidiInstrumentMaps")); |
204 |
|
|
|
205 |
|
|
String s = i18n.getMenuLabel("actions.export.MidiInstrumentMaps.tt"); |
206 |
|
|
putValue(SHORT_DESCRIPTION, s); |
207 |
|
|
putValue(Action.SMALL_ICON, Res.iconExport16); |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
public void |
211 |
|
|
actionPerformed(ActionEvent e) { |
212 |
|
|
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
213 |
|
|
fc.setFileFilter(new LscpFileFilter()); |
214 |
|
|
int result = fc.showSaveDialog(CC.getMainFrame()); |
215 |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
216 |
|
|
|
217 |
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
218 |
|
|
ClassicPrefs.setLastScriptLocation(path); |
219 |
|
|
|
220 |
|
|
try { |
221 |
|
|
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
222 |
|
|
fos.write(CC.exportInstrMapsToLscpScript().getBytes("US-ASCII")); |
223 |
|
|
fos.close(); |
224 |
|
|
} catch(Exception x) { |
225 |
|
|
CC.getLogger().log(Level.FINE, HF.getErrorMessage(x), x); |
226 |
|
|
HF.showErrorMessage(x); |
227 |
|
|
}; |
228 |
|
|
} |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
|
232 |
|
|
public final static Action exportSamplerConfig = new ExportSamplerConfig(); |
233 |
|
|
|
234 |
|
|
private static class ExportSamplerConfig extends AbstractAction { |
235 |
|
|
ExportSamplerConfig() { |
236 |
|
|
super(i18n.getMenuLabel("actions.export.samplerConfiguration")); |
237 |
|
|
|
238 |
|
|
String s = i18n.getMenuLabel("ttExportSamplerConfiguration"); |
239 |
|
|
putValue(SHORT_DESCRIPTION, s); |
240 |
|
|
putValue(Action.SMALL_ICON, Res.iconExportSession32); |
241 |
|
|
} |
242 |
|
|
|
243 |
|
|
public void |
244 |
|
|
actionPerformed(ActionEvent e) { |
245 |
|
|
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
246 |
|
|
fc.setFileFilter(new LscpFileFilter()); |
247 |
|
|
int result = fc.showSaveDialog(CC.getMainFrame()); |
248 |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
249 |
|
|
|
250 |
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
251 |
|
|
ClassicPrefs.setLastScriptLocation(path); |
252 |
|
|
|
253 |
|
|
try { |
254 |
|
|
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
255 |
|
|
fos.write(CC.exportSessionToLscpScript().getBytes("US-ASCII")); |
256 |
|
|
fos.close(); |
257 |
|
|
} catch(Exception x) { |
258 |
|
|
CC.getLogger().log(Level.FINE, HF.getErrorMessage(x), x); |
259 |
|
|
HF.showErrorMessage(x); |
260 |
|
|
} |
261 |
|
|
} |
262 |
|
|
} |
263 |
|
|
|
264 |
|
|
public final static Action loadScript = new LoadLscpScript(); |
265 |
|
|
|
266 |
|
|
private static class LoadLscpScript extends AbstractAction { |
267 |
|
|
LoadLscpScript() { |
268 |
|
|
super(i18n.getMenuLabel("actions.runScript")); |
269 |
|
|
|
270 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttRunScript")); |
271 |
|
|
putValue(Action.SMALL_ICON, Res.iconLoadScript32); |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
public void |
275 |
|
|
actionPerformed(ActionEvent e) { |
276 |
|
|
((MainFrame)CC.getMainFrame()).runScript(); |
277 |
|
|
} |
278 |
|
|
} |
279 |
|
|
|
280 |
iliev |
787 |
public final static Action addMidiDevice = new AddMidiDevice(); |
281 |
|
|
|
282 |
|
|
private static class AddMidiDevice extends AbstractAction { |
283 |
|
|
AddMidiDevice() { |
284 |
|
|
super(""); |
285 |
|
|
|
286 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttAddMidiDevice")); |
287 |
iliev |
911 |
putValue(Action.SMALL_ICON, Res.iconNew16); |
288 |
iliev |
787 |
} |
289 |
|
|
|
290 |
|
|
public void |
291 |
|
|
actionPerformed(ActionEvent e) { |
292 |
iliev |
842 |
if(!verifyConnection()) return; |
293 |
iliev |
787 |
new NewMidiDeviceDlg(CC.getMainFrame()).setVisible(true); |
294 |
|
|
} |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
public final static Action addAudioDevice = new AddAudioDevice(); |
298 |
|
|
|
299 |
|
|
private static class AddAudioDevice extends AbstractAction { |
300 |
|
|
AddAudioDevice() { |
301 |
|
|
super(""); |
302 |
|
|
|
303 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttAddAudioDevice")); |
304 |
iliev |
911 |
putValue(Action.SMALL_ICON, Res.iconNew16); |
305 |
iliev |
787 |
} |
306 |
|
|
|
307 |
|
|
public void |
308 |
|
|
actionPerformed(ActionEvent e) { |
309 |
iliev |
842 |
if(!verifyConnection()) return; |
310 |
iliev |
787 |
new NewAudioDeviceDlg(CC.getMainFrame()).setVisible(true); |
311 |
|
|
} |
312 |
|
|
} |
313 |
|
|
|
314 |
|
|
// EDIT |
315 |
|
|
public final static Action preferences = new Preferences(); |
316 |
|
|
|
317 |
|
|
private static class Preferences extends AbstractAction { |
318 |
|
|
Preferences() { |
319 |
|
|
super(i18n.getMenuLabel("edit.preferences")); |
320 |
|
|
|
321 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttPrefs")); |
322 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconPreferences32); |
323 |
iliev |
787 |
} |
324 |
|
|
|
325 |
|
|
public void |
326 |
|
|
actionPerformed(ActionEvent e) { new PrefsDlg(CC.getMainFrame()).setVisible(true); } |
327 |
|
|
} |
328 |
iliev |
911 |
|
329 |
|
|
// VIEW |
330 |
|
|
|
331 |
|
|
|
332 |
iliev |
787 |
|
333 |
|
|
// CHANNELS |
334 |
|
|
public final static Action newChannel = new NewChannel(); |
335 |
|
|
public final static Action newChannelWizard = new NewChannelWizard(); |
336 |
|
|
public final static Action duplicateChannels = new DuplicateChannels(); |
337 |
|
|
|
338 |
|
|
public final static Action moveChannelsOnTop = new MoveChannelsOnTop(); |
339 |
|
|
public final static Action moveChannelsUp = new MoveChannelsUp(); |
340 |
|
|
public final static Action moveChannelsDown = new MoveChannelsDown(); |
341 |
|
|
public final static Action moveChannelsAtBottom = new MoveChannelsAtBottom(); |
342 |
|
|
|
343 |
|
|
public final static Action selectAllChannels = new SelectAllChannels(); |
344 |
|
|
public final static Action deselectChannels = new DeselectChannels(); |
345 |
|
|
|
346 |
|
|
public final static Action removeChannels = new RemoveChannels(); |
347 |
|
|
|
348 |
|
|
|
349 |
|
|
private static class NewChannel extends AbstractAction { |
350 |
|
|
NewChannel() { |
351 |
|
|
super(i18n.getMenuLabel("channels.new")); |
352 |
|
|
|
353 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttNewChannel")); |
354 |
iliev |
911 |
putValue(Action.SMALL_ICON, Res.iconNew24); |
355 |
iliev |
787 |
} |
356 |
|
|
|
357 |
|
|
public void |
358 |
iliev |
842 |
actionPerformed(ActionEvent e) { |
359 |
|
|
if(!verifyConnection()) return; |
360 |
iliev |
1143 |
CC.getSamplerModel().addBackendChannel(); |
361 |
iliev |
842 |
} |
362 |
iliev |
787 |
} |
363 |
|
|
|
364 |
|
|
private static class NewChannelWizard extends AbstractAction { |
365 |
|
|
NewChannelWizard() { |
366 |
|
|
super(i18n.getMenuLabel("channels.wizard")); |
367 |
|
|
|
368 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttNewChannelWizard")); |
369 |
|
|
} |
370 |
|
|
|
371 |
|
|
public void |
372 |
|
|
actionPerformed(ActionEvent e) { |
373 |
iliev |
842 |
new org.jsampler.view.classic.NewChannelWizard().showWizard(); |
374 |
iliev |
787 |
} |
375 |
|
|
} |
376 |
|
|
|
377 |
|
|
private static class DuplicateChannels extends AbstractAction { |
378 |
|
|
DuplicateChannels() { |
379 |
|
|
super(i18n.getMenuLabel("channels.duplicate")); |
380 |
|
|
|
381 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttDuplicateChannels")); |
382 |
iliev |
911 |
putValue(Action.SMALL_ICON, Res.iconCopy24); |
383 |
iliev |
787 |
|
384 |
|
|
setEnabled(false); |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
public void |
388 |
|
|
actionPerformed(ActionEvent e) { |
389 |
|
|
JSChannel[] channels = |
390 |
|
|
CC.getMainFrame().getSelectedChannelsPane().getSelectedChannels(); |
391 |
|
|
|
392 |
|
|
if(channels.length > 2) { |
393 |
|
|
if(!HF.showYesNoDialog ( |
394 |
|
|
CC.getMainFrame(), |
395 |
|
|
i18n.getMessage("A4n.duplicateChannels?") |
396 |
|
|
)) return; |
397 |
|
|
} |
398 |
|
|
|
399 |
|
|
CC.getTaskQueue().add ( |
400 |
|
|
new org.jsampler.task.DuplicateChannels(channels) |
401 |
|
|
); |
402 |
|
|
} |
403 |
|
|
} |
404 |
|
|
|
405 |
|
|
private static class MoveChannelsOnTop extends AbstractAction { |
406 |
|
|
MoveChannelsOnTop() { |
407 |
|
|
super(i18n.getMenuLabel("channels.MoveOnTop")); |
408 |
|
|
|
409 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveChannelsOnTop")); |
410 |
|
|
setEnabled(false); |
411 |
|
|
} |
412 |
|
|
|
413 |
|
|
public void |
414 |
|
|
actionPerformed(ActionEvent e) { |
415 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
416 |
|
|
p.moveSelectedChannelsOnTop(); |
417 |
|
|
} |
418 |
|
|
} |
419 |
|
|
|
420 |
|
|
private static class MoveChannelsUp extends AbstractAction { |
421 |
|
|
MoveChannelsUp() { |
422 |
|
|
super(i18n.getMenuLabel("channels.MoveUp")); |
423 |
|
|
|
424 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveChannelsUp")); |
425 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconUp24); |
426 |
iliev |
787 |
|
427 |
|
|
setEnabled(false); |
428 |
|
|
} |
429 |
|
|
|
430 |
|
|
public void |
431 |
|
|
actionPerformed(ActionEvent e) { |
432 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
433 |
|
|
p.moveSelectedChannelsUp(); |
434 |
|
|
} |
435 |
|
|
} |
436 |
|
|
|
437 |
|
|
private static class MoveChannelsDown extends AbstractAction { |
438 |
|
|
MoveChannelsDown() { |
439 |
|
|
super(i18n.getMenuLabel("channels.MoveDown")); |
440 |
|
|
|
441 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveChannelsDown")); |
442 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconDown24); |
443 |
iliev |
787 |
|
444 |
|
|
setEnabled(false); |
445 |
|
|
} |
446 |
|
|
|
447 |
|
|
public void |
448 |
|
|
actionPerformed(ActionEvent e) { |
449 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
450 |
|
|
p.moveSelectedChannelsDown(); |
451 |
|
|
} |
452 |
|
|
} |
453 |
|
|
|
454 |
|
|
private static class MoveChannelsAtBottom extends AbstractAction { |
455 |
|
|
MoveChannelsAtBottom() { |
456 |
|
|
super(i18n.getMenuLabel("channels.MoveAtBottom")); |
457 |
|
|
|
458 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveChannelsAtBottom")); |
459 |
|
|
setEnabled(false); |
460 |
|
|
} |
461 |
|
|
|
462 |
|
|
public void |
463 |
|
|
actionPerformed(ActionEvent e) { |
464 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
465 |
|
|
p.moveSelectedChannelsAtBottom(); |
466 |
|
|
} |
467 |
|
|
} |
468 |
|
|
|
469 |
|
|
public static class |
470 |
|
|
MoveChannelsTo extends AbstractAction implements PropertyChangeListener { |
471 |
|
|
private final JSChannelsPane pane; |
472 |
|
|
|
473 |
|
|
MoveChannelsTo(JSChannelsPane pane) { |
474 |
|
|
super(pane.getTitle()); |
475 |
|
|
|
476 |
|
|
this.pane = pane; |
477 |
|
|
|
478 |
|
|
String desc = i18n.getMenuLabel("ttMoveChannelsTo", pane.getTitle()); |
479 |
|
|
putValue(SHORT_DESCRIPTION, desc); |
480 |
|
|
pane.addPropertyChangeListener(JSChannelsPane.TITLE, this); |
481 |
|
|
} |
482 |
|
|
|
483 |
|
|
public void |
484 |
|
|
actionPerformed(ActionEvent e) { |
485 |
|
|
JSChannelsPane acp = CC.getMainFrame().getSelectedChannelsPane(); |
486 |
|
|
JSChannel[] chns = acp.getSelectedChannels(); |
487 |
|
|
|
488 |
|
|
for(JSChannel c : chns) acp.removeChannel(c); |
489 |
|
|
|
490 |
|
|
pane.addChannels(chns); |
491 |
|
|
|
492 |
|
|
CC.getMainFrame().setSelectedChannelsPane(pane); |
493 |
|
|
|
494 |
|
|
} |
495 |
|
|
|
496 |
|
|
public void |
497 |
|
|
propertyChange(PropertyChangeEvent e) { |
498 |
|
|
putValue(NAME, pane.getTitle()); |
499 |
|
|
|
500 |
|
|
String desc = i18n.getMenuLabel("ttMoveChannelsTo", pane.getTitle()); |
501 |
|
|
putValue(SHORT_DESCRIPTION, desc); |
502 |
|
|
} |
503 |
|
|
|
504 |
|
|
public JSChannelsPane |
505 |
|
|
getChannelsPane() { return pane; } |
506 |
|
|
} |
507 |
|
|
|
508 |
|
|
private static class SelectAllChannels extends AbstractAction { |
509 |
|
|
SelectAllChannels() { |
510 |
|
|
super(i18n.getMenuLabel("channels.selectAll")); |
511 |
|
|
|
512 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttSelectAllChannels")); |
513 |
|
|
} |
514 |
|
|
|
515 |
|
|
public void |
516 |
|
|
actionPerformed(ActionEvent e) { |
517 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
518 |
|
|
p.selectAllChannels(); |
519 |
|
|
} |
520 |
|
|
} |
521 |
|
|
|
522 |
|
|
private static class DeselectChannels extends AbstractAction { |
523 |
|
|
DeselectChannels() { |
524 |
|
|
super(i18n.getMenuLabel("channels.selectNone")); |
525 |
|
|
|
526 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttDeselectChannels")); |
527 |
|
|
} |
528 |
|
|
|
529 |
|
|
public void |
530 |
|
|
actionPerformed(ActionEvent e) { |
531 |
|
|
ChannelsPane p = (ChannelsPane)CC.getMainFrame().getSelectedChannelsPane(); |
532 |
|
|
p.deselectChannels(); |
533 |
|
|
} |
534 |
|
|
} |
535 |
|
|
|
536 |
|
|
private static class RemoveChannels extends AbstractAction { |
537 |
|
|
RemoveChannels() { |
538 |
|
|
super(i18n.getMenuLabel("channels.RemoveChannel")); |
539 |
|
|
|
540 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttRemoveChannels")); |
541 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconDelete24); |
542 |
iliev |
787 |
|
543 |
|
|
setEnabled(false); |
544 |
|
|
} |
545 |
|
|
|
546 |
|
|
public void |
547 |
|
|
actionPerformed(ActionEvent e) { |
548 |
|
|
JSChannelsPane p = CC.getMainFrame().getSelectedChannelsPane(); |
549 |
|
|
if(p.getSelectedChannelCount() > 1) |
550 |
|
|
if(!HF.showYesNoDialog ( |
551 |
|
|
CC.getMainFrame(), i18n.getMessage("A4n.removeChannels?") |
552 |
|
|
)) return; |
553 |
|
|
|
554 |
|
|
JSChannel[] chnS = p.getSelectedChannels(); |
555 |
|
|
|
556 |
|
|
for(JSChannel c : chnS) removeChannel(c); |
557 |
|
|
} |
558 |
|
|
|
559 |
|
|
private void |
560 |
|
|
removeChannel(final JSChannel c) { |
561 |
|
|
final JSChannelsPane p = CC.getMainFrame().getSelectedChannelsPane(); |
562 |
iliev |
1143 |
int id = c.getChannelInfo().getChannelId(); |
563 |
iliev |
787 |
|
564 |
iliev |
1143 |
CC.getSamplerModel().removeBackendChannel(id); |
565 |
iliev |
787 |
} |
566 |
|
|
} |
567 |
|
|
|
568 |
|
|
// TABS |
569 |
|
|
public final static Action newChannelsTab = new NewChannelsTab(); |
570 |
|
|
|
571 |
|
|
public final static Action editTabTitle = new EditTabTitle(); |
572 |
|
|
|
573 |
|
|
public final static Action moveTab2Beginning = new MoveTab2Beginning(); |
574 |
|
|
public final static Action moveTab2Left = new MoveTab2Left(); |
575 |
|
|
public final static Action moveTab2Right = new MoveTab2Right(); |
576 |
|
|
public final static Action moveTab2End = new MoveTab2End(); |
577 |
|
|
|
578 |
|
|
public final static Action closeChannelsTab = new CloseChannelsTab(); |
579 |
|
|
|
580 |
|
|
|
581 |
|
|
private static class NewChannelsTab extends AbstractAction { |
582 |
|
|
NewChannelsTab() { |
583 |
|
|
super(i18n.getMenuLabel("tabs.new")); |
584 |
|
|
|
585 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttNewTab")); |
586 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconTabNew22); |
587 |
iliev |
787 |
} |
588 |
|
|
|
589 |
|
|
public void |
590 |
|
|
actionPerformed(ActionEvent e) { |
591 |
|
|
new NewChannelsTabDlg(CC.getMainFrame()).setVisible(true); |
592 |
|
|
} |
593 |
|
|
} |
594 |
|
|
|
595 |
|
|
private static class EditTabTitle extends AbstractAction { |
596 |
|
|
EditTabTitle() { |
597 |
|
|
super(i18n.getMenuLabel("tabs.changeTitle")); |
598 |
|
|
|
599 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttEditTabTitle")); |
600 |
|
|
setEnabled(false); |
601 |
|
|
} |
602 |
|
|
|
603 |
|
|
public void |
604 |
|
|
actionPerformed(ActionEvent e) { |
605 |
|
|
new ChangeTabTitleDlg(CC.getMainFrame()).setVisible(true); |
606 |
|
|
} |
607 |
|
|
} |
608 |
|
|
|
609 |
|
|
private static class MoveTab2Beginning extends AbstractAction { |
610 |
|
|
MoveTab2Beginning() { |
611 |
|
|
super(i18n.getMenuLabel("tabs.move2Beginning")); |
612 |
|
|
|
613 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveTab2Beginning")); |
614 |
|
|
setEnabled(false); |
615 |
|
|
} |
616 |
|
|
|
617 |
|
|
public void |
618 |
|
|
actionPerformed(ActionEvent e) { |
619 |
|
|
((MainFrame)CC.getMainFrame()).moveTab2Beginning(); |
620 |
|
|
} |
621 |
|
|
} |
622 |
|
|
|
623 |
|
|
private static class MoveTab2Left extends AbstractAction { |
624 |
|
|
MoveTab2Left() { |
625 |
|
|
super(i18n.getMenuLabel("tabs.move2Left")); |
626 |
|
|
|
627 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveTab2Left")); |
628 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconTabMoveLeft22); |
629 |
iliev |
787 |
setEnabled(false); |
630 |
|
|
} |
631 |
|
|
|
632 |
|
|
public void |
633 |
|
|
actionPerformed(ActionEvent e) { ((MainFrame)CC.getMainFrame()).moveTab2Left(); } |
634 |
|
|
} |
635 |
|
|
|
636 |
|
|
private static class MoveTab2Right extends AbstractAction { |
637 |
|
|
MoveTab2Right() { |
638 |
|
|
super(i18n.getMenuLabel("tabs.move2Right")); |
639 |
|
|
|
640 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveTab2Right")); |
641 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconTabMoveRight22); |
642 |
iliev |
787 |
setEnabled(false); |
643 |
|
|
} |
644 |
|
|
|
645 |
|
|
public void |
646 |
|
|
actionPerformed(ActionEvent e) { ((MainFrame)CC.getMainFrame()).moveTab2Right(); } |
647 |
|
|
} |
648 |
|
|
|
649 |
|
|
private static class MoveTab2End extends AbstractAction { |
650 |
|
|
MoveTab2End() { |
651 |
|
|
super(i18n.getMenuLabel("tabs.move2End")); |
652 |
|
|
|
653 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttMoveTab2End")); |
654 |
|
|
setEnabled(false); |
655 |
|
|
} |
656 |
|
|
|
657 |
|
|
public void |
658 |
|
|
actionPerformed(ActionEvent e) { ((MainFrame)CC.getMainFrame()).moveTab2End(); } |
659 |
|
|
} |
660 |
|
|
|
661 |
|
|
private static class CloseChannelsTab extends AbstractAction { |
662 |
|
|
CloseChannelsTab() { |
663 |
|
|
super(i18n.getMenuLabel("tabs.close")); |
664 |
|
|
|
665 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttCloseTab")); |
666 |
iliev |
1143 |
putValue(Action.SMALL_ICON, Res.iconTabRemove22); |
667 |
iliev |
787 |
setEnabled(false); |
668 |
|
|
} |
669 |
|
|
|
670 |
|
|
public void |
671 |
|
|
actionPerformed(ActionEvent e) { |
672 |
|
|
JSMainFrame frm = CC.getMainFrame(); |
673 |
|
|
JSChannelsPane chnPane = frm.getSelectedChannelsPane(); |
674 |
|
|
if(chnPane.getChannelCount() > 0) { |
675 |
|
|
CloseTabDlg dlg = new CloseTabDlg(frm); |
676 |
|
|
dlg.setVisible(true); |
677 |
|
|
if(dlg.isCancelled()) return; |
678 |
|
|
|
679 |
|
|
JSChannel[] chns = chnPane.getChannels(); |
680 |
|
|
|
681 |
|
|
if(dlg.remove()) { |
682 |
|
|
|
683 |
|
|
|
684 |
|
|
} else { |
685 |
|
|
JSChannelsPane p = dlg.getSelectedChannelsPane(); |
686 |
|
|
for(JSChannel c : chns) { |
687 |
|
|
chnPane.removeChannel(c); |
688 |
|
|
} |
689 |
|
|
p.addChannels(chns); |
690 |
|
|
frm.setSelectedChannelsPane(p); |
691 |
|
|
} |
692 |
|
|
} |
693 |
|
|
|
694 |
|
|
frm.removeChannelsPane(chnPane); |
695 |
|
|
} |
696 |
|
|
} |
697 |
iliev |
1204 |
|
698 |
|
|
// WINDOW |
699 |
|
|
public final static WindowInstrumentsDb windowInstrumentsDb = new WindowInstrumentsDb(); |
700 |
|
|
|
701 |
|
|
private static class WindowInstrumentsDb extends AbstractAction { |
702 |
|
|
InstrumentsDbFrame instrumentsDbFrame = null; |
703 |
|
|
|
704 |
|
|
WindowInstrumentsDb() { |
705 |
|
|
super(i18n.getMenuLabel("window.instrumentsDb")); |
706 |
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.instrumentsDb.tt")); |
707 |
|
|
putValue(Action.SMALL_ICON, Res.iconDb32); |
708 |
|
|
} |
709 |
|
|
|
710 |
|
|
public void |
711 |
|
|
actionPerformed(ActionEvent e) { |
712 |
|
|
if(CC.getInstrumentsDbTreeModel() == null) { |
713 |
|
|
String s = i18n.getMessage("A4n.noInstrumentsDbSupport!"); |
714 |
|
|
HF.showErrorMessage(s, CC.getMainFrame()); |
715 |
|
|
return; |
716 |
|
|
} |
717 |
|
|
|
718 |
|
|
if(instrumentsDbFrame != null && instrumentsDbFrame.isVisible()) { |
719 |
|
|
instrumentsDbFrame.toFront(); |
720 |
|
|
return; |
721 |
|
|
} |
722 |
|
|
|
723 |
|
|
instrumentsDbFrame = new InstrumentsDbFrame(); |
724 |
|
|
instrumentsDbFrame.setVisible(true); |
725 |
|
|
} |
726 |
|
|
} |
727 |
|
|
|
728 |
iliev |
787 |
// HELP |
729 |
|
|
public final static HelpAbout helpAbout = new HelpAbout(); |
730 |
|
|
|
731 |
|
|
private static class HelpAbout extends AbstractAction { |
732 |
|
|
HelpAbout() { |
733 |
|
|
super(i18n.getMenuLabel("help.about", "JS Classic")); |
734 |
|
|
} |
735 |
|
|
|
736 |
|
|
public void |
737 |
|
|
actionPerformed(ActionEvent e) { |
738 |
|
|
new HelpAboutDlg(CC.getMainFrame()).setVisible(true); |
739 |
|
|
} |
740 |
|
|
} |
741 |
|
|
} |