Subversion Repositories svn.mios

Rev

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