Subversion Repositories svn.mios

Rev

Rev 738 | Rev 741 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 738 Rev 739
Line 1... Line 1...
1
package org.midibox.midi.xml;
1
package org.midibox.midi.xml;
2
2
-
 
3
import java.util.HashMap;
3
import java.util.Iterator;
4
import java.util.Iterator;
4
import java.util.Vector;
-
 
5
5
6
import javax.sound.midi.MidiDevice;
6
import javax.sound.midi.MidiDevice;
7
7
8
import org.midibox.midi.MidiDeviceManager;
8
import org.midibox.midi.MidiDeviceManager;
9
import org.midibox.utils.xml.XMLUtils;
9
import org.midibox.utils.xml.XMLUtils;
Line 86... Line 86...
86
        Element deselectedMidiReadDevicesElement = document
86
        Element deselectedMidiReadDevicesElement = document
87
                .createElement(TAG_DESELECTED_MIDI_READ_DEVICES);
87
                .createElement(TAG_DESELECTED_MIDI_READ_DEVICES);
88
88
89
        rootElement.appendChild(deselectedMidiReadDevicesElement);
89
        rootElement.appendChild(deselectedMidiReadDevicesElement);
90
90
91
        Iterator it = midiDeviceManager.getMidiReadDevices().iterator();
91
        Iterator it = midiDeviceManager.getMidiReadDevices().values()
-
 
92
                .iterator();
92
93
93
        while (it.hasNext()) {
94
        while (it.hasNext()) {
94
95
95
            MidiDevice midiDevice = (MidiDevice) it.next();
96
            MidiDevice midiDevice = (MidiDevice) it.next();
96
97
97
            if (!midiDeviceManager.getSelectedMidiReadDevices().contains(
98
            if (!midiDeviceManager.getSelectedMidiReadDevices().values()
98
                    midiDevice)) {
99
                    .contains(midiDevice)) {
99
100
100
                MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
101
                MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
101
                        TAG_DESELECTED_MIDI_READ_DEVICE);
102
                        TAG_DESELECTED_MIDI_READ_DEVICE);
102
103
103
                midiDeviceXML.saveXML(deselectedMidiReadDevicesElement);
104
                midiDeviceXML.saveXML(deselectedMidiReadDevicesElement);
Line 107... Line 108...
107
        Element deselectedMidiWriteDevicesElement = document
108
        Element deselectedMidiWriteDevicesElement = document
108
                .createElement(TAG_DESELECTED_MIDI_WRITE_DEVICES);
109
                .createElement(TAG_DESELECTED_MIDI_WRITE_DEVICES);
109
110
110
        rootElement.appendChild(deselectedMidiWriteDevicesElement);
111
        rootElement.appendChild(deselectedMidiWriteDevicesElement);
111
112
112
        it = midiDeviceManager.getMidiWriteDevices().iterator();
113
        it = midiDeviceManager.getMidiWriteDevices().values().iterator();
113
114
114
        while (it.hasNext()) {
115
        while (it.hasNext()) {
115
116
116
            MidiDevice midiDevice = (MidiDevice) it.next();
117
            MidiDevice midiDevice = (MidiDevice) it.next();
117
118
118
            if (!midiDeviceManager.getSelectedMidiWriteDevices().contains(
119
            if (!midiDeviceManager.getSelectedMidiWriteDevices().values()
119
                    midiDevice)) {
120
                    .contains(midiDevice)) {
120
121
121
                MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
122
                MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
122
                        TAG_DESELECTED_MIDI_WRITE_DEVICE);
123
                        TAG_DESELECTED_MIDI_WRITE_DEVICE);
123
124
124
                midiDeviceXML.saveXML(deselectedMidiWriteDevicesElement);
125
                midiDeviceXML.saveXML(deselectedMidiWriteDevicesElement);
125
            }
126
            }
126
        }
127
        }
127
    }
128
    }
128
129
129
    protected MidiDevice findDeviceHash(Vector midiDevices, int hash) {
130
    protected MidiDevice findDeviceHash(HashMap midiDevices, int hash) {
130
131
131
        Iterator it = midiDevices.iterator();
-
 
132
-
 
133
        while (it.hasNext()) {
-
 
134
-
 
135
            MidiDevice midiDevice = (MidiDevice) it.next();
132
        return (MidiDevice) midiDevices.get("" + hash);
136
-
 
137
            if (midiDevice.getDeviceInfo().toString().hashCode() == hash) {
-
 
138
-
 
139
                return midiDevice;
-
 
140
            }
-
 
141
        }
-
 
142
-
 
143
        return null;
-
 
144
    }
133
    }
145
}
134
}