Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  static {
    String path = "org/jsampler/view/classic/res/icons/";
    URL url = ClassLoader.getSystemClassLoader().getResource(path + "mute_on.png");
    iconMuteOn = new ImageIcon(url);

    url = ClassLoader.getSystemClassLoader().getResource(path + "mute_off.png");
    iconMuteOff = new ImageIcon(url);

    url = ClassLoader.getSystemClassLoader().getResource(path + "muted_by_solo.png");
    iconMutedBySolo = new ImageIcon(url);

    url = ClassLoader.getSystemClassLoader().getResource(path + "solo_on.png");
    iconSoloOn = new ImageIcon(url);

    url = ClassLoader.getSystemClassLoader().getResource(path + "solo_off.png");
    iconSoloOff = new ImageIcon(url);

    url = ClassLoader.getSystemClassLoader().getResource(path + "Back16.gif");
    iconShowProperties = new ImageIcon(url);

    iconHideProperties = Res.iconDown16;

    if (ClassicPrefs.getCustomChannelBorderColor())
      setBorderColor(ClassicPrefs.getChannelBorderColor());
    else setBorderColor(ClassicPrefs.getDefaultChannelBorderColor());

    borderSelected = new LineBorder(getBorderColor(), 2, true);
    borderDeselected = BorderFactory.createEmptyBorder(2, 2, 2, 2);
  }
Exemplo n.º 3
0
  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();
  }
Exemplo n.º 4
0
  private void showBottomPane(boolean b) {
    if (!b) ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation());

    rightPane.remove(vSplitPane);
    rightPane.remove(channelsPane);

    if (b) {
      vSplitPane.setTopComponent(channelsPane);
      rightPane.add(vSplitPane);
      vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation());
    } else {
      rightPane.add(channelsPane);
    }

    validate();
    repaint();
  }
Exemplo n.º 5
0
  private void showToolbar(boolean b) {
    if (b) getContentPane().add(toolbar, BorderLayout.NORTH);
    else getContentPane().remove(toolbar);

    ClassicPrefs.setShowToolbar(b);

    validate();
    repaint();
  }
Exemplo n.º 6
0
  private void showLeftPane(boolean b) {
    ClassicPrefs.setShowLeftPane(b);

    mainPane.remove(hSplitPane);
    mainPane.remove(rightPane);

    if (b) {
      hSplitPane.setRightComponent(rightPane);
      mainPane.add(hSplitPane);
      if (ClassicPrefs.getSaveWindowProperties()) {
        int i = ClassicPrefs.getHSplitDividerLocation();
        hSplitPane.setDividerLocation(i);
      }
    } else {
      mainPane.add(rightPane);
    }

    validate();
    repaint();
  }
Exemplo n.º 7
0
  protected void updateRecentScriptsMenu() {
    while (recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) {
      recentScripts.removeElementAt(recentScripts.size() - 1);
    }

    recentScriptsMenu.removeAll();

    for (String script : recentScripts) {
      JMenuItem mi = new JMenuItem(script);
      recentScriptsMenu.add(mi);
      mi.addActionListener(new RecentScriptHandler(script));
    }

    recentScriptsMenu.setEnabled(recentScripts.size() != 0);
  }
Exemplo n.º 8
0
 private void showStatusbar(boolean b) {
   ClassicPrefs.setShowStatusbar(b);
   statusbar.setVisible(b);
 }
Exemplo n.º 9
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);
  }
Exemplo n.º 10
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();
  }
Exemplo n.º 11
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);
      }
    }
  }