Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
628 adamjking 1
package org.midibox.apps.miosstudiosid.gui;
2
 
3
import java.awt.Insets;
4
import java.awt.event.ActionEvent;
657 adamjking 5
import java.util.Observable;
6
import java.util.Observer;
628 adamjking 7
 
8
import javax.swing.Icon;
9
import javax.swing.JButton;
10
import javax.swing.JMenuItem;
11
 
12
import org.midibox.apps.SIDV2librarian.gui.SIDV2librarianGUI;
13
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
14
import org.midibox.apps.miosstudiosid.MIOSStudioSID;
15
import org.midibox.utils.gui.ImageLoader;
16
 
657 adamjking 17
public class MIOSStudioSIDGUI extends MIOSStudioGUI implements Observer {
628 adamjking 18
 
19
    protected SIDV2librarianGUI sidv2librariangui;
20
 
21
    protected MIOSStudioInternalFrame sidv2librarianWindow;
22
 
23
    public MIOSStudioSIDGUI(MIOSStudioSID miosStudioSID) {
24
        super(miosStudioSID);
657 adamjking 25
 
26
        sidv2librariangui.getSidv2librarian().getSIDLibController()
27
                .addObserver(this);
628 adamjking 28
    }
29
 
30
    public MIOSStudioInternalFrame getSidv2librarianWindow() {
31
        return sidv2librarianWindow;
32
    }
33
 
34
    protected void createInternalFrames() {
35
        super.createInternalFrames();
36
 
37
        // SIDV2 Librarian
38
 
39
        sidv2librariangui = new SIDV2librarianGUI(
40
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
41
                        .getSidv2librarian());
42
 
43
        Icon icon = ImageLoader.getImageIcon("sid.png");
44
 
45
        sidv2librarianWindow = new MIOSStudioInternalFrame("SIDV2 Librarian",
46
                false, true, false, true, icon, sidv2librariangui);
47
 
48
        sidv2librarianWindow.setJMenuBar(sidv2librariangui.createMenu());
49
 
50
        sidv2librarianWindow.pack();
51
 
52
        midiDeviceRoutingGUI.addMidiDeviceIcon(
53
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
54
                        .getSidv2librarian().getSysExControllerDevice(), icon);
55
    }
56
 
57
    protected void createMIOSMenu() {
58
 
59
        super.createMIOSMenu();
60
 
61
        JMenuItem menuItem = new JMenuItem("SIDV2 Librarian");
62
        menuItem.setActionCommand("sidv2_librarian");
63
        menuItem.addActionListener(this);
64
        miosMenu.add(menuItem);
65
    }
66
 
67
    protected void createMIOSButtons() {
68
 
69
        super.createMIOSButtons();
70
 
71
        Insets insets = new Insets(2, 2, 2, 2);
72
 
73
        JButton button = new JButton(ImageLoader.getImageIcon("sid.png"));
74
        button.setToolTipText("SIDV2 Librarian");
75
        button.setActionCommand("sidv2_librarian");
76
        button.addActionListener(this);
77
        button.setMargin(insets);
78
        toolBar.add(button);
79
    }
80
 
81
    public void actionPerformed(ActionEvent ae) {
82
 
83
        super.actionPerformed(ae);
84
 
85
        if (ae.getActionCommand().equals("sidv2_librarian")) {
86
            showFrame(sidv2librarianWindow);
87
 
88
        }
89
    }
657 adamjking 90
 
91
    public void update(Observable observable, Object object) {
92
 
93
        if (object == "Edit") {
94
 
95
            boolean portsReleased = miosStudio.getMidiDeviceRouting()
96
                    .getPortsReleased();
97
 
98
            if (!portsReleased) {
99
 
100
                System.out.println("Now releasing ports!");
101
 
102
                miosStudio.getMidiDeviceRouting().setPortsReleased(true);
103
 
104
                System.out.println("Ports released successfully");
105
 
106
                miosStudio.getMidiDeviceRouting().setPortsReleased(false);
107
 
108
                System.out.println("Ports recaimed successfully");
109
            }
110
        }
111
    }
628 adamjking 112
}