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