1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
34 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
35 |
import java.awt.Insets; |
import java.awt.Insets; |
36 |
import java.awt.Paint; |
import java.awt.Paint; |
37 |
|
import java.awt.Rectangle; |
38 |
|
|
39 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
40 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
49 |
import java.io.FileReader; |
import java.io.FileReader; |
50 |
|
|
51 |
import java.util.Vector; |
import java.util.Vector; |
|
import java.util.logging.Level; |
|
52 |
|
|
53 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
54 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
55 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
|
import javax.swing.JFileChooser; |
|
56 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
57 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
58 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
62 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
63 |
import javax.swing.Timer; |
import javax.swing.Timer; |
64 |
|
|
65 |
|
import javax.swing.event.ListSelectionEvent; |
66 |
|
import javax.swing.event.ListSelectionListener; |
67 |
|
|
68 |
import org.jsampler.CC; |
import org.jsampler.CC; |
69 |
import org.jsampler.HF; |
import org.jsampler.HF; |
70 |
import org.jsampler.LSConsoleModel; |
import org.jsampler.LSConsoleModel; |
71 |
import org.jsampler.Server; |
import org.jsampler.Server; |
72 |
|
|
73 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
74 |
import org.jsampler.view.JSMainFrame; |
import org.jsampler.view.SessionViewConfig; |
75 |
import org.jsampler.view.LscpFileFilter; |
|
76 |
|
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
77 |
|
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
78 |
|
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
79 |
|
|
80 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
81 |
import org.jsampler.view.std.JSConnectDlg; |
import org.jsampler.view.std.JSConnectDlg; |
82 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
import org.jsampler.view.std.JSDetailedErrorDlg; |
83 |
import org.jsampler.view.std.JSQuitDlg; |
import org.jsampler.view.std.JSQuitDlg; |
84 |
import org.jsampler.view.std.JSamplerHomeChooser; |
import org.jsampler.view.std.JSamplerHomeChooser; |
85 |
|
import org.jsampler.view.std.StdMainFrame; |
86 |
|
import org.jsampler.view.std.StdUtils; |
87 |
|
|
88 |
import static org.jsampler.view.fantasia.A4n.a4n; |
import static org.jsampler.view.fantasia.A4n.a4n; |
89 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
95 |
* |
* |
96 |
* @author Grigor Iliev |
* @author Grigor Iliev |
97 |
*/ |
*/ |
98 |
public class MainFrame extends JSMainFrame { |
public class MainFrame extends StdMainFrame { |
99 |
private final StandardBar standardBar = new StandardBar(); |
private final StandardBar standardBar = new StandardBar(); |
100 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
101 |
private final JPanel rootPane = new RootPane(); |
private final JPanel rootPane = new RootPane(); |
102 |
private final BottomPane bottomPane; |
private final BottomPane bottomPane; |
103 |
private final MainPane mainPane = new MainPane(); |
private final MainPane mainPane; |
104 |
private final PianoKeyboardPane pianoKeyboardPane; |
private final PianoKeyboardPane pianoKeyboardPane; |
105 |
|
|
106 |
private final JMenu recentScriptsMenu = |
private final JMenu recentScriptsMenu = |
108 |
|
|
109 |
private final JSplitPane hSplitPane; |
private final JSplitPane hSplitPane; |
110 |
|
|
111 |
private final LeftSidePane leftSidePane = new LeftSidePane(); |
private final LeftSidePane leftSidePane; |
112 |
private final RightSidePane rightSidePane = new RightSidePane(); |
private final RightSidePane rightSidePane; |
113 |
private final JPanel rightPane; |
private final JPanel rightPane; |
114 |
|
|
115 |
//private final StatusBar statusBar = new StatusBar(); |
//private final StatusBar statusBar = new StatusBar(); |
116 |
|
|
117 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
118 |
private final Vector<String> recentScripts = new Vector<String>(); |
private final Vector<String> recentScripts = new Vector<String>(); |
119 |
|
|
120 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
121 |
|
|
122 |
|
|
123 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
141 |
//setUndecorated(true); |
//setUndecorated(true); |
142 |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
143 |
|
|
144 |
|
CC.setMainFrame(this); // TODO: |
145 |
|
mainPane = new MainPane(); |
146 |
|
leftSidePane = new LeftSidePane(); |
147 |
|
rightSidePane = new RightSidePane(); |
148 |
|
|
149 |
|
setSelectedChannelsPane(mainPane.getChannelsPane(0)); |
150 |
|
|
151 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
152 |
|
|
153 |
rightPane = createRightPane(); |
rightPane = createRightPane(); |
159 |
); |
); |
160 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
161 |
|
|
|
addChannelsPane(mainPane.getChannelsPane()); |
|
|
|
|
162 |
pianoKeyboardPane = new PianoKeyboardPane(); |
pianoKeyboardPane = new PianoKeyboardPane(); |
163 |
getChannelsPane(0).addListSelectionListener(pianoKeyboardPane); |
|
164 |
|
for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) { |
165 |
|
addChannelsPane(mainPane.getChannelsPane(i)); |
166 |
|
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
int h = preferences().getIntProperty("midiKeyboard.height"); |
int h = preferences().getIntProperty("midiKeyboard.height"); |
171 |
setMidiKeyboardHeight(h); |
setMidiKeyboardHeight(h); |
172 |
|
|
186 |
rootPane.add(hSplitPane); |
rootPane.add(hSplitPane); |
187 |
rootPane.add(bottomPane, BorderLayout.SOUTH); |
rootPane.add(bottomPane, BorderLayout.SOUTH); |
188 |
add(rootPane); |
add(rootPane); |
189 |
|
|
190 |
|
if(CC.isMacOS()) { |
191 |
|
try { |
192 |
|
String s = "org.jsampler.view.fantasia.MacOSApplicationHandler"; |
193 |
|
Class.forName(s).newInstance(); } |
194 |
|
catch(Throwable e) { } |
195 |
|
} |
196 |
|
|
197 |
addMenu(); |
addMenu(); |
198 |
|
|
199 |
|
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
200 |
|
// fix for moving the menu bar on top of the screen |
201 |
|
// when running on Mac OS and third party plugin is used |
202 |
|
((ViewConfig)CC.getViewConfig()).restoreMenuProperties(); |
203 |
|
} |
204 |
|
|
205 |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
206 |
hSplitPane.setDividerLocation(i); |
hSplitPane.setDividerLocation(i); |
207 |
|
|
244 |
|
|
245 |
private void |
private void |
246 |
setSavedSize() { |
setSavedSize() { |
247 |
String s = preferences().getStringProperty("MainFrame.sizeAndLocation"); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
248 |
if(s == null) { |
if(r == null) { |
249 |
setDefaultSizeAndLocation(); |
setDefaultSizeAndLocation(); |
250 |
return; |
return; |
251 |
} |
} |
|
pack(); |
|
|
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); |
|
|
setDefaultSizeAndLocation(); |
|
|
} |
|
252 |
|
|
253 |
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
setBounds(r); |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
|
} |
|
254 |
} |
} |
255 |
|
|
256 |
private void |
private void |
263 |
|
|
264 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
265 |
@Override |
@Override |
266 |
protected void |
public void |
267 |
onWindowClose() { |
onWindowClose() { |
268 |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
269 |
if(b && CC.getSamplerModel().isModified()) { |
if(b && CC.getSamplerModel().isModified()) { |
288 |
return; |
return; |
289 |
} |
} |
290 |
|
|
291 |
java.awt.Point p = getLocation(); |
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
|
Dimension d = getSize(); |
|
|
StringBuffer sb = new StringBuffer(); |
|
|
sb.append(p.x).append(',').append(p.y).append(','); |
|
|
sb.append(d.width).append(',').append(d.height); |
|
|
preferences().setStringProperty("MainFrame.sizeAndLocation", sb.toString()); |
|
292 |
|
|
293 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
294 |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
297 |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
298 |
} |
} |
299 |
|
|
300 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
301 |
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
302 |
|
|
303 |
super.onWindowClose(); |
super.onWindowClose(); |
304 |
} |
} |
305 |
|
|
306 |
|
@Override |
307 |
|
public void |
308 |
|
setVisible(boolean b) { |
309 |
|
if(b == isVisible()) return; |
310 |
|
|
311 |
|
super.setVisible(b); |
312 |
|
|
313 |
|
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
314 |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
private void |
private void |
319 |
addMenu() { |
addMenu() { |
320 |
JMenu m; |
JMenu m; |
342 |
|
|
343 |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
344 |
m.add(exportMenu); |
m.add(exportMenu); |
345 |
|
|
346 |
|
int modKey = CC.getViewConfig().getDefaultModKey(); |
347 |
|
|
348 |
mi = new JMenuItem(a4n.exportSamplerConfig); |
mi = new JMenuItem(a4n.exportSamplerConfig); |
349 |
mi.setIcon(null); |
mi.setIcon(null); |
350 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, modKey)); |
351 |
exportMenu.add(mi); |
exportMenu.add(mi); |
352 |
|
|
353 |
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
358 |
|
|
359 |
mi = new JMenuItem(a4n.loadScript); |
mi = new JMenuItem(a4n.loadScript); |
360 |
mi.setIcon(null); |
mi.setIcon(null); |
361 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, modKey)); |
362 |
m.add(mi); |
m.add(mi); |
363 |
|
|
364 |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
372 |
|
|
373 |
mi = new JMenuItem(a4n.changeBackend); |
mi = new JMenuItem(a4n.changeBackend); |
374 |
mi.setIcon(null); |
mi.setIcon(null); |
375 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, modKey)); |
376 |
m.add(mi); |
m.add(mi); |
377 |
|
|
378 |
m.addSeparator(); |
m.addSeparator(); |
415 |
mi = new JMenuItem(a4n.editPreferences); |
mi = new JMenuItem(a4n.editPreferences); |
416 |
mi.setIcon(null); |
mi.setIcon(null); |
417 |
mi.setAccelerator(KeyStroke.getKeyStroke ( |
mi.setAccelerator(KeyStroke.getKeyStroke ( |
418 |
KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_P, modKey | KeyEvent.SHIFT_MASK |
419 |
)); |
)); |
420 |
m.add(mi); |
m.add(mi); |
421 |
|
|
437 |
showToolBar(b); |
showToolBar(b); |
438 |
|
|
439 |
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
440 |
KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_L, modKey | KeyEvent.SHIFT_MASK |
441 |
)); |
)); |
442 |
m.add(cbmiLeftSidePaneVisible); |
m.add(cbmiLeftSidePaneVisible); |
443 |
|
|
453 |
showSidePane(b); |
showSidePane(b); |
454 |
|
|
455 |
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
456 |
KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_R, modKey | KeyEvent.SHIFT_MASK |
457 |
)); |
)); |
458 |
m.add(cbmiRightSidePaneVisible); |
m.add(cbmiRightSidePaneVisible); |
459 |
|
|
484 |
setMidiKeyboardVisible(b); |
setMidiKeyboardVisible(b); |
485 |
|
|
486 |
|
|
487 |
|
// Channels |
488 |
|
m = new FantasiaMenu(i18n.getMenuLabel("channels")); |
489 |
|
|
490 |
|
mi = new JMenuItem(i18n.getMenuLabel("channels.newChannel")); |
491 |
|
mi.addActionListener(new ActionListener() { |
492 |
|
public void |
493 |
|
actionPerformed(ActionEvent e) { |
494 |
|
CC.getSamplerModel().addBackendChannel(); |
495 |
|
} |
496 |
|
}); |
497 |
|
m.add(mi); |
498 |
|
|
499 |
|
m.addSeparator(); |
500 |
|
|
501 |
|
MenuManager.ChannelViewGroup group = new MenuManager.ChannelViewGroup(); |
502 |
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
503 |
|
|
504 |
|
for(JMenuItem menuItem : group.getMenuItems()) m.add(menuItem); |
505 |
|
|
506 |
|
m.addSeparator(); |
507 |
|
|
508 |
|
m.add(new JMenuItem(a4n.moveChannelsOnTop)); |
509 |
|
m.add(new JMenuItem(a4n.moveChannelsUp)); |
510 |
|
m.add(new JMenuItem(a4n.moveChannelsDown)); |
511 |
|
m.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
512 |
|
|
513 |
|
m.add(new ToPanelMenu()); |
514 |
|
|
515 |
|
m.addSeparator(); |
516 |
|
|
517 |
|
mi = new JMenuItem(a4n.selectAllChannels); |
518 |
|
mi.setIcon(null); |
519 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, modKey)); |
520 |
|
m.add(mi); |
521 |
|
|
522 |
|
mi = new JMenuItem(a4n.deselectChannels); |
523 |
|
mi.setIcon(null); |
524 |
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
525 |
|
KeyEvent.VK_A, modKey | KeyEvent.SHIFT_MASK |
526 |
|
)); |
527 |
|
m.add(mi); |
528 |
|
|
529 |
|
menuBar.add(m); |
530 |
|
|
531 |
// Window |
// Window |
532 |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
533 |
menuBar.add(m); |
menuBar.add(m); |
540 |
mi.setIcon(null); |
mi.setIcon(null); |
541 |
m.add(mi); |
m.add(mi); |
542 |
|
|
543 |
|
m.addSeparator(); |
544 |
|
|
545 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
546 |
|
m.add(mi2); |
547 |
|
mi2.addActionListener(new ActionListener() { |
548 |
|
public void |
549 |
|
actionPerformed(ActionEvent e) { |
550 |
|
if(getBackendLogFrame().isVisible()) { |
551 |
|
getBackendLogFrame().setVisible(false); |
552 |
|
} |
553 |
|
|
554 |
|
getBackendLogFrame().setVisible(true); |
555 |
|
} |
556 |
|
}); |
557 |
|
|
558 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
559 |
|
|
560 |
|
CC.addBackendProcessListener(new ActionListener() { |
561 |
|
public void |
562 |
|
actionPerformed(ActionEvent e) { |
563 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
564 |
|
} |
565 |
|
}); |
566 |
|
|
567 |
|
|
568 |
// Help |
// Help |
569 |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
581 |
menuBar.add(m); |
menuBar.add(m); |
582 |
} |
} |
583 |
|
|
584 |
|
public static class ToPanelMenu extends FantasiaMenu implements ListSelectionListener { |
585 |
|
public |
586 |
|
ToPanelMenu() { |
587 |
|
super(i18n.getMenuLabel("channels.toPanel")); |
588 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
589 |
|
|
590 |
|
CC.getMainFrame().addChannelsPaneSelectionListener(this); |
591 |
|
|
592 |
|
for(int i = 0; i < CC.getMainFrame().getChannelsPaneCount(); i++) { |
593 |
|
JSChannelsPane p = CC.getMainFrame().getChannelsPane(i); |
594 |
|
add(new JMenuItem(new A4n.MoveChannelsToPanel(p))); |
595 |
|
p.addListSelectionListener(this); |
596 |
|
} |
597 |
|
} |
598 |
|
|
599 |
|
@Override |
600 |
|
public void |
601 |
|
valueChanged(ListSelectionEvent e) { |
602 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
603 |
|
} |
604 |
|
} |
605 |
|
|
606 |
public RightSidePane |
public RightSidePane |
607 |
getRightSidePane() { return rightSidePane; } |
getRightSidePane() { return rightSidePane; } |
608 |
|
|
609 |
|
@Override |
610 |
|
public A4n |
611 |
|
getA4n() { return A4n.a4n; } |
612 |
|
|
613 |
/** |
/** |
614 |
* This method does nothing, because <b>Fantasia</b> has exactly |
* This method does nothing, because <b>Fantasia</b> has constant |
615 |
* one pane containing sampler channels, which can not be changed. |
* number of panes containing sampler channels, which can not be changed. |
616 |
*/ |
*/ |
617 |
@Override |
@Override |
618 |
public void |
public void |
620 |
|
|
621 |
} |
} |
622 |
|
|
|
/** |
|
|
* This method always returns the <code>JSChannelsPane</code> at index 0, |
|
|
* because the <b>Fantasia</b> view has exactly one pane containing sampler channels. |
|
|
* @return The <code>JSChannelsPane</code> at index 0. |
|
|
*/ |
|
623 |
@Override |
@Override |
624 |
public JSChannelsPane |
public JSChannelsPane |
625 |
getSelectedChannelsPane() { return getChannelsPane(0); } |
getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); } |
626 |
|
|
|
/** |
|
|
* This method does nothing because the <b>Fantasia</b> view has |
|
|
* exactly one pane containing sampler channels which is always shown. |
|
|
*/ |
|
627 |
@Override |
@Override |
628 |
public void |
public void |
629 |
setSelectedChannelsPane(JSChannelsPane pane) { } |
setSelectedChannelsPane(JSChannelsPane pane) { |
630 |
|
mainPane.setSelectedChannelsPane(pane); |
631 |
|
fireChannelsPaneSelectionChanged(); |
632 |
|
} |
633 |
|
|
634 |
@Override |
@Override |
635 |
public void |
public void |
681 |
if(manualSelect) { |
if(manualSelect) { |
682 |
JSConnectDlg dlg = new JSConnectDlg(); |
JSConnectDlg dlg = new JSConnectDlg(); |
683 |
dlg.setVisible(true); |
dlg.setVisible(true); |
684 |
|
|
685 |
return dlg.getSelectedServer(); |
return dlg.getSelectedServer(); |
686 |
} |
} |
687 |
|
|
707 |
protected LSConsoleFrame |
protected LSConsoleFrame |
708 |
getLSConsoleFrame() { return lsConsoleFrame; } |
getLSConsoleFrame() { return lsConsoleFrame; } |
709 |
|
|
710 |
|
public JSBackendLogFrame |
711 |
|
getBackendLogFrame() { return backendLogFrame; } |
712 |
|
|
713 |
protected boolean |
protected boolean |
714 |
runScript() { |
runScript() { |
715 |
String s = preferences().getStringProperty("lastScriptLocation"); |
File f = StdUtils.showOpenLscpFileChooser(); |
716 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return false; |
717 |
fc.setFileFilter(new LscpFileFilter()); |
runScript(f); |
|
int result = fc.showOpenDialog(this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return false; |
|
|
|
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastScriptLocation", path); |
|
|
|
|
|
runScript(fc.getSelectedFile()); |
|
718 |
|
|
719 |
return true; |
return true; |
720 |
} |
} |
721 |
|
|
722 |
private void |
@Override |
723 |
|
public void |
724 |
runScript(String script) { runScript(new File(script)); } |
runScript(String script) { runScript(new File(script)); } |
725 |
|
|
726 |
private void |
private void |
728 |
FileReader fr; |
FileReader fr; |
729 |
try { fr = new FileReader(script); } |
try { fr = new FileReader(script); } |
730 |
catch(FileNotFoundException e) { |
catch(FileNotFoundException e) { |
731 |
HF.showErrorMessage(i18n.getMessage("FileNotFound!")); |
HF.showErrorMessage(i18n.getError("fileNotFound!")); |
732 |
return; |
return; |
733 |
} |
} |
734 |
|
|
735 |
|
String prefix = "#jsampler.fantasia: "; |
736 |
|
Vector<String> v = new Vector<String>(); |
737 |
BufferedReader br = new BufferedReader(fr); |
BufferedReader br = new BufferedReader(fr); |
738 |
|
|
739 |
try { |
try { |
741 |
while(s != null) { |
while(s != null) { |
742 |
getLSConsoleModel().setCommandLineText(s); |
getLSConsoleModel().setCommandLineText(s); |
743 |
getLSConsoleModel().execCommand(); |
getLSConsoleModel().execCommand(); |
744 |
|
if(s.startsWith(prefix)) v.add(s.substring(prefix.length())); |
745 |
s = br.readLine(); |
s = br.readLine(); |
746 |
} |
} |
747 |
} catch(Exception e) { |
} catch(Exception e) { |
754 |
recentScripts.insertElementAt(s, 0); |
recentScripts.insertElementAt(s, 0); |
755 |
|
|
756 |
updateRecentScriptsMenu(); |
updateRecentScriptsMenu(); |
757 |
|
|
758 |
|
CC.getViewConfig().setSessionViewConfig( |
759 |
|
new SessionViewConfig(v.toArray(new String[v.size()])) |
760 |
|
); |
761 |
} |
} |
762 |
|
|
763 |
protected void |
protected void |