Subversion Repositories svn.mios

Rev

Rev 716 | Rev 722 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
628 adamjking 1
/*
2
 * @(#)MidiFilterGUI.java   beta8   2006/04/23
3
 *
4
 * Copyright (C) 2008    Adam King (adamjking@optusnet.com.au)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.midi.gui;
22
 
23
import java.awt.BorderLayout;
24
import java.awt.Dimension;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
682 adamjking 27
import java.awt.Insets;
628 adamjking 28
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
703 adamjking 30
import java.io.File;
628 adamjking 31
import java.util.Observable;
32
import java.util.Observer;
33
 
713 adamjking 34
import javax.sound.midi.MetaMessage;
35
import javax.sound.midi.ShortMessage;
36
import javax.sound.midi.SysexMessage;
628 adamjking 37
import javax.swing.BorderFactory;
38
import javax.swing.Box;
682 adamjking 39
import javax.swing.JButton;
628 adamjking 40
import javax.swing.JCheckBox;
703 adamjking 41
import javax.swing.JFileChooser;
628 adamjking 42
import javax.swing.JPanel;
43
import javax.swing.JScrollPane;
44
import javax.swing.JTable;
682 adamjking 45
import javax.swing.JToolBar;
628 adamjking 46
import javax.swing.table.DefaultTableModel;
47
 
48
import org.midibox.midi.MidiFilter;
49
import org.midibox.midi.MidiUtils;
709 adamjking 50
import org.midibox.midi.xml.MidiFilterXML;
682 adamjking 51
import org.midibox.utils.gui.ImageLoader;
703 adamjking 52
import org.midibox.utils.gui.SimpleFileChooserFilter;
628 adamjking 53
 
709 adamjking 54
public class MidiFilterGUI extends JPanel implements Observer, ActionListener {
628 adamjking 55
 
56
    private MidiFilter midiFilter;
57
 
58
    // sysex messages
59
    private JCheckBox sysexMessage;
60
 
61
    // meta messages
62
    private JCheckBox metaMessage;
63
 
64
    // short messages
65
    private JCheckBox activeSensing;
66
 
67
    private JCheckBox channelPressure;
68
 
69
    private JCheckBox continueMessage;
70
 
71
    private JCheckBox controlChange;
72
 
73
    private JCheckBox midiTimeCode;
74
 
75
    private JCheckBox noteOff;
76
 
77
    private JCheckBox noteOn;
78
 
79
    private JCheckBox pitchBend;
80
 
713 adamjking 81
    private JCheckBox polyPressure;
628 adamjking 82
 
83
    private JCheckBox programChange;
84
 
85
    private JCheckBox songPositionPointer;
86
 
87
    private JCheckBox songSelect;
88
 
89
    private JCheckBox start;
90
 
91
    private JCheckBox stop;
92
 
93
    private JCheckBox systemReset;
94
 
95
    private JCheckBox timingClock;
96
 
97
    private JCheckBox tuneRequest;
98
 
99
    private JTable cc;
100
 
101
    private DefaultTableModel ccModel;
102
 
103
    private JTable channels;
104
 
105
    private DefaultTableModel channelsModel;
721 adamjking 106
 
107
    private String definitionTag = "midiFilter";
709 adamjking 108
 
703 adamjking 109
    private static String currentDirectory = "";
628 adamjking 110
 
703 adamjking 111
    private static JFileChooser fc = null;
112
 
628 adamjking 113
    public MidiFilterGUI(MidiFilter midiFilter) {
114
        super(new BorderLayout(5, 5));
115
        this.midiFilter = midiFilter;
116
 
713 adamjking 117
        midiFilter.addObserver(this);
714 adamjking 118
 
628 adamjking 119
        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
120
 
121
        // voice messages
122
        JPanel voicePanel = new JPanel(new GridBagLayout());
123
        GridBagConstraints gbc = new GridBagConstraints();
124
        gbc.gridy = 0;
125
        gbc.anchor = GridBagConstraints.NORTHWEST;
126
        gbc.fill = GridBagConstraints.BOTH;
127
        gbc.weightx = 1.0;
128
 
129
        voicePanel
130
                .setBorder(BorderFactory.createTitledBorder("Voice Messages"));
131
 
714 adamjking 132
        noteOff = new JCheckBox("Note Off", midiFilter
133
                .getVoiceMessage(ShortMessage.NOTE_OFF));
628 adamjking 134
        noteOff.addActionListener(this);
135
        voicePanel.add(noteOff, gbc);
136
        gbc.gridy++;
137
 
714 adamjking 138
        noteOn = new JCheckBox("Note On", midiFilter
139
                .getVoiceMessage(ShortMessage.NOTE_ON));
628 adamjking 140
        noteOn.addActionListener(this);
141
        voicePanel.add(noteOn, gbc);
142
        gbc.gridy++;
143
 
714 adamjking 144
        polyPressure = new JCheckBox("Aftertouch", midiFilter
145
                .getVoiceMessage(ShortMessage.POLY_PRESSURE));
713 adamjking 146
        polyPressure.addActionListener(this);
147
        voicePanel.add(polyPressure, gbc);
628 adamjking 148
        gbc.gridy++;
149
 
714 adamjking 150
        controlChange = new JCheckBox("Control Change", midiFilter
151
                .getVoiceMessage(ShortMessage.CONTROL_CHANGE));
628 adamjking 152
        controlChange.addActionListener(this);
153
        voicePanel.add(controlChange, gbc);
154
        gbc.gridy++;
155
 
714 adamjking 156
        programChange = new JCheckBox("Program Change", midiFilter
157
                .getVoiceMessage(ShortMessage.PROGRAM_CHANGE));
628 adamjking 158
        programChange.addActionListener(this);
159
        voicePanel.add(programChange, gbc);
160
        gbc.gridy++;
161
 
714 adamjking 162
        channelPressure = new JCheckBox("Channel Pressure", midiFilter
163
                .getVoiceMessage(ShortMessage.CHANNEL_PRESSURE));
628 adamjking 164
        channelPressure.addActionListener(this);
165
        voicePanel.add(channelPressure, gbc);
166
        gbc.gridy++;
167
 
714 adamjking 168
        pitchBend = new JCheckBox("Pitch Bend", midiFilter
169
                .getVoiceMessage(ShortMessage.PITCH_BEND));
628 adamjking 170
        pitchBend.addActionListener(this);
171
        voicePanel.add(pitchBend, gbc);
172
        gbc.gridy++;
173
 
174
        gbc.weighty = 1.0;
175
        voicePanel.add(Box.createVerticalGlue(), gbc);
176
 
177
        // sysex messages
178
        JPanel sysexPanel = new JPanel(new GridBagLayout());
179
        gbc.gridy = 0;
180
        gbc.weighty = 0.0;
181
        sysexPanel
182
                .setBorder(BorderFactory.createTitledBorder("Sysex Messages"));
183
 
714 adamjking 184
        sysexMessage = new JCheckBox("Sysex Message", midiFilter
185
                .isSysexMessages());
628 adamjking 186
        sysexMessage.addActionListener(this);
187
        sysexPanel.add(sysexMessage, gbc);
188
        gbc.gridy++;
189
 
190
        gbc.weighty = 1.0;
191
        sysexPanel.add(Box.createVerticalGlue(), gbc);
192
 
193
        // system common
194
        JPanel sysCommon = new JPanel(new GridBagLayout());
195
        gbc.gridy = 0;
196
        gbc.weighty = 0.0;
197
        sysCommon.setBorder(BorderFactory.createTitledBorder("System Common"));
198
 
716 adamjking 199
        midiTimeCode = new JCheckBox("MTC Quarter Frame", midiFilter
714 adamjking 200
                .getSystemCommonMessage(ShortMessage.MIDI_TIME_CODE));
628 adamjking 201
        midiTimeCode.addActionListener(this);
202
        sysCommon.add(midiTimeCode, gbc);
203
        gbc.gridy++;
204
 
714 adamjking 205
        songPositionPointer = new JCheckBox("Song Position Pointer", midiFilter
206
                .getSystemCommonMessage(ShortMessage.SONG_POSITION_POINTER));
628 adamjking 207
        songPositionPointer.addActionListener(this);
208
        sysCommon.add(songPositionPointer, gbc);
209
        gbc.gridy++;
210
 
714 adamjking 211
        songSelect = new JCheckBox("Song Select", midiFilter
212
                .getSystemCommonMessage(ShortMessage.SONG_SELECT));
628 adamjking 213
        songSelect.addActionListener(this);
214
        sysCommon.add(songSelect, gbc);
215
        gbc.gridy++;
216
 
714 adamjking 217
        tuneRequest = new JCheckBox("Tune Request", midiFilter
218
                .getSystemCommonMessage(ShortMessage.TUNE_REQUEST));
628 adamjking 219
        tuneRequest.addActionListener(this);
220
        sysCommon.add(tuneRequest, gbc);
221
        gbc.gridy++;
222
 
223
        gbc.weighty = 1.0;
224
        sysCommon.add(Box.createVerticalGlue(), gbc);
225
 
226
        // system realtime
227
        JPanel sysReal = new JPanel(new GridBagLayout());
228
        gbc.gridy = 0;
229
        gbc.weighty = 0.0;
230
        sysReal.setBorder(BorderFactory.createTitledBorder("System Realtime"));
231
 
714 adamjking 232
        timingClock = new JCheckBox("Timing Clock", midiFilter
233
                .getSystemRealtimeMessage(ShortMessage.TIMING_CLOCK));
628 adamjking 234
        timingClock.addActionListener(this);
235
        sysReal.add(timingClock, gbc);
236
        gbc.gridy++;
237
 
714 adamjking 238
        start = new JCheckBox("Start", midiFilter
239
                .getSystemRealtimeMessage(ShortMessage.START));
628 adamjking 240
        start.addActionListener(this);
241
        sysReal.add(start, gbc);
242
        gbc.gridy++;
243
 
714 adamjking 244
        continueMessage = new JCheckBox("Continue", midiFilter
245
                .getSystemRealtimeMessage(ShortMessage.CONTINUE));
628 adamjking 246
        continueMessage.addActionListener(this);
247
        sysReal.add(continueMessage, gbc);
248
        gbc.gridy++;
249
 
714 adamjking 250
        stop = new JCheckBox("Stop", midiFilter
251
                .getSystemRealtimeMessage(ShortMessage.STOP));
628 adamjking 252
        stop.addActionListener(this);
253
        sysReal.add(stop, gbc);
254
        gbc.gridy++;
255
 
714 adamjking 256
        activeSensing = new JCheckBox("Active Sensing", midiFilter
257
                .getSystemRealtimeMessage(ShortMessage.ACTIVE_SENSING));
628 adamjking 258
        activeSensing.addActionListener(this);
259
        sysReal.add(activeSensing, gbc);
260
        gbc.gridy++;
261
 
714 adamjking 262
        systemReset = new JCheckBox("System Reset", midiFilter
263
                .getSystemRealtimeMessage(ShortMessage.SYSTEM_RESET));
628 adamjking 264
        systemReset.addActionListener(this);
265
        sysReal.add(systemReset, gbc);
266
        gbc.gridy++;
267
 
268
        gbc.weighty = 1.0;
269
        sysReal.add(Box.createVerticalGlue(), gbc);
270
 
271
        // meta messages
272
        JPanel metaPanel = new JPanel(new GridBagLayout());
273
        gbc.gridy = 0;
274
        gbc.weighty = 0.0;
275
        metaPanel.setBorder(BorderFactory.createTitledBorder("Meta Messages"));
276
 
713 adamjking 277
        metaMessage = new JCheckBox("Meta Message", midiFilter.isMetaMessages());
628 adamjking 278
        metaMessage.addActionListener(this);
279
        metaPanel.add(metaMessage, gbc);
280
        gbc.gridy++;
281
 
282
        gbc.weighty = 1.0;
283
        metaPanel.add(Box.createVerticalGlue(), gbc);
284
 
285
        channelsModel = new MyTableModel(
286
                new String[] { "Selected", "Channel" }, 0);
287
        channels = new JTable(channelsModel);
288
 
713 adamjking 289
        for (int i = 1; i <= 16; i++) {
628 adamjking 290
            channelsModel.addRow(new Object[] {
713 adamjking 291
                    new Boolean(midiFilter.getChannel(i)), "Channel " + i });
628 adamjking 292
        }
293
 
294
        JScrollPane channelsScroll = new JScrollPane(channels);
295
        channelsScroll
296
                .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
297
        channelsScroll.setPreferredSize(new Dimension(150, 200));
298
        channelsScroll.setBorder(BorderFactory.createTitledBorder("Channels"));
299
        channels.setCellSelectionEnabled(false);
300
        channels.setShowGrid(false);
301
 
302
        ccModel = new MyTableModel(new String[] { "Selected", "Controller" }, 0);
303
        cc = new JTable(ccModel);
304
 
305
        for (int i = 0; i < 128; i++) {
714 adamjking 306
            ccModel.addRow(new Object[] {
307
                    new Boolean(midiFilter.getControlChange(i)),
628 adamjking 308
                    i + ": " + MidiUtils.ccNames[i] });
309
        }
310
 
311
        JScrollPane ccScroll = new JScrollPane(cc);
312
        ccScroll
313
                .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
314
        ccScroll.setPreferredSize(new Dimension(200, 200));
315
        ccScroll.setBorder(BorderFactory.createTitledBorder("Control Change"));
316
        cc.setRowSelectionAllowed(false);
317
        cc.setShowGrid(false);
318
 
319
        JPanel mainPanel = new JPanel(new GridBagLayout());
320
        gbc.gridx = 0;
321
        gbc.gridy = 0;
322
        gbc.gridheight = 2;
323
 
324
        mainPanel.add(voicePanel, gbc);
325
        gbc.gridx++;
326
 
327
        gbc.gridheight = 1;
328
 
329
        mainPanel.add(sysCommon, gbc);
330
        gbc.gridy++;
331
 
332
        mainPanel.add(sysexPanel, gbc);
333
        gbc.gridx++;
334
        gbc.gridy = 0;
335
 
336
        mainPanel.add(sysReal, gbc);
337
        gbc.gridy++;
338
 
339
        mainPanel.add(metaPanel, gbc);
340
 
341
        gbc.gridx++;
342
        gbc.gridy = 0;
343
 
344
        gbc.gridheight = 2;
345
 
346
        mainPanel.add(channelsScroll, gbc);
347
        gbc.gridx++;
348
 
349
        mainPanel.add(ccScroll, gbc);
350
 
682 adamjking 351
        add(mainPanel, BorderLayout.CENTER);
352
 
703 adamjking 353
        add(createToolBar(), BorderLayout.NORTH);
628 adamjking 354
    }
355
 
682 adamjking 356
    private JToolBar createToolBar() {
357
 
358
        JToolBar toolBar = new JToolBar();
359
 
360
        toolBar.setRollover(true);
361
 
362
        toolBar.setFloatable(false);
363
 
364
        JButton button = new JButton(ImageLoader.getImageIcon("open.png"));
365
 
366
        button.addActionListener(this);
367
 
368
        button.setMargin(new Insets(2, 2, 2, 2));
369
 
370
        button.setToolTipText("Load MIDI filter definition");
709 adamjking 371
 
703 adamjking 372
        button.setActionCommand("load");
682 adamjking 373
 
374
        toolBar.add(button);
375
 
376
        button = new JButton(ImageLoader.getImageIcon("save.png"));
377
 
378
        button.setToolTipText("Save MIDI filter definition");
709 adamjking 379
 
703 adamjking 380
        button.setActionCommand("save");
682 adamjking 381
 
382
        button.addActionListener(this);
383
 
384
        button.setMargin(new Insets(2, 2, 2, 2));
385
 
386
        toolBar.add(button);
387
 
388
        return toolBar;
389
    }
709 adamjking 390
 
703 adamjking 391
    protected void loadFilterDefinition() {
709 adamjking 392
 
703 adamjking 393
        if (fc == null) {
394
            fc = new JFileChooser(currentDirectory);
395
            SimpleFileChooserFilter fileFilter = new SimpleFileChooserFilter(
396
                    "XML files", "xml", "XML Filter Definition");
397
            fc.addChoosableFileFilter(fileFilter);
398
            fc.setAcceptAllFileFilterUsed(false);
399
        }
682 adamjking 400
 
703 adamjking 401
        File noFile = new File("");
402
        File noFiles[] = { noFile };
403
        fc.setSelectedFile(noFile);
404
        fc.setSelectedFiles(noFiles);
405
 
406
        int nRetVal = fc.showOpenDialog(this);
407
 
408
        if (nRetVal == JFileChooser.APPROVE_OPTION) {
409
            File file = fc.getSelectedFile();
709 adamjking 410
 
721 adamjking 411
            MidiFilterXML midiFilterXML = new MidiFilterXML(midiFilter, definitionTag);
412
 
413
            midiFilterXML.loadXML(file);
709 adamjking 414
 
703 adamjking 415
            setButtonStates();
709 adamjking 416
 
703 adamjking 417
            currentDirectory = fc.getCurrentDirectory().toString();
418
        }
419
    }
709 adamjking 420
 
703 adamjking 421
    protected void saveFilterDefinition() {
709 adamjking 422
 
423
        if (fc == null) {
424
            fc = new JFileChooser(currentDirectory);
425
            SimpleFileChooserFilter fileFilter = new SimpleFileChooserFilter(
426
                    "XML files", "xml", "XML Filter Definition");
427
            fc.addChoosableFileFilter(fileFilter);
428
            fc.setAcceptAllFileFilterUsed(false);
429
        }
430
 
431
        File noFile = new File("");
432
        File noFiles[] = { noFile };
433
        fc.setSelectedFile(noFile);
434
        fc.setSelectedFiles(noFiles);
435
 
436
        int nRetVal = fc.showSaveDialog(this);
437
 
438
        if (nRetVal == JFileChooser.APPROVE_OPTION) {
439
            File file = fc.getSelectedFile();
440
 
721 adamjking 441
            MidiFilterXML midiFilterXML = new MidiFilterXML(midiFilter, definitionTag);
442
 
443
            midiFilterXML.saveXML(file);
709 adamjking 444
 
445
            currentDirectory = fc.getCurrentDirectory().toString();
446
        }
703 adamjking 447
    }
709 adamjking 448
 
703 adamjking 449
    public void update(Observable observable, Object object) {
709 adamjking 450
 
713 adamjking 451
        setButtonStates();
703 adamjking 452
    }
453
 
628 adamjking 454
    public void actionPerformed(ActionEvent ae) {
455
 
456
        Object source = ae.getSource();
714 adamjking 457
 
628 adamjking 458
        if (source == noteOff)
714 adamjking 459
            midiFilter.setVoiceMessage(ShortMessage.NOTE_OFF, noteOff
460
                    .isSelected());
628 adamjking 461
 
462
        if (source == noteOn)
714 adamjking 463
            midiFilter.setVoiceMessage(ShortMessage.NOTE_ON, noteOn
464
                    .isSelected());
465
 
713 adamjking 466
        if (source == polyPressure)
714 adamjking 467
            midiFilter.setVoiceMessage(ShortMessage.POLY_PRESSURE, polyPressure
468
                    .isSelected());
628 adamjking 469
 
713 adamjking 470
        if (source == controlChange)
714 adamjking 471
            midiFilter.setVoiceMessage(ShortMessage.CONTROL_CHANGE,
472
                    controlChange.isSelected());
473
 
713 adamjking 474
        if (source == programChange)
714 adamjking 475
            midiFilter.setVoiceMessage(ShortMessage.PROGRAM_CHANGE,
476
                    programChange.isSelected());
477
 
713 adamjking 478
        if (source == channelPressure)
714 adamjking 479
            midiFilter.setVoiceMessage(ShortMessage.CHANNEL_PRESSURE,
480
                    channelPressure.isSelected());
481
 
628 adamjking 482
        if (source == pitchBend)
714 adamjking 483
            midiFilter.setVoiceMessage(ShortMessage.PITCH_BEND, pitchBend
484
                    .isSelected());
485
 
713 adamjking 486
        if (source == midiTimeCode)
714 adamjking 487
            midiFilter.setSystemCommonMessage(ShortMessage.MIDI_TIME_CODE,
488
                    midiTimeCode.isSelected());
489
 
628 adamjking 490
        if (source == songPositionPointer)
714 adamjking 491
            midiFilter.setSystemCommonMessage(
492
                    ShortMessage.SONG_POSITION_POINTER, songPositionPointer
493
                            .isSelected());
628 adamjking 494
 
495
        if (source == songSelect)
714 adamjking 496
            midiFilter.setSystemCommonMessage(ShortMessage.SONG_SELECT,
497
                    songSelect.isSelected());
498
 
713 adamjking 499
        if (source == tuneRequest)
714 adamjking 500
            midiFilter.setSystemCommonMessage(ShortMessage.TUNE_REQUEST,
501
                    tuneRequest.isSelected());
502
 
713 adamjking 503
        if (source == timingClock)
714 adamjking 504
            midiFilter.setSystemRealtimeMessage(ShortMessage.TIMING_CLOCK,
505
                    timingClock.isSelected());
506
 
628 adamjking 507
        if (source == start)
714 adamjking 508
            midiFilter.setSystemRealtimeMessage(ShortMessage.START, start
509
                    .isSelected());
628 adamjking 510
 
713 adamjking 511
        if (source == continueMessage)
714 adamjking 512
            midiFilter.setSystemRealtimeMessage(ShortMessage.CONTINUE,
513
                    continueMessage.isSelected());
713 adamjking 514
 
628 adamjking 515
        if (source == stop)
714 adamjking 516
            midiFilter.setSystemRealtimeMessage(ShortMessage.STOP, stop
517
                    .isSelected());
518
 
713 adamjking 519
        if (source == activeSensing)
714 adamjking 520
            midiFilter.setSystemRealtimeMessage(ShortMessage.ACTIVE_SENSING,
521
                    activeSensing.isSelected());
628 adamjking 522
 
523
        if (source == systemReset)
714 adamjking 524
            midiFilter.setSystemRealtimeMessage(ShortMessage.SYSTEM_RESET,
525
                    systemReset.isSelected());
628 adamjking 526
 
713 adamjking 527
        if (source == sysexMessage)
528
            midiFilter.setSysexMessages(sysexMessage.isSelected());
709 adamjking 529
 
713 adamjking 530
        if (source == metaMessage)
531
            midiFilter.setMetaMessages(metaMessage.isSelected());
532
 
703 adamjking 533
        if (ae.getActionCommand() == "load")
534
            loadFilterDefinition();
709 adamjking 535
 
536
        if (ae.getActionCommand() == "save")
703 adamjking 537
            saveFilterDefinition();
628 adamjking 538
    }
539
 
709 adamjking 540
    protected void setButtonStates() {
628 adamjking 541
 
714 adamjking 542
        noteOff.setSelected(midiFilter.getVoiceMessage(ShortMessage.NOTE_OFF));
543
 
544
        noteOn.setSelected(midiFilter.getVoiceMessage(ShortMessage.NOTE_ON));
545
 
546
        polyPressure.setSelected(midiFilter
547
                .getVoiceMessage(ShortMessage.POLY_PRESSURE));
548
 
549
        controlChange.setSelected(midiFilter
550
                .getVoiceMessage(ShortMessage.CONTROL_CHANGE));
551
 
552
        programChange.setSelected(midiFilter
553
                .getVoiceMessage(ShortMessage.PROGRAM_CHANGE));
554
 
555
        channelPressure.setSelected(midiFilter
556
                .getVoiceMessage(ShortMessage.CHANNEL_PRESSURE));
557
 
558
        pitchBend.setSelected(midiFilter
559
                .getVoiceMessage(ShortMessage.PITCH_BEND));
560
 
561
        midiTimeCode.setSelected(midiFilter
562
                .getSystemCommonMessage(ShortMessage.MIDI_TIME_CODE));
563
 
564
        songPositionPointer.setSelected(midiFilter
565
                .getSystemCommonMessage(ShortMessage.SONG_POSITION_POINTER));
566
 
567
        songSelect.setSelected(midiFilter
568
                .getSystemCommonMessage(ShortMessage.SONG_SELECT));
569
 
570
        tuneRequest.setSelected(midiFilter
571
                .getSystemCommonMessage(ShortMessage.TUNE_REQUEST));
572
 
573
        timingClock.setSelected(midiFilter
574
                .getSystemRealtimeMessage(ShortMessage.TIMING_CLOCK));
575
 
576
        start.setSelected(midiFilter
577
                .getSystemRealtimeMessage(ShortMessage.START));
578
 
579
        continueMessage.setSelected(midiFilter
580
                .getSystemRealtimeMessage(ShortMessage.CONTINUE));
581
 
582
        stop
583
                .setSelected(midiFilter
584
                        .getSystemRealtimeMessage(ShortMessage.STOP));
585
 
586
        activeSensing.setSelected(midiFilter
587
                .getSystemRealtimeMessage(ShortMessage.ACTIVE_SENSING));
588
 
589
        systemReset.setSelected(midiFilter
590
                .getSystemRealtimeMessage(ShortMessage.SYSTEM_RESET));
591
 
592
        sysexMessage.setSelected(midiFilter.isSysexMessages());
593
 
594
        metaMessage.setSelected(midiFilter.isMetaMessages());
595
 
709 adamjking 596
        ccModel.fireTableDataChanged();
628 adamjking 597
 
703 adamjking 598
        channelsModel.fireTableDataChanged();
714 adamjking 599
 
713 adamjking 600
        cc.setEnabled(midiFilter.getVoiceMessage(ShortMessage.CONTROL_CHANGE));
628 adamjking 601
    }
602
 
603
    class MyTableModel extends DefaultTableModel {
604
 
605
        public MyTableModel(Object[] a, int b) {
606
            super(a, b);
607
        }
709 adamjking 608
 
628 adamjking 609
        public Class getColumnClass(int c) {
610
            return getValueAt(0, c).getClass();
611
        }
612
 
703 adamjking 613
        public Object getValueAt(int row, int column) {
709 adamjking 614
 
615
            if (column == 0) {
616
 
617
                if (getRowCount() == 128) {
618
 
713 adamjking 619
                    return new Boolean(midiFilter.getControlChange(row));
709 adamjking 620
                } else {
621
 
714 adamjking 622
                    return new Boolean(midiFilter.getChannel(row + 1));
709 adamjking 623
                }
624
            }
625
 
626
            return super.getValueAt(row, column);
627
        }
628
 
629
        public void setValueAt(Object value, int row, int column) {
714 adamjking 630
 
703 adamjking 631
            if (column == 0) {
709 adamjking 632
 
633
                if (getRowCount() == 128) {
634
 
714 adamjking 635
                    midiFilter.setControlChange(row, ((Boolean) value)
636
                            .booleanValue());
709 adamjking 637
                } else {
638
 
714 adamjking 639
                    midiFilter.setChannel(row + 1, ((Boolean) value)
640
                            .booleanValue());
709 adamjking 641
                }
703 adamjking 642
            } else {
714 adamjking 643
 
709 adamjking 644
                super.setValueAt(value, row, column);
703 adamjking 645
            }
646
        }
647
 
628 adamjking 648
        public boolean isCellEditable(int row, int col) {
714 adamjking 649
 
709 adamjking 650
            if (col == 0) {
714 adamjking 651
                return true;
652
            }
709 adamjking 653
            return false;
628 adamjking 654
        }
655
    }
656
}