示例#1
0
 /**
  * Invoked when a sampler channel is removed.
  *
  * @param e A <code>SamplerChannelListEvent</code> instance providing the event information.
  */
 public void channelRemoved(SamplerChannelListEvent e) {
   // Some cleanup when the channel is removed.
   if (e.getChannelModel().getChannelID() == channelModel.getChannelID()) {
     CC.getSamplerModel().removeMidiDeviceListListener(getHandler());
     CC.getSamplerModel().removeAudioDeviceListListener(getHandler());
   }
 }
示例#2
0
  /** Invoked when this window is about to close. */
  protected void onWindowClose() {
    if (ClassicPrefs.getSaveWindowProperties()) {
      ClassicPrefs.setWindowMaximized((getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH);

      setVisible(false);
      if (ClassicPrefs.getWindowMaximized()) {
        // setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH);
        CC.cleanExit();
        return;
      }

      java.awt.Point p = getLocation();
      Dimension d = getSize();
      StringBuffer sb = new StringBuffer();
      sb.append(p.x).append(',').append(p.y).append(',');
      sb.append(d.width).append(',').append(d.height);
      ClassicPrefs.setWindowSizeAndLocation(sb.toString());

      ClassicPrefs.setHSplitDividerLocation(hSplitPane.getDividerLocation());
    }

    if (ClassicPrefs.getSaveLeftPaneState()) {
      int idx = 0;
      for (int i = 0; i < getLeftPane().getPages().length; i++) {
        if (getLeftPane().getPages()[i] == getLeftPane().getCurrentPage()) {
          idx = i;
          break;
        }
      }

      ClassicPrefs.setLeftPanePageIndex(idx);

      idx = getLeftPane().getOrchestrasPage().getCurrentOrchestraIndex();

      if (idx >= 0 && idx < CC.getOrchestras().getOrchestraCount())
        ClassicPrefs.setCurrentOrchestraIndex(idx);
    }

    StringBuffer sb = new StringBuffer();
    for (String s : recentScripts) sb.append(s).append("\n");
    ClassicPrefs.setRecentScripts(sb.toString());

    LSConsoleModel model = getLSConsoleModel();
    sb = new StringBuffer();
    for (String s : model.getCommandHistory()) sb.append(s).append("\n");
    ClassicPrefs.setLSConsoleHistory(sb.toString());

    ClassicPrefs.setShowLSConsole(isLSConsoleShown());
    ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut());

    ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation());
    super.onWindowClose();
  }
示例#3
0
  public void moveTab2End() {
    int idx = tabbedPane.getSelectedIndex();
    if (idx == -1 && idx >= tabbedPane.getTabCount()) {
      CC.getLogger().info("Can't move tab to right");
      return;
    }

    JSChannelsPane c = (JSChannelsPane) tabbedPane.getSelectedComponent();
    if (getChannelsPane(idx) != c) CC.getLogger().warning("Channels pane indices don't match");
    removeChannelsPane(c);
    addChannelsPane(c);
    tabbedPane.setSelectedComponent(c);
  }
示例#4
0
  public void moveTab2Left() {
    int idx = tabbedPane.getSelectedIndex();
    if (idx < 1) {
      CC.getLogger().info("Can't move tab to left");
      return;
    }

    JSChannelsPane c = (JSChannelsPane) tabbedPane.getSelectedComponent();
    if (getChannelsPane(idx) != c) CC.getLogger().warning("Channels pane indices don't match");
    removeChannelsPane(c);
    insertChannelsPane(c, idx - 1);
    tabbedPane.setSelectedComponent(c);
  }
示例#5
0
  private void setSavedSize() {
    String s = ClassicPrefs.getWindowSizeAndLocation();
    if (s == null) {
      setDefaultSize();
      return;
    }

    try {
      int i = s.indexOf(',');
      int x = Integer.parseInt(s.substring(0, i));

      s = s.substring(i + 1);
      i = s.indexOf(',');
      int y = Integer.parseInt(s.substring(0, i));

      s = s.substring(i + 1);
      i = s.indexOf(',');
      int width = Integer.parseInt(s.substring(0, i));

      s = s.substring(i + 1);
      int height = Integer.parseInt(s);

      setBounds(x, y, width, height);
    } catch (Exception x) {
      String msg = "Parsing of window size and location string failed";
      CC.getLogger().log(Level.INFO, msg, x);
      setDefaultSize();
    }

    if (ClassicPrefs.getWindowMaximized()) setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
  }
示例#6
0
  private void loadInstrument() {
    InstrumentChooser dlg = new InstrumentChooser(CC.getMainFrame());
    dlg.setVisible(true);

    if (!dlg.isCancelled()) {
      getModel().loadInstrument(dlg.getFileName(), dlg.getInstrumentIndex());
    }
  }
示例#7
0
 @Override
 public void handleConnectionFailure() {
   if (processConnectionFailure) return;
   processConnectionFailure = true;
   CC.getTaskQueue().add(new Global.Disconnect());
   JSConnectionFailurePane p = new JSConnectionFailurePane();
   p.showDialog();
   processConnectionFailure = false;
 }
示例#8
0
    /**
     * Invoked when a new sampler channel is created.
     *
     * @param e A <code>SamplerChannelListEvent</code> instance providing the event information.
     */
    public void channelAdded(SamplerChannelListEvent e) {
      Integer id = e.getChannelModel().getChannelID();
      if (findChannel(id) != null) {
        CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);
        return;
      }

      getSelectedChannelsPane().addChannel(e.getChannelModel());
    }
    public void setValueAt(Object value, int row, int column) {
      if (column == 0) return;
      int c = channel.getChannelId();
      int o = (Integer) getValueAt(row, 0);
      int i = (Integer) value;
      CC.getTaskQueue().add(new SetAudioOutputChannel(c, o, i));
      channel.getAudioOutputRouting()[row] = i;

      fireTableCellUpdated(row, column);
    }
示例#10
0
  /** Updates the audio device list. */
  private void updateAudioDevices() {
    SamplerModel sm = CC.getSamplerModel();
    SamplerChannel sc = getModel().getChannelInfo();

    setUpdate(true);

    try {
      cbAudioDevice.removeAllItems();

      for (AudioDeviceModel m : sm.getAudioDeviceModels()) cbAudioDevice.addItem(m.getDeviceInfo());

      AudioDeviceModel am = sm.getAudioDeviceModel(sc.getAudioOutputDevice());
      cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
    } catch (Exception x) {
      CC.getLogger().log(Level.WARNING, "Unkown error", x);
    }

    setUpdate(false);
  }
示例#11
0
    public void setInstrument(String instr) {
      if (!Instrument.isDnDString(instr)) return;

      String[] args = instr.split("\n");
      if (args.length < 6) return;

      try {
        int idx = Integer.parseInt(args[5]);
        Channel.this.getModel().loadInstrument(args[4], idx);
      } catch (Exception x) {
        CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
      }
    }
示例#12
0
  /** Creates a new instance of <code>JSMainFrame</code>. */
  public JSMainFrame() {
    super(JSampler.NAME + ' ' + JSampler.VERSION);

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            onWindowClose();
          }
        });

    CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());
  }
示例#13
0
  /** Updates the channel settings. This method is invoked when changes to the channel were made. */
  private void updateChannelProperties() {
    SamplerModel sm = CC.getSamplerModel();
    SamplerChannel sc = getModel().getChannelInfo();

    MidiDeviceModel mm = sm.getMidiDeviceModel(sc.getMidiInputDevice());
    AudioDeviceModel am = sm.getAudioDeviceModel(sc.getAudioOutputDevice());

    if (isUpdate()) CC.getLogger().warning("Unexpected update state!");

    setUpdate(true);

    try {
      cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo());

      cbEngines.setSelectedItem(sc.getEngine());

      cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
    } catch (Exception x) {
      CC.getLogger().log(Level.WARNING, "Unkown error", x);
    }

    setUpdate(false);
  }
    ChannelRoutingTable() {
      super(new ChannelRoutingTableModel());

      JComboBox cb = new JComboBox();
      int devId = channel.getAudioOutputDevice();
      AudioDeviceModel adm = CC.getSamplerModel().getAudioDeviceModel(devId);

      if (adm == null) {
        setEnabled(false);
      } else {
        int chns = adm.getDeviceInfo().getAudioChannelCount();
        for (Integer i = 0; i < chns; i++) cb.addItem(i);
      }

      TableColumn column = getColumnModel().getColumn(1);
      column.setCellEditor(new DefaultCellEditor(cb));
    }
示例#15
0
  /** Invoked when the user clicks the mute button. */
  private void changeMute() {
    SamplerChannel sc = getChannelInfo();
    boolean b = true;

    /*
     * Changing the mute button icon now instead of
     * leaving the work to the notification mechanism of the LinuxSampler.
     */
    if (sc.isMuted() && !sc.isMutedBySolo()) {
      b = false;
      boolean hasSolo = CC.getSamplerModel().hasSoloChannel();

      if (sc.isSoloChannel() || !hasSolo) btnMute.setIcon(iconMuteOff);
      else btnMute.setIcon(iconMutedBySolo);
    } else btnMute.setIcon(iconMuteOn);

    getModel().setMute(b);
  }
  /**
   * Creates new instrument using the specified drag & drop string representation of the instrument.
   *
   * @param instr The drag & drop string representation of the instrument.
   * @see OrchestraInstrument#getDnDString
   */
  public void setInstrument(String instr) {
    if (!OrchestraInstrument.isDnDString(instr)) return;

    OrchestraInstrument instrument = new OrchestraInstrument();
    try {
      instrument.setDnDString(instr);
    } catch (Exception x) {
      CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
      return;
    }

    int idx;
    idx = getModel().getOrchestraModel().getInstrumentIndex(getSelectedInstrument());
    if (idx < 0) getModel().getOrchestraModel().addInstrument(instrument);
    else getModel().getOrchestraModel().insertInstrument(instrument, idx);

    setSelectedInstrument(instrument);
  }
示例#17
0
  /** Invoked when the user clicks the solo button. */
  private void changeSolo() {
    SamplerChannel sc = getChannelInfo();
    boolean b = !sc.isSoloChannel();

    /*
     * Changing the solo button icon (and related) now instead of
     * leaving the work to the notification mechanism of the LinuxSampler.
     */
    if (b) {
      btnSolo.setIcon(iconSoloOn);
      if (sc.isMutedBySolo()) btnMute.setIcon(iconMuteOff);
    } else {
      btnSolo.setIcon(iconSoloOff);
      if (!sc.isMuted() && CC.getSamplerModel().getSoloChannelCount() > 1)
        btnMute.setIcon(iconMutedBySolo);
    }

    getModel().setSolo(b);
  }
示例#18
0
  private void addMenu() {
    JMenu m;
    JMenuItem mi;

    setJMenuBar(menuBar);

    // Actions
    m = new JMenu(i18n.getMenuLabel("actions"));
    menuBar.add(m);

    mi = new JMenuItem(A4n.connect);
    mi.setIcon(null);
    // mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.refresh);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
    m.add(mi);

    mi = new JMenuItem(A4n.resetSampler);
    mi.setIcon(null);
    m.add(mi);

    mi = new JMenuItem(A4n.samplerInfo);
    mi.setIcon(null);
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(i18n.getMenuLabel("actions.runScript"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            runScript();
          }
        });

    String s = ClassicPrefs.getRecentScripts();
    BufferedReader br = new BufferedReader(new StringReader(s));

    try {
      s = br.readLine();
      while (s != null) {
        recentScripts.add(s);
        s = br.readLine();
      }
    } catch (Exception x) {
      CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
    }

    updateRecentScriptsMenu();

    m.add(recentScriptsMenu);

    m.addSeparator();

    mi = new JMenuItem(i18n.getMenuLabel("actions.exit"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CC.cleanExit();
          }
        });

    // Edit
    m = new JMenu(i18n.getMenuLabel("edit"));
    menuBar.add(m);

    mi = new JMenuItem(i18n.getMenuLabel("edit.audioDevices"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0);
            LeftPane.getLeftPane().showAudioDevicesPage();
          }
        });

    mi = new JMenuItem(i18n.getMenuLabel("edit.midiDevices"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0);
            LeftPane.getLeftPane().showMidiDevicesPage();
          }
        });

    mi = new JMenuItem(i18n.getMenuLabel("edit.orchestras"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0);
            LeftPane.getLeftPane().showManageOrchestrasPage();
          }
        });

    m.addSeparator();

    mi = new JMenuItem(A4n.preferences);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    // View
    m = new JMenu(i18n.getMenuLabel("view"));
    menuBar.add(m);

    final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbar"));

    m.add(cbmi);
    cbmi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showToolbar(cbmi.getState());
          }
        });

    boolean b = ClassicPrefs.shouldShowToolbar();
    cbmi.setSelected(b);
    showToolbar(b);

    m.add(cbmiLeftPaneVisible);
    cbmiLeftPaneVisible.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showLeftPane(cbmiLeftPaneVisible.getState());
          }
        });

    b = ClassicPrefs.shouldShowLeftPane();
    cbmiLeftPaneVisible.setSelected(b);
    showLeftPane(b);

    final JCheckBoxMenuItem cbmi2 = new JCheckBoxMenuItem(i18n.getMenuLabel("view.statusbar"));

    m.add(cbmi2);
    cbmi2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showStatusbar(cbmi2.getState());
          }
        });
    b = ClassicPrefs.shouldShowStatusbar();
    cbmi2.setSelected(b);
    showStatusbar(b);

    m.addSeparator();

    setLSConsolePopOut(ClassicPrefs.isLSConsolePopOut());
    cbmiLSConsoleShown.setSelected(ClassicPrefs.shouldShowLSConsole());
    showLSConsole(ClassicPrefs.shouldShowLSConsole());

    cbmiLSConsoleShown.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showLSConsole(cbmiLSConsoleShown.isSelected());
          }
        });
    m.add(cbmiLSConsoleShown);

    lsConsolePane.updateLSConsoleViewMode();

    // Channels
    m = new JMenu(i18n.getMenuLabel("channels"));
    menuBar.add(m);

    mi = new JMenuItem(A4n.newChannel);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.newChannelWizard);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.duplicateChannels);
    mi.setIcon(null);
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(A4n.moveChannelsOnTop);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveChannelsUp);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveChannelsDown);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.ALT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveChannelsAtBottom);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    tabsMenu.setEnabled(false);
    m.add(tabsMenu);

    m.addSeparator();

    mi = new JMenuItem(A4n.selectAllChannels);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.deselectChannels);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(A4n.removeChannels);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.SHIFT_MASK));
    m.add(mi);

    // Tabs
    m = new JMenu(i18n.getMenuLabel("tabs"));
    menuBar.add(m);

    mi = new JMenuItem(A4n.newChannelsTab);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.editTabTitle);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(A4n.moveTab2Beginning);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveTab2Left);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveTab2Right);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK));
    m.add(mi);

    mi = new JMenuItem(A4n.moveTab2End);
    mi.setIcon(null);
    mi.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK));
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(A4n.closeChannelsTab);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK));
    m.add(mi);

    // Help
    m = new JMenu(i18n.getMenuLabel("help"));
    menuBar.add(m);

    mi = new JMenuItem(A4n.helpAbout);
    mi.setIcon(null);
    m.add(mi);
  }
示例#19
0
  /** Creates a new instance of JSMainFrame */
  public MainFrame() {
    setTitle(i18n.getLabel("MainFrame.title"));

    getContentPane().add(toolbar, BorderLayout.NORTH);
    getContentPane().add(mainPane);

    mainPane.setLayout(new BorderLayout());
    mainPane.add(statusbar, BorderLayout.SOUTH);

    ChannelsPane p = new ChannelsPane("Untitled");
    p.addListSelectionListener(this);
    getChannelsPaneList().add(p);
    miList.add(new JMenuItem(new A4n.MoveChannelsTo(p)));

    channelsPane.add(getChannelsPane(0));

    bottomPane.setLayout(new BorderLayout());

    rightPane.setLayout(new BorderLayout());
    rightPane.add(channelsPane);

    hSplitPane =
        new JSplitPane(
            JSplitPane.HORIZONTAL_SPLIT,
            true, // continuousLayout
            getLeftPane(),
            rightPane);

    hSplitPane.setOneTouchExpandable(true);
    if (ClassicPrefs.getSaveWindowProperties()) {
      hSplitPane.setDividerLocation(ClassicPrefs.getHSplitDividerLocation());
    }

    mainPane.add(hSplitPane);

    vSplitPane =
        new JSplitPane(
            JSplitPane.VERTICAL_SPLIT,
            true, // continuousLayout
            channelsPane,
            bottomPane);

    vSplitPane.setDividerSize(3);
    vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation());

    rightPane.add(vSplitPane);

    if (applicationIcon != null) setIconImage(applicationIcon.getImage());

    initMainFrame();

    pack();

    if (ClassicPrefs.getSaveWindowProperties()) setSavedSize();
    else setDefaultSize();

    if (ClassicPrefs.getSaveLeftPaneState()) {
      NavigationPage page = getLeftPane().getPages()[ClassicPrefs.getLeftPanePageIndex()];

      getLeftPane().getModel().addPage(page);
      getLeftPane().getModel().clearHistory();

      int idx = ClassicPrefs.getCurrentOrchestraIndex();
      if (idx >= 0 && idx < CC.getOrchestras().getOrchestraCount()) {
        OrchestraModel om = CC.getOrchestras().getOrchestra(idx);
        getLeftPane().getOrchestrasPage().setSelectedOrchestra(om);
      }
    }
  }
示例#20
0
 /**
  * Invoked when this window is about to close. Don't forget to call <code>super.onWindowClose()
  * </code> at the end, when override this method.
  */
 protected void onWindowClose() {
   CC.cleanExit();
 }
示例#21
0
  /**
   * Creates a new instance of <code>ChannelProperties</code> using the specified non-null channel
   * model.
   *
   * @param model The model to be used by this channel properties pane.
   */
  ChannelProperties(SamplerChannelModel model) {
    channelModel = model;

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(new JSeparator());

    JPanel enginesPane = new JPanel();

    for (SamplerEngine e : CC.getSamplerModel().getEngines()) cbEngines.addItem(e);

    // cbEngines.setMaximumSize(cbEngines.getPreferredSize());

    enginesPane.add(cbEngines);
    String s = i18n.getLabel("ChannelProperties.enginesPane");
    enginesPane.setBorder(BorderFactory.createTitledBorder(s));

    JPanel devicesPane = new JPanel();
    devicesPane.setLayout(new BoxLayout(devicesPane, BoxLayout.X_AXIS));

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    devicesPane.add(createMidiPane());

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    devicesPane.add(enginesPane);

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    JPanel audioPane = createAudioPane();
    Dimension d = audioPane.getPreferredSize();
    d.height = Short.MAX_VALUE;

    audioPane.setMaximumSize(d);
    devicesPane.add(audioPane);

    add(devicesPane);
    add(Box.createRigidArea(new Dimension(0, 6)));

    add(new JSeparator());

    cbMidiChannel.addItem("All");
    for (int i = 1; i <= 16; i++) cbMidiChannel.addItem(String.valueOf(i));

    cbMidiDevice.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiDevice();
          }
        });

    cbMidiPort.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiPort();
          }
        });

    cbMidiChannel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiChannel();
          }
        });

    cbEngines.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEngineType();
          }
        });

    cbAudioDevice.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setAudioDevice();
          }
        });

    getModel()
        .addSamplerChannelListener(
            new SamplerChannelAdapter() {
              public void channelChanged(SamplerChannelEvent e) {
                updateChannelProperties();
              }
            });

    CC.getSamplerModel().addMidiDeviceListListener(getHandler());
    CC.getSamplerModel().addAudioDeviceListListener(getHandler());
    CC.getSamplerModel().addSamplerChannelListListener(getHandler());

    btnAudioProps.setToolTipText(i18n.getLabel("ChannelProperties.routing"));
    btnAudioProps.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SamplerChannel c = getModel().getChannelInfo();
            new ChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);
          }
        });

    updateMidiDevices();
    updateAudioDevices();
    updateChannelProperties();
  }
  private void addMenu() {
    JMenu m;
    JMenuItem mi;

    setJMenuBar(menuBar);

    // Actions
    m = new JMenu(i18n.getMenuLabel("instrumentsdb.actions"));
    menuBar.add(m);

    mi = new JMenuItem(mainPane.getInstrumentsTable().createDirectoryAction);
    mi.setIcon(null);
    m.add(mi);

    mi = new JMenuItem(mainPane.getInstrumentsTable().deleteAction);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
    m.add(mi);

    JMenu addInstrumentsMenu = new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addInstruments"));
    m.add(addInstrumentsMenu);

    mi = new JMenuItem(mainPane.getInstrumentsTable().addInstrumentsFromFileAction);
    mi.setIcon(null);
    addInstrumentsMenu.add(mi);

    mi = new JMenuItem(mainPane.getInstrumentsTable().addInstrumentsFromDirAction);
    mi.setIcon(null);
    addInstrumentsMenu.add(mi);

    m.addSeparator();

    mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.actions.format"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String s = i18n.getMessage("InstrumentsDbFrame.formatDatabase?");
            if (!SHF.showYesNoDialog(InstrumentsDbFrame.this, s)) return;
            CC.getTaskQueue().add(new InstrumentsDb.Format());
          }
        });

    mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.actions.checkForLostFiles"));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new JSLostFilesDlg(InstrumentsDbFrame.this).setVisible(true);
          }
        });

    m.addSeparator();

    loadInstrumentMenu = new JMenu(i18n.getMenuLabel("instrumentsdb.actions.loadInstrument"));
    m.add(loadInstrumentMenu);
    mainPane.getInstrumentsTable().registerLoadInstrumentMenus(loadInstrumentMenu);

    addToMidiMapMenu = new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addToMidiMap"));
    m.add(addToMidiMapMenu);
    mainPane.getInstrumentsTable().registerAddToMidiMapMenu(addToMidiMapMenu);

    addToOrchestraMenu = new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addToOrchestra"));
    m.add(addToOrchestraMenu);
    mainPane.getInstrumentsTable().registerAddToOrchestraMenu(addToOrchestraMenu);

    m.addSeparator();

    mi = new JMenuItem(mainPane.getInstrumentsTable().reloadAction);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(mainPane.getInstrumentsTable().propertiesAction);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_MASK));
    m.add(mi);

    m = new JMenu(i18n.getMenuLabel("instrumentsdb.edit"));
    menuBar.add(m);

    int modKey = CC.getViewConfig().getDefaultModKey();
    mi = new JMenuItem(mainPane.getInstrumentsTable().cutAction);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, modKey));
    mi.setIcon(null);
    m.add(mi);

    mi = new JMenuItem(mainPane.getInstrumentsTable().copyAction);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, modKey));
    mi.setIcon(null);
    m.add(mi);

    mi = new JMenuItem(mainPane.getInstrumentsTable().pasteAction);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, modKey));
    mi.setIcon(null);
    m.add(mi);

    m.addSeparator();

    mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.edit.find"));
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, modKey));
    m.add(mi);
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (toolbar.btnFind.isSelected()) return;

            String path = instrumentsDbTree.getSelectedDirectoryPath();
            if (path != null) sidePane.searchPage.setSearchPath(path);
            toolbar.btnFind.doClick(0);
          }
        });

    m.addSeparator();

    mi = new JMenuItem(mainPane.getInstrumentsTable().renameAction);
    mi.setIcon(null);
    m.add(mi);

    mi = new JMenuItem(mainPane.getInstrumentsTable().changeDescriptionAction);
    mi.setIcon(null);
    m.add(mi);

    m = new JMenu(i18n.getMenuLabel("instrumentsdb.go"));
    menuBar.add(m);

    instrumentsDbTree.actionGoUp.putValue(Action.SMALL_ICON, Res.iconGoUp22);
    mi = new JMenuItem(instrumentsDbTree.actionGoUp);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK));
    m.add(mi);

    instrumentsDbTree.actionGoBack.putValue(Action.SMALL_ICON, Res.iconGoBack22);
    mi = new JMenuItem(instrumentsDbTree.actionGoBack);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK));
    m.add(mi);

    instrumentsDbTree.actionGoForward.putValue(Action.SMALL_ICON, Res.iconGoForward22);
    mi = new JMenuItem(instrumentsDbTree.actionGoForward);
    mi.setIcon(null);
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK));
    m.add(mi);
  }
 /**
  * Creates a new instance of <code>AbstractInstrumentsDbTree</code> using the specified tree
  * model.
  *
  * @param model The model to be used by this tree.
  */
 public AbstractInstrumentsDbTree(InstrumentsDbTreeModel model) {
   setView(CC.getViewConfig().getInstrumentsDbTreeView());
   setModel(model);
   addTreeWillExpandListener(getHandler());
   addTreeSelectionListener(getHandler());
 }