Subversion Repositories svn.mios

Rev

Rev 684 | Rev 723 | 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;
658 adamjking 5
import java.awt.event.KeyEvent;
657 adamjking 6
import java.util.Observable;
7
import java.util.Observer;
628 adamjking 8
 
9
import javax.swing.Icon;
10
import javax.swing.JButton;
11
import javax.swing.JMenuItem;
658 adamjking 12
import javax.swing.KeyStroke;
628 adamjking 13
 
14
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
15
import org.midibox.apps.miosstudiosid.MIOSStudioSID;
684 adamjking 16
import org.midibox.apps.sidv2editor.gui.SIDV2EditorGUI;
628 adamjking 17
import org.midibox.utils.gui.ImageLoader;
18
 
657 adamjking 19
public class MIOSStudioSIDGUI extends MIOSStudioGUI implements Observer {
628 adamjking 20
 
684 adamjking 21
    protected SIDV2EditorGUI sidv2librariangui;
628 adamjking 22
 
23
    protected MIOSStudioInternalFrame sidv2librarianWindow;
24
 
25
    public MIOSStudioSIDGUI(MIOSStudioSID miosStudioSID) {
26
        super(miosStudioSID);
657 adamjking 27
 
28
        sidv2librariangui.getSidv2librarian().getSIDLibController()
29
                .addObserver(this);
628 adamjking 30
    }
31
 
32
    public MIOSStudioInternalFrame getSidv2librarianWindow() {
33
        return sidv2librarianWindow;
34
    }
35
 
36
    protected void createInternalFrames() {
37
        super.createInternalFrames();
38
 
39
        // SIDV2 Librarian
40
 
684 adamjking 41
        sidv2librariangui = new SIDV2EditorGUI(
628 adamjking 42
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
43
                        .getSidv2librarian());
44
 
45
        Icon icon = ImageLoader.getImageIcon("sid.png");
46
 
658 adamjking 47
        sidv2librarianWindow = new MIOSStudioInternalFrame("SID V2 Editor",
628 adamjking 48
                false, true, false, true, icon, sidv2librariangui);
49
 
50
        sidv2librarianWindow.setJMenuBar(sidv2librariangui.createMenu());
51
 
52
        sidv2librarianWindow.pack();
53
 
54
        midiDeviceRoutingGUI.addMidiDeviceIcon(
55
                ((org.midibox.apps.miosstudiosid.MIOSStudioSID) miosStudio)
56
                        .getSidv2librarian().getSysExControllerDevice(), icon);
57
    }
58
 
59
    protected void createMIOSMenu() {
60
 
61
        super.createMIOSMenu();
62
 
658 adamjking 63
        JMenuItem menuItem = new JMenuItem("SID V2 Editor");
64
        menuItem.setMnemonic(KeyEvent.VK_E);
65
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
66
                ActionEvent.CTRL_MASK));
628 adamjking 67
        menuItem.setActionCommand("sidv2_librarian");
68
        menuItem.addActionListener(this);
69
        miosMenu.add(menuItem);
70
    }
71
 
72
    protected void createMIOSButtons() {
73
 
74
        super.createMIOSButtons();
75
 
76
        Insets insets = new Insets(2, 2, 2, 2);
77
 
78
        JButton button = new JButton(ImageLoader.getImageIcon("sid.png"));
658 adamjking 79
        button.setToolTipText("SID V2 Editor");
628 adamjking 80
        button.setActionCommand("sidv2_librarian");
81
        button.addActionListener(this);
82
        button.setMargin(insets);
83
        toolBar.add(button);
84
    }
85
 
86
    public void actionPerformed(ActionEvent ae) {
87
 
88
        super.actionPerformed(ae);
89
 
90
        if (ae.getActionCommand().equals("sidv2_librarian")) {
91
            showFrame(sidv2librarianWindow);
92
 
93
        }
94
    }
657 adamjking 95
 
96
    public void update(Observable observable, Object object) {
97
 
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
}