Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
684 adamjking 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
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
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
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
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.apps.sidv2editor.gui;
22
 
23
import java.awt.BorderLayout;
719 adamjking 24
import java.awt.Color;
684 adamjking 25
import java.awt.Dimension;
26
import java.awt.Font;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.awt.event.ItemEvent;
30
import java.awt.event.ItemListener;
31
import java.awt.event.KeyEvent;
32
import java.awt.event.WindowAdapter;
33
import java.awt.event.WindowEvent;
34
import java.util.Observable;
35
import java.util.Observer;
36
 
37
import javax.swing.ImageIcon;
38
import javax.swing.JButton;
39
import javax.swing.JCheckBoxMenuItem;
40
import javax.swing.JDialog;
41
import javax.swing.JMenu;
42
import javax.swing.JMenuBar;
43
import javax.swing.JMenuItem;
44
import javax.swing.JOptionPane;
45
import javax.swing.JPanel;
46
import javax.swing.JPopupMenu;
698 rutgerv 47
import javax.swing.JToggleButton;
684 adamjking 48
import javax.swing.JToolBar;
49
import javax.swing.KeyStroke;
50
 
51
import org.midibox.apps.sidv2editor.SIDV2Editor;
52
import org.midibox.sidedit.SIDEditController;
53
import org.midibox.sidedit.gui.MBSIDV2EditorGUI;
54
import org.midibox.sidlibr.Patch;
55
import org.midibox.sidlibr.SIDLibController;
56
import org.midibox.sidlibr.gui.LibraryGUI;
57
import org.midibox.utils.gui.DialogOwner;
58
import org.midibox.utils.gui.ImageLoader;
719 adamjking 59
import org.midibox.utils.gui.MyColoredButtonUI;
684 adamjking 60
import org.midibox.utils.gui.SplitButton;
61
 
738 adamjking 62
public class SIDV2EditorGUI extends JPanel implements Observer, ActionListener,
63
        ItemListener {
684 adamjking 64
 
65
    JCheckBoxMenuItem cbMenuItem1, cbMenuItem2, cbMenuItem3, cbMenuItem4;
698 rutgerv 66
    JToggleButton b1, b2, b3, b4;
738 adamjking 67
 
698 rutgerv 68
    JMenuItem initL, initB, initD, initM, initE;
69
    JButton initButL, initButB, initButD, initButM, initButE;
738 adamjking 70
 
684 adamjking 71
    private SIDV2Editor sidv2librarian;
72
    private SIDLibController sidLibController;
73
 
74
    private LibraryGUI libraryGUI;
75
    private JDialog midiRoutingDialog;
76
    private MBSIDV2EditorGUI mbsidV2EditorGUI;
77
    private JDialog mbsidV2EditorGUIDialog;
78
 
79
    private SIDV2EditorMidiDeviceRoutingGUI midiDeviceRoutingGUI;
80
 
81
    private JMenu fileMenu;
82
 
83
    private JMenu editMenu;
84
 
85
    public SIDV2EditorGUI(SIDV2Editor sidv2librarian) {
86
 
87
        this.sidv2librarian = sidv2librarian;
88
 
89
        this.sidLibController = sidv2librarian.getSIDLibController();
90
 
91
        // Setup frame
92
        setLayout(new BorderLayout());
93
        add(createToolbar(), BorderLayout.PAGE_START);
94
 
95
        // Setup Librarian GUI (table view)
96
        libraryGUI = new LibraryGUI(sidLibController);
698 rutgerv 97
        add(libraryGUI, BorderLayout.CENTER);
738 adamjking 98
 
698 rutgerv 99
        sidLibController.addObserver(this);
738 adamjking 100
 
684 adamjking 101
        mbsidV2EditorGUI = new MBSIDV2EditorGUI();
738 adamjking 102
        mbsidV2EditorGUIDialog = new JDialog(DialogOwner.getFrame(),
103
                "MidiBox SID V2 Editor - no patch selected", true);
684 adamjking 104
 
105
        mbsidV2EditorGUIDialog
106
                .setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
107
        mbsidV2EditorGUIDialog.setResizable(false);
108
 
109
        mbsidV2EditorGUIDialog.addWindowListener(new WindowAdapter() {
110
 
111
            public void windowClosing(WindowEvent we) {
112
                int result = JOptionPane
113
                        .showConfirmDialog(
114
                                null,
115
                                "The current patch has been changed. Would you like to save?",
116
                                "Save patch?",
117
                                JOptionPane.YES_NO_CANCEL_OPTION,
118
                                JOptionPane.QUESTION_MESSAGE);
119
                switch (result) {
120
                case JOptionPane.YES_OPTION:
121
                    mbsidV2EditorGUI.getSIDEditController().Save();
122
                    mbsidV2EditorGUIDialog.setVisible(false);
123
                    break;
124
                case JOptionPane.NO_OPTION:
125
                    mbsidV2EditorGUIDialog.setVisible(false);
126
                    break;
127
                case JOptionPane.CANCEL_OPTION:
128
                    break;
129
                default:
130
                    break;
131
                }
132
            }
133
        });
134
 
135
        mbsidV2EditorGUIDialog.setContentPane(mbsidV2EditorGUI);
136
 
137
        if (sidv2librarian.getMidiDeviceRouting() != null) {
138
            // Setup midiDevice routing GUI
738 adamjking 139
            midiDeviceRoutingGUI = new SIDV2EditorMidiDeviceRoutingGUI(
140
                    sidv2librarian);
684 adamjking 141
            // Setup Midi Routing Dialog
738 adamjking 142
            midiRoutingDialog = new JDialog(DialogOwner.getFrame(),
143
                    "Midi Routing", true);
684 adamjking 144
            midiRoutingDialog.setContentPane(midiDeviceRoutingGUI);
145
            midiRoutingDialog.pack();
146
        }
147
    }
148
 
149
    public SIDV2Editor getSidv2librarian() {
150
        return sidv2librarian;
151
    }
152
 
153
    private void showEditGUI() {
738 adamjking 154
        SIDEditController sidEditController = mbsidV2EditorGUI
155
                .getSIDEditController();
684 adamjking 156
        if (sidEditController != null) {
157
            sidEditController.deleteObserver(this);
158
        }
738 adamjking 159
        sidv2librarian.reconnectAllDevices(); // java.sound.midi SysEx bug
160
                                                // workaround
684 adamjking 161
 
738 adamjking 162
        sidEditController = new SIDEditController(sidLibController
163
                .getCurrentPatch());
684 adamjking 164
        sidEditController.addObserver(this);
738 adamjking 165
        mbsidV2EditorGUI.editThis(sidEditController, sidLibController
166
                .getCores());
684 adamjking 167
        Patch p = mbsidV2EditorGUI.getSIDEditController().getPatch();
168
        if (p.isEnsemble()) {
738 adamjking 169
            mbsidV2EditorGUIDialog.setTitle("MidiBox SID V2 Editor - "
170
                    + "Ensemble "
171
                    + intToStr3(sidLibController.getCurrentPatchNumber() + 1));
684 adamjking 172
        } else {
738 adamjking 173
            mbsidV2EditorGUIDialog.setTitle("MidiBox SID V2 Editor - "
174
                    + p.getEngineStr() + " engine: " + p.getPatchName());
684 adamjking 175
        }
176
        mbsidV2EditorGUIDialog.pack();
177
        mbsidV2EditorGUIDialog.setLocationRelativeTo(this);
178
        mbsidV2EditorGUIDialog.setVisible(true);
179
    }
738 adamjking 180
 
684 adamjking 181
    private String intToStr3(int i) {
182
        String s = Integer.toString(i);
183
        switch (s.length()) {
184
        case 1:
185
            s = "00" + s;
186
            break;
187
        case 2:
188
            s = "0" + s;
189
            break;
190
        }
191
        return s;
192
    }
193
 
194
    public void actionPerformed(ActionEvent ae) {
195
        sidLibController.actionPerformed(ae);
196
    }
197
 
198
    public void update(Observable observable, Object object) {
199
        if (object == "Edit") {
200
            showEditGUI();
201
        } else if (object == "Save editor patch") {
738 adamjking 202
            sidLibController.setPatchAt(mbsidV2EditorGUI.getSIDEditController()
203
                    .getPatch(), sidLibController.getCurrentPatchNumber(),
204
                    sidLibController.getCurrentBankNumber());
698 rutgerv 205
        } else if (object == "Cores changes") {
738 adamjking 206
            updateCoreEnabling();
698 rutgerv 207
        } else if (object == "Bank changed") {
208
            updateInitEnabling();
738 adamjking 209
        }
684 adamjking 210
    }
738 adamjking 211
 
698 rutgerv 212
    public void updateCoreEnabling() {
738 adamjking 213
        int cores = sidLibController.getCores();
698 rutgerv 214
        cbMenuItem1.setSelected((cores & 0x01) > 0);
215
        cbMenuItem2.setSelected((cores & 0x02) > 0);
216
        cbMenuItem3.setSelected((cores & 0x04) > 0);
738 adamjking 217
        cbMenuItem4.setSelected((cores & 0x08) > 0);
698 rutgerv 218
        b1.setSelected((cores & 0x01) > 0);
219
        b2.setSelected((cores & 0x02) > 0);
220
        b3.setSelected((cores & 0x04) > 0);
221
        b4.setSelected((cores & 0x08) > 0);
222
    }
738 adamjking 223
 
698 rutgerv 224
    public void updateInitEnabling() {
225
        boolean b = sidLibController.isEnsembleBank();
226
        initL.setEnabled(!b);
227
        initB.setEnabled(!b);
228
        initD.setEnabled(!b);
229
        initM.setEnabled(!b);
738 adamjking 230
        initE.setEnabled(b);
698 rutgerv 231
        initButL.setEnabled(!b);
232
        initButB.setEnabled(!b);
233
        initButD.setEnabled(!b);
234
        initButM.setEnabled(!b);
235
        initButE.setEnabled(b);
236
    }
684 adamjking 237
 
238
    public void itemStateChanged(ItemEvent e) {
738 adamjking 239
        if ((e.getItem() == cbMenuItem1) || (e.getItem() == cbMenuItem2)
240
                || (e.getItem() == cbMenuItem3) || (e.getItem() == cbMenuItem4)) {
684 adamjking 241
            int tempVal = 0;
738 adamjking 242
            if (cbMenuItem1.isSelected()) {
243
                tempVal += 1;
244
            }
245
            if (cbMenuItem2.isSelected()) {
246
                tempVal += 2;
247
            }
248
            if (cbMenuItem3.isSelected()) {
249
                tempVal += 4;
250
            }
251
            if (cbMenuItem4.isSelected()) {
252
                tempVal += 8;
253
            }
684 adamjking 254
            sidLibController.setCores(tempVal);
698 rutgerv 255
            updateCoreEnabling();
738 adamjking 256
        } else if ((e.getItem() == b1) || (e.getItem() == b2)
257
                || (e.getItem() == b3) || (e.getItem() == b4)) {
698 rutgerv 258
            int tempVal = 0;
738 adamjking 259
            if (b1.isSelected()) {
260
                tempVal += 1;
261
            }
262
            if (b2.isSelected()) {
263
                tempVal += 2;
264
            }
265
            if (b3.isSelected()) {
266
                tempVal += 4;
267
            }
268
            if (b4.isSelected()) {
269
                tempVal += 8;
270
            }
698 rutgerv 271
            sidLibController.setCores(tempVal);
272
            updateCoreEnabling();
684 adamjking 273
        }
274
    }
275
 
276
    public JMenuBar createMenu() {
277
        JMenuBar menuBar = new JMenuBar();
278
        JMenu menu, submenu;
279
        JMenuItem menuItem;
280
 
281
        // File menu
282
        fileMenu = new JMenu("File");
283
        fileMenu.setMnemonic(KeyEvent.VK_F);
284
        menuBar.add(fileMenu);
285
 
286
        // File menu items:
287
        menuItem = new JMenuItem("Load patch", KeyEvent.VK_L);
288
        menuItem.setActionCommand("Load patch");
289
        menuItem.addActionListener(this);
290
        fileMenu.add(menuItem);
291
 
292
        menuItem = new JMenuItem("Save patch", KeyEvent.VK_S);
293
        menuItem.setActionCommand("Save patch");
294
        menuItem.addActionListener(this);
295
        fileMenu.add(menuItem);
296
 
297
        fileMenu.addSeparator();
298
 
299
        menuItem = new JMenuItem("Load bank", KeyEvent.VK_O);
300
        menuItem.setActionCommand("Load bank");
301
        menuItem.addActionListener(this);
302
        fileMenu.add(menuItem);
303
 
304
        menuItem = new JMenuItem("Save bank", KeyEvent.VK_A);
305
        menuItem.setActionCommand("Save bank");
306
        menuItem.addActionListener(this);
307
        fileMenu.add(menuItem);
308
 
309
        // Build second menu in the menu bar.
310
        editMenu = new JMenu("Edit");
311
        editMenu.setMnemonic(KeyEvent.VK_E);
312
        menuBar.add(editMenu);
313
 
314
        // Edit menu items:
315
        menuItem = new JMenuItem("Edit", KeyEvent.VK_E);
316
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
317
                ActionEvent.CTRL_MASK));
318
        menuItem.setActionCommand("Edit");
319
        menuItem.addActionListener(this);
320
        editMenu.add(menuItem);
321
 
322
        menuItem = new JMenuItem("Rename", KeyEvent.VK_R);
323
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
324
                ActionEvent.CTRL_MASK));
325
        menuItem.setActionCommand("Rename");
326
        menuItem.addActionListener(this);
327
        editMenu.add(menuItem);
328
 
329
        editMenu.addSeparator();
330
 
331
        menuItem = new JMenuItem("Cut", KeyEvent.VK_U);
332
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
333
                ActionEvent.CTRL_MASK));
334
        menuItem.setActionCommand("Cut");
335
        menuItem.addActionListener(this);
336
        editMenu.add(menuItem);
337
 
338
        menuItem = new JMenuItem("Copy", KeyEvent.VK_C);
339
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
340
                ActionEvent.CTRL_MASK));
341
        menuItem.setActionCommand("Copy");
342
        menuItem.addActionListener(this);
343
        editMenu.add(menuItem);
344
 
345
        menuItem = new JMenuItem("Paste", KeyEvent.VK_P);
346
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
347
                ActionEvent.CTRL_MASK));
348
        menuItem.setActionCommand("Paste");
349
        menuItem.addActionListener(this);
350
        editMenu.add(menuItem);
351
 
352
        editMenu.addSeparator();
353
 
354
        submenu = new JMenu("Init current patch");
355
        submenu.setMnemonic(KeyEvent.VK_I);
356
        editMenu.add(submenu);
357
 
698 rutgerv 358
        initL = new JMenuItem("LEAD engine", KeyEvent.VK_P);
359
        initL.setActionCommand("Init LEAD patch");
360
        initL.addActionListener(this);
361
        submenu.add(initL);
684 adamjking 362
 
698 rutgerv 363
        initB = new JMenuItem("BASSLINE engine", KeyEvent.VK_P);
364
        initB.setActionCommand("Init BASSLINE patch");
365
        initB.addActionListener(this);
366
        submenu.add(initB);
738 adamjking 367
 
698 rutgerv 368
        initD = new JMenuItem("DRUM engine", KeyEvent.VK_P);
369
        initD.setActionCommand("Init DRUM patch");
370
        initD.addActionListener(this);
371
        submenu.add(initD);
684 adamjking 372
 
698 rutgerv 373
        initM = new JMenuItem("MULTI engine", KeyEvent.VK_P);
374
        initM.setActionCommand("Init MULTI patch");
375
        initM.addActionListener(this);
376
        submenu.add(initM);
738 adamjking 377
 
698 rutgerv 378
        initE = new JMenuItem("ENSEMBLE", KeyEvent.VK_P);
379
        initE.setActionCommand("Init ensemble");
380
        initE.addActionListener(this);
381
        submenu.add(initE);
738 adamjking 382
 
684 adamjking 383
        menuItem = new JMenuItem("Init current bank", KeyEvent.VK_N);
384
        menuItem.setActionCommand("Init current bank");
385
        menuItem.addActionListener(this);
386
        editMenu.add(menuItem);
387
 
388
        // Build third menu in the menu bar.
389
        menu = new JMenu("Transmit");
390
        menu.setMnemonic(KeyEvent.VK_T);
391
        menuBar.add(menu);
392
 
393
        // Transmit menu items:
394
        menuItem = new JMenuItem("Patch to buffer", KeyEvent.VK_B);
395
        menuItem.setActionCommand("Transmit patch to buffer");
396
        menuItem.addActionListener(this);
397
        menu.add(menuItem);
398
 
399
        menuItem = new JMenuItem("Patch to memory", KeyEvent.VK_M);
400
        menuItem.setActionCommand("Transmit patch to memory");
401
        menuItem.addActionListener(this);
402
        menu.add(menuItem);
403
 
404
        menu.addSeparator();
405
 
406
        menuItem = new JMenuItem("Bank", KeyEvent.VK_A);
407
        menuItem.setActionCommand("Transmit bank to memory");
408
        menuItem.addActionListener(this);
409
        menu.add(menuItem);
410
 
411
        // Build fourth menu in the menu bar.
412
        menu = new JMenu("Receive");
413
        menu.setMnemonic(KeyEvent.VK_R);
414
        menuBar.add(menu);
415
 
416
        menuItem = new JMenuItem("Patch from buffer", KeyEvent.VK_B);
417
        menuItem.setActionCommand("Receive patch from buffer");
418
        menuItem.addActionListener(this);
419
        menu.add(menuItem);
420
 
421
        menuItem = new JMenuItem("Patch from memory", KeyEvent.VK_M);
422
        menuItem.setActionCommand("Receive patch from memory");
423
        menuItem.addActionListener(this);
424
        menu.add(menuItem);
425
 
426
        menu.addSeparator();
427
 
428
        menuItem = new JMenuItem("Bank", KeyEvent.VK_A);
429
        menuItem.setActionCommand("Receive bank from memory");
430
        menuItem.addActionListener(this);
431
        menu.add(menuItem);
432
 
433
        // Build fifth menu in the menu bar.
434
        menu = new JMenu("Cores");
435
        menu.setMnemonic(KeyEvent.VK_C);
436
        menuBar.add(menu);
437
 
438
        cbMenuItem1 = new JCheckBoxMenuItem("Edit on core 1");
439
        cbMenuItem1.setSelected(true);
440
        cbMenuItem1.setMnemonic(KeyEvent.VK_1);
441
        cbMenuItem1.addItemListener(this);
442
        menu.add(cbMenuItem1);
443
 
444
        cbMenuItem2 = new JCheckBoxMenuItem("Edit on core 2");
445
        cbMenuItem2.setMnemonic(KeyEvent.VK_2);
446
        cbMenuItem2.addItemListener(this);
447
        menu.add(cbMenuItem2);
448
 
449
        cbMenuItem3 = new JCheckBoxMenuItem("Edit on core 3");
450
        cbMenuItem3.setMnemonic(KeyEvent.VK_3);
451
        cbMenuItem3.addItemListener(this);
452
        menu.add(cbMenuItem3);
453
 
454
        cbMenuItem4 = new JCheckBoxMenuItem("Edit on core 4");
455
        cbMenuItem4.setMnemonic(KeyEvent.VK_4);
456
        cbMenuItem4.addItemListener(this);
457
        menu.add(cbMenuItem4);
738 adamjking 458
 
698 rutgerv 459
        /*
738 adamjking 460
         * menu.addSeparator(); menuItem = new JMenuItem("Scan hardware",
461
         * KeyEvent.VK_S); menuItem.setActionCommand("Scan hardware");
462
         * menuItem.addActionListener(this); menu.add(menuItem);
463
         */
464
 
698 rutgerv 465
        updateCoreEnabling();
466
        updateInitEnabling();
738 adamjking 467
 
684 adamjking 468
        return menuBar;
469
    }
470
 
471
    private JToolBar createToolbar() {
472
        JToolBar toolBar = new JToolBar();
473
        toolBar.setFloatable(false);
698 rutgerv 474
        initButL = makeButton("init_lead.png", "Init LEAD patch", "Init LEAD");
738 adamjking 475
        initButB = makeButton("init_bassline.png", "Init BASSLINE patch",
476
                "Init BASSLINE");
698 rutgerv 477
        initButD = makeButton("init_drum.png", "Init DRUM patch", "Init DRUM");
738 adamjking 478
        initButM = makeButton("init_multi.png", "Init MULTI patch",
479
                "Init MULTI");
480
        initButE = makeButton("init_ensemble.png", "Init ensemble",
481
                "Init ENSEMBLE");
698 rutgerv 482
        toolBar.add(initButL);
483
        toolBar.add(initButB);
484
        toolBar.add(initButD);
485
        toolBar.add(initButM);
486
        toolBar.add(initButE);
738 adamjking 487
 
488
        // toolBar.addSeparator()
684 adamjking 489
        toolBar.add(makeButton("cut.png", "Cut", "Cut"));
490
        toolBar.add(makeButton("copy.png", "Copy", "Copy"));
491
        toolBar.add(makeButton("paste.png", "Paste", "Paste"));
738 adamjking 492
        // toolBar.addSeparator();
493
        toolBar.add(new SplitButton(makeButton("transmit.png",
494
                "Transmit patch to buffer", "Transmit patch to buffer"),
495
                dropTransmit()));
496
        toolBar.add(new SplitButton(makeButton("receive.png",
497
                "Receive patch from buffer", "Receive patch from buffer"),
498
                dropReceive()));
499
 
698 rutgerv 500
        // Create and initialize the button.
501
        b1 = new JToggleButton();
502
        b2 = new JToggleButton();
503
        b3 = new JToggleButton();
504
        b4 = new JToggleButton();
738 adamjking 505
 
719 adamjking 506
        b1.setUI(new MyColoredButtonUI(ImageLoader
507
                .getImageIcon("pushButton_on.png"), ImageLoader
508
                .getImageIcon("pushButton_off.png"),
509
                MyColoredButtonUI.RECTANGLE, Color.GREEN));
510
 
511
        b2.setUI(new MyColoredButtonUI(ImageLoader
512
                .getImageIcon("pushButton_on.png"), ImageLoader
513
                .getImageIcon("pushButton_off.png"),
514
                MyColoredButtonUI.RECTANGLE, Color.GREEN));
515
 
516
        b3.setUI(new MyColoredButtonUI(ImageLoader
517
                .getImageIcon("pushButton_on.png"), ImageLoader
518
                .getImageIcon("pushButton_off.png"),
519
                MyColoredButtonUI.RECTANGLE, Color.GREEN));
520
 
521
        b4.setUI(new MyColoredButtonUI(ImageLoader
522
                .getImageIcon("pushButton_on.png"), ImageLoader
523
                .getImageIcon("pushButton_off.png"),
524
                MyColoredButtonUI.RECTANGLE, Color.GREEN));
525
 
698 rutgerv 526
        b1.setToolTipText("Enable core 1");
527
        b2.setToolTipText("Enable core 2");
528
        b3.setToolTipText("Enable core 3");
529
        b4.setToolTipText("Enable core 4");
738 adamjking 530
 
698 rutgerv 531
        b1.addItemListener(this);
532
        b2.addItemListener(this);
533
        b3.addItemListener(this);
534
        b4.addItemListener(this);
738 adamjking 535
 
698 rutgerv 536
        toolBar.add(b1);
537
        toolBar.add(b2);
538
        toolBar.add(b3);
738 adamjking 539
        toolBar.add(b4);
540
 
684 adamjking 541
        return toolBar;
542
    }
738 adamjking 543
 
684 adamjking 544
    public JMenu getFileMenu() {
545
        return fileMenu;
546
    }
547
 
548
    public JMenu getEditMenu() {
549
        return editMenu;
550
    }
551
 
552
    public void showMidiDeviceRoutingDialog() {
553
        midiRoutingDialog.setVisible(true);
554
    }
555
 
738 adamjking 556
    protected JButton makeButton(String imageName, String actionCommand,
557
            String toolTipText) {
684 adamjking 558
        // Create and initialize the button.
559
        ImageIcon icon = ImageLoader.getImageIcon(imageName);
560
        int s = Math.max(icon.getIconWidth(), icon.getIconHeight()) + 4;
561
        JButton button = new JButton();
562
        button.setPreferredSize(new Dimension(s, s));
563
        button.setActionCommand(actionCommand);
564
        button.setToolTipText(toolTipText);
565
        button.addActionListener(this);
566
        button.setIcon(icon);
567
        button.setFocusPainted(false);
568
        return button;
569
    }
738 adamjking 570
 
684 adamjking 571
    protected JPopupMenu dropTransmit() {
572
        JPopupMenu toolbarMenu = new JPopupMenu();
573
 
574
        JMenuItem item1 = new JMenuItem();
575
        item1.setText("Patch to buffer");
576
        item1.setIcon(ImageLoader.getImageIcon("transmit.png"));
577
        item1.setActionCommand("Transmit patch to buffer");
578
        item1.addActionListener(this);
579
        toolbarMenu.add(item1);
580
 
581
        JMenuItem item2 = new JMenuItem();
582
        item2.setText("Patch to memory");
583
        item2.setFont(item2.getFont().deriveFont(Font.PLAIN));
584
        item2.setIcon(ImageLoader.getImageIcon("transmit.png"));
585
        item2.setActionCommand("Transmit patch to memory");
586
        item2.addActionListener(this);
587
        toolbarMenu.add(item2);
588
 
589
        toolbarMenu.addSeparator();
590
 
591
        JMenuItem item3 = new JMenuItem();
592
        item3.setText("Bank");
593
        item3.setFont(item3.getFont().deriveFont(Font.PLAIN));
594
        item3.setIcon(ImageLoader.getImageIcon("transmit.png"));
595
        item3.setActionCommand("Transmit bank to memory");
596
        item3.addActionListener(this);
597
        toolbarMenu.add(item3);
598
 
599
        return toolbarMenu;
600
    }
601
 
602
    protected JPopupMenu dropReceive() {
603
        JPopupMenu toolbarMenu = new JPopupMenu();
604
 
605
        JMenuItem item1 = new JMenuItem();
606
        item1.setText("Patch from buffer");
607
        item1.setIcon(ImageLoader.getImageIcon("receive.png"));
608
        item1.setActionCommand("Receive patch from buffer");
609
        item1.addActionListener(this);
610
        toolbarMenu.add(item1);
611
 
612
        JMenuItem item2 = new JMenuItem();
613
        item2.setText("Patch from memory");
614
        item2.setFont(item2.getFont().deriveFont(Font.PLAIN));
615
        item2.setIcon(ImageLoader.getImageIcon("receive.png"));
616
        item2.setActionCommand("Receive patch from memory");
617
        item2.addActionListener(this);
618
        toolbarMenu.add(item2);
619
 
620
        toolbarMenu.addSeparator();
621
 
622
        JMenuItem item3 = new JMenuItem();
623
        item3.setText("Bank");
624
        item3.setFont(item3.getFont().deriveFont(Font.PLAIN));
625
        item3.setIcon(ImageLoader.getImageIcon("receive.png"));
626
        item3.setActionCommand("Receive bank from memory");
627
        item3.addActionListener(this);
628
        toolbarMenu.add(item3);
629
 
630
        return toolbarMenu;
631
    }
632
}