Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
628 adamjking 1
/*
2
 * @(#)MidiParameterControlProperties.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.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.event.ActionEvent;
27
 
28
import javax.swing.BorderFactory;
29
import javax.swing.JCheckBox;
30
import javax.swing.JPanel;
31
 
32
import org.midibox.midi.MidiParameterControl;
33
 
34
public class MidiParameterControlProperties extends MidiParameterProperties {
35
 
36
    protected JCheckBox receiveCheckBox;
37
 
38
    protected JCheckBox sendCheckBox;
39
 
40
    protected JCheckBox globalCheckBox;
41
 
42
    public MidiParameterControlProperties(MidiParameterControl midiParameter) {
43
        super(midiParameter);
44
        globalCheckBox = new JCheckBox("Global");
45
        globalCheckBox.addActionListener(this);
46
        GridBagConstraints gbc = ((GridBagLayout) channelPanel.getLayout())
47
                .getConstraints(channelSpinner);
48
        gbc.gridy++;
49
        channelPanel.add(globalCheckBox, gbc);
50
        add(createBottomPanel(), BorderLayout.SOUTH);
51
        updateControls();
52
    }
53
 
54
    public JPanel createBottomPanel() {
55
 
56
        JPanel messagesPanel = new JPanel(new GridBagLayout());
57
        GridBagConstraints gbc = new GridBagConstraints();
58
        gbc.anchor = GridBagConstraints.WEST;
59
        gbc.gridy = 0;
60
 
61
        receiveCheckBox = new JCheckBox("Receive MIDI Messages");
62
        receiveCheckBox.addActionListener(this);
63
        messagesPanel.add(receiveCheckBox, gbc);
64
        gbc.gridy++;
65
 
66
        sendCheckBox = new JCheckBox("Send MIDI Messages");
67
        sendCheckBox.addActionListener(this);
68
        messagesPanel.add(sendCheckBox, gbc);
69
 
70
        messagesPanel.setBorder(BorderFactory
71
                .createTitledBorder("MIDI Controller"));
72
 
73
        return messagesPanel;
74
    }
75
 
76
    public void updateControls() {
77
 
78
        super.updateControls();
79
 
80
        if (sendCheckBox != null && receiveCheckBox != null
81
                && globalCheckBox != null) {
82
 
721 adamjking 83
            sendCheckBox.setSelected(((MidiParameterControl) midiParameterControl)
628 adamjking 84
                    .isSend());
721 adamjking 85
            sendCheckBox.setEnabled(!((MidiParameterControl) midiParameterControl)
628 adamjking 86
                    .isLearn());
721 adamjking 87
            receiveCheckBox.setSelected(((MidiParameterControl) midiParameterControl)
628 adamjking 88
                    .isReceive());
721 adamjking 89
            receiveCheckBox.setEnabled(!((MidiParameterControl) midiParameterControl)
628 adamjking 90
                    .isLearn());
91
 
721 adamjking 92
            globalCheckBox.setSelected(((MidiParameterControl) midiParameterControl)
628 adamjking 93
                    .isGlobal());
721 adamjking 94
            globalCheckBox.setEnabled(!((MidiParameterControl) midiParameterControl)
628 adamjking 95
                    .isLearn());
96
 
721 adamjking 97
            channelSpinner.setEnabled(!((MidiParameterControl) midiParameterControl)
628 adamjking 98
                    .isGlobal()
721 adamjking 99
                    && !((MidiParameterControl) midiParameterControl).isLearn());
628 adamjking 100
        }
101
    }
102
 
103
    public void actionPerformed(ActionEvent ae) {
104
 
105
        super.actionPerformed(ae);
106
 
107
        if (update) {
108
            update = false;
109
 
110
            Object source = ae.getSource();
111
 
112
            if (source == receiveCheckBox) {
721 adamjking 113
                ((MidiParameterControl) midiParameterControl)
628 adamjking 114
                        .setReceive(receiveCheckBox.isSelected());
115
            } else if (source == sendCheckBox) {
721 adamjking 116
                ((MidiParameterControl) midiParameterControl).setSend(sendCheckBox
628 adamjking 117
                        .isSelected());
118
            } else if (source == globalCheckBox) {
721 adamjking 119
                ((MidiParameterControl) midiParameterControl).setGlobal(globalCheckBox
628 adamjking 120
                        .isSelected());
121
            }
122
            update = true;
123
        }
124
    }
125
}