Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 740 → Rev 741

/trunk/java/org/midibox/midi/gui/MidiDeviceManagerGUI.java
20,6 → 20,7
 
package org.midibox.midi.gui;
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
31,12 → 32,16
import java.util.Observer;
 
import javax.sound.midi.MidiDevice;
import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
 
import org.midibox.midi.MidiDeviceManager;
 
81,6 → 86,14
200));
midiReadDevices.setCellSelectionEnabled(false);
midiReadDevices.setShowGrid(false);
midiReadDevices.setDefaultRenderer(Boolean.class,
new MidiDeviceTableCellRenderer(midiDeviceManager
.getMidiReadDevices(), midiDeviceManager
.getSelectedMidiReadDevices()));
midiReadDevices.setDefaultEditor(Boolean.class,
new MidiDeviceTableCellEditor(midiDeviceManager
.getMidiReadDevices(), midiDeviceManager
.getSelectedMidiReadDevices()));
 
JScrollPane scrollPane = new JScrollPane(midiReadDevices);
scrollPane
95,6 → 108,14
200));
midiWriteDevices.setCellSelectionEnabled(false);
midiWriteDevices.setShowGrid(false);
midiWriteDevices.setDefaultRenderer(Boolean.class,
new MidiDeviceTableCellRenderer(midiDeviceManager
.getMidiWriteDevices(), midiDeviceManager
.getSelectedMidiWriteDevices()));
midiWriteDevices.setDefaultEditor(Boolean.class,
new MidiDeviceTableCellEditor(midiDeviceManager
.getMidiWriteDevices(), midiDeviceManager
.getSelectedMidiWriteDevices()));
 
scrollPane = new JScrollPane(midiWriteDevices);
scrollPane
130,9 → 151,77
}
}
 
class MidiDeviceTableCellEditor extends AbstractCellEditor implements
TableCellEditor {
 
private LinkedHashMap midiDevices;
 
private LinkedHashMap selectedMidiDevices;
 
private JCheckBox checkBox;
 
public MidiDeviceTableCellEditor(LinkedHashMap midiDevices,
LinkedHashMap selectedMidiDevices) {
this.midiDevices = midiDevices;
this.selectedMidiDevices = selectedMidiDevices;
}
 
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
 
MidiDevice midiDevice = (MidiDevice) midiDevices.values().toArray()[row];
 
checkBox = new JCheckBox(midiDevice.getDeviceInfo().getName(),
((Boolean) value).booleanValue());
 
checkBox.setOpaque(false);
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
fireEditingStopped();
}
});
 
return checkBox;
}
 
public Object getCellEditorValue() {
 
return new Boolean(checkBox.isSelected());
}
}
 
class MidiDeviceTableCellRenderer extends DefaultTableCellRenderer {
 
private LinkedHashMap midiDevices;
 
private LinkedHashMap selectedMidiDevices;
 
public MidiDeviceTableCellRenderer(LinkedHashMap midiDevices,
LinkedHashMap selectedMidiDevices) {
this.midiDevices = midiDevices;
this.selectedMidiDevices = selectedMidiDevices;
}
 
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
 
MidiDevice midiDevice = (MidiDevice) midiDevices.values().toArray()[row];
 
JCheckBox checkBox = new JCheckBox(midiDevice.getDeviceInfo()
.getName(), ((Boolean) value).booleanValue());
 
checkBox.setOpaque(false);
 
return checkBox;
}
}
 
class MidiDeviceTableModel extends DefaultTableModel {
private String[] headers = { "Selected", "MIDI Device Name" };
 
private String[] headers = { "MIDI Device" };
 
private LinkedHashMap midiDevices;
 
private LinkedHashMap selectedMidiDevices;
165,8 → 254,6
if (col == 0) {
return new Boolean(selectedMidiDevices
.containsValue(midiDevices.values().toArray()[row]));
} else if (col == 1) {
return midiDevice.getDeviceInfo().getName();
}
return null;
}
/trunk/java/org/midibox/midi/gui/MidiFilterGUI.java
21,6 → 21,7
package org.midibox.midi.gui;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
32,6 → 33,7
import java.util.Observer;
 
import javax.sound.midi.ShortMessage;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
41,7 → 43,9
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
 
import org.midibox.midi.MidiFilter;
import org.midibox.midi.MidiUtils;
53,13 → 57,16
 
private MidiFilter midiFilter;
 
// sysex messages
private JCheckBox sysexMessage;
private JCheckBox voiceMessages;
 
// meta messages
private JCheckBox metaMessage;
private JCheckBox systemCommonMessages;
 
// short messages
private JCheckBox systemRealtimeMessages;
 
private JCheckBox sysexMessages;
 
private JCheckBox metaMessages;
 
private JCheckBox activeSensing;
 
private JCheckBox channelPressure;
94,11 → 101,11
 
private JCheckBox tuneRequest;
 
private JTable cc;
private JTable controlChangeTable;
 
private DefaultTableModel ccModel;
private DefaultTableModel controlChangeModel;
 
private JTable channels;
private JTable channelsTable;
 
private DefaultTableModel channelsModel;
 
115,16 → 122,58
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 
// voice messages
JPanel voicePanel = new JPanel(new GridBagLayout());
JPanel masterPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.insets = new Insets(0, 2, 0, 2);
 
voicePanel
.setBorder(BorderFactory.createTitledBorder("Voice Messages"));
masterPanel.setBorder(BorderFactory.createTitledBorder("Message Type"));
 
voiceMessages = new JCheckBox("Voice", midiFilter.isVoiceMessages());
voiceMessages.addActionListener(this);
 
masterPanel.add(voiceMessages, gbc);
gbc.gridy++;
 
systemCommonMessages = new JCheckBox("System Common", midiFilter
.isSystemCommonMessages());
systemCommonMessages.addActionListener(this);
 
masterPanel.add(systemCommonMessages, gbc);
gbc.gridy++;
 
systemRealtimeMessages = new JCheckBox("System Realtime", midiFilter
.isSystemRealtimeMessages());
systemRealtimeMessages.addActionListener(this);
 
masterPanel.add(systemRealtimeMessages, gbc);
gbc.gridy++;
 
sysexMessages = new JCheckBox("SysEx", midiFilter.isSysexMessages());
sysexMessages.addActionListener(this);
 
masterPanel.add(sysexMessages, gbc);
gbc.gridy++;
 
metaMessages = new JCheckBox("Meta", midiFilter.isMetaMessages());
metaMessages.addActionListener(this);
 
masterPanel.add(metaMessages, gbc);
gbc.gridy++;
 
gbc.weighty = 1.0;
masterPanel.add(Box.createVerticalGlue(), gbc);
 
JPanel voicePanel = new JPanel(new GridBagLayout());
gbc.gridy = 0;
gbc.weighty = 0.0;
 
voicePanel.setBorder(BorderFactory.createTitledBorder("Voice"));
 
noteOff = new JCheckBox("Note Off", midiFilter
.getVoiceMessage(ShortMessage.NOTE_OFF));
noteOff.addActionListener(this);
170,185 → 219,148
gbc.weighty = 1.0;
voicePanel.add(Box.createVerticalGlue(), gbc);
 
// sysex messages
JPanel sysexPanel = new JPanel(new GridBagLayout());
gbc.gridheight = 8;
gbc.weighty = 0.0;
gbc.gridy = 0;
gbc.weighty = 0.0;
sysexPanel
.setBorder(BorderFactory.createTitledBorder("Sysex Messages"));
 
sysexMessage = new JCheckBox("Sysex Message", midiFilter
.isSysexMessages());
sysexMessage.addActionListener(this);
sysexPanel.add(sysexMessage, gbc);
gbc.gridy++;
gbc.gridx++;
 
gbc.weighty = 1.0;
sysexPanel.add(Box.createVerticalGlue(), gbc);
controlChangeModel = new MidiFilterTableModel(
new String[] { "Controller" }, 128);
controlChangeTable = new JTable(controlChangeModel);
 
JScrollPane ccScroll = new JScrollPane(controlChangeTable);
ccScroll
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ccScroll.setPreferredSize(new Dimension(200, 200));
controlChangeTable.setRowSelectionAllowed(false);
controlChangeTable.setShowGrid(false);
controlChangeTable.setDefaultRenderer(Boolean.class,
new MidiFilterTableCellRenderer());
controlChangeTable.setDefaultEditor(Boolean.class,
new MidiFilterTableCellEditor());
 
voicePanel.add(ccScroll, gbc);
 
gbc.gridx++;
 
channelsModel = new MidiFilterTableModel(new String[] { "Channel" }, 16);
channelsTable = new JTable(channelsModel);
 
JScrollPane channelsScroll = new JScrollPane(channelsTable);
channelsScroll
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
channelsScroll.setPreferredSize(new Dimension(150, 200));
channelsTable.setCellSelectionEnabled(false);
channelsTable.setShowGrid(false);
channelsTable.setDefaultRenderer(Boolean.class,
new MidiFilterTableCellRenderer());
channelsTable.setDefaultEditor(Boolean.class,
new MidiFilterTableCellEditor());
 
voicePanel.add(channelsScroll, gbc);
 
// system common
JPanel sysCommon = new JPanel(new GridBagLayout());
JPanel systemCommonPanel = new JPanel(new GridBagLayout());
gbc.gridy = 0;
gbc.weighty = 0.0;
sysCommon.setBorder(BorderFactory.createTitledBorder("System Common"));
gbc.gridheight = 1;
systemCommonPanel.setBorder(BorderFactory
.createTitledBorder("System Common"));
 
midiTimeCode = new JCheckBox("MTC Quarter Frame", midiFilter
.getSystemCommonMessage(ShortMessage.MIDI_TIME_CODE));
midiTimeCode.addActionListener(this);
sysCommon.add(midiTimeCode, gbc);
systemCommonPanel.add(midiTimeCode, gbc);
gbc.gridy++;
 
songPositionPointer = new JCheckBox("Song Position Pointer", midiFilter
.getSystemCommonMessage(ShortMessage.SONG_POSITION_POINTER));
songPositionPointer.addActionListener(this);
sysCommon.add(songPositionPointer, gbc);
systemCommonPanel.add(songPositionPointer, gbc);
gbc.gridy++;
 
songSelect = new JCheckBox("Song Select", midiFilter
.getSystemCommonMessage(ShortMessage.SONG_SELECT));
songSelect.addActionListener(this);
sysCommon.add(songSelect, gbc);
systemCommonPanel.add(songSelect, gbc);
gbc.gridy++;
 
tuneRequest = new JCheckBox("Tune Request", midiFilter
.getSystemCommonMessage(ShortMessage.TUNE_REQUEST));
tuneRequest.addActionListener(this);
sysCommon.add(tuneRequest, gbc);
systemCommonPanel.add(tuneRequest, gbc);
gbc.gridy++;
 
gbc.weighty = 1.0;
sysCommon.add(Box.createVerticalGlue(), gbc);
systemCommonPanel.add(Box.createVerticalGlue(), gbc);
 
// system realtime
JPanel sysReal = new JPanel(new GridBagLayout());
JPanel systemRealtimePanel = new JPanel(new GridBagLayout());
gbc.gridy = 0;
gbc.weighty = 0.0;
sysReal.setBorder(BorderFactory.createTitledBorder("System Realtime"));
systemRealtimePanel.setBorder(BorderFactory
.createTitledBorder("System Realtime"));
 
timingClock = new JCheckBox("Timing Clock", midiFilter
.getSystemRealtimeMessage(ShortMessage.TIMING_CLOCK));
timingClock.addActionListener(this);
sysReal.add(timingClock, gbc);
systemRealtimePanel.add(timingClock, gbc);
gbc.gridy++;
 
start = new JCheckBox("Start", midiFilter
.getSystemRealtimeMessage(ShortMessage.START));
start.addActionListener(this);
sysReal.add(start, gbc);
systemRealtimePanel.add(start, gbc);
gbc.gridy++;
 
continueMessage = new JCheckBox("Continue", midiFilter
.getSystemRealtimeMessage(ShortMessage.CONTINUE));
continueMessage.addActionListener(this);
sysReal.add(continueMessage, gbc);
systemRealtimePanel.add(continueMessage, gbc);
gbc.gridy++;
 
stop = new JCheckBox("Stop", midiFilter
.getSystemRealtimeMessage(ShortMessage.STOP));
stop.addActionListener(this);
sysReal.add(stop, gbc);
systemRealtimePanel.add(stop, gbc);
gbc.gridy++;
 
activeSensing = new JCheckBox("Active Sensing", midiFilter
.getSystemRealtimeMessage(ShortMessage.ACTIVE_SENSING));
activeSensing.addActionListener(this);
sysReal.add(activeSensing, gbc);
systemRealtimePanel.add(activeSensing, gbc);
gbc.gridy++;
 
systemReset = new JCheckBox("System Reset", midiFilter
.getSystemRealtimeMessage(ShortMessage.SYSTEM_RESET));
systemReset.addActionListener(this);
sysReal.add(systemReset, gbc);
systemRealtimePanel.add(systemReset, gbc);
gbc.gridy++;
 
gbc.weighty = 1.0;
sysReal.add(Box.createVerticalGlue(), gbc);
systemRealtimePanel.add(Box.createVerticalGlue(), gbc);
 
// meta messages
JPanel metaPanel = new JPanel(new GridBagLayout());
gbc.gridy = 0;
gbc.weighty = 0.0;
metaPanel.setBorder(BorderFactory.createTitledBorder("Meta Messages"));
 
metaMessage = new JCheckBox("Meta Message", midiFilter.isMetaMessages());
metaMessage.addActionListener(this);
metaPanel.add(metaMessage, gbc);
gbc.gridy++;
 
gbc.weighty = 1.0;
metaPanel.add(Box.createVerticalGlue(), gbc);
 
channelsModel = new MyTableModel(
new String[] { "Selected", "Channel" }, 0);
channels = new JTable(channelsModel);
 
for (int i = 0; i < 16; i++) {
channelsModel
.addRow(new Object[] {
new Boolean(midiFilter.getChannel(i)),
"Channel " + (i + 1) });
}
 
JScrollPane channelsScroll = new JScrollPane(channels);
channelsScroll
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
channelsScroll.setPreferredSize(new Dimension(150, 200));
channelsScroll.setBorder(BorderFactory.createTitledBorder("Channels"));
channels.setCellSelectionEnabled(false);
channels.setShowGrid(false);
 
ccModel = new MyTableModel(new String[] { "Selected", "Controller" }, 0);
cc = new JTable(ccModel);
 
for (int i = 0; i < 128; i++) {
ccModel.addRow(new Object[] {
new Boolean(midiFilter.getControlChange(i)),
i + ": " + MidiUtils.ccNames[i] });
}
 
JScrollPane ccScroll = new JScrollPane(cc);
ccScroll
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ccScroll.setPreferredSize(new Dimension(200, 200));
ccScroll.setBorder(BorderFactory.createTitledBorder("Control Change"));
cc.setRowSelectionAllowed(false);
cc.setShowGrid(false);
 
JPanel mainPanel = new JPanel(new GridBagLayout());
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridheight = 2;
 
mainPanel.add(voicePanel, gbc);
mainPanel.add(masterPanel, gbc);
gbc.gridx++;
 
gbc.gridheight = 1;
 
mainPanel.add(sysCommon, gbc);
gbc.gridy++;
 
mainPanel.add(sysexPanel, gbc);
mainPanel.add(voicePanel, gbc);
gbc.gridx++;
gbc.gridy = 0;
 
mainPanel.add(sysReal, gbc);
gbc.gridy++;
 
mainPanel.add(metaPanel, gbc);
 
mainPanel.add(systemCommonPanel, gbc);
gbc.gridx++;
gbc.gridy = 0;
 
gbc.gridheight = 2;
mainPanel.add(systemRealtimePanel, gbc);
 
mainPanel.add(channelsScroll, gbc);
gbc.gridx++;
 
mainPanel.add(ccScroll, gbc);
 
add(mainPanel, BorderLayout.CENTER);
 
add(createToolBar(), BorderLayout.NORTH);
 
setButtonStates();
}
 
private JToolBar createToolBar() {
463,6 → 475,23
 
Object source = ae.getSource();
 
if (source == voiceMessages)
midiFilter.setVoiceMessages(voiceMessages.isSelected());
 
if (source == systemCommonMessages)
midiFilter.setSystemCommonMessages(systemCommonMessages
.isSelected());
 
if (source == systemRealtimeMessages)
midiFilter.setSystemRealtimeMessages(systemRealtimeMessages
.isSelected());
 
if (source == sysexMessages)
midiFilter.setSysexMessages(sysexMessages.isSelected());
 
if (source == metaMessages)
midiFilter.setMetaMessages(metaMessages.isSelected());
 
if (source == noteOff)
midiFilter.setVoiceMessage(ShortMessage.NOTE_OFF, noteOff
.isSelected());
532,12 → 561,6
midiFilter.setSystemRealtimeMessage(ShortMessage.SYSTEM_RESET,
systemReset.isSelected());
 
if (source == sysexMessage)
midiFilter.setSysexMessages(sysexMessage.isSelected());
 
if (source == metaMessage)
midiFilter.setMetaMessages(metaMessage.isSelected());
 
if (ae.getActionCommand() == "load")
loadFilterDefinition();
 
547,70 → 570,163
 
protected void setButtonStates() {
 
voiceMessages.setSelected(midiFilter.isVoiceMessages());
 
systemCommonMessages.setSelected(midiFilter.isSystemCommonMessages());
 
systemRealtimeMessages.setSelected(midiFilter
.isSystemRealtimeMessages());
 
sysexMessages.setSelected(midiFilter.isSysexMessages());
 
metaMessages.setSelected(midiFilter.isMetaMessages());
 
noteOff.setSelected(midiFilter.getVoiceMessage(ShortMessage.NOTE_OFF));
noteOff.setEnabled(midiFilter.isVoiceMessages());
 
noteOn.setSelected(midiFilter.getVoiceMessage(ShortMessage.NOTE_ON));
noteOn.setEnabled(midiFilter.isVoiceMessages());
 
polyPressure.setSelected(midiFilter
.getVoiceMessage(ShortMessage.POLY_PRESSURE));
polyPressure.setEnabled(midiFilter.isVoiceMessages());
 
controlChange.setSelected(midiFilter
.getVoiceMessage(ShortMessage.CONTROL_CHANGE));
controlChange.setEnabled(midiFilter.isVoiceMessages());
 
programChange.setSelected(midiFilter
.getVoiceMessage(ShortMessage.PROGRAM_CHANGE));
programChange.setEnabled(midiFilter.isVoiceMessages());
 
channelPressure.setSelected(midiFilter
.getVoiceMessage(ShortMessage.CHANNEL_PRESSURE));
channelPressure.setEnabled(midiFilter.isVoiceMessages());
 
pitchBend.setSelected(midiFilter
.getVoiceMessage(ShortMessage.PITCH_BEND));
pitchBend.setEnabled(midiFilter.isVoiceMessages());
 
controlChangeModel.fireTableDataChanged();
 
channelsModel.fireTableDataChanged();
 
midiTimeCode.setSelected(midiFilter
.getSystemCommonMessage(ShortMessage.MIDI_TIME_CODE));
midiTimeCode.setEnabled(midiFilter.isSystemCommonMessages());
 
songPositionPointer.setSelected(midiFilter
.getSystemCommonMessage(ShortMessage.SONG_POSITION_POINTER));
songPositionPointer.setEnabled(midiFilter.isSystemCommonMessages());
 
songSelect.setSelected(midiFilter
.getSystemCommonMessage(ShortMessage.SONG_SELECT));
songSelect.setEnabled(midiFilter.isSystemCommonMessages());
 
tuneRequest.setSelected(midiFilter
.getSystemCommonMessage(ShortMessage.TUNE_REQUEST));
tuneRequest.setEnabled(midiFilter.isSystemCommonMessages());
 
timingClock.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.TIMING_CLOCK));
timingClock.setEnabled(midiFilter.isSystemRealtimeMessages());
 
start.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.START));
start.setEnabled(midiFilter.isSystemRealtimeMessages());
 
continueMessage.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.CONTINUE));
continueMessage.setEnabled(midiFilter.isSystemRealtimeMessages());
 
stop
.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.STOP));
stop.setEnabled(midiFilter.isSystemRealtimeMessages());
 
activeSensing.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.ACTIVE_SENSING));
activeSensing.setEnabled(midiFilter.isSystemRealtimeMessages());
 
systemReset.setSelected(midiFilter
.getSystemRealtimeMessage(ShortMessage.SYSTEM_RESET));
systemReset.setEnabled(midiFilter.isSystemRealtimeMessages());
}
 
sysexMessage.setSelected(midiFilter.isSysexMessages());
class MidiFilterTableCellEditor extends AbstractCellEditor implements
TableCellEditor {
 
metaMessage.setSelected(midiFilter.isMetaMessages());
private JCheckBox checkBox;
 
ccModel.fireTableDataChanged();
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
 
channelsModel.fireTableDataChanged();
if (table.getRowCount() == 128) {
 
cc.setEnabled(midiFilter.getVoiceMessage(ShortMessage.CONTROL_CHANGE));
checkBox = new JCheckBox(row + ": " + MidiUtils.ccNames[row],
midiFilter.getControlChange(row));
 
checkBox.setEnabled(midiFilter.isVoiceMessages()
&& midiFilter
.getVoiceMessage(ShortMessage.CONTROL_CHANGE));
 
} else {
 
checkBox = new JCheckBox("Channel " + (row + 1), midiFilter
.getChannel(row));
}
 
checkBox.setOpaque(false);
 
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
fireEditingStopped();
}
});
 
return checkBox;
}
 
public Object getCellEditorValue() {
 
return new Boolean(checkBox.isSelected());
}
}
 
class MyTableModel extends DefaultTableModel {
class MidiFilterTableCellRenderer extends DefaultTableCellRenderer {
 
public MyTableModel(Object[] a, int b) {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
 
JCheckBox checkBox;
 
if (table.getRowCount() == 128) {
 
checkBox = new JCheckBox(row + ": " + MidiUtils.ccNames[row],
midiFilter.getControlChange(row));
 
checkBox.setEnabled(midiFilter.isVoiceMessages()
&& midiFilter
.getVoiceMessage(ShortMessage.CONTROL_CHANGE));
 
} else {
 
checkBox = new JCheckBox("Channel " + (row + 1), midiFilter
.getChannel(row));
 
checkBox.setEnabled(midiFilter.isVoiceMessages());
}
 
checkBox.setOpaque(false);
 
return checkBox;
}
}
 
class MidiFilterTableModel extends DefaultTableModel {
 
public MidiFilterTableModel(Object[] a, int b) {
super(a, b);
}
 
/trunk/java/org/midibox/midi/xml/MidiDeviceManagerXML.java
51,7 → 51,7
 
} else if (name == TAG_DESELECTED_MIDI_READ_DEVICE) {
 
int hash = Integer.parseInt(element
int hash = stringToInt(element
.getAttribute(MidiDeviceXML.ATTR_HASH_CODE));
 
MidiDevice midiDevice = findDeviceHash(midiDeviceManager
66,7 → 66,7
 
} else if (name == TAG_DESELECTED_MIDI_WRITE_DEVICE) {
 
int hash = Integer.parseInt(element
int hash = stringToInt(element
.getAttribute(MidiDeviceXML.ATTR_HASH_CODE));
 
MidiDevice midiDevice = findDeviceHash(midiDeviceManager
129,6 → 129,6
 
protected MidiDevice findDeviceHash(HashMap midiDevices, int hash) {
 
return (MidiDevice) midiDevices.get("" + hash);
return (MidiDevice) midiDevices.get(intToString(hash));
}
}
/trunk/java/org/midibox/apps/miosstudio/MIOSStudio.java
189,57 → 189,15
// disable all messages by default, only allow pass SysEx
// user can enable other MIDI events again if required
 
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.NOTE_OFF, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.NOTE_ON, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.POLY_PRESSURE, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.CONTROL_CHANGE, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.PROGRAM_CHANGE, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.CHANNEL_PRESSURE, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessage(
ShortMessage.PITCH_BEND, false);
miosTerminalFiltered.getMidiFilter().setVoiceMessages(false);
miosTerminalFiltered.getMidiFilter().setSystemCommonMessages(false);
 
miosTerminalFiltered.getMidiFilter().setSystemCommonMessage(
ShortMessage.MIDI_TIME_CODE, false);
miosTerminalFiltered.getMidiFilter().setSystemCommonMessage(
ShortMessage.SONG_POSITION_POINTER, false);
miosTerminalFiltered.getMidiFilter().setSystemCommonMessage(
ShortMessage.SONG_SELECT, false);
miosTerminalFiltered.getMidiFilter().setSystemCommonMessage(
ShortMessage.TUNE_REQUEST, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessages(false);
miosTerminalFiltered.getMidiFilter().setSysexMessages(true);
 
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.TIMING_CLOCK, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.START, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.CONTINUE, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.STOP, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.ACTIVE_SENSING, false);
miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessage(
ShortMessage.SYSTEM_RESET, false);
 
/*
* miosTerminalFiltered.getMidiFilter().setVoiceMessages(false);
*
* miosTerminalFiltered.getMidiFilter().setSystemCommonMessages(false);
*
*
*
*
* miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessages(false);
*/
 
miosTerminalFiltered.getMidiFilter().setSysexMessages(true);
 
miosTerminalFiltered.getMidiFilter().setMetaMessages(false);
miosTerminalFiltered.getMidiFilter().setMetaMessages(false);
}
 
public MidiDeviceManager getMidiDeviceManager() {
/trunk/java/org/midibox/apps/miosstudio/gui/xml/MIOSStudioGUIXML.java
New file
0,0 → 1,475
package org.midibox.apps.miosstudio.gui.xml;
 
import java.util.Iterator;
import java.util.Vector;
 
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.UIManager;
 
import org.midibox.apps.miosstudio.MIOSStudio;
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI.ExternalCommandButton;
import org.midibox.apps.miosstudio.xml.MIOSStudioXML;
import org.midibox.midi.gui.MidiFilterGUI;
import org.midibox.mios.gui.HexFileUploadGUI;
import org.midibox.utils.gui.DialogOwner;
import org.midibox.utils.xml.XMLUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 
public class MIOSStudioGUIXML extends XMLUtils {
 
public final static String TAG_ROOT_ELEMENT = "miosStudioGUI";
 
public final static String TAG_LOOK_AND_FEEL = "lookAndFeel";
 
public final static String TAG_MAIN_WINDOW = "mainWindow";
 
public final static String TAG_INTERNAL_FRAMES = "internalFrames";
 
public final static String TAG_INTERNAL_FRAME = "internalFrame";
 
public final static String TAG_EXTERNAL_COMMANDS = "externalCommands";
 
public final static String TAG_EXTERNAL_COMMAND = "externalCommand";
 
public final static String TAG_WORKSPACE_CURRENT_DIRECTORY = "workspaceCurrentDirectory";
 
public final static String TAG_MIDI_FILTER_DEVICE_MANAGER_GUI = "midiFilterDeviceManagerGUI";
 
public final static String TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY = "midiFilterGUICurrentDirectory";
 
public final static String TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI = "hexFileUploadDeviceManagerGUI";
 
public final static String TAG_HEX_FILE_GUI_CURRENT_DIRECTORY = "hexFileGUICurrentDirectory";
 
public final static String ATTR_TITLE = "title";
 
public final static String ATTR_POS_X = "posX";
 
public final static String ATTR_POS_Y = "posY";
 
public final static String ATTR_WIDTH = "width";
 
public final static String ATTR_HEIGHT = "height";
 
public final static String ATTR_VISIBLE = "visible";
 
public final static String ATTR_ICONIFIED = "iconified";
 
public final static String ATTR_MAXIMIZED = "maximized";
 
public final static String ATTR_COMMAND_NAME = "commandName";
 
public final static String ATTR_EXTERNAL_COMMAND = "externalCommand";
 
public final static String ATTR_SELECTED_TAB = "selectedTab";
 
protected MIOSStudioGUI miosStudioGUI;
 
protected MIOSStudio miosStudio;
 
protected boolean includeModel;
 
protected boolean includeGUI;
 
public MIOSStudioGUIXML(MIOSStudio miosStudio, String rootElementTag,
boolean includeModel, boolean includeGUI) {
 
this(null, miosStudio, rootElementTag, includeModel, includeGUI);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, String rootElementTag,
boolean includeModel, boolean includeGUI) {
 
this(miosStudioGUI, miosStudioGUI.getMiosStudio(), rootElementTag,
includeModel, includeGUI);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, MIOSStudio miosStudio,
String rootElementTag, boolean includeModel, boolean includeGUI) {
 
super(rootElementTag);
 
this.miosStudioGUI = miosStudioGUI;
 
this.miosStudio = miosStudio;
 
this.includeModel = includeModel;
 
this.includeGUI = includeGUI;
 
if (includeModel) {
 
tags.add(MIOSStudioXML.TAG_ROOT_ELEMENT);
}
 
if (includeGUI) {
 
tags.add(TAG_LOOK_AND_FEEL);
tags.add(TAG_MAIN_WINDOW);
tags.add(TAG_INTERNAL_FRAMES);
tags.add(TAG_EXTERNAL_COMMANDS);
tags.add(TAG_EXTERNAL_COMMAND);
tags.add(TAG_WORKSPACE_CURRENT_DIRECTORY);
tags.add(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
tags.add(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
tags.add(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
tags.add(TAG_HEX_FILE_GUI_CURRENT_DIRECTORY);
}
}
 
protected void createGUI() {
 
miosStudioGUI = new MIOSStudioGUI(miosStudio);
}
 
protected void parseElement(Element element) {
 
super.parseElement(element);
 
String name = element.getNodeName();
 
if (name == rootElementTag) {
 
} else if (name == MIOSStudioXML.TAG_ROOT_ELEMENT) {
 
MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
MIOSStudioXML.TAG_ROOT_ELEMENT);
 
miosStudioXML.loadXML(element);
 
} else if (name == TAG_MAIN_WINDOW) {
 
JFrame mainWindow = DialogOwner.getFrame();
 
if (mainWindow != null) {
 
mainWindow.setBounds(stringToInt(element
.getAttribute(ATTR_POS_X)), stringToInt(element
.getAttribute(ATTR_POS_Y)), stringToInt(element
.getAttribute(ATTR_WIDTH)), stringToInt(element
.getAttribute(ATTR_HEIGHT)));
}
 
} else if (name == TAG_LOOK_AND_FEEL) {
 
String lookAndFeel = element.getTextContent();
 
if (miosStudioGUI == null) {
 
try {
 
UIManager.setLookAndFeel(lookAndFeel);
 
} catch (Exception e) {
 
e.printStackTrace();
}
 
createGUI();
}
 
miosStudioGUI.setLookAndFeel(lookAndFeel);
 
} else if (name == TAG_INTERNAL_FRAMES) {
 
Iterator it = miosStudioGUI.getInternalFrames().iterator();
 
while (it.hasNext()) {
 
JInternalFrame internalFrame = (JInternalFrame) it.next();
 
internalFrame.setVisible(false);
 
miosStudioGUI.getDesktop().remove(internalFrame);
}
 
Node childNode = element.getLastChild();
 
while (childNode != null) {
 
element = (Element) childNode;
 
if (element.getNodeName() == TAG_INTERNAL_FRAME) {
 
JInternalFrame internalFrame = findInternalFrame(element
.getAttribute(ATTR_TITLE));
 
if (internalFrame != null) {
 
internalFrame.setBounds(stringToInt(element
.getAttribute(ATTR_POS_X)), stringToInt(element
.getAttribute(ATTR_POS_Y)), stringToInt(element
.getAttribute(ATTR_WIDTH)), stringToInt(element
.getAttribute(ATTR_HEIGHT)));
 
try {
 
internalFrame.setMaximum(stringToBoolean(element
.getAttribute(ATTR_MAXIMIZED)));
 
internalFrame.setIcon(stringToBoolean(element
.getAttribute(ATTR_ICONIFIED)));
 
} catch (Exception e) {
 
e.printStackTrace();
}
 
if (stringToBoolean(element.getAttribute(ATTR_VISIBLE))) {
 
miosStudioGUI.showFrame(internalFrame);
}
}
 
childNode = childNode.getPreviousSibling();
}
}
 
} else if (name == TAG_EXTERNAL_COMMANDS) {
 
Iterator it = ((Vector) miosStudioGUI.getExternalCommands().clone())
.iterator();
 
while (it.hasNext()) {
 
ExternalCommandButton externalCommandButton = (ExternalCommandButton) it
.next();
 
miosStudioGUI
.removeExternalCommandButton(externalCommandButton);
}
 
} else if (name == TAG_EXTERNAL_COMMAND) {
 
miosStudioGUI.addExternalCommandButton(element
.getAttribute(ATTR_COMMAND_NAME), element
.getAttribute(ATTR_EXTERNAL_COMMAND));
 
} else if (name == TAG_WORKSPACE_CURRENT_DIRECTORY) {
 
MIOSStudioGUI.setCurrentDirectory(element.getTextContent());
 
} else if (name == TAG_MIDI_FILTER_DEVICE_MANAGER_GUI) {
 
} else if (name == TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY) {
 
MidiFilterGUI.setCurrentDirectory(element.getTextContent());
 
} else if (name == TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI) {
 
int tabIndex = stringToInt(element.getAttribute(ATTR_SELECTED_TAB));
 
if (tabIndex < miosStudioGUI.getHexFileUploadDeviceManagerGUI()
.getTabbedPane().getTabCount()) {
 
miosStudioGUI.getHexFileUploadDeviceManagerGUI()
.getTabbedPane().setSelectedIndex(tabIndex);
 
}
 
} else if (name == TAG_HEX_FILE_GUI_CURRENT_DIRECTORY) {
 
HexFileUploadGUI.setCurrentDirectory(element.getTextContent());
}
}
 
public void saveXML(Node node) {
 
super.saveXML(node);
 
if (includeModel) {
 
MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
MIOSStudioXML.TAG_ROOT_ELEMENT);
 
miosStudioXML.saveXML(rootElement);
}
 
if (includeGUI) {
 
JFrame mainWindow = DialogOwner.getFrame();
 
if (mainWindow != null) {
 
Element mainWindowElement = document
.createElement(TAG_MAIN_WINDOW);
 
rootElement.appendChild(mainWindowElement);
 
mainWindowElement.setAttribute(ATTR_POS_X,
intToString(mainWindow.getX()));
 
mainWindowElement.setAttribute(ATTR_POS_Y,
intToString(mainWindow.getY()));
 
mainWindowElement.setAttribute(ATTR_WIDTH,
intToString(mainWindow.getWidth()));
 
mainWindowElement.setAttribute(ATTR_HEIGHT,
intToString(mainWindow.getHeight()));
}
 
Element lookAndFeelElement = document
.createElement(TAG_LOOK_AND_FEEL);
 
rootElement.appendChild(lookAndFeelElement);
 
lookAndFeelElement.setTextContent(miosStudioGUI.getLookAndFeel());
 
Element internalFramesElement = document
.createElement(TAG_INTERNAL_FRAMES);
 
rootElement.appendChild(internalFramesElement);
 
Vector internalFrames = (Vector) miosStudioGUI.getInternalFrames()
.clone();
 
JInternalFrame[] visibleInternalFrames = miosStudioGUI.getDesktop()
.getAllFrames();
 
for (int i = 0; i < visibleInternalFrames.length; i++) {
 
JInternalFrame internalFrame = visibleInternalFrames[i];
 
Element internalFrameElement = document
.createElement(TAG_INTERNAL_FRAME);
 
internalFramesElement.appendChild(internalFrameElement);
 
saveInternalFrame(internalFrame, internalFrameElement);
 
internalFrames.remove(internalFrame);
}
 
Iterator it = internalFrames.iterator();
 
while (it.hasNext()) {
 
JInternalFrame internalFrame = (JInternalFrame) it.next();
 
Element internalFrameElement = document
.createElement(TAG_INTERNAL_FRAME);
 
internalFramesElement.appendChild(internalFrameElement);
 
saveInternalFrame(internalFrame, internalFrameElement);
}
 
Element externalCommandsElement = document
.createElement(TAG_EXTERNAL_COMMANDS);
 
rootElement.appendChild(externalCommandsElement);
 
it = miosStudioGUI.getExternalCommands().iterator();
 
while (it.hasNext()) {
 
ExternalCommandButton externalCommandButton = (ExternalCommandButton) it
.next();
 
Element externalCommandElement = document
.createElement(TAG_EXTERNAL_COMMAND);
 
externalCommandsElement.appendChild(externalCommandElement);
 
externalCommandElement.setAttribute(ATTR_COMMAND_NAME,
externalCommandButton.commandName);
 
externalCommandElement.setAttribute(ATTR_EXTERNAL_COMMAND,
externalCommandButton.externalCommand);
}
 
Element workSpaceCurrentDirectory = document
.createElement(TAG_WORKSPACE_CURRENT_DIRECTORY);
 
rootElement.appendChild(workSpaceCurrentDirectory);
 
workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
.getCurrentDirectory());
 
Element midiFilterDeviceManagerGUIelement = document
.createElement(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
 
rootElement.appendChild(midiFilterDeviceManagerGUIelement);
 
Element midiFilterCurrentDirectory = document
.createElement(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
 
midiFilterDeviceManagerGUIelement
.appendChild(midiFilterCurrentDirectory);
 
midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
.getCurrentDirectory());
 
Element hexFileUploadDeviceManagerGUIelement = document
.createElement(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
 
rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
 
hexFileUploadDeviceManagerGUIelement.setAttribute(
ATTR_SELECTED_TAB, intToString(miosStudioGUI
.getHexFileUploadDeviceManagerGUI().getTabbedPane()
.getSelectedIndex()));
 
Element hexFileCurrentDirectoryElement = document
.createElement(TAG_HEX_FILE_GUI_CURRENT_DIRECTORY);
 
hexFileUploadDeviceManagerGUIelement
.appendChild(hexFileCurrentDirectoryElement);
 
hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
.getCurrentDirectory());
}
}
 
public MIOSStudioGUI getMiosStudioGUI() {
return miosStudioGUI;
}
 
protected void saveInternalFrame(JInternalFrame internalFrame,
Element internalFrameElement) {
 
internalFrameElement.setAttribute(ATTR_TITLE, internalFrame.getTitle());
 
internalFrameElement.setAttribute(ATTR_POS_X, intToString(internalFrame
.getX()));
 
internalFrameElement.setAttribute(ATTR_POS_Y, intToString(internalFrame
.getY()));
 
internalFrameElement.setAttribute(ATTR_WIDTH, intToString(internalFrame
.getWidth()));
 
internalFrameElement.setAttribute(ATTR_HEIGHT,
intToString(internalFrame.getHeight()));
 
internalFrameElement.setAttribute(ATTR_VISIBLE,
booleanToString(internalFrame.isVisible()));
 
internalFrameElement.setAttribute(ATTR_ICONIFIED,
booleanToString(internalFrame.isIcon()));
 
internalFrameElement.setAttribute(ATTR_MAXIMIZED,
booleanToString(internalFrame.isMaximum()));
}
 
protected JInternalFrame findInternalFrame(String name) {
 
Iterator it = miosStudioGUI.getInternalFrames().iterator();
 
while (it.hasNext()) {
 
JInternalFrame internalFrame = (JInternalFrame) it.next();
 
if (internalFrame.getTitle().equals(name)) {
 
return internalFrame;
}
}
 
return null;
}
}
/trunk/java/org/midibox/apps/miosstudio/gui/MIOSStudioGUI$7.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/java/org/midibox/apps/miosstudio/gui/MIOSStudioGUI$7.class
New file
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: midibox/apps/miosstudio/gui/MIOSStudioGUI$8.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: midibox/apps/miosstudio/gui/MIOSStudioGUI$8.class
===================================================================
--- midibox/apps/miosstudio/gui/MIOSStudioGUI$8.class (revision 0)
+++ midibox/apps/miosstudio/gui/MIOSStudioGUI$8.class (revision 741)
/midibox/apps/miosstudio/gui/MIOSStudioGUI$8.class
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: midibox/apps/miosstudio/gui/MIOSStudioGUI$WorkspaceOptionDialog.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: midibox/apps/miosstudio/gui/MIOSStudioGUI$WorkspaceOptionDialog.class
===================================================================
--- midibox/apps/miosstudio/gui/MIOSStudioGUI$WorkspaceOptionDialog.class (revision 0)
+++ midibox/apps/miosstudio/gui/MIOSStudioGUI$WorkspaceOptionDialog.class (revision 741)
/midibox/apps/miosstudio/gui/MIOSStudioGUI$WorkspaceOptionDialog.class
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: midibox/apps/miosstudio/gui/MIOSStudioGUI.java
===================================================================
--- midibox/apps/miosstudio/gui/MIOSStudioGUI.java (revision 740)
+++ midibox/apps/miosstudio/gui/MIOSStudioGUI.java (revision 741)
@@ -45,6 +45,7 @@
import java.util.Vector;
import javax.swing.Box;
+import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@@ -53,7 +54,6 @@
import javax.swing.JDesktopPane;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
-import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
@@ -62,6 +62,7 @@
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
+import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JToolBar;
@@ -71,7 +72,7 @@
import javax.swing.event.MenuListener;
import org.midibox.apps.miosstudio.MIOSStudio;
-import org.midibox.apps.miosstudio.xml.MIOSStudioXML;
+import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
import org.midibox.midi.MidiFilterDevice;
import org.midibox.midi.MidiKeyboardControllerDevice;
import org.midibox.midi.MidiRouterDevice;
@@ -102,6 +103,8 @@
private HelpPane helpPane;
+ protected Vector internalFrames;
+
private MIOSStudioInternalFrame helpWindow;
private JDialog midiDeviceManagerDialog;
@@ -184,8 +187,6 @@
private String lookAndFeel;
- private boolean defaultDecoratedFrames;
-
private JLabel commentLabel;
private static String currentDirectory = "";
@@ -201,7 +202,6 @@
miosStudio.addObserver(this);
lookAndFeel = UIManager.getLookAndFeel().getClass().getName();
- defaultDecoratedFrames = JFrame.isDefaultLookAndFeelDecorated();
add(createToolBar(), BorderLayout.NORTH);
add(createMainPanel(), BorderLayout.CENTER);
@@ -270,6 +270,8 @@
protected void createInternalFrames() {
+ internalFrames = new Vector();
+
// Help Window
helpPane = HelpPane.createSingleton(ResourceLoader
@@ -281,6 +283,8 @@
helpPane);
helpWindow.pack();
+ internalFrames.add(helpWindow);
+
// MIDI Device Routing
Icon icon = ImageLoader.getImageIcon("midiRouting.png");
@@ -295,6 +299,8 @@
midiDeviceRoutingWindow.pack();
+ internalFrames.add(midiDeviceRoutingWindow);
+
icon = ImageLoader.getImageIcon("ucIcon.png");
/*
@@ -317,6 +323,8 @@
midiOutPortMonitorWindow.pack();
+ internalFrames.add(midiOutPortMonitorWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(miosStudio
.getMidiOutPortMonitorDevice(), icon);
@@ -332,6 +340,8 @@
midiInPortMonitorWindow.pack();
+ internalFrames.add(midiInPortMonitorWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(miosStudio
.getMidiInPortMonitorDevice(), icon);
@@ -350,6 +360,8 @@
midiKeyboardControllerWindow.pack();
+ internalFrames.add(midiKeyboardControllerWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(
MidiKeyboardControllerDevice.class, icon);
@@ -384,6 +396,8 @@
hexFileUploadDeviceManagerWindow.pack();
+ internalFrames.add(hexFileUploadDeviceManagerWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(HexFileUploadDevice.class, icon);
// Read/Write
@@ -410,6 +424,8 @@
lcdMessageWindow.pack();
+ internalFrames.add(lcdMessageWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(
miosStudio.getLcdMessageDevice(), icon);
@@ -426,6 +442,8 @@
debugFunctionWindow.pack();
+ internalFrames.add(debugFunctionWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(miosStudio
.getDebugFunctionDevice(), icon);
@@ -440,6 +458,8 @@
miosTerminalWindow.pack();
+ internalFrames.add(miosTerminalWindow);
+
midiDeviceRoutingGUI.addMidiDeviceIcon(miosStudio
.getMIOSTerminalDevice(), icon);
}
@@ -660,15 +680,39 @@
toolBar.setVisible(true);
}
+ public HexFileUploadDeviceManagerGUI getHexFileUploadDeviceManagerGUI() {
+ return hexFileUploadDeviceManagerGUI;
+ }
+
+ public Vector getInternalFrames() {
+ return internalFrames;
+ }
+
public static String getCurrentDirectory() {
return currentDirectory;
}
public static void setCurrentDirectory(String currentDirectory) {
+
MIOSStudioGUI.currentDirectory = currentDirectory;
}
- protected void removeExternalCommandButton(ExternalCommandButton button) {
+ public void setLookAndFeel(String lookAndFeel) {
+
+ this.lookAndFeel = lookAndFeel;
+
+ if (!lookAndFeel
+ .equals(UIManager.getLookAndFeel().getClass().getName())) {
+
+ JOptionPane
+ .showMessageDialog(
+ MIOSStudioGUI.this,
+ "The selected Look & Feel will be applied the next time you restart MIOS Studio",
+ "ALERT", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void removeExternalCommandButton(ExternalCommandButton button) {
externalCommands.remove(button);
toolBar.remove(button);
assignExternalButtonMnemonics();
@@ -703,6 +747,8 @@
createHelpButtons();
+ toolBar.addSeparator();
+
toolBarMenu = new JPopupMenu();
JMenuItem addButton = new JMenuItem("Add External Command Button");
addButton.setActionCommand("add_command_button");
@@ -1025,13 +1071,10 @@
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try {
- lookAndFeel = UIManager.getInstalledLookAndFeels()[l]
- .getClassName();
- JOptionPane
- .showMessageDialog(
- MIOSStudioGUI.this,
- "The selected Look & Feel will be applied the next time you restart MIOS Studio",
- "ALERT", JOptionPane.ERROR_MESSAGE);
+
+ setLookAndFeel(UIManager.getInstalledLookAndFeels()[l]
+ .getClassName());
+
} catch (Exception e) {
System.out.println(e.toString());
}
@@ -1038,14 +1081,6 @@
}
});
}
-
- item = new JCheckBoxMenuItem("Include Frames/Dialogs",
- defaultDecoratedFrames);
- item.setActionCommand("dialogs");
- item.addActionListener(this);
-
- lookAndFeelMenu.addSeparator();
- lookAndFeelMenu.add(item);
}
public JMenu getFileMenu() {
@@ -1052,10 +1087,6 @@
return fileMenu;
}
- public boolean isDefaultDecoratedFrames() {
- return defaultDecoratedFrames;
- }
-
public MIOSStudio getMiosStudio() {
return miosStudio;
}
@@ -1126,14 +1157,57 @@
int nRetVal = fc.showOpenDialog(this);
if (nRetVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
- MIOSStudioXML.TAG_ROOT_ELEMENT);
+ final File file = fc.getSelectedFile();
- miosStudioXML.loadXML(file);
+ final WorkspaceOptionDialog workspaceOptionDialog = new WorkspaceOptionDialog();
- currentDirectory = fc.getCurrentDirectory().toString();
+ workspaceOptionDialog.pack();
+
+ workspaceOptionDialog.okButton
+ .addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ae) {
+
+ workspaceOptionDialog.setVisible(false);
+
+ boolean gui;
+
+ boolean model;
+
+ if (workspaceOptionDialog.guiRadioButton
+ .isSelected()) {
+
+ gui = true;
+ model = false;
+
+ } else if (workspaceOptionDialog.modelRadioButton
+ .isSelected()) {
+
+ gui = false;
+ model = true;
+
+ } else {
+
+ gui = true;
+ model = true;
+ }
+
+ MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
+ MIOSStudioGUI.this,
+ MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
+ gui);
+
+ miosStudioGUIXML.loadXML(file);
+
+ currentDirectory = fc.getCurrentDirectory()
+ .toString();
+ }
+ });
+
+ workspaceOptionDialog.setLocationRelativeTo(this);
+
+ workspaceOptionDialog.setVisible(true);
}
}
@@ -1155,14 +1229,57 @@
int nRetVal = fc.showSaveDialog(this);
if (nRetVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
- MIOSStudioXML.TAG_ROOT_ELEMENT);
+ final File file = fc.getSelectedFile();
- miosStudioXML.saveXML(file);
+ final WorkspaceOptionDialog workspaceOptionDialog = new WorkspaceOptionDialog();
- currentDirectory = fc.getCurrentDirectory().toString();
+ workspaceOptionDialog.pack();
+
+ workspaceOptionDialog.okButton
+ .addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ae) {
+
+ workspaceOptionDialog.setVisible(false);
+
+ boolean gui;
+
+ boolean model;
+
+ if (workspaceOptionDialog.guiRadioButton
+ .isSelected()) {
+
+ gui = true;
+ model = false;
+
+ } else if (workspaceOptionDialog.modelRadioButton
+ .isSelected()) {
+
+ gui = false;
+ model = true;
+
+ } else {
+
+ gui = true;
+ model = true;
+ }
+
+ MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
+ MIOSStudioGUI.this,
+ MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
+ gui);
+
+ miosStudioGUIXML.saveXML(file);
+
+ currentDirectory = fc.getCurrentDirectory()
+ .toString();
+ }
+ });
+
+ workspaceOptionDialog.setLocationRelativeTo(this);
+
+ workspaceOptionDialog.setVisible(true);
}
}
@@ -1302,10 +1419,6 @@
} else if (ae.getActionCommand().equals("add_command_button")) {
addExternalCommandButton("[empty]", "");
- } else if (ae.getActionCommand().equals("dialogs")) {
- defaultDecoratedFrames = ((JCheckBoxMenuItem) ae.getSource())
- .isSelected();
-
} else if (ae.getActionCommand().equals("open_workspace")) {
openWorkspace();
@@ -1535,4 +1648,60 @@
}
}
}
+
+ class WorkspaceOptionDialog extends JDialog {
+
+ ButtonGroup buttonGroup;
+
+ JRadioButton modelRadioButton;
+
+ JRadioButton guiRadioButton;
+
+ JButton okButton;
+
+ public WorkspaceOptionDialog() {
+
+ super(DialogOwner.getFrame(), "Workspace Options", true);
+
+ JPanel panel = new JPanel(new GridBagLayout());
+
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.gridwidth = 1;
+ gbc.gridheight = 1;
+ gbc.anchor = (GridBagConstraints.WEST);
+ gbc.insets = new Insets(5, 5, 5, 5);
+
+ JLabel label = new JLabel("Load/save workspace: ");
+ panel.add(label, gbc);
+ gbc.gridy++;
+
+ buttonGroup = new ButtonGroup();
+
+ JRadioButton radioButton = new JRadioButton(
+ "Graphical layout and MIOS Studio setup", true);
+ panel.add(radioButton, gbc);
+ buttonGroup.add(radioButton);
+ gbc.gridy++;
+
+ guiRadioButton = new JRadioButton("Graphical layout only", false);
+ panel.add(guiRadioButton, gbc);
+ buttonGroup.add(guiRadioButton);
+ gbc.gridy++;
+
+ modelRadioButton = new JRadioButton("MIOS Studio setup only", false);
+ panel.add(modelRadioButton, gbc);
+ buttonGroup.add(modelRadioButton);
+ gbc.gridy++;
+
+ gbc.anchor = (GridBagConstraints.CENTER);
+
+ okButton = new JButton("OK");
+ panel.add(okButton, gbc);
+
+ setContentPane(panel);
+ }
+ }
}
/trunk/java/org/midibox/apps/miosstudiosid/gui/xml/MIOSStudioSIDGUIXML.java
New file
0,0 → 1,29
package org.midibox.apps.miosstudiosid.gui.xml;
 
import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
import org.midibox.apps.miosstudiosid.MIOSStudioSID;
import org.midibox.apps.miosstudiosid.gui.MIOSStudioSIDGUI;
 
public class MIOSStudioSIDGUIXML extends MIOSStudioGUIXML {
 
public MIOSStudioSIDGUIXML(MIOSStudioSID miosStudioSID, String rootElementTag,
boolean includeModel, boolean includeGUI) {
super(miosStudioSID, rootElementTag, includeModel, includeGUI);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
String rootElementTag, boolean includeModel, boolean includeGUI) {
super(miosStudioSIDGUI, rootElementTag, includeModel, includeGUI);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
MIOSStudioSID miosStudioSID, String rootElementTag, boolean includeModel,
boolean includeGUI) {
super(miosStudioSIDGUI, miosStudioSID, rootElementTag, includeModel, includeGUI);
}
protected void createGUI() {
this.miosStudioGUI = new MIOSStudioSIDGUI((MIOSStudioSID) miosStudio);
}
}
/trunk/java/org/midibox/apps/miosstudiosid/gui/MIOSStudioSIDGUI.java
51,6 → 51,8
sidv2librariangui.createMenu();
 
sidv2librarianWindow.pack();
internalFrames.add(sidv2librarianWindow);
 
midiDeviceRoutingGUI.addMidiDeviceIcon(
((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
/trunk/java/org/midibox/apps/virtualkeyboard/gui/xml/VirtualKeyboardGUIXML.java
New file
0,0 → 1,165
package org.midibox.apps.virtualkeyboard.gui.xml;
 
import java.awt.Dimension;
import java.awt.Point;
 
import javax.swing.JFrame;
import javax.swing.UIManager;
 
import org.midibox.apps.miosstudio.xml.MIOSStudioXML;
import org.midibox.apps.virtualkeyboard.VirtualKeyboard;
import org.midibox.apps.virtualkeyboard.gui.VirtualKeyboardGUI;
import org.midibox.apps.virtualkeyboard.xml.VirtualKeyboardXML;
import org.midibox.utils.gui.DialogOwner;
import org.midibox.utils.xml.XMLUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 
public class VirtualKeyboardGUIXML extends XMLUtils {
 
public static final String TAG_ROOT_ELEMENT = "virtualKeyboardGUI";
 
public final static String TAG_LOOK_AND_FEEL = "lookAndFeel";
 
public final static String TAG_MAIN_WINDOW = "mainWindow";
 
public final static String TAG_CONNECTIONS_VISIBLE = "connectionsVisible";
 
public final static String ATTR_POS_X = "posX";
 
public final static String ATTR_POS_Y = "posY";
 
public final static String ATTR_WIDTH = "width";
 
public final static String ATTR_HEIGHT = "height";
 
public final static String ATTR_ENABLE = "enable";
 
protected VirtualKeyboardGUI virtualKeyboardGUI;
 
protected VirtualKeyboard virtualKeyboard;
 
public VirtualKeyboardGUIXML(VirtualKeyboard virtualKeyboard,
String rootElementTag) {
 
this(null, virtualKeyboard, rootElementTag);
}
 
public VirtualKeyboardGUIXML(VirtualKeyboardGUI virtualKeyboardGUI,
String rootElementTag) {
 
this(virtualKeyboardGUI, virtualKeyboardGUI.getVirtualKeyboard(),
rootElementTag);
}
 
public VirtualKeyboardGUIXML(VirtualKeyboardGUI virtualKeyboardGUI,
VirtualKeyboard virtualKeyboard, String rootElementTag) {
 
super(rootElementTag);
 
this.virtualKeyboard = virtualKeyboard;
 
this.virtualKeyboardGUI = virtualKeyboardGUI;
 
tags.add(VirtualKeyboardXML.TAG_ROOT_ELEMENT);
tags.add(TAG_LOOK_AND_FEEL);
tags.add(TAG_MAIN_WINDOW);
tags.add(TAG_CONNECTIONS_VISIBLE);
}
 
protected void parseElement(Element element) {
 
super.parseElement(element);
 
String name = element.getNodeName();
 
if (name == rootElementTag) {
 
} else if (name == VirtualKeyboardXML.TAG_ROOT_ELEMENT) {
 
VirtualKeyboardXML virtualKeyboardXML = new VirtualKeyboardXML(
virtualKeyboard, VirtualKeyboardXML.TAG_ROOT_ELEMENT);
 
virtualKeyboardXML.loadXML(element);
 
} else if (name == TAG_MAIN_WINDOW) {
 
JFrame mainWindow = DialogOwner.getFrame();
 
if (mainWindow != null) {
 
mainWindow.setLocation(new Point(stringToInt(element
.getAttribute(ATTR_POS_X)), stringToInt(element
.getAttribute(ATTR_POS_Y))));
}
 
} else if (name == TAG_LOOK_AND_FEEL) {
 
String lookAndFeel = element.getTextContent();
 
if (virtualKeyboardGUI == null) {
 
try {
 
UIManager.setLookAndFeel(lookAndFeel);
 
} catch (Exception e) {
 
e.printStackTrace();
}
 
virtualKeyboardGUI = new VirtualKeyboardGUI(virtualKeyboard);
}
 
virtualKeyboardGUI.setLookAndFeel(lookAndFeel);
 
} else if (name == TAG_CONNECTIONS_VISIBLE) {
 
virtualKeyboardGUI.setShowConnections(stringToBoolean(element
.getAttribute(ATTR_ENABLE)));
}
}
 
public void saveXML(Node node) {
 
super.saveXML(node);
 
VirtualKeyboardXML virtualKeyboardXML = new VirtualKeyboardXML(
virtualKeyboard, VirtualKeyboardXML.TAG_ROOT_ELEMENT);
 
virtualKeyboardXML.saveXML(rootElement);
 
JFrame mainWindow = DialogOwner.getFrame();
 
if (mainWindow != null) {
 
Element mainWindowElement = document.createElement(TAG_MAIN_WINDOW);
 
rootElement.appendChild(mainWindowElement);
 
mainWindowElement.setAttribute(ATTR_POS_X, intToString(mainWindow
.getX()));
 
mainWindowElement.setAttribute(ATTR_POS_Y, intToString(mainWindow
.getY()));
}
 
Element lookAndFeelElement = document.createElement(TAG_LOOK_AND_FEEL);
 
rootElement.appendChild(lookAndFeelElement);
 
lookAndFeelElement.setTextContent(virtualKeyboardGUI.getLookAndFeel());
 
Element connectionsVisibleElement = document
.createElement(TAG_CONNECTIONS_VISIBLE);
 
rootElement.appendChild(connectionsVisibleElement);
 
connectionsVisibleElement.setAttribute(ATTR_ENABLE,
booleanToString(virtualKeyboardGUI.isShowConnections()));
}
 
public VirtualKeyboardGUI getVirtualKeyboardGUI() {
return virtualKeyboardGUI;
}
}
/trunk/java/org/midibox/apps/virtualkeyboard/gui/VirtualKeyboardGUI.java
36,6 → 36,7
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
 
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
import org.midibox.apps.virtualkeyboard.VirtualKeyboard;
import org.midibox.midi.MidiRouterDevice;
import org.midibox.midi.gui.MidiDeviceRoutingGUI;
57,15 → 58,16
private JMenu lookAndFeelMenu;
 
private String lookAndFeel;
protected VirtualKeyboard virtualKeyboard;
 
private boolean defaultDecoratedFrames;
 
public VirtualKeyboardGUI(VirtualKeyboard virtualKeyboard) {
 
super(new GridBagLayout());
 
this.virtualKeyboard = virtualKeyboard;
lookAndFeel = UIManager.getLookAndFeel().getClass().getName();
defaultDecoratedFrames = JFrame.isDefaultLookAndFeelDecorated();
 
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
160,13 → 162,10
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try {
lookAndFeel = UIManager.getInstalledLookAndFeels()[l]
.getClassName();
JOptionPane
.showMessageDialog(
VirtualKeyboardGUI.this,
"The selected Look & Feel will be applied the next time you restart Virtual Keyboard",
"ALERT", JOptionPane.ERROR_MESSAGE);
setLookAndFeel(UIManager.getInstalledLookAndFeels()[l]
.getClassName());
} catch (Exception e) {
System.out.println(e.toString());
}
173,20 → 172,25
}
});
}
}
 
item = new JCheckBoxMenuItem("Include Frames/Dialogs",
defaultDecoratedFrames);
item.setActionCommand("dialogs");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
defaultDecoratedFrames = ((JCheckBoxMenuItem) ae.getSource())
.isSelected();
}
});
 
lookAndFeelMenu.addSeparator();
lookAndFeelMenu.add(item);
public void setLookAndFeel(String lookAndFeel) {
this.lookAndFeel = lookAndFeel;
if (!lookAndFeel.equals(UIManager.getLookAndFeel().getClass().getName())) {
JOptionPane
.showMessageDialog(
VirtualKeyboardGUI.this,
"The selected Look & Feel will be applied the next time you restart Virtual Keyboard",
"ALERT", JOptionPane.ERROR_MESSAGE);
}
}
public VirtualKeyboard getVirtualKeyboard() {
return virtualKeyboard;
}
 
public boolean isShowConnections() {
return showConnections;
194,7 → 198,6
 
public void setShowConnections(boolean showConnections) {
this.showConnections = showConnections;
showConnectionsItem.setSelected(showConnections);
midiDeviceRoutingGUI.setVisible(showConnections);
revalidate();
}
207,12 → 210,7
return fileMenu;
}
 
public boolean isDefaultDecoratedFrames() {
return defaultDecoratedFrames;
}
 
public String getLookAndFeel() {
return lookAndFeel;
}
 
}
/trunk/java/org/midibox/mios/gui/HexFileUploadDeviceManagerGUI.java
63,6 → 63,10
 
createGUIs();
}
public JTabbedPane getTabbedPane() {
return tabbedPane;
}
 
private JPanel createButtonPanel() {
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));