Subversion Repositories svn.mios

Rev

Rev 871 | 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;
874 adamjking 10
import javax.swing.JMenu;
628 adamjking 11
import javax.swing.JMenuItem;
12
 
13
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
14
import org.midibox.apps.miosstudiosid.MIOSStudioSID;
684 adamjking 15
import org.midibox.apps.sidv2editor.gui.SIDV2EditorGUI;
628 adamjking 16
import org.midibox.utils.gui.ImageLoader;
17
 
657 adamjking 18
public class MIOSStudioSIDGUI extends MIOSStudioGUI implements Observer {
628 adamjking 19
 
684 adamjking 20
    protected SIDV2EditorGUI sidv2librariangui;
628 adamjking 21
 
22
    protected MIOSStudioInternalFrame sidv2librarianWindow;
23
 
24
    public MIOSStudioSIDGUI(MIOSStudioSID miosStudioSID) {
25
        super(miosStudioSID);
657 adamjking 26
 
27
        sidv2librariangui.getSidv2librarian().getSIDLibController()
28
                .addObserver(this);
628 adamjking 29
    }
30
 
31
    public MIOSStudioInternalFrame getSidv2librarianWindow() {
32
        return sidv2librarianWindow;
33
    }
34
 
35
    protected void createInternalFrames() {
871 adamjking 36
        super.createFrames();
628 adamjking 37
 
38
        // SIDV2 Librarian
39
 
684 adamjking 40
        sidv2librariangui = new SIDV2EditorGUI(
628 adamjking 41
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
42
                        .getSidv2librarian());
43
 
44
        Icon icon = ImageLoader.getImageIcon("sid.png");
45
 
658 adamjking 46
        sidv2librarianWindow = new MIOSStudioInternalFrame("SID V2 Editor",
871 adamjking 47
                true, true, icon, sidv2librariangui);
628 adamjking 48
 
730 adamjking 49
        // Don't display menu bar when integrated in MIOS Studio
50
        sidv2librariangui.createMenu();
628 adamjking 51
 
52
        sidv2librarianWindow.pack();
808 adamjking 53
 
741 adamjking 54
        internalFrames.add(sidv2librarianWindow);
628 adamjking 55
 
56
        midiDeviceRoutingGUI.addMidiDeviceIcon(
57
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
808 adamjking 58
                        .getSidv2librarian().getSysExController(), icon);
628 adamjking 59
    }
60
 
874 adamjking 61
    protected JMenu createMIOSMenu() {
628 adamjking 62
 
874 adamjking 63
        JMenu miosMenu = super.createMIOSMenu();
628 adamjking 64
 
658 adamjking 65
        JMenuItem menuItem = new JMenuItem("SID V2 Editor");
628 adamjking 66
        menuItem.setActionCommand("sidv2_librarian");
67
        menuItem.addActionListener(this);
68
        miosMenu.add(menuItem);
874 adamjking 69
 
70
        return miosMenu;
628 adamjking 71
    }
72
 
73
    protected void createMIOSButtons() {
74
 
75
        super.createMIOSButtons();
76
 
77
        Insets insets = new Insets(2, 2, 2, 2);
78
 
79
        JButton button = new JButton(ImageLoader.getImageIcon("sid.png"));
658 adamjking 80
        button.setToolTipText("SID V2 Editor");
628 adamjking 81
        button.setActionCommand("sidv2_librarian");
82
        button.addActionListener(this);
83
        button.setMargin(insets);
84
        toolBar.add(button);
85
    }
86
 
87
    public void actionPerformed(ActionEvent ae) {
88
 
89
        super.actionPerformed(ae);
90
 
91
        if (ae.getActionCommand().equals("sidv2_librarian")) {
92
            showFrame(sidv2librarianWindow);
93
 
94
        }
95
    }
657 adamjking 96
 
97
    public void update(Observable observable, Object object) {
98
 
723 adamjking 99
        super.update(observable, object);
100
 
657 adamjking 101
        if (object == "Edit") {
102
 
103
            boolean portsReleased = miosStudio.getMidiDeviceRouting()
721 adamjking 104
                    .isPortsReleased();
657 adamjking 105
 
106
            if (!portsReleased) {
107
 
108
                System.out.println("Now releasing ports!");
109
 
110
                miosStudio.getMidiDeviceRouting().setPortsReleased(true);
111
 
112
                System.out.println("Ports released successfully");
113
 
114
                miosStudio.getMidiDeviceRouting().setPortsReleased(false);
115
 
116
                System.out.println("Ports recaimed successfully");
117
            }
118
        }
119
    }
628 adamjking 120
}