Subversion Repositories svn.mios

Rev

Rev 247 | Rev 666 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 247 Rev 628
1
/*
1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
5
 *
6
 * This application is free software; you can redistribute it and/or modify
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
9
 * (at your option) any later version.
10
 *
10
 *
11
 * This application is distributed in the hope that it will be useful,
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
14
 * GNU General Public License for more details.
15
 *
15
 *
16
 * You should have received a copy of the GNU General Public License
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
20
21
package org.midibox.sidlibr.gui;
21
package org.midibox.sidlibr.gui;
22
22
23
import java.awt.Dimension;
23
import java.awt.Dimension;
24
-
 
25
import javax.swing.event.*;
24
import java.awt.Font;
-
 
25
import java.awt.event.ActionEvent;
-
 
26
import java.awt.event.ActionListener;
26
import java.awt.event.*;
27
import java.awt.event.KeyEvent;
-
 
28
import java.awt.event.KeyListener;
27
import javax.swing.table.TableModel;
29
import java.awt.event.MouseEvent;
-
 
30
import java.awt.event.MouseListener;
28
import javax.swing.*;
31
import java.util.EventObject;
29
import java.util.Observable;
32
import java.util.Observable;
30
import java.util.Observer;
33
import java.util.Observer;
31
import java.util.EventObject;
-
 
32
import org.midibox.sidlibr.SIDLibController;
-
 
33
34
34
import javax.swing.JMenu;
35
import javax.swing.JMenu;
35
import javax.swing.JMenuItem;
36
import javax.swing.JMenuItem;
36
import javax.swing.JPanel;
37
import javax.swing.JPanel;
-
 
38
import javax.swing.JPopupMenu;
37
import javax.swing.JScrollPane;
39
import javax.swing.JScrollPane;
38
import javax.swing.JTable;
40
import javax.swing.JTable;
39
import javax.swing.KeyStroke;
41
import javax.swing.KeyStroke;
40
import javax.swing.ListSelectionModel;
42
import javax.swing.ListSelectionModel;
-
 
43
import javax.swing.event.ListSelectionEvent;
-
 
44
import javax.swing.event.ListSelectionListener;
-
 
45
import javax.swing.event.TableModelEvent;
-
 
46
import javax.swing.event.TableModelListener;
-
 
47
import javax.swing.table.TableModel;
-
 
48
41
import org.midibox.sidlibr.Bank;
49
import org.midibox.sidlibr.Bank;
42
import java.awt.Font;
50
import org.midibox.sidlibr.SIDLibController;
43
51
44
public class BankTable extends JPanel implements TableModelListener, ListSelectionListener, Observer, MouseListener, ActionListener, KeyListener {
52
public class BankTable extends JPanel implements TableModelListener,
-
 
53
        ListSelectionListener, Observer, MouseListener, ActionListener,
-
 
54
        KeyListener {
45
    private SIDLibController sidLibController;
55
    private SIDLibController sidLibController;
46
    JTable table;
56
    JTable table;
47
    JPopupMenu popupMenu;
57
    JPopupMenu popupMenu;
48
    int bankNumber;
58
    int bankNumber;
49
    int selectedBeforeDrag = 0;
59
    int selectedBeforeDrag = 0;
50
   
60
51
    public BankTable(SIDLibController sidLibController, int bankNumber) {
61
    public BankTable(SIDLibController sidLibController, int bankNumber) {
52
        this.sidLibController = sidLibController;
62
        this.sidLibController = sidLibController;
53
        this.bankNumber = bankNumber;
63
        this.bankNumber = bankNumber;
54
        sidLibController.addObserver(this);
64
        sidLibController.addObserver(this);
55
       
65
56
        createPopupMenu();
66
        createPopupMenu();
57
       
67
58
        table = new JTable(new BankTableModel(sidLibController.getBank(bankNumber)));
68
        table = new JTable(new BankTableModel(sidLibController
-
 
69
                .getBank(bankNumber)));
59
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
70
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
60
        table.getModel().addTableModelListener(this);      
71
        table.getModel().addTableModelListener(this);
61
        table.addMouseListener(this);
72
        table.addMouseListener(this);
62
        table.addKeyListener(this);
73
        table.addKeyListener(this);
63
        table.getSelectionModel().addListSelectionListener(this);
74
        table.getSelectionModel().addListSelectionListener(this);
64
       
75
-
 
76
        table.getColumnModel().getColumn(1)
65
        table.getColumnModel().getColumn(1).setCellEditor(new PatchNameEditor());
77
                .setCellEditor(new PatchNameEditor());
66
        table.getColumnModel().getColumn(0).setPreferredWidth(30);
78
        table.getColumnModel().getColumn(0).setPreferredWidth(30);
67
        table.getColumnModel().getColumn(1).setPreferredWidth(170);
79
        table.getColumnModel().getColumn(1).setPreferredWidth(170);
68
        table.getColumnModel().getColumn(2).setPreferredWidth(70);
80
        table.getColumnModel().getColumn(2).setPreferredWidth(70);
69
       
81
70
        table.setPreferredScrollableViewportSize(new Dimension(table.getPreferredSize().width, Math.round(table.getPreferredSize().height/4)));
82
        table.setPreferredScrollableViewportSize(new Dimension(table
-
 
83
                .getPreferredSize().width, Math
-
 
84
                .round(table.getPreferredSize().height / 4)));
71
        // TK: temporary commented out - not available under MacOS, we need a replacement
85
        // TK: temporary commented out - not available under MacOS, we need a
-
 
86
        // replacement
72
        // table.setFillsViewportHeight(true);
87
        // table.setFillsViewportHeight(true);
73
       
88
74
        JScrollPane scrollPane = new JScrollPane(table);
89
        JScrollPane scrollPane = new JScrollPane(table);
-
 
90
        scrollPane.setPreferredSize(new Dimension(
75
        scrollPane.setPreferredSize(new Dimension(table.getPreferredSize().width, Math.round(table.getPreferredSize().height/4)));
91
                table.getPreferredSize().width, Math.round(table
-
 
92
                        .getPreferredSize().height / 4)));
76
       
93
77
        add(scrollPane);
94
        add(scrollPane);
78
    }
95
    }
79
   
96
80
    public void tableChanged(TableModelEvent e) {
97
    public void tableChanged(TableModelEvent e) {
81
        int row = e.getFirstRow();
98
        int row = e.getFirstRow();
82
        int column = e.getColumn();
99
        int column = e.getColumn();
83
        TableModel model = (TableModel)e.getSource();
100
        TableModel model = (TableModel) e.getSource();
84
        Object data = model.getValueAt(row, column);
101
        Object data = model.getValueAt(row, column);
-
 
102
        if ((column == 1)
85
        if ((column == 1) && !(sidLibController.getBank(bankNumber).getPatchAt(row).getPatchName().equals((String)data))) {
103
                && !(sidLibController.getBank(bankNumber).getPatchAt(row)
-
 
104
                        .getPatchName().equals((String) data))) {
86
            sidLibController.getBank(bankNumber).getPatchAt(row).setPatchName((String)data);
105
            sidLibController.getBank(bankNumber).getPatchAt(row).setPatchName(
-
 
106
                    (String) data);
87
        }
107
        }
88
    }
108
    }
89
   
109
90
    public void update(Observable observable, Object object) {
110
    public void update(Observable observable, Object object) {
91
        if (object=="Data changed") {
111
        if (object == "Data changed") {
92
            Bank b = sidLibController.getBank(bankNumber);
112
            Bank b = sidLibController.getBank(bankNumber);
93
            TableModel m = table.getModel();
113
            TableModel m = table.getModel();
94
            for (int c = 0; c < b.bankSize; c++) {
114
            for (int c = 0; c < b.bankSize; c++) {
95
                m.setValueAt(b.getPatchAt(c).getPatchName(), c, 1);
115
                m.setValueAt(b.getPatchAt(c).getPatchName(), c, 1);
96
                m.setValueAt(b.getPatchAt(c).getEngineStr(), c, 2);            
116
                m.setValueAt(b.getPatchAt(c).getEngineStr(), c, 2);
97
            }
117
            }
98
        }
118
        }
99
        if (object=="Rename") {
119
        if (object == "Rename") {
100
            table.editCellAt(table.getSelectedRow(), 1, new EventObject(this));
120
            table.editCellAt(table.getSelectedRow(), 1, new EventObject(this));
101
        }
121
        }
102
    }
122
    }
103
   
123
104
    public int getSelectedRow() {
124
    public int getSelectedRow() {
105
        return table.getSelectedRow();
125
        return table.getSelectedRow();
106
    }
126
    }
107
   
127
108
    private void maybeShowPopup(MouseEvent e) {
128
    private void maybeShowPopup(MouseEvent e) {
109
        if (e.isPopupTrigger()) {
129
        if (e.isPopupTrigger()) {
110
            popupMenu.show(e.getComponent(),
130
            popupMenu.show(e.getComponent(), e.getX(), e.getY());
111
                       e.getX(), e.getY());
-
 
112
        }
131
        }
113
    }
132
    }
114
   
133
115
    public void mousePressed(MouseEvent e) {
134
    public void mousePressed(MouseEvent e) {
116
        if (e.getButton() == MouseEvent.BUTTON1) {
135
        if (e.getButton() == MouseEvent.BUTTON1) {
117
            selectedBeforeDrag = table.getSelectedRow();
136
            selectedBeforeDrag = table.getSelectedRow();
118
        }
137
        }
119
        maybeShowPopup(e);
138
        maybeShowPopup(e);
120
    }
139
    }
121
   
140
122
    public void mouseReleased(MouseEvent e) {
141
    public void mouseReleased(MouseEvent e) {
123
        if (e.getButton() == MouseEvent.BUTTON1) {
142
        if (e.getButton() == MouseEvent.BUTTON1) {
124
            if (table.getSelectedRow() != selectedBeforeDrag) {
143
            if (table.getSelectedRow() != selectedBeforeDrag) {
125
                sidLibController.editSwap(selectedBeforeDrag, table.getSelectedRow());
144
                sidLibController.editSwap(selectedBeforeDrag, table
-
 
145
                        .getSelectedRow());
126
            }
146
            }
127
        }
147
        }
128
        maybeShowPopup(e);
148
        maybeShowPopup(e);
129
    }
149
    }
130
150
131
    public void mouseEntered(MouseEvent e) {}
151
    public void mouseEntered(MouseEvent e) {
-
 
152
    }
132
153
133
    public void mouseExited(MouseEvent e) {}
154
    public void mouseExited(MouseEvent e) {
-
 
155
    }
134
156
135
    public void mouseClicked(MouseEvent e) {
157
    public void mouseClicked(MouseEvent e) {
136
        if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount()==2)) {
158
        if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) {
137
            sidLibController.editCurrentPatch();
159
            sidLibController.editCurrentPatch();
138
        }
160
        }
139
    }
161
    }
140
   
162
141
    private void createPopupMenu() {
163
    private void createPopupMenu() {
142
        popupMenu = new JPopupMenu();
164
        popupMenu = new JPopupMenu();
143
        JMenu submenu;
165
        JMenu submenu;
144
        JMenuItem menuItem;
166
        JMenuItem menuItem;
145
       
167
146
        menuItem = new JMenuItem("Edit",KeyEvent.VK_E);
168
        menuItem = new JMenuItem("Edit", KeyEvent.VK_E);
147
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
169
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
-
 
170
                ActionEvent.CTRL_MASK));
148
        menuItem.setActionCommand("Edit");
171
        menuItem.setActionCommand("Edit");
149
        menuItem.addActionListener(this);
172
        menuItem.addActionListener(this);
150
        popupMenu.add(menuItem);
173
        popupMenu.add(menuItem);
151
       
174
152
        menuItem = new JMenuItem("Rename",KeyEvent.VK_R);
175
        menuItem = new JMenuItem("Rename", KeyEvent.VK_R);
153
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
176
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
154
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
177
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
-
 
178
                ActionEvent.CTRL_MASK));
155
        menuItem.setActionCommand("Rename");
179
        menuItem.setActionCommand("Rename");
156
        menuItem.addActionListener(this);
180
        menuItem.addActionListener(this);
157
        popupMenu.add(menuItem);
181
        popupMenu.add(menuItem);
158
       
182
159
        popupMenu.addSeparator();
183
        popupMenu.addSeparator();
160
       
184
161
        menuItem = new JMenuItem("Cut",KeyEvent.VK_U);
185
        menuItem = new JMenuItem("Cut", KeyEvent.VK_U);
162
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
186
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
163
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
187
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
-
 
188
                ActionEvent.CTRL_MASK));
164
        menuItem.setActionCommand("Cut");
189
        menuItem.setActionCommand("Cut");
165
        menuItem.addActionListener(this);
190
        menuItem.addActionListener(this);
166
        popupMenu.add(menuItem);
191
        popupMenu.add(menuItem);
167
       
192
168
        menuItem = new JMenuItem("Copy",KeyEvent.VK_C);
193
        menuItem = new JMenuItem("Copy", KeyEvent.VK_C);
169
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
194
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
170
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
195
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
-
 
196
                ActionEvent.CTRL_MASK));
171
        menuItem.setActionCommand("Copy");
197
        menuItem.setActionCommand("Copy");
172
        menuItem.addActionListener(this);
198
        menuItem.addActionListener(this);
173
        popupMenu.add(menuItem);
199
        popupMenu.add(menuItem);
174
       
200
175
        menuItem = new JMenuItem("Paste",KeyEvent.VK_P);
201
        menuItem = new JMenuItem("Paste", KeyEvent.VK_P);
176
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
202
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
177
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
203
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
-
 
204
                ActionEvent.CTRL_MASK));
178
        menuItem.setActionCommand("Paste");
205
        menuItem.setActionCommand("Paste");
179
        menuItem.addActionListener(this);
206
        menuItem.addActionListener(this);
180
        popupMenu.add(menuItem);
207
        popupMenu.add(menuItem);
181
       
208
182
        menuItem = new JMenuItem("Clear",KeyEvent.VK_L);
209
        menuItem = new JMenuItem("Clear", KeyEvent.VK_L);
183
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
210
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
184
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
211
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
185
        menuItem.setActionCommand("Clear");
212
        menuItem.setActionCommand("Clear");
186
        menuItem.addActionListener(this);
213
        menuItem.addActionListener(this);
187
        popupMenu.add(menuItem);
214
        popupMenu.add(menuItem);
188
               
215
189
        popupMenu.addSeparator();  
216
        popupMenu.addSeparator();
190
       
217
191
        submenu = new JMenu("Init current patch");
218
        submenu = new JMenu("Init current patch");
192
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
219
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
193
        submenu.setMnemonic(KeyEvent.VK_I);
220
        submenu.setMnemonic(KeyEvent.VK_I);
194
        popupMenu.add(submenu);
221
        popupMenu.add(submenu);
195
       
222
196
        menuItem = new JMenuItem("LEAD engine",KeyEvent.VK_P);
223
        menuItem = new JMenuItem("LEAD engine", KeyEvent.VK_P);
197
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
224
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
198
        menuItem.setActionCommand("Init LEAD patch");
225
        menuItem.setActionCommand("Init LEAD patch");
199
        menuItem.addActionListener(this);
226
        menuItem.addActionListener(this);
200
        submenu.add(menuItem);
227
        submenu.add(menuItem);
201
       
228
202
        menuItem = new JMenuItem("BASSLINE engine",KeyEvent.VK_P);
229
        menuItem = new JMenuItem("BASSLINE engine", KeyEvent.VK_P);
203
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
230
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
204
        menuItem.setActionCommand("Init BASSLINE patch");
231
        menuItem.setActionCommand("Init BASSLINE patch");
205
        menuItem.addActionListener(this);
232
        menuItem.addActionListener(this);
206
        submenu.add(menuItem);
233
        submenu.add(menuItem);
207
       
234
208
        menuItem = new JMenuItem("DRUM engine",KeyEvent.VK_P);
235
        menuItem = new JMenuItem("DRUM engine", KeyEvent.VK_P);
209
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
236
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
210
        menuItem.setActionCommand("Init DRUM patch");
237
        menuItem.setActionCommand("Init DRUM patch");
211
        menuItem.addActionListener(this);
238
        menuItem.addActionListener(this);
212
        submenu.add(menuItem);
239
        submenu.add(menuItem);
213
       
240
214
        menuItem = new JMenuItem("MULTI engine",KeyEvent.VK_P);
241
        menuItem = new JMenuItem("MULTI engine", KeyEvent.VK_P);
215
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
242
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
216
        menuItem.setActionCommand("Init MULTI patch");
243
        menuItem.setActionCommand("Init MULTI patch");
217
        menuItem.addActionListener(this);
244
        menuItem.addActionListener(this);
218
        submenu.add(menuItem);
245
        submenu.add(menuItem);
219
       
246
220
        menuItem = new JMenuItem("Init current bank",KeyEvent.VK_N);
247
        menuItem = new JMenuItem("Init current bank", KeyEvent.VK_N);
221
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
248
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
222
        menuItem.setActionCommand("Init current bank");
249
        menuItem.setActionCommand("Init current bank");
223
        menuItem.addActionListener(this);
250
        menuItem.addActionListener(this);
224
        popupMenu.add(menuItem);
251
        popupMenu.add(menuItem);
225
       
252
226
        popupMenu.addSeparator();
253
        popupMenu.addSeparator();
227
       
254
228
        submenu = new JMenu("Transmit");
255
        submenu = new JMenu("Transmit");
229
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
256
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
230
        submenu.setMnemonic(KeyEvent.VK_I);
257
        submenu.setMnemonic(KeyEvent.VK_I);
231
        popupMenu.add(submenu);
258
        popupMenu.add(submenu);
232
       
259
233
        //Transmit menu items:
260
        // Transmit menu items:
234
        menuItem = new JMenuItem("Patch to buffer",KeyEvent.VK_B);
261
        menuItem = new JMenuItem("Patch to buffer", KeyEvent.VK_B);
235
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
262
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
236
        menuItem.setActionCommand("Transmit patch to buffer");
263
        menuItem.setActionCommand("Transmit patch to buffer");
237
        menuItem.addActionListener(this);
264
        menuItem.addActionListener(this);
238
        submenu.add(menuItem);
265
        submenu.add(menuItem);
239
       
266
240
        menuItem = new JMenuItem("Patch to memory",KeyEvent.VK_M);
267
        menuItem = new JMenuItem("Patch to memory", KeyEvent.VK_M);
241
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
268
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
242
        menuItem.setActionCommand("Transmit patch to memory");
269
        menuItem.setActionCommand("Transmit patch to memory");
243
        menuItem.addActionListener(this);
270
        menuItem.addActionListener(this);
244
        submenu.add(menuItem);
271
        submenu.add(menuItem);
245
       
272
246
        submenu.addSeparator();
273
        submenu.addSeparator();
247
               
274
248
        menuItem = new JMenuItem("Bank",KeyEvent.VK_A);
275
        menuItem = new JMenuItem("Bank", KeyEvent.VK_A);
249
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
276
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
250
        menuItem.setActionCommand("Transmit bank to memory");
277
        menuItem.setActionCommand("Transmit bank to memory");
251
        menuItem.addActionListener(this);
278
        menuItem.addActionListener(this);
252
        submenu.add(menuItem);
279
        submenu.add(menuItem);
253
       
280
254
        submenu = new JMenu("Receive");
281
        submenu = new JMenu("Receive");
255
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
282
        submenu.setFont(submenu.getFont().deriveFont(Font.PLAIN));
256
        submenu.setMnemonic(KeyEvent.VK_I);
283
        submenu.setMnemonic(KeyEvent.VK_I);
257
        popupMenu.add(submenu);
284
        popupMenu.add(submenu);
258
       
285
259
        menuItem = new JMenuItem("Patch from buffer",KeyEvent.VK_B);
286
        menuItem = new JMenuItem("Patch from buffer", KeyEvent.VK_B);
260
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
287
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
261
        menuItem.setActionCommand("Receive patch from buffer");
288
        menuItem.setActionCommand("Receive patch from buffer");
262
        menuItem.addActionListener(this);
289
        menuItem.addActionListener(this);
263
        submenu.add(menuItem);
290
        submenu.add(menuItem);
264
       
291
265
        menuItem = new JMenuItem("Patch from memory",KeyEvent.VK_M);
292
        menuItem = new JMenuItem("Patch from memory", KeyEvent.VK_M);
266
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
293
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
267
        menuItem.setActionCommand("Receive patch from memory");
294
        menuItem.setActionCommand("Receive patch from memory");
268
        menuItem.addActionListener(this);
295
        menuItem.addActionListener(this);
269
        submenu.add(menuItem);
296
        submenu.add(menuItem);
270
       
297
271
        submenu.addSeparator();
298
        submenu.addSeparator();
272
               
299
273
        menuItem = new JMenuItem("Bank",KeyEvent.VK_A);
300
        menuItem = new JMenuItem("Bank", KeyEvent.VK_A);
274
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
301
        menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
275
        menuItem.setActionCommand("Receive bank from memory");
302
        menuItem.setActionCommand("Receive bank from memory");
276
        menuItem.addActionListener(this);
303
        menuItem.addActionListener(this);
277
        submenu.add(menuItem);
304
        submenu.add(menuItem);
278
    }
305
    }
279
   
306
280
    public void actionPerformed(ActionEvent ae) {
307
    public void actionPerformed(ActionEvent ae) {
281
        sidLibController.actionPerformed(ae);
308
        sidLibController.actionPerformed(ae);
282
    }
309
    }
283
   
310
284
    public void valueChanged(ListSelectionEvent event) {
311
    public void valueChanged(ListSelectionEvent event) {
285
        int patchNumber = table.getSelectedRow();
312
        int patchNumber = table.getSelectedRow();
286
        if (patchNumber < 0) {
313
        if (patchNumber < 0) {
287
            patchNumber = 0;
314
            patchNumber = 0;
288
        }
315
        }
289
        sidLibController.setCurrentPatchNumber(patchNumber);
316
        sidLibController.setCurrentPatchNumber(patchNumber);
290
    }
317
    }
291
   
318
292
    public void keyPressed(KeyEvent e) {
319
    public void keyPressed(KeyEvent e) {
-
 
320
        if ((e.getKeyCode() == KeyEvent.VK_E)
293
        if ((e.getKeyCode()==KeyEvent.VK_E) && (e.getModifiers()==ActionEvent.CTRL_MASK)) {
321
                && (e.getModifiers() == ActionEvent.CTRL_MASK)) {
294
            sidLibController.editCurrentPatch();
322
            sidLibController.editCurrentPatch();
-
 
323
        } else if ((e.getKeyCode() == KeyEvent.VK_R)
295
        } else if ((e.getKeyCode()==KeyEvent.VK_R) && (e.getModifiers()==ActionEvent.CTRL_MASK)) {
324
                && (e.getModifiers() == ActionEvent.CTRL_MASK)) {
296
            sidLibController.editRename();
325
            sidLibController.editRename();
-
 
326
        } else if ((e.getKeyCode() == KeyEvent.VK_X)
297
        } else if ((e.getKeyCode()==KeyEvent.VK_X) && (e.getModifiers()==ActionEvent.CTRL_MASK)) {
327
                && (e.getModifiers() == ActionEvent.CTRL_MASK)) {
298
            sidLibController.editCut();        
328
            sidLibController.editCut();
-
 
329
        } else if ((e.getKeyCode() == KeyEvent.VK_C)
299
        } else if ((e.getKeyCode()==KeyEvent.VK_C) && (e.getModifiers()==ActionEvent.CTRL_MASK)) {
330
                && (e.getModifiers() == ActionEvent.CTRL_MASK)) {
300
            sidLibController.editCopy();
331
            sidLibController.editCopy();
-
 
332
        } else if ((e.getKeyCode() == KeyEvent.VK_V)
301
        } else if ((e.getKeyCode()==KeyEvent.VK_V) && (e.getModifiers()==ActionEvent.CTRL_MASK)) {
333
                && (e.getModifiers() == ActionEvent.CTRL_MASK)) {
302
            sidLibController.editPaste();
334
            sidLibController.editPaste();
303
        } else if (e.getKeyCode()==KeyEvent.VK_DELETE) {
335
        } else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
304
            sidLibController.editClear();
336
            sidLibController.editClear();
305
        }
337
        }
306
    }
338
    }
-
 
339
307
    public void keyReleased(KeyEvent e) {
340
    public void keyReleased(KeyEvent e) {
308
       
341
309
    }
342
    }
310
    public void keyTyped(KeyEvent e) {
-
 
311
       
343
-
 
344
    public void keyTyped(KeyEvent e) {
312
       
345
313
    }
346
    }
314
   
347
315
}
348
}
316
 
349