Subversion Repositories svn.mios

Rev

Rev 753 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 753 Rev 808
1
package org.midibox.apps.virtualkeyboard.xml;
1
package org.midibox.apps.virtualkeyboard.xml;
2
2
3
import org.midibox.apps.virtualkeyboard.VirtualKeyboard;
3
import org.midibox.apps.virtualkeyboard.VirtualKeyboard;
4
import org.midibox.midi.xml.MidiDeviceRoutingXML;
4
import org.midibox.midi.xml.MidiDeviceRoutingXML;
5
import org.midibox.midi.xml.MidiKeyboardControllerDeviceXML;
5
import org.midibox.midi.xml.MidiKeyboardControllerXML;
6
import org.midibox.utils.xml.XMLUtils;
6
import org.midibox.utils.xml.XMLUtils;
7
import org.w3c.dom.Element;
7
import org.w3c.dom.Element;
8
import org.w3c.dom.Node;
8
import org.w3c.dom.Node;
9
9
10
public class VirtualKeyboardXML extends XMLUtils {
10
public class VirtualKeyboardXML extends XMLUtils {
11
11
12
    public final static String TAG_ROOT_ELEMENT = "virtualKeyboard";
12
    public final static String TAG_ROOT_ELEMENT = "virtualKeyboard";
13
13
14
    protected VirtualKeyboard virtualKeyboard;
14
    protected VirtualKeyboard virtualKeyboard;
15
15
16
    public VirtualKeyboardXML(VirtualKeyboard virtualKeyboard,
16
    public VirtualKeyboardXML(VirtualKeyboard virtualKeyboard,
17
            String rootElementTag) {
17
            String rootElementTag) {
18
18
19
        super(rootElementTag);
19
        super(rootElementTag);
20
20
21
        this.virtualKeyboard = virtualKeyboard;
21
        this.virtualKeyboard = virtualKeyboard;
22
22
23
        addTag(MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
23
        addTag(MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
24
        addTag(MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT);
24
        addTag(MidiKeyboardControllerXML.TAG_ROOT_ELEMENT);
25
    }
25
    }
26
26
27
    protected void parseElement(Element element) {
27
    protected void parseElement(Element element) {
28
28
29
        super.parseElement(element);
29
        super.parseElement(element);
30
30
31
        String name = element.getNodeName();
31
        String name = element.getNodeName();
32
32
33
        if (name == rootElementTag) {
33
        if (name == rootElementTag) {
34
34
35
        } else if (name == MidiDeviceRoutingXML.TAG_ROOT_ELEMENT) {
35
        } else if (name == MidiDeviceRoutingXML.TAG_ROOT_ELEMENT) {
36
36
37
            MidiDeviceRoutingXML midiDeviceRoutingXML = new MidiDeviceRoutingXML(
37
            MidiDeviceRoutingXML midiDeviceRoutingXML = new MidiDeviceRoutingXML(
38
                    virtualKeyboard.getMidiDeviceRouting(),
38
                    virtualKeyboard.getMidiDeviceRouting(),
39
                    MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
39
                    MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
40
40
41
            midiDeviceRoutingXML.loadXML(element);
41
            midiDeviceRoutingXML.loadXML(element);
42
42
43
        } else if (name == MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT) {
43
        } else if (name == MidiKeyboardControllerXML.TAG_ROOT_ELEMENT) {
44
44
45
            MidiKeyboardControllerDeviceXML midiKeyboardControllerDeviceXML = new MidiKeyboardControllerDeviceXML(
45
            MidiKeyboardControllerXML midiKeyboardControllerXML = new MidiKeyboardControllerXML(
46
                    virtualKeyboard.getMidiKeyboardControllerDevice(),
46
                    virtualKeyboard.getMidiKeyboardController(),
47
                    MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT);
47
                    MidiKeyboardControllerXML.TAG_ROOT_ELEMENT);
48
48
49
            midiKeyboardControllerDeviceXML.loadXML(element);
49
            midiKeyboardControllerXML.loadXML(element);
50
        }
50
        }
51
    }
51
    }
52
52
53
    public void saveXML(Node node) {
53
    public void saveXML(Node node) {
54
54
55
        super.saveXML(node);
55
        super.saveXML(node);
56
56
57
        MidiDeviceRoutingXML midiDeviceRoutingXML = new MidiDeviceRoutingXML(
57
        MidiDeviceRoutingXML midiDeviceRoutingXML = new MidiDeviceRoutingXML(
58
                virtualKeyboard.getMidiDeviceRouting(),
58
                virtualKeyboard.getMidiDeviceRouting(),
59
                MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
59
                MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
60
60
61
        midiDeviceRoutingXML.saveXML(rootElement);
61
        midiDeviceRoutingXML.saveXML(rootElement);
62
62
63
        MidiKeyboardControllerDeviceXML midiKeyboardControllerDeviceXML = new MidiKeyboardControllerDeviceXML(
63
        MidiKeyboardControllerXML midiKeyboardControllerDeviceXML = new MidiKeyboardControllerXML(
64
                virtualKeyboard.getMidiKeyboardControllerDevice(),
64
                virtualKeyboard.getMidiKeyboardController(),
65
                MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT);
65
                MidiKeyboardControllerXML.TAG_ROOT_ELEMENT);
66
66
67
        midiKeyboardControllerDeviceXML.saveXML(rootElement);
67
        midiKeyboardControllerDeviceXML.saveXML(rootElement);
68
    }
68
    }
69
}
69
}
70
 
70