23 |
package org.jsampler.view.fantasia; |
package org.jsampler.view.fantasia; |
24 |
|
|
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
|
import java.awt.Color; |
27 |
|
import java.awt.Composite; |
28 |
import java.awt.Dialog; |
import java.awt.Dialog; |
29 |
import java.awt.Dimension; |
import java.awt.Dimension; |
30 |
import java.awt.Frame; |
import java.awt.Frame; |
31 |
import java.awt.Graphics; |
import java.awt.Graphics; |
32 |
|
import java.awt.Graphics2D; |
33 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagConstraints; |
34 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
35 |
import java.awt.Insets; |
import java.awt.Insets; |
36 |
import java.awt.Point; |
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; |
41 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
42 |
import java.awt.event.MouseAdapter; |
|
43 |
import java.awt.event.MouseEvent; |
import java.beans.PropertyChangeEvent; |
44 |
|
import java.beans.PropertyChangeListener; |
45 |
|
|
46 |
import java.io.BufferedReader; |
import java.io.BufferedReader; |
47 |
import java.io.File; |
import java.io.File; |
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; |
|
import javax.swing.Box; |
|
54 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
55 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
|
import javax.swing.JComponent; |
|
|
import javax.swing.JDialog; |
|
56 |
import javax.swing.JFileChooser; |
import javax.swing.JFileChooser; |
|
import javax.swing.JFrame; |
|
57 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
58 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
59 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
60 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
|
import javax.swing.JPopupMenu; |
|
|
import javax.swing.JScrollPane; |
|
61 |
import javax.swing.JSplitPane; |
import javax.swing.JSplitPane; |
|
import javax.swing.JToggleButton; |
|
62 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
63 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
64 |
import javax.swing.Timer; |
import javax.swing.Timer; |
|
import javax.swing.UIManager; |
|
65 |
|
|
66 |
import net.sf.juife.TitleBar; |
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 |
|
|
|
import org.jsampler.view.JSChannel; |
|
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; |
79 |
|
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
80 |
|
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
81 |
|
|
82 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
83 |
import org.jsampler.view.std.JSConnectDlg; |
import org.jsampler.view.std.JSConnectDlg; |
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; |
89 |
|
|
90 |
import static org.jsampler.view.fantasia.A4n.a4n; |
import static org.jsampler.view.fantasia.A4n.a4n; |
91 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
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 JPanel(); |
private final JPanel rootPane = new RootPane(); |
104 |
private final MainPane mainPane = new MainPane(); |
private final BottomPane bottomPane; |
105 |
|
private final MainPane mainPane; |
106 |
|
private final PianoKeyboardPane pianoKeyboardPane; |
107 |
|
|
108 |
private final JMenu recentScriptsMenu = |
private final JMenu recentScriptsMenu = |
109 |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
110 |
|
|
111 |
private final JSplitPane hSplitPane; |
private final JSplitPane hSplitPane; |
112 |
|
|
113 |
private final LeftSidePane leftSidePane = new LeftSidePane(); |
private final LeftSidePane leftSidePane; |
114 |
private final RightSidePane rightSidePane = new RightSidePane(); |
private final RightSidePane rightSidePane; |
115 |
private final JPanel rightPane; |
private final JPanel rightPane; |
116 |
|
|
117 |
//private final StatusBar statusBar = new StatusBar(); |
//private final StatusBar statusBar = new StatusBar(); |
118 |
|
|
119 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
120 |
private final Vector<String> recentScripts = new Vector<String>(); |
private final Vector<String> recentScripts = new Vector<String>(); |
121 |
|
|
122 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
123 |
|
|
124 |
|
|
125 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
131 |
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
132 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
133 |
|
|
134 |
|
private final JCheckBoxMenuItem cbmiMidiKeyboardVisible = |
135 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard")); |
136 |
|
|
137 |
private final Timer guiTimer = new Timer(1000, null); |
private final Timer guiTimer = new Timer(1000, null); |
138 |
|
|
139 |
/** Creates a new instance of <code>MainFrame</code> */ |
/** Creates a new instance of <code>MainFrame</code> */ |
140 |
public |
public |
141 |
MainFrame() { |
MainFrame() { |
142 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
143 |
|
//setUndecorated(true); |
144 |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
145 |
|
|
146 |
|
CC.setMainFrame(this); // TODO: |
147 |
|
mainPane = new MainPane(); |
148 |
|
leftSidePane = new LeftSidePane(); |
149 |
|
rightSidePane = new RightSidePane(); |
150 |
|
|
151 |
|
setSelectedChannelsPane(mainPane.getChannelsPane(0)); |
152 |
|
|
153 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
|
//getContentPane().add(statusBar, BorderLayout.SOUTH); |
|
154 |
|
|
155 |
rightPane = createRightPane(); |
rightPane = createRightPane(); |
156 |
|
|
161 |
); |
); |
162 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
163 |
|
|
164 |
rootPane.setLayout(new BorderLayout()); |
pianoKeyboardPane = new PianoKeyboardPane(); |
|
rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0)); |
|
|
rootPane.setOpaque(false); |
|
|
rootPane.add(hSplitPane); |
|
165 |
|
|
166 |
addMenu(); |
for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) { |
167 |
|
addChannelsPane(mainPane.getChannelsPane(i)); |
168 |
|
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
169 |
|
} |
170 |
|
|
|
addChannelsPane(mainPane.getChannelsPane()); |
|
171 |
|
|
172 |
getContentPane().add(rootPane); |
int h = preferences().getIntProperty("midiKeyboard.height"); |
173 |
|
setMidiKeyboardHeight(h); |
174 |
|
|
175 |
|
PropertyChangeListener l = new PropertyChangeListener() { |
176 |
|
public void |
177 |
|
propertyChange(PropertyChangeEvent e) { |
178 |
|
int h = preferences().getIntProperty("midiKeyboard.height"); |
179 |
|
setMidiKeyboardHeight(h); |
180 |
|
} |
181 |
|
}; |
182 |
|
|
183 |
|
CC.preferences().addPropertyChangeListener("midiKeyboard.height", l); |
184 |
|
|
185 |
|
bottomPane = new BottomPane(); |
186 |
|
|
187 |
|
hSplitPane.setOpaque(false); |
188 |
|
rootPane.add(hSplitPane); |
189 |
|
rootPane.add(bottomPane, BorderLayout.SOUTH); |
190 |
|
add(rootPane); |
191 |
|
|
192 |
|
addMenu(); |
193 |
|
|
194 |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
195 |
hSplitPane.setDividerLocation(i); |
hSplitPane.setDividerLocation(i); |
201 |
|
|
202 |
private JPanel |
private JPanel |
203 |
createRightPane() { |
createRightPane() { |
204 |
JPanel p = new JPanel(); |
JPanel p = new FantasiaPanel(); |
205 |
|
p.setOpaque(false); |
206 |
|
|
207 |
GridBagLayout gridbag = new GridBagLayout(); |
GridBagLayout gridbag = new GridBagLayout(); |
208 |
GridBagConstraints c = new GridBagConstraints(); |
GridBagConstraints c = new GridBagConstraints(); |
209 |
|
|
223 |
c.gridy = 0; |
c.gridy = 0; |
224 |
c.weightx = 0.0; |
c.weightx = 0.0; |
225 |
c.weighty = 1.0; |
c.weighty = 1.0; |
226 |
c.insets = new Insets(0, 3, 0, 3); |
c.insets = new Insets(0, 0, 0, 3); |
227 |
c.fill = GridBagConstraints.VERTICAL; |
c.fill = GridBagConstraints.VERTICAL; |
228 |
gridbag.setConstraints(mainPane, c); |
gridbag.setConstraints(mainPane, c); |
229 |
p.add(mainPane); |
p.add(mainPane); |
233 |
|
|
234 |
private void |
private void |
235 |
setSavedSize() { |
setSavedSize() { |
236 |
String s = preferences().getStringProperty("MainFrame.sizeAndLocation"); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
237 |
if(s == null) { |
if(r == null) { |
238 |
setDefaultSizeAndLocation(); |
setDefaultSizeAndLocation(); |
239 |
return; |
return; |
240 |
} |
} |
|
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(); |
|
|
} |
|
241 |
|
|
242 |
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
setBounds(r); |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
|
} |
|
243 |
} |
} |
244 |
|
|
245 |
private void |
private void |
251 |
|
|
252 |
|
|
253 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
254 |
|
@Override |
255 |
protected void |
protected void |
256 |
onWindowClose() { |
onWindowClose() { |
257 |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
277 |
return; |
return; |
278 |
} |
} |
279 |
|
|
280 |
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()); |
|
281 |
|
|
282 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
283 |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
286 |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
287 |
} |
} |
288 |
|
|
289 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
290 |
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
291 |
|
|
292 |
super.onWindowClose(); |
super.onWindowClose(); |
293 |
} |
} |
294 |
|
|
295 |
|
@Override |
296 |
|
public void |
297 |
|
setVisible(boolean b) { |
298 |
|
if(b == isVisible()) return; |
299 |
|
|
300 |
|
super.setVisible(b); |
301 |
|
|
302 |
|
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
303 |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
304 |
|
} |
305 |
|
} |
306 |
|
|
307 |
private void |
private void |
308 |
addMenu() { |
addMenu() { |
309 |
JMenu m; |
JMenu m; |
455 |
cbmiRightSidePaneVisible.setSelected(b); |
cbmiRightSidePaneVisible.setSelected(b); |
456 |
showDevicesPane(b); |
showDevicesPane(b); |
457 |
|
|
458 |
|
m.addSeparator(); |
459 |
|
|
460 |
|
m.add(cbmiMidiKeyboardVisible); |
461 |
|
|
462 |
|
cbmiMidiKeyboardVisible.addActionListener(new ActionListener() { |
463 |
|
public void |
464 |
|
actionPerformed(ActionEvent e) { |
465 |
|
setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState()); |
466 |
|
} |
467 |
|
}); |
468 |
|
|
469 |
|
b = preferences().getBoolProperty("midiKeyboard.visible"); |
470 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
471 |
|
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")); |
527 |
mi.setIcon(null); |
mi.setIcon(null); |
528 |
m.add(mi); |
m.add(mi); |
529 |
|
|
530 |
|
m.addSeparator(); |
531 |
|
|
532 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
533 |
|
m.add(mi2); |
534 |
|
mi2.addActionListener(new ActionListener() { |
535 |
|
public void |
536 |
|
actionPerformed(ActionEvent e) { |
537 |
|
if(getBackendLogFrame().isVisible()) { |
538 |
|
getBackendLogFrame().setVisible(false); |
539 |
|
} |
540 |
|
|
541 |
|
getBackendLogFrame().setVisible(true); |
542 |
|
} |
543 |
|
}); |
544 |
|
|
545 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
546 |
|
|
547 |
|
CC.addBackendProcessListener(new ActionListener() { |
548 |
|
public void |
549 |
|
actionPerformed(ActionEvent e) { |
550 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
551 |
|
} |
552 |
|
}); |
553 |
|
|
554 |
|
|
555 |
// Help |
// Help |
556 |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
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 exactly |
* This method does nothing, because <b>Fantasia</b> has constant |
602 |
* one pane containing sampler channels, which can not be changed. |
* number of panes containing sampler channels, which can not be changed. |
603 |
*/ |
*/ |
604 |
|
@Override |
605 |
public void |
public void |
606 |
insertChannelsPane(JSChannelsPane pane, int idx) { |
insertChannelsPane(JSChannelsPane pane, int idx) { |
607 |
|
|
608 |
} |
} |
609 |
|
|
610 |
/** |
@Override |
|
* 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. |
|
|
*/ |
|
611 |
public JSChannelsPane |
public JSChannelsPane |
612 |
getSelectedChannelsPane() { return getChannelsPane(0); } |
getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); } |
613 |
|
|
614 |
/** |
@Override |
|
* This method does nothing because the <b>Fantasia</b> view has |
|
|
* exactly one pane containing sampler channels which is always shown. |
|
|
*/ |
|
615 |
public void |
public void |
616 |
setSelectedChannelsPane(JSChannelsPane pane) { } |
setSelectedChannelsPane(JSChannelsPane pane) { |
617 |
|
mainPane.setSelectedChannelsPane(pane); |
618 |
|
fireChannelsPaneSelectionChanged(); |
619 |
|
} |
620 |
|
|
621 |
|
@Override |
622 |
public void |
public void |
623 |
installJSamplerHome() { |
installJSamplerHome() { |
624 |
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
628 |
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
629 |
} |
} |
630 |
|
|
631 |
|
@Override |
632 |
public void |
public void |
633 |
showDetailedErrorMessage(Frame owner, String err, String details) { |
showDetailedErrorMessage(Frame owner, String err, String details) { |
634 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
637 |
dlg.setVisible(true); |
dlg.setVisible(true); |
638 |
} |
} |
639 |
|
|
640 |
|
@Override |
641 |
public void |
public void |
642 |
showDetailedErrorMessage(Dialog owner, String err, String details) { |
showDetailedErrorMessage(Dialog owner, String err, String details) { |
643 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
650 |
* Gets the server address to which to connect. If the server should be |
* Gets the server address to which to connect. If the server should be |
651 |
* manually selected, a dialog asking the user to choose a server is displayed. |
* manually selected, a dialog asking the user to choose a server is displayed. |
652 |
*/ |
*/ |
653 |
|
@Override |
654 |
public Server |
public Server |
655 |
getServer() { |
getServer() { |
656 |
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
662 |
* manually selected, a dialog asking the user to choose a server is displayed. |
* manually selected, a dialog asking the user to choose a server is displayed. |
663 |
* @param manualSelect Determines whether the server should be manually selected. |
* @param manualSelect Determines whether the server should be manually selected. |
664 |
*/ |
*/ |
665 |
|
@Override |
666 |
public Server |
public Server |
667 |
getServer(boolean manualSelect) { |
getServer(boolean manualSelect) { |
668 |
if(manualSelect) { |
if(manualSelect) { |
669 |
JSConnectDlg dlg = new JSConnectDlg(); |
JSConnectDlg dlg = new JSConnectDlg(); |
670 |
dlg.setVisible(true); |
dlg.setVisible(true); |
671 |
|
|
672 |
return dlg.getSelectedServer(); |
return dlg.getSelectedServer(); |
673 |
} |
} |
674 |
|
|
694 |
protected LSConsoleFrame |
protected LSConsoleFrame |
695 |
getLSConsoleFrame() { return lsConsoleFrame; } |
getLSConsoleFrame() { return lsConsoleFrame; } |
696 |
|
|
697 |
|
public JSBackendLogFrame |
698 |
|
getBackendLogFrame() { return backendLogFrame; } |
699 |
|
|
700 |
protected boolean |
protected boolean |
701 |
runScript() { |
runScript() { |
702 |
String s = preferences().getStringProperty("lastScriptLocation"); |
String s = preferences().getStringProperty("lastScriptLocation"); |
713 |
return true; |
return true; |
714 |
} |
} |
715 |
|
|
716 |
private void |
@Override |
717 |
|
public void |
718 |
runScript(String script) { runScript(new File(script)); } |
runScript(String script) { runScript(new File(script)); } |
719 |
|
|
720 |
private void |
private void |
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 |
853 |
}); |
}); |
854 |
} |
} |
855 |
|
|
856 |
|
public void |
857 |
|
setMidiKeyboardVisible(boolean b) { |
858 |
|
preferences().setBoolProperty("midiKeyboard.visible", b); |
859 |
|
pianoKeyboardPane.setVisible(b); |
860 |
|
|
861 |
|
if(cbmiMidiKeyboardVisible.isSelected() != b) { |
862 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
863 |
|
} |
864 |
|
|
865 |
|
if(standardBar.btnMidiKeyboard.isSelected() != b) { |
866 |
|
standardBar.btnMidiKeyboard.setSelected(b); |
867 |
|
} |
868 |
|
|
869 |
|
if(pianoKeyboardPane.btnPower.isSelected() != b) { |
870 |
|
pianoKeyboardPane.btnPower.setSelected(b); |
871 |
|
} |
872 |
|
|
873 |
|
rootPane.validate(); |
874 |
|
rootPane.repaint(); |
875 |
|
} |
876 |
|
|
877 |
|
public void |
878 |
|
setMidiKeyboardHeight(int height) { |
879 |
|
Dimension d = pianoKeyboardPane.getPreferredSize(); |
880 |
|
d = new Dimension(d.width, height); |
881 |
|
pianoKeyboardPane.setPreferredSize(d); |
882 |
|
pianoKeyboardPane.setMinimumSize(d); |
883 |
|
pianoKeyboardPane.revalidate(); |
884 |
|
pianoKeyboardPane.repaint(); |
885 |
|
} |
886 |
|
|
887 |
private void |
private void |
888 |
sidePanesVisibilityChanged() { |
sidePanesVisibilityChanged() { |
889 |
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
909 |
|
|
910 |
RecentScriptHandler(String script) { this.script = script; } |
RecentScriptHandler(String script) { this.script = script; } |
911 |
|
|
912 |
|
@Override |
913 |
public void |
public void |
914 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
915 |
runScript(script); |
runScript(script); |
924 |
super(s); |
super(s); |
925 |
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
926 |
setOpaque(false); |
setOpaque(false); |
927 |
|
setContentAreaFilled(false); |
928 |
} |
} |
929 |
} |
} |
930 |
|
|
931 |
private class FantasiaMenuBar extends JMenuBar { |
private class FantasiaMenuBar extends JMenuBar { |
|
private Insets pixmapInsets = new Insets(6, 6, 0, 6); |
|
|
private Insets pixmapInsets2 = new Insets(6, 6, 6, 6); |
|
|
|
|
932 |
FantasiaMenuBar() { |
FantasiaMenuBar() { |
933 |
setOpaque(false); |
setOpaque(false); |
934 |
|
setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0)); |
935 |
} |
} |
936 |
|
|
937 |
|
@Override |
938 |
protected void |
protected void |
939 |
paintComponent(Graphics g) { |
paintComponent(Graphics g) { |
940 |
super.paintComponent(g); |
//super.paintComponent(g); |
941 |
|
Graphics2D g2 = (Graphics2D)g; |
942 |
|
|
943 |
|
Paint oldPaint = g2.getPaint(); |
944 |
|
Composite oldComposite = g2.getComposite(); |
945 |
|
|
946 |
|
double h = getSize().getHeight(); |
947 |
|
double w = getSize().getWidth(); |
948 |
|
|
949 |
|
FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5); |
950 |
|
|
951 |
|
FantasiaPainter.Border b; |
952 |
|
|
953 |
|
|
954 |
if(standardBar.isVisible()) { |
if(standardBar.isVisible()) { |
955 |
PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets); |
b = new FantasiaPainter.Border(true, true, false, true); |
956 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b); |
957 |
} else { |
} else { |
958 |
PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2); |
b = new FantasiaPainter.Border(true, true, true, true); |
959 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b); |
960 |
} |
} |
961 |
|
|
962 |
|
g2.setPaint(oldPaint); |
963 |
|
g2.setComposite(oldComposite); |
964 |
|
} |
965 |
|
} |
966 |
|
|
967 |
|
class RootPane extends FantasiaSubPanel { |
968 |
|
private final Color color1 = new Color(0x454545); |
969 |
|
private final Color color2 = new Color(0x2e2e2e); |
970 |
|
|
971 |
|
RootPane() { |
972 |
|
setLayout(new BorderLayout()); |
973 |
|
setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10)); |
974 |
|
setOpaque(false); |
975 |
|
|
976 |
|
} |
977 |
|
|
978 |
|
@Override |
979 |
|
public void |
980 |
|
paintComponent(Graphics g) { |
981 |
|
Graphics2D g2 = (Graphics2D)g; |
982 |
|
|
983 |
|
Paint oldPaint = g2.getPaint(); |
984 |
|
Composite oldComposite = g2.getComposite(); |
985 |
|
|
986 |
|
double h = getSize().getHeight(); |
987 |
|
double w = getSize().getWidth(); |
988 |
|
|
989 |
|
FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false); |
990 |
|
paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2); |
991 |
|
|
992 |
|
g2.setPaint(oldPaint); |
993 |
|
g2.setComposite(oldComposite); |
994 |
|
} |
995 |
|
} |
996 |
|
|
997 |
|
class BottomPane extends FantasiaPanel { |
998 |
|
BottomPane() { |
999 |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
1000 |
|
setOpaque(false); |
1001 |
|
add(pianoKeyboardPane); |
1002 |
|
|
1003 |
} |
} |
1004 |
} |
} |
1005 |
} |
} |