/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/NormalChannelOptionsView.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/NormalChannelOptionsView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1743 - (show annotations) (download)
Sat May 31 23:04:01 2008 UTC (15 years, 10 months ago) by iliev
File size: 19493 byte(s)
* Renamed the column labels in the Channel Routing dialog: The column
  representing the sampler channel's audio channels is "Audio In" and
  the column representing the audio device's channels is "Audio Out"
* Remember the last used tab in the Preferences dialog
* Fantasia: The sampler channels are now referenced by their position
  in the list, not by their ID
* Fantasia: Implemented options to show the channel number and/or the MIDI
  input port/channel on the sampler channel screen when using Small View
  (choose Edit/Preferences, then click the `Channels' tab)
* Fantasia: Migrated to substance 5

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 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.BorderLayout;
26 import java.awt.Dimension;
27 import java.awt.Insets;
28
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31
32 import java.util.logging.Level;
33
34 import javax.swing.BorderFactory;
35 import javax.swing.Box;
36 import javax.swing.BoxLayout;
37 import javax.swing.JComboBox;
38 import javax.swing.JComponent;
39 import javax.swing.JLabel;
40 import javax.swing.JPanel;
41 import javax.swing.SwingConstants;
42
43 import org.jsampler.AudioDeviceModel;
44 import org.jsampler.CC;
45 import org.jsampler.MidiDeviceModel;
46 import org.jsampler.MidiInstrumentMap;
47 import org.jsampler.SamplerModel;
48
49 import org.jsampler.event.ListEvent;
50 import org.jsampler.event.ListListener;
51 import org.jsampler.event.MidiDeviceEvent;
52 import org.jsampler.event.MidiDeviceListEvent;
53 import org.jsampler.event.MidiDeviceListListener;
54 import org.jsampler.event.MidiDeviceListener;
55 import org.jsampler.event.SamplerAdapter;
56 import org.jsampler.event.SamplerChannelAdapter;
57 import org.jsampler.event.SamplerChannelEvent;
58 import org.jsampler.event.SamplerEvent;
59 import org.jsampler.event.SamplerListener;
60
61 import org.jsampler.view.std.JSChannelOutputRoutingDlg;
62
63 import org.linuxsampler.lscp.AudioOutputDevice;
64 import org.linuxsampler.lscp.MidiInputDevice;
65 import org.linuxsampler.lscp.MidiPort;
66 import org.linuxsampler.lscp.SamplerChannel;
67
68 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
69
70 /**
71 *
72 * @author Grigor Iliev
73 */
74 public class NormalChannelOptionsView extends JPanel implements ChannelOptionsView {
75 private final Channel channel;
76 private MidiDeviceModel midiDevice = null;
77
78 private final JComboBox cbMidiDevice = new FantasiaComboBox();
79 private final JComboBox cbMidiPort = new FantasiaComboBox();
80 private final JComboBox cbMidiChannel = new FantasiaComboBox();
81 private final JComboBox cbInstrumentMap = new FantasiaComboBox();
82 private final JComboBox cbAudioDevice = new FantasiaComboBox();
83
84 private final PixmapButton btnChannelRouting;
85
86 private boolean update = false;
87
88 private final SamplerListener samplerListener;
89 private final MapListListener mapListListener = new MapListListener();
90
91 private class NoMap {
92 public String
93 toString() { return "[None]"; }
94 }
95
96 private NoMap noMap = new NoMap();
97
98 private class DefaultMap {
99 public String
100 toString() { return "[Default]"; }
101 }
102
103 private DefaultMap defaultMap = new DefaultMap();
104
105 /** Creates a new instance of <code>NormalChannelOptionsView</code> */
106 public
107 NormalChannelOptionsView(final Channel channel) {
108 setLayout(new BorderLayout());
109 PixmapPane bgp = new PixmapPane(Res.gfxChannelOptions);
110 bgp.setPixmapInsets(new Insets(1, 1, 1, 1));
111
112 this.channel = channel;
113
114 bgp.setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4));
115 bgp.setLayout(new BoxLayout(bgp, BoxLayout.X_AXIS));
116
117 bgp.setPreferredSize(new Dimension(420, 44));
118 bgp.setMinimumSize(getPreferredSize());
119 bgp.setMaximumSize(getPreferredSize());
120
121 JPanel p = new FantasiaPanel();
122 p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4));
123 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
124 JLabel l = new JLabel(Res.gfxMidiInputTitle);
125 l.setAlignmentX(LEFT_ALIGNMENT);
126 p.add(l);
127
128 JPanel p2 = new FantasiaPanel();
129 p2.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
130 p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
131
132 Object o = cbMidiDevice.getRenderer();
133 if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER);
134
135 cbMidiDevice.setPreferredSize(new Dimension(40, 18));
136 cbMidiDevice.setMinimumSize(cbMidiDevice.getPreferredSize());
137 cbMidiDevice.setMaximumSize(cbMidiDevice.getPreferredSize());
138 p2.add(cbMidiDevice);
139
140 p2.add(Box.createRigidArea(new Dimension(3, 0)));
141
142 o = cbMidiPort.getRenderer();
143 if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER);
144
145 cbMidiPort.setPreferredSize(new Dimension(62, 18));
146 cbMidiPort.setMinimumSize(cbMidiPort.getPreferredSize());
147 cbMidiPort.setMaximumSize(cbMidiPort.getPreferredSize());
148 p2.add(cbMidiPort);
149
150 p2.add(Box.createRigidArea(new Dimension(3, 0)));
151
152 o = cbMidiChannel.getRenderer();
153 if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER);
154
155 cbMidiChannel.addItem("All");
156 for(int i = 1; i <= 16; i++) cbMidiChannel.addItem("Channel " + String.valueOf(i));
157 cbMidiChannel.setPreferredSize(new Dimension(84, 18));
158 cbMidiChannel.setMinimumSize(cbMidiChannel.getPreferredSize());
159 cbMidiChannel.setMaximumSize(cbMidiChannel.getPreferredSize());
160
161 p2.add(cbMidiChannel);
162 p2.setAlignmentX(LEFT_ALIGNMENT);
163 p2.setOpaque(false);
164 p.add(p2);
165 p.setBackground(new java.awt.Color(0x818181));
166
167 bgp.add(p);
168
169 bgp.add(Box.createRigidArea(new Dimension(4, 0)));
170
171 p = new FantasiaPanel();
172 p.setOpaque(true);
173 p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4));
174 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
175 l = new JLabel(Res.gfxInstrumentMapTitle);
176 l.setAlignmentX(LEFT_ALIGNMENT);
177 l.setAlignmentX(LEFT_ALIGNMENT);
178 p.add(l);
179
180 p.add(Box.createRigidArea(new Dimension(0, 3)));
181
182 //o = cbInstrumentMap.getRenderer();
183 //if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER);
184
185 cbInstrumentMap.setPreferredSize(new Dimension(122, 18));
186 cbInstrumentMap.setMinimumSize(cbInstrumentMap.getPreferredSize());
187 cbInstrumentMap.setMaximumSize(cbInstrumentMap.getPreferredSize());
188 cbInstrumentMap.setAlignmentX(LEFT_ALIGNMENT);
189 p.add(cbInstrumentMap);
190 p.setBackground(new java.awt.Color(0x818181));
191 bgp.add(p);
192
193 bgp.add(Box.createRigidArea(new Dimension(4, 0)));
194
195 p = new FantasiaPanel();
196 p.setOpaque(true);
197 p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4));
198 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
199 l = new JLabel(Res.gfxAudioOutputTitle);
200 l.setAlignmentX(LEFT_ALIGNMENT);
201 p.add(l);
202
203 //p.add(Box.createRigidArea(new Dimension(0, 3)));
204
205 p2 = new FantasiaPanel();
206 p2.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
207 p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
208 p2.setOpaque(false);
209 p2.setAlignmentX(LEFT_ALIGNMENT);
210
211 o = cbAudioDevice.getRenderer();
212 if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.RIGHT);
213
214 cbAudioDevice.setPreferredSize(new Dimension(40, 18));
215 cbAudioDevice.setMinimumSize(cbAudioDevice.getPreferredSize());
216 cbAudioDevice.setMaximumSize(cbAudioDevice.getPreferredSize());
217
218 p2.add(cbAudioDevice);
219 p2.add(Box.createRigidArea(new Dimension(3, 0)));
220 btnChannelRouting = new PixmapButton(Res.gfxBtnCr, Res.gfxBtnCrRO);
221 btnChannelRouting.setPressedIcon(Res.gfxBtnCrRO);
222 btnChannelRouting.setEnabled(false);
223 btnChannelRouting.setToolTipText(i18n.getLabel("ChannelOptions.routing"));
224
225 btnChannelRouting.addActionListener(new ActionListener() {
226 public void
227 actionPerformed(ActionEvent e) {
228 SamplerChannel c = channel.getChannelInfo();
229 new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);
230
231 }
232 });
233
234 p2.add(btnChannelRouting);
235
236 p.add(p2);
237 p.setBackground(new java.awt.Color(0x818181));
238 p2 = new FantasiaPanel();
239 p2.setLayout(new java.awt.BorderLayout());
240 p.add(p2);
241 bgp.add(p);
242
243 add(bgp);
244
245 cbMidiDevice.addActionListener(new ActionListener() {
246 public void
247 actionPerformed(ActionEvent e) { setMidiDevice(); }
248 });
249
250 cbMidiPort.addActionListener(new ActionListener() {
251 public void
252 actionPerformed(ActionEvent e) { setMidiPort(); }
253 });
254
255 cbMidiChannel.addActionListener(new ActionListener() {
256 public void
257 actionPerformed(ActionEvent e) { setMidiChannel(); }
258 });
259
260 samplerListener = new SamplerAdapter() {
261 /** Invoked when the default MIDI instrument map is changed. */
262 public void
263 defaultMapChanged(SamplerEvent e) {
264 updateCbInstrumentMapToolTipText();
265
266 }
267 };
268
269 CC.getSamplerModel().addSamplerListener(samplerListener);
270
271 cbInstrumentMap.addItem(noMap);
272 cbInstrumentMap.addItem(defaultMap);
273 for(MidiInstrumentMap map : CC.getSamplerModel().getMidiInstrumentMaps()) {
274 cbInstrumentMap.addItem(map);
275 }
276
277 int map = channel.getModel().getChannelInfo().getMidiInstrumentMapId();
278 cbInstrumentMap.setSelectedItem(CC.getSamplerModel().getMidiInstrumentMapById(map));
279 if(cbInstrumentMap.getSelectedItem() == null) {
280 if(map == -1) cbInstrumentMap.setSelectedItem(noMap);
281 else if(map == -2) {
282 cbInstrumentMap.setSelectedItem(defaultMap);
283 }
284 }
285
286 updateCbInstrumentMapToolTipText();
287
288 if(channel.getModel().getChannelInfo().getEngine() == null) {
289 cbInstrumentMap.setEnabled(false);
290 }
291
292 cbInstrumentMap.addActionListener(new ActionListener() {
293 public void
294 actionPerformed(ActionEvent e) { updateInstrumentMap(); }
295 });
296
297 CC.getSamplerModel().addMidiInstrumentMapListListener(mapListListener);
298
299 cbAudioDevice.addActionListener(new ActionListener() {
300 public void
301 actionPerformed(ActionEvent e) { setBackendAudioDevice(); }
302 });
303
304 channel.getModel().addSamplerChannelListener(new SamplerChannelAdapter() {
305 public void
306 channelChanged(SamplerChannelEvent e) { updateChannelProperties(); }
307 });
308
309 CC.getSamplerModel().addMidiDeviceListListener(getHandler());
310 CC.getSamplerModel().addAudioDeviceListListener(getHandler());
311
312 updateMidiDevices();
313 updateAudioDevices();
314 updateChannelProperties();
315 }
316
317 //////////////////////////////////////////////
318 // Implementation of the ChannelOptionsView interface
319 //////////////////////////////////////////////
320
321 public JComponent
322 getComponent() { return this; }
323
324 public void
325 installView() { }
326
327 public void
328 uninstallView() {
329 onDestroy();
330 }
331
332 public void
333 updateChannelInfo() {
334
335 }
336
337 //////////////////////////////////////////////
338
339 /**
340 * Updates the channel settings. This method is invoked when changes to the
341 * channel were made.
342 */
343 private void
344 updateChannelProperties() {
345 SamplerModel sm = CC.getSamplerModel();
346 SamplerChannel sc = channel.getModel().getChannelInfo();
347
348 MidiDeviceModel mm = sm.getMidiDeviceById(sc.getMidiInputDevice());
349 AudioDeviceModel am = sm.getAudioDeviceById(sc.getAudioOutputDevice());
350
351 if(isUpdate()) CC.getLogger().warning("Unexpected update state!");
352
353 setUpdate(true);
354
355 try {
356 cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo());
357
358 cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
359 btnChannelRouting.setEnabled(am != null);
360 } catch(Exception x) {
361 CC.getLogger().log(Level.WARNING, "Unkown error", x);
362 }
363
364 if(sc.getEngine() != null) {
365 cbInstrumentMap.setEnabled(true);
366 int id = sc.getMidiInstrumentMapId();
367 Object o;
368 if(id == -2) o = defaultMap;
369 else if(id == -1) o = noMap;
370 else o = CC.getSamplerModel().getMidiInstrumentMapById(id);
371
372 if(cbInstrumentMap.getSelectedItem() != o) {
373 cbInstrumentMap.setSelectedItem(o);
374 }
375 } else {
376 cbInstrumentMap.setSelectedItem(noMap);
377 cbInstrumentMap.setEnabled(false);
378 }
379
380 setUpdate(false);
381 }
382
383 /**
384 * Updates the MIDI device list.
385 */
386 private void
387 updateMidiDevices() {
388 SamplerModel sm = CC.getSamplerModel();
389 SamplerChannel sc = channel.getModel().getChannelInfo();
390
391 setUpdate(true);
392
393 try {
394 cbMidiDevice.removeAllItems();
395
396 for(MidiDeviceModel m : sm.getMidiDevices())
397 cbMidiDevice.addItem(m.getDeviceInfo());
398
399 MidiDeviceModel mm = sm.getMidiDeviceById(sc.getMidiInputDevice());
400 cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo());
401 } catch(Exception x) {
402 CC.getLogger().log(Level.WARNING, "Unkown error", x);
403 }
404
405 setUpdate(false);
406 }
407
408
409 private void
410 updateInstrumentMap() {
411 updateCbInstrumentMapToolTipText();
412
413 int id = channel.getModel().getChannelInfo().getMidiInstrumentMapId();
414 Object o = cbInstrumentMap.getSelectedItem();
415 if(o == null && id == -1) return;
416
417 int cbId;
418 if(o == null || o == noMap) cbId = -1;
419 else if(o == defaultMap) cbId = -2;
420 else cbId = ((MidiInstrumentMap)o).getMapId();
421
422 if(cbId == id) return;
423
424 channel.getModel().setBackendMidiInstrumentMap(cbId);
425 }
426
427 private void
428 updateCbInstrumentMapToolTipText() {
429 if(cbInstrumentMap.getSelectedItem() != defaultMap) {
430 cbInstrumentMap.setToolTipText(null);
431 return;
432 }
433
434 MidiInstrumentMap m = CC.getSamplerModel().getDefaultMidiInstrumentMap();
435 if(m != null) {
436 String s = i18n.getLabel("Channel.ttDefault", m.getName());
437 cbInstrumentMap.setToolTipText(s);
438 } else {
439 cbInstrumentMap.setToolTipText(null);
440 }
441 }
442
443 /**
444 * Updates the audio device list.
445 */
446 private void
447 updateAudioDevices() {
448 SamplerModel sm = CC.getSamplerModel();
449 SamplerChannel sc = channel.getModel().getChannelInfo();
450
451 setUpdate(true);
452
453 try {
454 cbAudioDevice.removeAllItems();
455
456 for(AudioDeviceModel m : sm.getAudioDevices())
457 cbAudioDevice.addItem(m.getDeviceInfo());
458
459 AudioDeviceModel am = sm.getAudioDeviceById(sc.getAudioOutputDevice());
460 cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
461 } catch(Exception x) {
462 CC.getLogger().log(Level.WARNING, "Unkown error", x);
463 }
464
465 setUpdate(false);
466 }
467
468 private void
469 setMidiDevice() {
470 MidiInputDevice mid = (MidiInputDevice)cbMidiDevice.getSelectedItem();
471
472 if(!isUpdate()) {
473 if(mid != null) {
474 channel.getModel().setBackendMidiInputDevice(mid.getDeviceId());
475 }
476
477 return;
478 }
479
480 if(midiDevice != null) midiDevice.removeMidiDeviceListener(getHandler());
481
482 cbMidiPort.removeAllItems();
483
484 if(mid == null) {
485 midiDevice = null;
486 cbMidiPort.setEnabled(false);
487
488 cbMidiChannel.setSelectedItem(null);
489 cbMidiChannel.setEnabled(false);
490 } else {
491 midiDevice = CC.getSamplerModel().getMidiDeviceById(mid.getDeviceId());
492 if(midiDevice != null) midiDevice.addMidiDeviceListener(getHandler());
493
494 cbMidiPort.setEnabled(true);
495
496 MidiPort[] ports = mid.getMidiPorts();
497 for(MidiPort port : ports) cbMidiPort.addItem(port);
498
499 int p = channel.getModel().getChannelInfo().getMidiInputPort();
500 cbMidiPort.setSelectedItem(p >= 0 && p < ports.length ? ports[p] : null);
501
502 cbMidiChannel.setEnabled(true);
503 int c = channel.getModel().getChannelInfo().getMidiInputChannel();
504 cbMidiChannel.setSelectedItem(c == -1 ? "All" : "Channel " + (c + 1));
505 }
506 }
507
508 private void
509 setMidiPort() {
510 if(isUpdate()) return;
511
512 channel.getModel().setBackendMidiInputPort(cbMidiPort.getSelectedIndex());
513 }
514
515 private void
516 setMidiChannel() {
517 if(isUpdate()) return;
518
519 Object o = cbMidiChannel.getSelectedItem();
520 if(o == null) return;
521 String s = o.toString();
522
523 int c = s.equals("All") ? -1 : Integer.parseInt(s.substring(8)) - 1;
524
525 channel.getModel().setBackendMidiInputChannel(c);
526 }
527
528 private void
529 setBackendAudioDevice() {
530 if(isUpdate()) return;
531 AudioOutputDevice dev = (AudioOutputDevice)cbAudioDevice.getSelectedItem();
532 if(dev != null) channel.getModel().setBackendAudioOutputDevice(dev.getDeviceId());
533 }
534
535 /**
536 * Determines whether the currently processed changes are due to update.
537 * @return <code>true</code> if the currently processed changes are due to update and
538 * <code>false</code> if the currently processed changes are due to user input.
539 */
540 private boolean
541 isUpdate() { return update; }
542
543 /**
544 * Sets whether the currently processed changes are due to update.
545 * @param b Specify <code>true</code> to indicate that the currently
546 * processed changes are due to update; <code>false</code>
547 * indicates that the currently processed changes are due to user input.
548 */
549 private void
550 setUpdate(boolean b) { update = b; }
551
552 protected void
553 onDestroy() {
554 SamplerModel sm = CC.getSamplerModel();
555
556 sm.removeMidiDeviceListListener(getHandler());
557 sm.removeAudioDeviceListListener(getHandler());
558 sm.removeMidiInstrumentMapListListener(mapListListener);
559 sm.removeSamplerListener(samplerListener);
560
561 if(midiDevice != null) {
562 midiDevice.removeMidiDeviceListener(getHandler());
563 }
564 }
565
566 private final Handler handler = new Handler();
567
568 private Handler
569 getHandler() { return handler; }
570
571 private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel>,
572 MidiDeviceListener {
573 /**
574 * Invoked when a new MIDI device is created.
575 * @param e A <code>MidiDeviceListEvent</code>
576 * instance providing the event information.
577 */
578 public void
579 deviceAdded(MidiDeviceListEvent e) {
580 cbMidiDevice.addItem(e.getMidiDeviceModel().getDeviceInfo());
581 }
582
583 /**
584 * Invoked when a MIDI device is removed.
585 * @param e A <code>MidiDeviceListEvent</code>
586 * instance providing the event information.
587 */
588 public void
589 deviceRemoved(MidiDeviceListEvent e) {
590 cbMidiDevice.removeItem(e.getMidiDeviceModel().getDeviceInfo());
591 }
592
593 /**
594 * Invoked when a new audio device is created.
595 * @param e An <code>AudioDeviceListEvent</code>
596 * instance providing the event information.
597 */
598 public void
599 entryAdded(ListEvent<AudioDeviceModel> e) {
600 cbAudioDevice.addItem(e.getEntry().getDeviceInfo());
601 }
602
603 /**
604 * Invoked when an audio device is removed.
605 * @param e An <code>AudioDeviceListEvent</code>
606 * instance providing the event information.
607 */
608 public void
609 entryRemoved(ListEvent<AudioDeviceModel> e) {
610 cbAudioDevice.removeItem(e.getEntry().getDeviceInfo());
611 }
612
613 public void
614 settingsChanged(MidiDeviceEvent e) {
615 if(isUpdate()) {
616 CC.getLogger().warning("Invalid update state");
617 return;
618 }
619
620 setUpdate(true);
621 int idx = cbMidiPort.getSelectedIndex();
622 MidiInputDevice d = e.getMidiDeviceModel().getDeviceInfo();
623
624 cbMidiPort.removeAllItems();
625 for(MidiPort port : d.getMidiPorts()) cbMidiPort.addItem(port);
626
627 if(idx >= cbMidiPort.getModel().getSize()) idx = 0;
628
629 setUpdate(false);
630
631 if(cbMidiPort.getModel().getSize() > 0) cbMidiPort.setSelectedIndex(idx);
632 }
633 }
634
635 private class MapListListener implements ListListener<MidiInstrumentMap> {
636 /** Invoked when a new MIDI instrument map is added to a list. */
637 public void
638 entryAdded(ListEvent<MidiInstrumentMap> e) {
639 cbInstrumentMap.insertItemAt(e.getEntry(), cbInstrumentMap.getItemCount());
640 boolean b = channel.getModel().getChannelInfo().getEngine() != null;
641 if(b && !cbInstrumentMap.isEnabled()) cbInstrumentMap.setEnabled(true);
642 }
643
644 /** Invoked when a new MIDI instrument map is removed from a list. */
645 public void
646 entryRemoved(ListEvent<MidiInstrumentMap> e) {
647 cbInstrumentMap.removeItem(e.getEntry());
648 if(cbInstrumentMap.getItemCount() == 0) { // TODO: ?
649 cbInstrumentMap.setSelectedItem(noMap);
650 cbInstrumentMap.setEnabled(false);
651 }
652 }
653 }
654 }

  ViewVC Help
Powered by ViewVC