1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
23 |
package org.jsampler.view.classic; |
package org.jsampler.view.classic; |
24 |
|
|
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
|
import java.awt.Color; |
27 |
|
import java.awt.Dialog; |
28 |
import java.awt.Dimension; |
import java.awt.Dimension; |
29 |
|
import java.awt.Frame; |
30 |
|
|
31 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
33 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
34 |
|
|
35 |
|
import java.io.BufferedReader; |
36 |
|
import java.io.File; |
37 |
|
import java.io.FileNotFoundException; |
38 |
|
import java.io.FileReader; |
39 |
|
import java.io.StringReader; |
40 |
|
|
41 |
import java.util.logging.Level; |
import java.util.logging.Level; |
42 |
import java.util.Vector; |
import java.util.Vector; |
43 |
|
|
44 |
import javax.swing.Action; |
import javax.swing.Action; |
45 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
46 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
47 |
|
import javax.swing.JFileChooser; |
48 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
49 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
50 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
62 |
import net.sf.juife.NavigationPane; |
import net.sf.juife.NavigationPane; |
63 |
|
|
64 |
import org.jsampler.CC; |
import org.jsampler.CC; |
65 |
|
import org.jsampler.HF; |
66 |
|
import org.jsampler.LSConsoleModel; |
67 |
|
import org.jsampler.OrchestraModel; |
68 |
import org.jsampler.Prefs; |
import org.jsampler.Prefs; |
69 |
|
|
70 |
import org.jsampler.view.JSChannel; |
import org.jsampler.view.JSChannel; |
71 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
72 |
|
import org.jsampler.view.LscpFileFilter; |
73 |
|
|
74 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
75 |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
81 |
*/ |
*/ |
82 |
public class |
public class |
83 |
MainFrame extends org.jsampler.view.JSMainFrame implements ChangeListener, ListSelectionListener { |
MainFrame extends org.jsampler.view.JSMainFrame implements ChangeListener, ListSelectionListener { |
84 |
public static ImageIcon applicationIcon = null; |
public static ImageIcon applicationIcon = Res.appIcon; |
|
|
|
|
static { |
|
|
String s = "org/jsampler/view/classic/res/icons/app-icon.png"; |
|
|
java.net.URL url = ClassLoader.getSystemClassLoader().getResource(s); |
|
|
if(url != null) applicationIcon = new ImageIcon(url); |
|
|
} |
|
85 |
|
|
86 |
private final Toolbar toolbar = new Toolbar(); |
private final ChannelsBar channelsBar = new ChannelsBar(); |
87 |
private final Statusbar statusbar = new Statusbar(); |
private final Statusbar statusbar = new Statusbar(); |
88 |
private final JMenuBar menuBar = new JMenuBar(); |
private final JMenuBar menuBar = new JMenuBar(); |
89 |
|
private final JMenu recentScriptsMenu = |
90 |
|
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
91 |
|
private final JMenu tabsMenu = new JMenu(i18n.getMenuLabel("channels.MoveToTab")); |
92 |
|
|
93 |
private final JSplitPane splitPane; |
private final JSplitPane vSplitPane; |
94 |
|
private final JSplitPane hSplitPane; |
95 |
|
|
96 |
private final JPanel mainPane = new JPanel(); |
private final JPanel mainPane = new JPanel(); |
97 |
|
private final StandardBar standardBar = new StandardBar(); |
98 |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
99 |
|
private final JPanel rightPane = new JPanel(); |
100 |
|
private final JPanel bottomPane = new JPanel(); |
101 |
|
private final LSConsolePane lsConsolePane = new LSConsolePane(this); |
102 |
|
private LSConsoleDlg lsConsoleDlg = null; |
103 |
|
|
104 |
private final JTabbedPane tabbedPane = |
private final JTabbedPane tabbedPane = |
105 |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
|
private final JMenu tabsMenu = new JMenu(i18n.getMenuLabel("channels.MoveToTab")); |
|
106 |
private final Vector<JMenuItem> miList = new Vector<JMenuItem>(); |
private final Vector<JMenuItem> miList = new Vector<JMenuItem>(); |
107 |
|
|
108 |
/** Creates a new instance of JSMainFrame */ |
private final JCheckBoxMenuItem cbmiLeftPaneVisible = |
109 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
110 |
|
|
111 |
|
private final JCheckBoxMenuItem cbmiStandardBarVisible = |
112 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.standard")); |
113 |
|
|
114 |
|
private final JCheckBoxMenuItem cbmiLSConsoleShown = |
115 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.lsconsole")); |
116 |
|
|
117 |
|
private boolean lsConsolePopOut; |
118 |
|
|
119 |
|
private final Vector<String> recentScripts = new Vector<String>(); |
120 |
|
|
121 |
|
|
122 |
|
/** Creates a new instance of <code>MainFrame</code>. */ |
123 |
public |
public |
124 |
MainFrame() { |
MainFrame() { |
125 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
126 |
|
|
127 |
getContentPane().add(toolbar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
128 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
129 |
|
|
130 |
mainPane.setLayout(new BorderLayout()); |
mainPane.setLayout(new BorderLayout()); |
137 |
|
|
138 |
channelsPane.add(getChannelsPane(0)); |
channelsPane.add(getChannelsPane(0)); |
139 |
|
|
140 |
splitPane = new JSplitPane ( |
bottomPane.setLayout(new BorderLayout()); |
141 |
|
|
142 |
|
rightPane.setLayout(new BorderLayout()); |
143 |
|
|
144 |
|
rightPane.add(channelsBar, BorderLayout.NORTH); |
145 |
|
rightPane.add(channelsPane); |
146 |
|
|
147 |
|
hSplitPane = new JSplitPane ( |
148 |
JSplitPane.HORIZONTAL_SPLIT, |
JSplitPane.HORIZONTAL_SPLIT, |
149 |
true, // continuousLayout |
true, // continuousLayout |
150 |
getLeftPane(), |
getLeftPane(), |
151 |
channelsPane |
rightPane |
152 |
); |
); |
153 |
|
|
154 |
splitPane.setOneTouchExpandable(true); |
hSplitPane.setOneTouchExpandable(true); |
155 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
156 |
|
hSplitPane.setDividerLocation(ClassicPrefs.getHSplitDividerLocation()); |
157 |
|
} |
158 |
|
|
159 |
|
mainPane.add(hSplitPane); |
160 |
|
|
161 |
mainPane.add(splitPane); |
|
162 |
|
vSplitPane = new JSplitPane ( |
163 |
|
JSplitPane.VERTICAL_SPLIT, |
164 |
|
true, // continuousLayout |
165 |
|
channelsPane, |
166 |
|
bottomPane |
167 |
|
); |
168 |
|
|
169 |
|
vSplitPane.setDividerSize(3); |
170 |
|
vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation()); |
171 |
|
|
172 |
|
rightPane.add(vSplitPane); |
173 |
|
|
174 |
if(applicationIcon != null) setIconImage(applicationIcon.getImage()); |
if(applicationIcon != null) setIconImage(applicationIcon.getImage()); |
175 |
|
|
176 |
initMainFrame(); |
initMainFrame(); |
177 |
|
|
178 |
pack(); |
pack(); |
179 |
|
|
180 |
if(Prefs.getSaveWindowProperties()) setSavedSize(); |
if(ClassicPrefs.getSaveWindowProperties()) setSavedSize(); |
181 |
else setDefaultSize(); |
else setDefaultSize(); |
182 |
|
|
183 |
|
if(ClassicPrefs.getSaveLeftPaneState()) { |
184 |
|
NavigationPage page = |
185 |
|
getLeftPane().getPages()[ClassicPrefs.getLeftPanePageIndex()]; |
186 |
|
|
187 |
|
getLeftPane().getModel().addPage(page); |
188 |
|
getLeftPane().getModel().clearHistory(); |
189 |
|
|
190 |
|
int idx = ClassicPrefs.getCurrentOrchestraIndex(); |
191 |
|
if(idx >= 0 && idx < CC.getOrchestras().getOrchestraCount()) { |
192 |
|
OrchestraModel om = CC.getOrchestras().getOrchestra(idx); |
193 |
|
getLeftPane().getOrchestrasPage().setSelectedOrchestra(om); |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
//CC.getInstrumentsDbTreeModel(); // used to initialize the db tree model |
198 |
|
} |
199 |
|
|
200 |
|
/** Invoked when this window is about to close. */ |
201 |
|
protected void |
202 |
|
onWindowClose() { |
203 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
204 |
|
ClassicPrefs.setWindowMaximized ( |
205 |
|
"Mainframe", (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
206 |
|
); |
207 |
|
|
208 |
|
setVisible(false); |
209 |
|
if(ClassicPrefs.getWindowMaximized("Mainframe")) { |
210 |
|
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
211 |
|
CC.cleanExit(); |
212 |
|
return; |
213 |
|
} |
214 |
|
|
215 |
|
java.awt.Point p = getLocation(); |
216 |
|
Dimension d = getSize(); |
217 |
|
StringBuffer sb = new StringBuffer(); |
218 |
|
sb.append(p.x).append(',').append(p.y).append(','); |
219 |
|
sb.append(d.width).append(',').append(d.height); |
220 |
|
ClassicPrefs.setWindowSizeAndLocation("Mainframe", sb.toString()); |
221 |
|
|
222 |
|
ClassicPrefs.setHSplitDividerLocation(hSplitPane.getDividerLocation()); |
223 |
|
} |
224 |
|
|
225 |
|
if(ClassicPrefs.getSaveLeftPaneState()) { |
226 |
|
int idx = 0; |
227 |
|
for(int i = 0; i < getLeftPane().getPages().length; i++) { |
228 |
|
if(getLeftPane().getPages()[i] == getLeftPane().getCurrentPage()) { |
229 |
|
idx = i; |
230 |
|
break; |
231 |
|
} |
232 |
|
} |
233 |
|
|
234 |
|
ClassicPrefs.setLeftPanePageIndex(idx); |
235 |
|
|
236 |
|
idx = getLeftPane().getOrchestrasPage().getCurrentOrchestraIndex(); |
237 |
|
|
238 |
|
if(idx >= 0 && idx < CC.getOrchestras().getOrchestraCount()) |
239 |
|
ClassicPrefs.setCurrentOrchestraIndex(idx); |
240 |
|
} |
241 |
|
|
242 |
|
StringBuffer sb = new StringBuffer(); |
243 |
|
for(String s : recentScripts) sb.append(s).append("\n"); |
244 |
|
ClassicPrefs.setRecentScripts(sb.toString()); |
245 |
|
|
246 |
|
if(ClassicPrefs.getSaveConsoleHistory()) lsConsolePane.saveConsoleHistory(); |
247 |
|
|
248 |
|
ClassicPrefs.setShowLSConsole(isLSConsoleShown()); |
249 |
|
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
250 |
|
|
251 |
|
ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
252 |
|
super.onWindowClose(); |
253 |
} |
} |
254 |
|
|
255 |
private void |
private void |
268 |
|
|
269 |
private void |
private void |
270 |
setSavedSize() { |
setSavedSize() { |
271 |
String s = Prefs.getWindowSizeAndLocation(); |
String s = ClassicPrefs.getWindowSizeAndLocation("Mainframe"); |
272 |
if(s == null) { |
if(s == null) { |
273 |
setDefaultSize(); |
setDefaultSize(); |
274 |
return; |
return; |
296 |
setDefaultSize(); |
setDefaultSize(); |
297 |
} |
} |
298 |
|
|
299 |
if(Prefs.getWindowMaximized()) |
if(ClassicPrefs.getWindowMaximized("Mainframe")) |
300 |
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
301 |
} |
} |
302 |
|
|
303 |
private void |
private void |
304 |
addMenu() { |
addMenu() { |
305 |
JMenu m; |
JMenu m; |
|
JMenu submenu; |
|
306 |
JMenuItem mi; |
JMenuItem mi; |
307 |
|
|
308 |
setJMenuBar(menuBar); |
setJMenuBar(menuBar); |
329 |
mi.setIcon(null); |
mi.setIcon(null); |
330 |
m.add(mi); |
m.add(mi); |
331 |
|
|
332 |
|
JMenu midiInstrMenu = new JMenu(i18n.getMenuLabel("actions.midiInstruments")); |
333 |
|
m.add(midiInstrMenu); |
334 |
|
|
335 |
|
mi = new JMenuItem(A4n.addMidiInstrumentMap); |
336 |
|
mi.setIcon(null); |
337 |
|
midiInstrMenu.add(mi); |
338 |
|
|
339 |
|
mi = new JMenuItem(A4n.removeMidiInstrumentMap); |
340 |
|
mi.setIcon(null); |
341 |
|
midiInstrMenu.add(mi); |
342 |
|
|
343 |
|
mi = new JMenuItem(A4n.addMidiInstrumentWizard); |
344 |
|
mi.setIcon(null); |
345 |
|
midiInstrMenu.add(mi); |
346 |
|
|
347 |
|
m.addSeparator(); |
348 |
|
|
349 |
|
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
350 |
|
m.add(exportMenu); |
351 |
|
|
352 |
|
mi = new JMenuItem(A4n.exportSamplerConfig); |
353 |
|
mi.setIcon(null); |
354 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
355 |
|
exportMenu.add(mi); |
356 |
|
|
357 |
|
mi = new JMenuItem(A4n.exportMidiInstrumentMaps); |
358 |
|
mi.setIcon(null); |
359 |
|
exportMenu.add(mi); |
360 |
|
|
361 |
|
m.addSeparator(); |
362 |
|
|
363 |
|
mi = new JMenuItem(A4n.loadScript); |
364 |
|
mi.setIcon(null); |
365 |
|
m.add(mi); |
366 |
|
|
367 |
|
String s = ClassicPrefs.getRecentScripts(); |
368 |
|
BufferedReader br = new BufferedReader(new StringReader(s)); |
369 |
|
|
370 |
|
try { |
371 |
|
s = br.readLine(); |
372 |
|
while(s != null) { |
373 |
|
recentScripts.add(s); |
374 |
|
s = br.readLine(); |
375 |
|
} |
376 |
|
} catch(Exception x) { |
377 |
|
CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x); |
378 |
|
} |
379 |
|
|
380 |
|
updateRecentScriptsMenu(); |
381 |
|
|
382 |
|
m.add(recentScriptsMenu); |
383 |
|
|
384 |
m.addSeparator(); |
m.addSeparator(); |
385 |
|
|
386 |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
394 |
m = new JMenu(i18n.getMenuLabel("edit")); |
m = new JMenu(i18n.getMenuLabel("edit")); |
395 |
menuBar.add(m); |
menuBar.add(m); |
396 |
|
|
397 |
|
mi = new JMenuItem(i18n.getMenuLabel("edit.audioDevices")); |
398 |
|
m.add(mi); |
399 |
|
mi.addActionListener(new ActionListener() { |
400 |
|
public void |
401 |
|
actionPerformed(ActionEvent e) { |
402 |
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
403 |
|
LeftPane.getLeftPane().showAudioDevicesPage(); |
404 |
|
} |
405 |
|
}); |
406 |
|
|
407 |
|
mi = new JMenuItem(i18n.getMenuLabel("edit.midiDevices")); |
408 |
|
m.add(mi); |
409 |
|
mi.addActionListener(new ActionListener() { |
410 |
|
public void |
411 |
|
actionPerformed(ActionEvent e) { |
412 |
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
413 |
|
LeftPane.getLeftPane().showMidiDevicesPage(); |
414 |
|
} |
415 |
|
}); |
416 |
|
|
417 |
|
mi = new JMenuItem(i18n.getMenuLabel("edit.orchestras")); |
418 |
|
m.add(mi); |
419 |
|
mi.addActionListener(new ActionListener() { |
420 |
|
public void |
421 |
|
actionPerformed(ActionEvent e) { |
422 |
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
423 |
|
LeftPane.getLeftPane().showManageOrchestrasPage(); |
424 |
|
} |
425 |
|
}); |
426 |
|
|
427 |
m.addSeparator(); |
m.addSeparator(); |
428 |
|
|
429 |
mi = new JMenuItem(A4n.preferences); |
mi = new JMenuItem(A4n.preferences); |
437 |
m = new JMenu(i18n.getMenuLabel("view")); |
m = new JMenu(i18n.getMenuLabel("view")); |
438 |
menuBar.add(m); |
menuBar.add(m); |
439 |
|
|
440 |
|
JMenu toolbarsMenu = new JMenu(i18n.getMenuLabel("view.toolbars")); |
441 |
|
m.add(toolbarsMenu); |
442 |
|
|
443 |
|
toolbarsMenu.add(cbmiStandardBarVisible); |
444 |
|
cbmiStandardBarVisible.addActionListener(new ActionListener() { |
445 |
|
public void |
446 |
|
actionPerformed(ActionEvent e) { |
447 |
|
showStandardBar(cbmiStandardBarVisible.getState()); |
448 |
|
} |
449 |
|
}); |
450 |
|
|
451 |
|
boolean b = ClassicPrefs.shouldShowStandardBar(); |
452 |
|
cbmiStandardBarVisible.setSelected(b); |
453 |
|
showStandardBar(b); |
454 |
|
|
455 |
final JCheckBoxMenuItem cbmi = |
final JCheckBoxMenuItem cbmi = |
456 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbar")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.channels")); |
457 |
|
|
458 |
m.add(cbmi); |
toolbarsMenu.add(cbmi); |
459 |
cbmi.addActionListener(new ActionListener() { |
cbmi.addActionListener(new ActionListener() { |
460 |
public void |
public void |
461 |
actionPerformed(ActionEvent e) { showToolbar(cbmi.getState()); } |
actionPerformed(ActionEvent e) { showChannelsBar(cbmi.getState()); } |
462 |
}); |
}); |
463 |
|
|
464 |
boolean b = ClassicPrefs.shouldShowToolbar(); |
b = ClassicPrefs.shouldShowChannelsBar(); |
465 |
cbmi.setSelected(b); |
cbmi.setSelected(b); |
466 |
showToolbar(b); |
showChannelsBar(b); |
|
|
|
|
final JCheckBoxMenuItem cbmi1 = |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
|
467 |
|
|
468 |
m.add(cbmi1); |
m.add(cbmiLeftPaneVisible); |
469 |
cbmi1.addActionListener(new ActionListener() { |
cbmiLeftPaneVisible.addActionListener(new ActionListener() { |
470 |
public void |
public void |
471 |
actionPerformed(ActionEvent e) { showLeftPane(cbmi1.getState()); } |
actionPerformed(ActionEvent e) { |
472 |
|
showLeftPane(cbmiLeftPaneVisible.getState()); |
473 |
|
} |
474 |
}); |
}); |
475 |
|
|
476 |
b = ClassicPrefs.shouldShowLeftPane(); |
b = ClassicPrefs.shouldShowLeftPane(); |
477 |
cbmi1.setSelected(b); |
cbmiLeftPaneVisible.setSelected(b); |
478 |
showLeftPane(b); |
showLeftPane(b); |
479 |
|
|
480 |
final JCheckBoxMenuItem cbmi2 = |
final JCheckBoxMenuItem cbmi2 = |
489 |
cbmi2.setSelected(b); |
cbmi2.setSelected(b); |
490 |
showStatusbar(b); |
showStatusbar(b); |
491 |
|
|
492 |
|
m.addSeparator(); |
493 |
|
|
494 |
|
setLSConsolePopOut(ClassicPrefs.isLSConsolePopOut()); |
495 |
|
cbmiLSConsoleShown.setSelected(ClassicPrefs.shouldShowLSConsole()); |
496 |
|
showLSConsole(ClassicPrefs.shouldShowLSConsole()); |
497 |
|
|
498 |
|
cbmiLSConsoleShown.addActionListener(new ActionListener() { |
499 |
|
public void |
500 |
|
actionPerformed(ActionEvent e) { |
501 |
|
showLSConsole(cbmiLSConsoleShown.isSelected()); |
502 |
|
} |
503 |
|
}); |
504 |
|
m.add(cbmiLSConsoleShown); |
505 |
|
|
506 |
|
lsConsolePane.updateLSConsoleViewMode(); |
507 |
|
|
508 |
// Channels |
// Channels |
509 |
m = new JMenu(i18n.getMenuLabel("channels")); |
m = new JMenu(i18n.getMenuLabel("channels")); |
510 |
menuBar.add(m); |
menuBar.add(m); |
624 |
m.add(mi); |
m.add(mi); |
625 |
|
|
626 |
|
|
627 |
|
// Window |
628 |
|
m = new JMenu(i18n.getMenuLabel("window")); |
629 |
|
menuBar.add(m); |
630 |
|
|
631 |
|
mi = new JMenuItem(A4n.windowInstrumentsDb); |
632 |
|
mi.setIcon(null); |
633 |
|
m.add(mi); |
634 |
|
|
635 |
|
|
636 |
// Help |
// Help |
637 |
m = new JMenu(i18n.getMenuLabel("help")); |
m = new JMenu(i18n.getMenuLabel("help")); |
638 |
menuBar.add(m); |
menuBar.add(m); |
642 |
m.add(mi); |
m.add(mi); |
643 |
} |
} |
644 |
|
|
645 |
|
private class RecentScriptHandler implements ActionListener { |
646 |
|
private String script; |
647 |
|
|
648 |
|
RecentScriptHandler(String script) { this.script = script; } |
649 |
|
|
650 |
|
public void |
651 |
|
actionPerformed(ActionEvent e) { runScript(script); } |
652 |
|
} |
653 |
|
|
654 |
private void |
private void |
655 |
handleEvents() { |
handleEvents() { |
656 |
tabbedPane.addChangeListener(this); |
tabbedPane.addChangeListener(this); |
657 |
} |
} |
658 |
|
|
659 |
private void |
private void |
660 |
showToolbar(boolean b) { |
showChannelsBar(boolean b) { |
661 |
if(b) getContentPane().add(toolbar, BorderLayout.NORTH); |
channelsBar.setVisible(b); |
662 |
else getContentPane().remove(toolbar); |
ClassicPrefs.setShowChannelsBar(b); |
|
|
|
|
ClassicPrefs.setShowToolbar(b); |
|
663 |
|
|
664 |
validate(); |
validate(); |
665 |
repaint(); |
repaint(); |
671 |
statusbar.setVisible(b); |
statusbar.setVisible(b); |
672 |
} |
} |
673 |
|
|
674 |
|
protected boolean |
675 |
|
isLeftPaneVisible() { return cbmiLeftPaneVisible.isSelected(); } |
676 |
|
|
677 |
|
protected void |
678 |
|
setLeftPaneVisible(boolean b) { |
679 |
|
if(b != cbmiLeftPaneVisible.isSelected()) cbmiLeftPaneVisible.doClick(0); |
680 |
|
} |
681 |
|
|
682 |
|
protected boolean |
683 |
|
isLSConsoleVisible() { return cbmiLSConsoleShown.isSelected(); } |
684 |
|
|
685 |
|
protected void |
686 |
|
setLSConsoleVisible(boolean b) { |
687 |
|
if(b != cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0); |
688 |
|
} |
689 |
|
|
690 |
private void |
private void |
691 |
showLeftPane(boolean b) { |
showLeftPane(boolean b) { |
692 |
ClassicPrefs.setShowLeftPane(b); |
ClassicPrefs.setShowLeftPane(b); |
693 |
|
|
694 |
mainPane.remove(splitPane); |
mainPane.remove(hSplitPane); |
695 |
mainPane.remove(channelsPane); |
mainPane.remove(rightPane); |
696 |
|
|
697 |
if(b) { |
if(b) { |
698 |
splitPane.setRightComponent(channelsPane); |
hSplitPane.setRightComponent(rightPane); |
699 |
mainPane.add(splitPane); |
mainPane.add(hSplitPane); |
700 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
701 |
|
int i = ClassicPrefs.getHSplitDividerLocation(); |
702 |
|
hSplitPane.setDividerLocation(i); |
703 |
|
} |
704 |
} else { |
} else { |
705 |
mainPane.add(channelsPane); |
mainPane.add(rightPane); |
706 |
} |
} |
707 |
|
|
708 |
validate(); |
validate(); |
709 |
repaint(); |
repaint(); |
710 |
} |
} |
711 |
|
|
712 |
|
private void |
713 |
|
showStandardBar(boolean b) { |
714 |
|
ClassicPrefs.setShowStandardBar(b); |
715 |
|
standardBar.setVisible(b); |
716 |
|
validate(); |
717 |
|
repaint(); |
718 |
|
} |
719 |
|
|
720 |
|
private void |
721 |
|
showBottomPane(boolean b) { |
722 |
|
if(!b) ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
723 |
|
|
724 |
|
rightPane.remove(vSplitPane); |
725 |
|
rightPane.remove(channelsPane); |
726 |
|
|
727 |
|
if(b) { |
728 |
|
vSplitPane.setTopComponent(channelsPane); |
729 |
|
rightPane.add(vSplitPane); |
730 |
|
vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation()); |
731 |
|
} else { |
732 |
|
rightPane.add(channelsPane); |
733 |
|
} |
734 |
|
|
735 |
|
validate(); |
736 |
|
repaint(); |
737 |
|
} |
738 |
|
|
739 |
|
protected void |
740 |
|
setLSConsolePopOut(boolean b) { |
741 |
|
if(b == lsConsolePopOut) return; |
742 |
|
|
743 |
|
lsConsolePopOut = b; |
744 |
|
|
745 |
|
if(isLSConsoleShown()) setLSConsolePopOut0(b); |
746 |
|
} |
747 |
|
|
748 |
|
/** |
749 |
|
* Changes the pop-out state of the LS Console. |
750 |
|
* Invoke this method only when LS Console is shown. |
751 |
|
*/ |
752 |
|
private void |
753 |
|
setLSConsolePopOut0(boolean b) { |
754 |
|
if(b) { |
755 |
|
bottomPane.remove(lsConsolePane); |
756 |
|
showBottomPane(false); |
757 |
|
|
758 |
|
lsConsoleDlg = new LSConsoleDlg(this, lsConsolePane); |
759 |
|
lsConsoleDlg.setVisible(true); |
760 |
|
} else { |
761 |
|
if(lsConsoleDlg != null) lsConsoleDlg.setVisible(false); |
762 |
|
lsConsoleDlg = null; |
763 |
|
bottomPane.add(lsConsolePane); |
764 |
|
showBottomPane(true); |
765 |
|
} |
766 |
|
} |
767 |
|
|
768 |
|
protected boolean |
769 |
|
isLSConsolePopOut() { return lsConsolePopOut; } |
770 |
|
|
771 |
|
protected boolean |
772 |
|
isLSConsoleShown() { return cbmiLSConsoleShown.isSelected(); } |
773 |
|
|
774 |
|
protected void |
775 |
|
setLSConsoleShown(boolean b) { cbmiLSConsoleShown.setSelected(b); } |
776 |
|
|
777 |
|
protected LSConsoleModel |
778 |
|
getLSConsoleModel() { return lsConsolePane.getModel(); } |
779 |
|
|
780 |
|
/** |
781 |
|
* Sets the text color of the LS Console. |
782 |
|
* @param c The text color of the LS Console. |
783 |
|
*/ |
784 |
|
protected void |
785 |
|
setLSConsoleTextColor(Color c) { lsConsolePane.setTextColor(c); } |
786 |
|
|
787 |
|
/** |
788 |
|
* Sets the background color of the LS Console. |
789 |
|
* @param c The background color of the LS Console. |
790 |
|
*/ |
791 |
|
protected void |
792 |
|
setLSConsoleBackgroundColor(Color c) { lsConsolePane.setBackgroundColor(c); } |
793 |
|
|
794 |
|
/** |
795 |
|
* Sets the notification messages' color of the LS Console. |
796 |
|
* @param c The notification messages' color of the LS Console. |
797 |
|
*/ |
798 |
|
protected void |
799 |
|
setLSConsoleNotifyColor(Color c) { lsConsolePane.setNotifyColor(c); } |
800 |
|
|
801 |
|
/** |
802 |
|
* Sets the warning messages' color of the LS Console. |
803 |
|
* @param c The warning messages' color of the LS Console. |
804 |
|
*/ |
805 |
|
protected void |
806 |
|
setLSConsoleWarningColor(Color c) { lsConsolePane.setWarningColor(c); } |
807 |
|
|
808 |
|
/** |
809 |
|
* Sets the error messages' color of the LS Console. |
810 |
|
* @param c The error messages' color of the LS Console. |
811 |
|
*/ |
812 |
|
protected void |
813 |
|
setLSConsoleErrorColor(Color c) { lsConsolePane.setErrorColor(c); } |
814 |
|
|
815 |
|
protected void |
816 |
|
showLSConsole(boolean b) { |
817 |
|
if(!b) { |
818 |
|
showBottomPane(false); |
819 |
|
if(lsConsoleDlg != null) lsConsoleDlg.setVisible(false); |
820 |
|
lsConsolePane.hideAutoCompleteWindow(); |
821 |
|
return; |
822 |
|
} |
823 |
|
|
824 |
|
setLSConsolePopOut0(isLSConsolePopOut()); |
825 |
|
} |
826 |
|
|
827 |
|
/** |
828 |
|
* Adds the specified <code>JSChannelsPane</code> to the view. |
829 |
|
* @param chnPane The <code>JSChannelsPane</code> to be added. |
830 |
|
*/ |
831 |
public void |
public void |
832 |
addChannelsPane(JSChannelsPane chnPane) { |
addChannelsPane(JSChannelsPane chnPane) { |
833 |
insertChannelsPane(chnPane, getChannelsPaneCount()); |
insertChannelsPane(chnPane, getChannelsPaneCount()); |
853 |
updateTabsMenu(); |
updateTabsMenu(); |
854 |
} |
} |
855 |
|
|
856 |
|
/** |
857 |
|
* Gets the <code>JSChannelsPane</code> that is currently shown. |
858 |
|
* @return The currently shown <code>JSChannelsPane</code>. |
859 |
|
*/ |
860 |
public JSChannelsPane |
public JSChannelsPane |
861 |
getSelectedChannelsPane() { |
getSelectedChannelsPane() { |
862 |
if(getChannelsPaneList().size() == 1) return getChannelsPane(0); |
if(getChannelsPaneList().size() == 1) return getChannelsPane(0); |
863 |
return (JSChannelsPane)tabbedPane.getSelectedComponent(); |
return (JSChannelsPane)tabbedPane.getSelectedComponent(); |
864 |
} |
} |
865 |
|
|
866 |
|
/** |
867 |
|
* Sets the <code>JSChannelsPane</code> to be selected. |
868 |
|
* @param pane The <code>JSChannelsPane</code> to be shown. |
869 |
|
*/ |
870 |
public void |
public void |
871 |
setSelectedChannelsPane(JSChannelsPane pane) { |
setSelectedChannelsPane(JSChannelsPane pane) { |
872 |
if(getChannelsPaneList().size() == 1) return; |
if(getChannelsPaneList().size() == 1) return; |
873 |
tabbedPane.setSelectedComponent(pane); |
tabbedPane.setSelectedComponent(pane); |
874 |
} |
} |
875 |
|
|
876 |
|
/** |
877 |
|
* Removes the specified <code>JSChannelsPane</code> from the view. |
878 |
|
* @param chnPane The <code>JSChannelsPane</code> to be removed. |
879 |
|
* @return <code>true</code> if the specified code>JSChannelsPane</code> |
880 |
|
* is actually removed from the view, <code>false</code> otherwise. |
881 |
|
*/ |
882 |
public boolean |
public boolean |
883 |
removeChannelsPane(JSChannelsPane chnPane) { |
removeChannelsPane(JSChannelsPane chnPane) { |
884 |
chnPane.removeListSelectionListener(this); |
chnPane.removeListSelectionListener(this); |
1099 |
addChannelsPane(c); |
addChannelsPane(c); |
1100 |
tabbedPane.setSelectedComponent(c); |
tabbedPane.setSelectedComponent(c); |
1101 |
} |
} |
1102 |
|
|
1103 |
|
protected void |
1104 |
|
runScript() { |
1105 |
|
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
1106 |
|
fc.setFileFilter(new LscpFileFilter()); |
1107 |
|
int result = fc.showOpenDialog(this); |
1108 |
|
if(result != JFileChooser.APPROVE_OPTION) return; |
1109 |
|
|
1110 |
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
1111 |
|
ClassicPrefs.setLastScriptLocation(path); |
1112 |
|
|
1113 |
|
runScript(fc.getSelectedFile()); |
1114 |
|
} |
1115 |
|
|
1116 |
|
private void |
1117 |
|
runScript(String script) { runScript(new File(script)); } |
1118 |
|
|
1119 |
|
private void |
1120 |
|
runScript(File script) { |
1121 |
|
FileReader fr; |
1122 |
|
try { fr = new FileReader(script); } |
1123 |
|
catch(FileNotFoundException e) { |
1124 |
|
HF.showErrorMessage(i18n.getMessage("FileNotFound!")); |
1125 |
|
return; |
1126 |
|
} |
1127 |
|
|
1128 |
|
BufferedReader br = new BufferedReader(fr); |
1129 |
|
|
1130 |
|
try { |
1131 |
|
String s = br.readLine(); |
1132 |
|
while(s != null) { |
1133 |
|
getLSConsoleModel().setCommandLineText(s); |
1134 |
|
getLSConsoleModel().execCommand(); |
1135 |
|
s = br.readLine(); |
1136 |
|
} |
1137 |
|
} catch(Exception e) { |
1138 |
|
HF.showErrorMessage(e); |
1139 |
|
return; |
1140 |
|
} |
1141 |
|
|
1142 |
|
if(!cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0); |
1143 |
|
|
1144 |
|
String s = script.getAbsolutePath(); |
1145 |
|
recentScripts.remove(s); |
1146 |
|
recentScripts.insertElementAt(s, 0); |
1147 |
|
|
1148 |
|
while(recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) { |
1149 |
|
recentScripts.removeElementAt(recentScripts.size() - 1); |
1150 |
|
} |
1151 |
|
|
1152 |
|
updateRecentScriptsMenu(); |
1153 |
|
} |
1154 |
|
|
1155 |
|
protected void |
1156 |
|
clearRecentScripts() { |
1157 |
|
recentScripts.removeAllElements(); |
1158 |
|
updateRecentScriptsMenu(); |
1159 |
|
} |
1160 |
|
|
1161 |
|
protected void |
1162 |
|
updateRecentScriptsMenu() { |
1163 |
|
while(recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) { |
1164 |
|
recentScripts.removeElementAt(recentScripts.size() - 1); |
1165 |
|
} |
1166 |
|
|
1167 |
|
recentScriptsMenu.removeAll(); |
1168 |
|
|
1169 |
|
for(String script : recentScripts) { |
1170 |
|
JMenuItem mi = new JMenuItem(script); |
1171 |
|
recentScriptsMenu.add(mi); |
1172 |
|
mi.addActionListener(new RecentScriptHandler(script)); |
1173 |
|
} |
1174 |
|
|
1175 |
|
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
1176 |
|
} |
1177 |
|
|
1178 |
|
public void |
1179 |
|
installJSamplerHome() { |
1180 |
|
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
1181 |
|
chooser.setVisible(true); |
1182 |
|
if(chooser.isCancelled()) return; |
1183 |
|
|
1184 |
|
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
1185 |
|
} |
1186 |
|
|
1187 |
|
public boolean |
1188 |
|
getInstrumentsDbSupport() { return true; } |
1189 |
|
|
1190 |
|
public void |
1191 |
|
showDetailedErrorMessage(Frame owner, String err, String details) { |
1192 |
|
new DetailedErrorDlg(owner, i18n.getError("error"), err, details).setVisible(true); |
1193 |
|
} |
1194 |
|
|
1195 |
|
public void |
1196 |
|
showDetailedErrorMessage(Dialog owner, String err, String details) { |
1197 |
|
new DetailedErrorDlg(owner, i18n.getError("error"), err, details).setVisible(true); |
1198 |
|
} |
1199 |
} |
} |