63 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
64 |
import javax.swing.Timer; |
import javax.swing.Timer; |
65 |
|
|
66 |
|
import javax.swing.event.ListSelectionEvent; |
67 |
|
import javax.swing.event.ListSelectionListener; |
68 |
|
|
69 |
import org.jsampler.CC; |
import org.jsampler.CC; |
70 |
import org.jsampler.HF; |
import org.jsampler.HF; |
71 |
import org.jsampler.LSConsoleModel; |
import org.jsampler.LSConsoleModel; |
72 |
import org.jsampler.Server; |
import org.jsampler.Server; |
73 |
|
|
74 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
|
import org.jsampler.view.JSMainFrame; |
|
75 |
import org.jsampler.view.LscpFileFilter; |
import org.jsampler.view.LscpFileFilter; |
76 |
|
import org.jsampler.view.SessionViewConfig; |
77 |
|
|
78 |
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
79 |
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
84 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
import org.jsampler.view.std.JSDetailedErrorDlg; |
85 |
import org.jsampler.view.std.JSQuitDlg; |
import org.jsampler.view.std.JSQuitDlg; |
86 |
import org.jsampler.view.std.JSamplerHomeChooser; |
import org.jsampler.view.std.JSamplerHomeChooser; |
87 |
|
import org.jsampler.view.std.StdMainFrame; |
88 |
import org.jsampler.view.std.StdUtils; |
import org.jsampler.view.std.StdUtils; |
89 |
|
|
90 |
import static org.jsampler.view.fantasia.A4n.a4n; |
import static org.jsampler.view.fantasia.A4n.a4n; |
97 |
* |
* |
98 |
* @author Grigor Iliev |
* @author Grigor Iliev |
99 |
*/ |
*/ |
100 |
public class MainFrame extends JSMainFrame { |
public class MainFrame extends StdMainFrame { |
101 |
private final StandardBar standardBar = new StandardBar(); |
private final StandardBar standardBar = new StandardBar(); |
102 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
103 |
private final JPanel rootPane = new RootPane(); |
private final JPanel rootPane = new RootPane(); |
471 |
setMidiKeyboardVisible(b); |
setMidiKeyboardVisible(b); |
472 |
|
|
473 |
|
|
474 |
|
// Channels |
475 |
|
m = new FantasiaMenu(i18n.getMenuLabel("channels")); |
476 |
|
|
477 |
|
mi = new JMenuItem(i18n.getMenuLabel("channels.newChannel")); |
478 |
|
mi.addActionListener(new ActionListener() { |
479 |
|
public void |
480 |
|
actionPerformed(ActionEvent e) { |
481 |
|
CC.getSamplerModel().addBackendChannel(); |
482 |
|
} |
483 |
|
}); |
484 |
|
m.add(mi); |
485 |
|
|
486 |
|
m.addSeparator(); |
487 |
|
|
488 |
|
MenuManager.ChannelViewGroup group = new MenuManager.ChannelViewGroup(); |
489 |
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
490 |
|
|
491 |
|
for(JMenuItem menuItem : group.getMenuItems()) m.add(menuItem); |
492 |
|
|
493 |
|
m.addSeparator(); |
494 |
|
|
495 |
|
m.add(new JMenuItem(a4n.moveChannelsOnTop)); |
496 |
|
m.add(new JMenuItem(a4n.moveChannelsUp)); |
497 |
|
m.add(new JMenuItem(a4n.moveChannelsDown)); |
498 |
|
m.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
499 |
|
|
500 |
|
m.add(new ToPanelMenu()); |
501 |
|
|
502 |
|
m.addSeparator(); |
503 |
|
|
504 |
|
mi = new JMenuItem(a4n.selectAllChannels); |
505 |
|
mi.setIcon(null); |
506 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)); |
507 |
|
m.add(mi); |
508 |
|
|
509 |
|
mi = new JMenuItem(a4n.deselectChannels); |
510 |
|
mi.setIcon(null); |
511 |
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
512 |
|
KeyEvent.VK_A, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
513 |
|
)); |
514 |
|
m.add(mi); |
515 |
|
|
516 |
|
menuBar.add(m); |
517 |
|
|
518 |
// Window |
// Window |
519 |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
520 |
menuBar.add(m); |
menuBar.add(m); |
568 |
menuBar.add(m); |
menuBar.add(m); |
569 |
} |
} |
570 |
|
|
571 |
|
public static class ToPanelMenu extends FantasiaMenu implements ListSelectionListener { |
572 |
|
public |
573 |
|
ToPanelMenu() { |
574 |
|
super(i18n.getMenuLabel("channels.toPanel")); |
575 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
576 |
|
|
577 |
|
CC.getMainFrame().addChannelsPaneSelectionListener(this); |
578 |
|
|
579 |
|
for(int i = 0; i < CC.getMainFrame().getChannelsPaneCount(); i++) { |
580 |
|
JSChannelsPane p = CC.getMainFrame().getChannelsPane(i); |
581 |
|
add(new JMenuItem(new A4n.MoveChannelsToPanel(p))); |
582 |
|
p.addListSelectionListener(this); |
583 |
|
} |
584 |
|
} |
585 |
|
|
586 |
|
@Override |
587 |
|
public void |
588 |
|
valueChanged(ListSelectionEvent e) { |
589 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
590 |
|
} |
591 |
|
} |
592 |
|
|
593 |
public RightSidePane |
public RightSidePane |
594 |
getRightSidePane() { return rightSidePane; } |
getRightSidePane() { return rightSidePane; } |
595 |
|
|
596 |
|
@Override |
597 |
|
public A4n |
598 |
|
getA4n() { return A4n.a4n; } |
599 |
|
|
600 |
/** |
/** |
601 |
* This method does nothing, because <b>Fantasia</b> has constant |
* This method does nothing, because <b>Fantasia</b> has constant |
602 |
* number of panes containing sampler channels, which can not be changed. |
* number of panes containing sampler channels, which can not be changed. |
726 |
return; |
return; |
727 |
} |
} |
728 |
|
|
729 |
|
String prefix = "#jsampler.fantasia: "; |
730 |
|
Vector<String> v = new Vector<String>(); |
731 |
BufferedReader br = new BufferedReader(fr); |
BufferedReader br = new BufferedReader(fr); |
732 |
|
|
733 |
try { |
try { |
735 |
while(s != null) { |
while(s != null) { |
736 |
getLSConsoleModel().setCommandLineText(s); |
getLSConsoleModel().setCommandLineText(s); |
737 |
getLSConsoleModel().execCommand(); |
getLSConsoleModel().execCommand(); |
738 |
|
if(s.startsWith(prefix)) v.add(s.substring(prefix.length())); |
739 |
s = br.readLine(); |
s = br.readLine(); |
740 |
} |
} |
741 |
} catch(Exception e) { |
} catch(Exception e) { |
748 |
recentScripts.insertElementAt(s, 0); |
recentScripts.insertElementAt(s, 0); |
749 |
|
|
750 |
updateRecentScriptsMenu(); |
updateRecentScriptsMenu(); |
751 |
|
|
752 |
|
CC.getViewConfig().setSessionViewConfig( |
753 |
|
new SessionViewConfig(v.toArray(new String[v.size()])) |
754 |
|
); |
755 |
} |
} |
756 |
|
|
757 |
protected void |
protected void |