private void runScript(File script) {
    FileReader fr;
    try {
      fr = new FileReader(script);
    } catch (FileNotFoundException e) {
      HF.showErrorMessage(i18n.getMessage("FileNotFound!"));
      return;
    }

    BufferedReader br = new BufferedReader(fr);

    try {
      String s = br.readLine();
      while (s != null) {
        getLSConsoleModel().setCommandLineText(s);
        getLSConsoleModel().execCommand();
        s = br.readLine();
      }
    } catch (Exception e) {
      HF.showErrorMessage(e);
      return;
    }

    if (!cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0);

    String s = script.getAbsolutePath();
    recentScripts.remove(s);
    recentScripts.insertElementAt(s, 0);

    while (recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) {
      recentScripts.removeElementAt(recentScripts.size() - 1);
    }

    updateRecentScriptsMenu();
  }
Exemple #2
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);
      }
    }
  /**
   * 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);
  }
  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);
  }