1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
87 |
if(url != null) applicationIcon = new ImageIcon(url); |
if(url != null) applicationIcon = new ImageIcon(url); |
88 |
} |
} |
89 |
|
|
90 |
private final Toolbar toolbar = new Toolbar(); |
private final ChannelsBar channelsBar = new ChannelsBar(); |
91 |
private final Statusbar statusbar = new Statusbar(); |
private final Statusbar statusbar = new Statusbar(); |
92 |
private final JMenuBar menuBar = new JMenuBar(); |
private final JMenuBar menuBar = new JMenuBar(); |
93 |
private final JMenu recentScriptsMenu = |
private final JMenu recentScriptsMenu = |
98 |
private final JSplitPane hSplitPane; |
private final JSplitPane hSplitPane; |
99 |
|
|
100 |
private final JPanel mainPane = new JPanel(); |
private final JPanel mainPane = new JPanel(); |
101 |
|
private final StandardBar standardBar = new StandardBar(); |
102 |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
103 |
private final JPanel rightPane = new JPanel(); |
private final JPanel rightPane = new JPanel(); |
104 |
private final JPanel bottomPane = new JPanel(); |
private final JPanel bottomPane = new JPanel(); |
112 |
private final JCheckBoxMenuItem cbmiLeftPaneVisible = |
private final JCheckBoxMenuItem cbmiLeftPaneVisible = |
113 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
114 |
|
|
115 |
|
private final JCheckBoxMenuItem cbmiStandardBarVisible = |
116 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.standard")); |
117 |
|
|
118 |
private final JCheckBoxMenuItem cbmiLSConsoleShown = |
private final JCheckBoxMenuItem cbmiLSConsoleShown = |
119 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.lsconsole")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.lsconsole")); |
120 |
|
|
123 |
private final Vector<String> recentScripts = new Vector<String>(); |
private final Vector<String> recentScripts = new Vector<String>(); |
124 |
|
|
125 |
|
|
126 |
/** Creates a new instance of JSMainFrame */ |
/** Creates a new instance of <code>MainFrame</code>. */ |
127 |
public |
public |
128 |
MainFrame() { |
MainFrame() { |
129 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
130 |
|
|
131 |
getContentPane().add(toolbar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
132 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
133 |
|
|
134 |
mainPane.setLayout(new BorderLayout()); |
mainPane.setLayout(new BorderLayout()); |
144 |
bottomPane.setLayout(new BorderLayout()); |
bottomPane.setLayout(new BorderLayout()); |
145 |
|
|
146 |
rightPane.setLayout(new BorderLayout()); |
rightPane.setLayout(new BorderLayout()); |
147 |
|
|
148 |
|
rightPane.add(channelsBar, BorderLayout.NORTH); |
149 |
rightPane.add(channelsPane); |
rightPane.add(channelsPane); |
150 |
|
|
151 |
hSplitPane = new JSplitPane ( |
hSplitPane = new JSplitPane ( |
245 |
for(String s : recentScripts) sb.append(s).append("\n"); |
for(String s : recentScripts) sb.append(s).append("\n"); |
246 |
ClassicPrefs.setRecentScripts(sb.toString()); |
ClassicPrefs.setRecentScripts(sb.toString()); |
247 |
|
|
248 |
LSConsoleModel model = getLSConsoleModel(); |
if(ClassicPrefs.getSaveConsoleHistory()) lsConsolePane.saveConsoleHistory(); |
|
sb = new StringBuffer(); |
|
|
for(String s : model.getCommandHistory()) sb.append(s).append("\n"); |
|
|
ClassicPrefs.setLSConsoleHistory(sb.toString()); |
|
249 |
|
|
250 |
ClassicPrefs.setShowLSConsole(isLSConsoleShown()); |
ClassicPrefs.setShowLSConsole(isLSConsoleShown()); |
251 |
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
331 |
mi.setIcon(null); |
mi.setIcon(null); |
332 |
m.add(mi); |
m.add(mi); |
333 |
|
|
334 |
|
JMenu midiInstrMenu = new JMenu(i18n.getMenuLabel("actions.midiInstruments")); |
335 |
|
m.add(midiInstrMenu); |
336 |
|
|
337 |
|
mi = new JMenuItem(A4n.addMidiInstrumentMap); |
338 |
|
mi.setIcon(null); |
339 |
|
midiInstrMenu.add(mi); |
340 |
|
|
341 |
|
mi = new JMenuItem(A4n.removeMidiInstrumentMap); |
342 |
|
mi.setIcon(null); |
343 |
|
midiInstrMenu.add(mi); |
344 |
|
|
345 |
|
mi = new JMenuItem(A4n.addMidiInstrumentWizard); |
346 |
|
mi.setIcon(null); |
347 |
|
midiInstrMenu.add(mi); |
348 |
|
|
349 |
m.addSeparator(); |
m.addSeparator(); |
350 |
|
|
351 |
mi = new JMenuItem(i18n.getMenuLabel("actions.runScript")); |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
352 |
|
m.add(exportMenu); |
353 |
|
|
354 |
|
mi = new JMenuItem(A4n.exportSamplerConfig); |
355 |
|
mi.setIcon(null); |
356 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
357 |
|
exportMenu.add(mi); |
358 |
|
|
359 |
|
mi = new JMenuItem(A4n.exportMidiInstrumentMaps); |
360 |
|
mi.setIcon(null); |
361 |
|
exportMenu.add(mi); |
362 |
|
|
363 |
|
m.addSeparator(); |
364 |
|
|
365 |
|
mi = new JMenuItem(A4n.loadScript); |
366 |
|
mi.setIcon(null); |
367 |
m.add(mi); |
m.add(mi); |
|
mi.addActionListener(new ActionListener() { |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { runScript(); } |
|
|
}); |
|
368 |
|
|
369 |
String s = ClassicPrefs.getRecentScripts(); |
String s = ClassicPrefs.getRecentScripts(); |
370 |
BufferedReader br = new BufferedReader(new StringReader(s)); |
BufferedReader br = new BufferedReader(new StringReader(s)); |
439 |
m = new JMenu(i18n.getMenuLabel("view")); |
m = new JMenu(i18n.getMenuLabel("view")); |
440 |
menuBar.add(m); |
menuBar.add(m); |
441 |
|
|
442 |
|
JMenu toolbarsMenu = new JMenu(i18n.getMenuLabel("view.toolbars")); |
443 |
|
m.add(toolbarsMenu); |
444 |
|
|
445 |
|
toolbarsMenu.add(cbmiStandardBarVisible); |
446 |
|
cbmiStandardBarVisible.addActionListener(new ActionListener() { |
447 |
|
public void |
448 |
|
actionPerformed(ActionEvent e) { |
449 |
|
showStandardBar(cbmiStandardBarVisible.getState()); |
450 |
|
} |
451 |
|
}); |
452 |
|
|
453 |
|
boolean b = ClassicPrefs.shouldShowStandardBar(); |
454 |
|
cbmiStandardBarVisible.setSelected(b); |
455 |
|
showStandardBar(b); |
456 |
|
|
457 |
final JCheckBoxMenuItem cbmi = |
final JCheckBoxMenuItem cbmi = |
458 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbar")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.channels")); |
459 |
|
|
460 |
m.add(cbmi); |
toolbarsMenu.add(cbmi); |
461 |
cbmi.addActionListener(new ActionListener() { |
cbmi.addActionListener(new ActionListener() { |
462 |
public void |
public void |
463 |
actionPerformed(ActionEvent e) { showToolbar(cbmi.getState()); } |
actionPerformed(ActionEvent e) { showChannelsBar(cbmi.getState()); } |
464 |
}); |
}); |
465 |
|
|
466 |
boolean b = ClassicPrefs.shouldShowToolbar(); |
b = ClassicPrefs.shouldShowChannelsBar(); |
467 |
cbmi.setSelected(b); |
cbmi.setSelected(b); |
468 |
showToolbar(b); |
showChannelsBar(b); |
469 |
|
|
470 |
m.add(cbmiLeftPaneVisible); |
m.add(cbmiLeftPaneVisible); |
471 |
cbmiLeftPaneVisible.addActionListener(new ActionListener() { |
cbmiLeftPaneVisible.addActionListener(new ActionListener() { |
650 |
} |
} |
651 |
|
|
652 |
private void |
private void |
653 |
showToolbar(boolean b) { |
showChannelsBar(boolean b) { |
654 |
if(b) getContentPane().add(toolbar, BorderLayout.NORTH); |
channelsBar.setVisible(b); |
655 |
else getContentPane().remove(toolbar); |
ClassicPrefs.setShowChannelsBar(b); |
|
|
|
|
ClassicPrefs.setShowToolbar(b); |
|
656 |
|
|
657 |
validate(); |
validate(); |
658 |
repaint(); |
repaint(); |
703 |
} |
} |
704 |
|
|
705 |
private void |
private void |
706 |
|
showStandardBar(boolean b) { |
707 |
|
ClassicPrefs.setShowStandardBar(b); |
708 |
|
standardBar.setVisible(b); |
709 |
|
validate(); |
710 |
|
repaint(); |
711 |
|
} |
712 |
|
|
713 |
|
private void |
714 |
showBottomPane(boolean b) { |
showBottomPane(boolean b) { |
715 |
if(!b) ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
if(!b) ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
716 |
|
|
1095 |
|
|
1096 |
protected void |
protected void |
1097 |
runScript() { |
runScript() { |
1098 |
JFileChooser fc = new JFileChooser(); |
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
1099 |
fc.setFileFilter(new LscpFileFilter()); |
fc.setFileFilter(new LscpFileFilter()); |
1100 |
int result = fc.showOpenDialog(this); |
int result = fc.showOpenDialog(this); |
1101 |
if(result != JFileChooser.APPROVE_OPTION) return; |
if(result != JFileChooser.APPROVE_OPTION) return; |
1102 |
|
|
1103 |
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
1104 |
|
ClassicPrefs.setLastScriptLocation(path); |
1105 |
|
|
1106 |
runScript(fc.getSelectedFile()); |
runScript(fc.getSelectedFile()); |
1107 |
} |
} |
1108 |
|
|
1167 |
|
|
1168 |
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
1169 |
} |
} |
1170 |
|
|
1171 |
|
public void |
1172 |
|
installJSamplerHome() { |
1173 |
|
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
1174 |
|
chooser.setVisible(true); |
1175 |
|
if(chooser.isCancelled()) return; |
1176 |
|
|
1177 |
|
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
1178 |
|
} |
1179 |
} |
} |