1 |
iliev |
912 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
1864 |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
912 |
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.fantasia; |
24 |
|
|
|
25 |
|
|
import java.awt.BorderLayout; |
26 |
iliev |
1778 |
import java.awt.Color; |
27 |
|
|
import java.awt.Composite; |
28 |
iliev |
1204 |
import java.awt.Dialog; |
29 |
iliev |
912 |
import java.awt.Dimension; |
30 |
iliev |
1204 |
import java.awt.Frame; |
31 |
iliev |
1285 |
import java.awt.Graphics; |
32 |
iliev |
1778 |
import java.awt.Graphics2D; |
33 |
iliev |
1285 |
import java.awt.GridBagConstraints; |
34 |
|
|
import java.awt.GridBagLayout; |
35 |
|
|
import java.awt.Insets; |
36 |
iliev |
1778 |
import java.awt.Paint; |
37 |
iliev |
1786 |
import java.awt.Rectangle; |
38 |
iliev |
912 |
|
39 |
|
|
import java.awt.event.ActionEvent; |
40 |
|
|
import java.awt.event.ActionListener; |
41 |
iliev |
1285 |
import java.awt.event.KeyEvent; |
42 |
iliev |
912 |
|
43 |
iliev |
1778 |
import java.beans.PropertyChangeEvent; |
44 |
|
|
import java.beans.PropertyChangeListener; |
45 |
|
|
|
46 |
iliev |
1285 |
import java.io.BufferedReader; |
47 |
|
|
import java.io.File; |
48 |
|
|
import java.io.FileNotFoundException; |
49 |
|
|
import java.io.FileReader; |
50 |
|
|
|
51 |
|
|
import java.util.Vector; |
52 |
iliev |
912 |
|
53 |
iliev |
1285 |
import javax.swing.BorderFactory; |
54 |
iliev |
1778 |
import javax.swing.BoxLayout; |
55 |
iliev |
912 |
import javax.swing.JCheckBoxMenuItem; |
56 |
|
|
import javax.swing.JMenu; |
57 |
iliev |
1285 |
import javax.swing.JMenuBar; |
58 |
iliev |
912 |
import javax.swing.JMenuItem; |
59 |
|
|
import javax.swing.JPanel; |
60 |
iliev |
1285 |
import javax.swing.JSplitPane; |
61 |
|
|
import javax.swing.KeyStroke; |
62 |
|
|
import javax.swing.SwingUtilities; |
63 |
iliev |
1734 |
import javax.swing.Timer; |
64 |
iliev |
912 |
|
65 |
iliev |
1818 |
import javax.swing.event.ListSelectionEvent; |
66 |
|
|
import javax.swing.event.ListSelectionListener; |
67 |
|
|
|
68 |
iliev |
912 |
import org.jsampler.CC; |
69 |
|
|
import org.jsampler.HF; |
70 |
iliev |
1915 |
import org.jsampler.JSUtils; |
71 |
iliev |
1285 |
import org.jsampler.LSConsoleModel; |
72 |
iliev |
1688 |
import org.jsampler.Server; |
73 |
iliev |
912 |
|
74 |
|
|
import org.jsampler.view.JSChannelsPane; |
75 |
iliev |
1818 |
import org.jsampler.view.SessionViewConfig; |
76 |
iliev |
912 |
|
77 |
iliev |
1785 |
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
78 |
|
|
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
79 |
|
|
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
80 |
|
|
|
81 |
iliev |
1786 |
import org.jsampler.view.std.JSBackendLogFrame; |
82 |
iliev |
1688 |
import org.jsampler.view.std.JSConnectDlg; |
83 |
iliev |
1355 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
84 |
iliev |
1567 |
import org.jsampler.view.std.JSQuitDlg; |
85 |
iliev |
1285 |
import org.jsampler.view.std.JSamplerHomeChooser; |
86 |
iliev |
1818 |
import org.jsampler.view.std.StdMainFrame; |
87 |
iliev |
1786 |
import org.jsampler.view.std.StdUtils; |
88 |
iliev |
1285 |
|
89 |
|
|
import static org.jsampler.view.fantasia.A4n.a4n; |
90 |
iliev |
912 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
91 |
iliev |
1285 |
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
92 |
|
|
import static org.jsampler.view.std.StdPrefs.*; |
93 |
iliev |
912 |
|
94 |
|
|
|
95 |
|
|
/** |
96 |
|
|
* |
97 |
|
|
* @author Grigor Iliev |
98 |
|
|
*/ |
99 |
iliev |
1818 |
public class MainFrame extends StdMainFrame { |
100 |
iliev |
1872 |
public final static int MAX_CHANNEL_LANE_NUMBER = 8; |
101 |
|
|
|
102 |
iliev |
1323 |
private final StandardBar standardBar = new StandardBar(); |
103 |
iliev |
1285 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
104 |
iliev |
1778 |
private final JPanel rootPane = new RootPane(); |
105 |
|
|
private final BottomPane bottomPane; |
106 |
iliev |
1785 |
private final MainPane mainPane; |
107 |
iliev |
1776 |
private final PianoKeyboardPane pianoKeyboardPane; |
108 |
iliev |
912 |
|
109 |
iliev |
1285 |
private final JMenu recentScriptsMenu = |
110 |
|
|
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
111 |
iliev |
912 |
|
112 |
iliev |
1285 |
private final JSplitPane hSplitPane; |
113 |
|
|
|
114 |
iliev |
1785 |
private final LeftSidePane leftSidePane; |
115 |
|
|
private final RightSidePane rightSidePane; |
116 |
iliev |
1323 |
private final JPanel rightPane; |
117 |
iliev |
1285 |
|
118 |
iliev |
1767 |
//private final StatusBar statusBar = new StatusBar(); |
119 |
|
|
|
120 |
iliev |
1311 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
121 |
iliev |
1285 |
private final Vector<String> recentScripts = new Vector<String>(); |
122 |
iliev |
1786 |
|
123 |
|
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
124 |
iliev |
1285 |
|
125 |
|
|
|
126 |
iliev |
1323 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
127 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
128 |
|
|
|
129 |
iliev |
1729 |
private final JCheckBoxMenuItem cbmiLeftSidePaneVisible = |
130 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane")); |
131 |
iliev |
1323 |
|
132 |
iliev |
1729 |
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
133 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
134 |
iliev |
1323 |
|
135 |
iliev |
1776 |
private final JCheckBoxMenuItem cbmiMidiKeyboardVisible = |
136 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard")); |
137 |
|
|
|
138 |
iliev |
1734 |
private final Timer guiTimer = new Timer(1000, null); |
139 |
|
|
|
140 |
iliev |
912 |
/** Creates a new instance of <code>MainFrame</code> */ |
141 |
|
|
public |
142 |
|
|
MainFrame() { |
143 |
|
|
setTitle(i18n.getLabel("MainFrame.title")); |
144 |
iliev |
1778 |
//setUndecorated(true); |
145 |
iliev |
1285 |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
146 |
iliev |
912 |
|
147 |
iliev |
1785 |
CC.setMainFrame(this); // TODO: |
148 |
|
|
mainPane = new MainPane(); |
149 |
|
|
leftSidePane = new LeftSidePane(); |
150 |
|
|
rightSidePane = new RightSidePane(); |
151 |
|
|
|
152 |
|
|
setSelectedChannelsPane(mainPane.getChannelsPane(0)); |
153 |
|
|
|
154 |
iliev |
1285 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
155 |
iliev |
912 |
|
156 |
iliev |
1323 |
rightPane = createRightPane(); |
157 |
iliev |
912 |
|
158 |
iliev |
1285 |
hSplitPane = new JSplitPane ( |
159 |
|
|
JSplitPane.HORIZONTAL_SPLIT, |
160 |
|
|
true, // continuousLayout |
161 |
iliev |
1729 |
leftSidePane, rightPane |
162 |
iliev |
1285 |
); |
163 |
iliev |
1323 |
hSplitPane.setResizeWeight(0.5); |
164 |
iliev |
912 |
|
165 |
iliev |
1785 |
pianoKeyboardPane = new PianoKeyboardPane(); |
166 |
iliev |
1776 |
|
167 |
iliev |
1785 |
for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) { |
168 |
|
|
addChannelsPane(mainPane.getChannelsPane(i)); |
169 |
|
|
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
170 |
|
|
} |
171 |
iliev |
1872 |
|
172 |
|
|
PropertyChangeListener l = new PropertyChangeListener() { |
173 |
|
|
public void |
174 |
|
|
propertyChange(PropertyChangeEvent e) { |
175 |
|
|
onChangeChannelLaneCount(); |
176 |
|
|
} |
177 |
|
|
}; |
178 |
|
|
|
179 |
|
|
preferences().addPropertyChangeListener("channelLanes.count", l); |
180 |
iliev |
1785 |
|
181 |
iliev |
1778 |
int h = preferences().getIntProperty("midiKeyboard.height"); |
182 |
|
|
setMidiKeyboardHeight(h); |
183 |
iliev |
1776 |
|
184 |
iliev |
1872 |
l = new PropertyChangeListener() { |
185 |
iliev |
1778 |
public void |
186 |
|
|
propertyChange(PropertyChangeEvent e) { |
187 |
|
|
int h = preferences().getIntProperty("midiKeyboard.height"); |
188 |
|
|
setMidiKeyboardHeight(h); |
189 |
|
|
} |
190 |
|
|
}; |
191 |
iliev |
1776 |
|
192 |
iliev |
1778 |
CC.preferences().addPropertyChangeListener("midiKeyboard.height", l); |
193 |
iliev |
1776 |
|
194 |
iliev |
1778 |
bottomPane = new BottomPane(); |
195 |
|
|
|
196 |
|
|
hSplitPane.setOpaque(false); |
197 |
iliev |
1323 |
rootPane.add(hSplitPane); |
198 |
iliev |
1778 |
rootPane.add(bottomPane, BorderLayout.SOUTH); |
199 |
|
|
add(rootPane); |
200 |
iliev |
1865 |
|
201 |
|
|
if(CC.isMacOS()) { |
202 |
iliev |
1866 |
try { |
203 |
|
|
String s = "org.jsampler.view.fantasia.MacOSApplicationHandler"; |
204 |
|
|
Class.forName(s).newInstance(); } |
205 |
iliev |
1865 |
catch(Throwable e) { } |
206 |
|
|
} |
207 |
iliev |
912 |
|
208 |
iliev |
1323 |
addMenu(); |
209 |
|
|
|
210 |
iliev |
1865 |
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
211 |
|
|
// fix for moving the menu bar on top of the screen |
212 |
|
|
// when running on Mac OS and third party plugin is used |
213 |
|
|
((ViewConfig)CC.getViewConfig()).restoreMenuProperties(); |
214 |
|
|
} |
215 |
|
|
|
216 |
iliev |
1285 |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
217 |
|
|
hSplitPane.setDividerLocation(i); |
218 |
iliev |
912 |
|
219 |
iliev |
1285 |
setSavedSize(); |
220 |
iliev |
1734 |
|
221 |
|
|
guiTimer.start(); |
222 |
iliev |
1285 |
} |
223 |
|
|
|
224 |
|
|
private JPanel |
225 |
|
|
createRightPane() { |
226 |
iliev |
1778 |
JPanel p = new FantasiaPanel(); |
227 |
|
|
p.setOpaque(false); |
228 |
|
|
|
229 |
iliev |
1285 |
GridBagLayout gridbag = new GridBagLayout(); |
230 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
231 |
iliev |
912 |
|
232 |
iliev |
1285 |
p.setLayout(gridbag); |
233 |
iliev |
912 |
|
234 |
iliev |
1285 |
c.fill = GridBagConstraints.BOTH; |
235 |
iliev |
912 |
|
236 |
iliev |
1285 |
c.gridx = 1; |
237 |
|
|
c.gridy = 0; |
238 |
|
|
c.weightx = 1.0; |
239 |
|
|
c.weighty = 1.0; |
240 |
iliev |
1729 |
c.insets = new Insets(0, 3, 0, 0); |
241 |
|
|
gridbag.setConstraints(rightSidePane, c); |
242 |
|
|
p.add(rightSidePane); |
243 |
iliev |
912 |
|
244 |
iliev |
1285 |
c.gridx = 0; |
245 |
|
|
c.gridy = 0; |
246 |
|
|
c.weightx = 0.0; |
247 |
|
|
c.weighty = 1.0; |
248 |
iliev |
1778 |
c.insets = new Insets(0, 0, 0, 3); |
249 |
iliev |
1285 |
c.fill = GridBagConstraints.VERTICAL; |
250 |
|
|
gridbag.setConstraints(mainPane, c); |
251 |
|
|
p.add(mainPane); |
252 |
iliev |
912 |
|
253 |
iliev |
1285 |
return p; |
254 |
|
|
} |
255 |
|
|
|
256 |
|
|
private void |
257 |
|
|
setSavedSize() { |
258 |
iliev |
1786 |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
259 |
|
|
if(r == null) { |
260 |
iliev |
1285 |
setDefaultSizeAndLocation(); |
261 |
|
|
return; |
262 |
|
|
} |
263 |
|
|
|
264 |
iliev |
1786 |
setBounds(r); |
265 |
iliev |
912 |
} |
266 |
|
|
|
267 |
|
|
private void |
268 |
iliev |
1285 |
setDefaultSizeAndLocation() { |
269 |
|
|
setPreferredSize(new Dimension(900, 600)); |
270 |
|
|
pack(); |
271 |
|
|
setLocationRelativeTo(null); |
272 |
iliev |
912 |
} |
273 |
|
|
|
274 |
|
|
|
275 |
|
|
/** Invoked when this window is about to close. */ |
276 |
iliev |
1778 |
@Override |
277 |
iliev |
1864 |
public void |
278 |
iliev |
912 |
onWindowClose() { |
279 |
iliev |
1688 |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
280 |
|
|
if(b && CC.getSamplerModel().isModified()) { |
281 |
iliev |
1567 |
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
282 |
|
|
dlg.setVisible(true); |
283 |
|
|
if(dlg.isCancelled()) return; |
284 |
|
|
} |
285 |
|
|
|
286 |
iliev |
1729 |
leftSidePane.savePreferences(); |
287 |
|
|
rightSidePane.savePreferences(); |
288 |
iliev |
912 |
|
289 |
iliev |
1285 |
int i = hSplitPane.getDividerLocation(); |
290 |
|
|
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
291 |
|
|
|
292 |
|
|
preferences().setBoolProperty ( |
293 |
|
|
"MainFrame.windowMaximized", |
294 |
|
|
(getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
295 |
|
|
); |
296 |
|
|
|
297 |
|
|
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
298 |
|
|
super.onWindowClose(); |
299 |
|
|
return; |
300 |
|
|
} |
301 |
|
|
|
302 |
iliev |
1786 |
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
303 |
iliev |
912 |
|
304 |
iliev |
1308 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
305 |
|
|
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
306 |
iliev |
1285 |
|
307 |
|
|
if(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY)) { |
308 |
|
|
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
309 |
|
|
} |
310 |
|
|
|
311 |
iliev |
1786 |
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
312 |
|
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
313 |
|
|
|
314 |
iliev |
912 |
super.onWindowClose(); |
315 |
|
|
} |
316 |
iliev |
1872 |
|
317 |
|
|
private void |
318 |
|
|
onChangeChannelLaneCount() { |
319 |
|
|
int newCount = preferences().getIntProperty("channelLanes.count"); |
320 |
|
|
if(newCount < 1 || newCount > MAX_CHANNEL_LANE_NUMBER) return; |
321 |
|
|
if(newCount == getChannelsPaneCount()) return; |
322 |
|
|
int current = getChannelsPaneIndex(getSelectedChannelsPane()); |
323 |
|
|
|
324 |
|
|
if(newCount > getChannelsPaneCount()) { |
325 |
|
|
int d = newCount - getChannelsPaneCount(); |
326 |
|
|
for(int i = 0; i < d; i++) { |
327 |
|
|
JSChannelsPane p = mainPane.addChannelsPane(); |
328 |
|
|
addChannelsPane(p); |
329 |
|
|
p.addListSelectionListener(pianoKeyboardPane); |
330 |
|
|
} |
331 |
|
|
} else { |
332 |
|
|
int d = getChannelsPaneCount() - newCount; |
333 |
|
|
for(int i = 0; i < d; i++) { |
334 |
|
|
int idx = getChannelsPaneCount() - 1 - i; |
335 |
|
|
if(getChannelsPane(idx).getChannelCount() > 0) { |
336 |
|
|
String s; |
337 |
|
|
s = i18n.getError("MainFrame.notEmptyChannelLane!", idx + 1); |
338 |
|
|
HF.showErrorMessage(s); |
339 |
|
|
return; |
340 |
|
|
} |
341 |
|
|
} |
342 |
|
|
|
343 |
|
|
for(int i = 0; i < d; i++) { |
344 |
|
|
int idx = getChannelsPaneCount() - 1; |
345 |
|
|
JSChannelsPane p = getChannelsPane(idx); |
346 |
|
|
removeChannelsPane(p); |
347 |
|
|
p.removeListSelectionListener(pianoKeyboardPane); |
348 |
|
|
mainPane.removeChannelsPane(idx); |
349 |
|
|
} |
350 |
|
|
} |
351 |
|
|
|
352 |
|
|
if(newCount == 1) { |
353 |
|
|
mainPane.getButtonsPanel().setVisible(false); |
354 |
|
|
} else if(!mainPane.getButtonsPanel().isVisible()) { |
355 |
|
|
mainPane.getButtonsPanel().setVisible(true); |
356 |
|
|
} |
357 |
|
|
mainPane.getButtonsPanel().setButtonNumber(newCount); |
358 |
|
|
if(current < 0 || current >= getChannelsPaneCount()) current = 0; |
359 |
|
|
setSelectedChannelsPane(getChannelsPane(current)); |
360 |
|
|
} |
361 |
iliev |
912 |
|
362 |
iliev |
1786 |
@Override |
363 |
|
|
public void |
364 |
|
|
setVisible(boolean b) { |
365 |
|
|
if(b == isVisible()) return; |
366 |
|
|
|
367 |
|
|
super.setVisible(b); |
368 |
|
|
|
369 |
|
|
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
370 |
|
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
371 |
|
|
} |
372 |
|
|
} |
373 |
|
|
|
374 |
iliev |
1285 |
private void |
375 |
|
|
addMenu() { |
376 |
|
|
JMenu m; |
377 |
|
|
JMenuItem mi; |
378 |
|
|
|
379 |
|
|
setJMenuBar(menuBar); |
380 |
|
|
|
381 |
|
|
// Actions |
382 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("actions")); |
383 |
|
|
|
384 |
iliev |
1688 |
mi = new JMenuItem(a4n.refresh); |
385 |
iliev |
1285 |
mi.setIcon(null); |
386 |
iliev |
1688 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
387 |
iliev |
1285 |
m.add(mi); |
388 |
|
|
|
389 |
|
|
mi = new JMenuItem(a4n.samplerInfo); |
390 |
|
|
mi.setIcon(null); |
391 |
|
|
m.add(mi); |
392 |
|
|
|
393 |
iliev |
1688 |
mi = new JMenuItem(a4n.resetSampler); |
394 |
|
|
mi.setIcon(null); |
395 |
|
|
m.add(mi); |
396 |
|
|
|
397 |
iliev |
1285 |
m.addSeparator(); |
398 |
|
|
|
399 |
|
|
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
400 |
|
|
m.add(exportMenu); |
401 |
iliev |
1864 |
|
402 |
|
|
int modKey = CC.getViewConfig().getDefaultModKey(); |
403 |
iliev |
1285 |
|
404 |
|
|
mi = new JMenuItem(a4n.exportSamplerConfig); |
405 |
|
|
mi.setIcon(null); |
406 |
iliev |
1864 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, modKey)); |
407 |
iliev |
1285 |
exportMenu.add(mi); |
408 |
|
|
|
409 |
|
|
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
410 |
|
|
mi.setIcon(null); |
411 |
|
|
exportMenu.add(mi); |
412 |
|
|
|
413 |
|
|
m.addSeparator(); |
414 |
|
|
|
415 |
|
|
mi = new JMenuItem(a4n.loadScript); |
416 |
|
|
mi.setIcon(null); |
417 |
iliev |
1864 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, modKey)); |
418 |
iliev |
1285 |
m.add(mi); |
419 |
|
|
|
420 |
iliev |
1308 |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
421 |
|
|
for(String s : list) recentScripts.add(s); |
422 |
iliev |
1285 |
|
423 |
|
|
updateRecentScriptsMenu(); |
424 |
|
|
|
425 |
|
|
m.add(recentScriptsMenu); |
426 |
|
|
|
427 |
|
|
m.addSeparator(); |
428 |
|
|
|
429 |
iliev |
1688 |
mi = new JMenuItem(a4n.changeBackend); |
430 |
|
|
mi.setIcon(null); |
431 |
iliev |
1864 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, modKey)); |
432 |
iliev |
1688 |
m.add(mi); |
433 |
|
|
|
434 |
|
|
m.addSeparator(); |
435 |
|
|
|
436 |
iliev |
1285 |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
437 |
|
|
m.add(mi); |
438 |
|
|
mi.addActionListener(new ActionListener() { |
439 |
|
|
public void |
440 |
|
|
actionPerformed(ActionEvent e) { onWindowClose(); } |
441 |
|
|
}); |
442 |
|
|
|
443 |
|
|
menuBar.add(m); |
444 |
|
|
|
445 |
|
|
|
446 |
|
|
// Edit |
447 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("edit")); |
448 |
|
|
menuBar.add(m); |
449 |
|
|
|
450 |
iliev |
1323 |
mi = new JMenuItem(i18n.getMenuLabel("edit.addChannel")); |
451 |
|
|
m.add(mi); |
452 |
|
|
mi.addActionListener(new ActionListener() { |
453 |
|
|
public void |
454 |
|
|
actionPerformed(ActionEvent e) { |
455 |
|
|
CC.getSamplerModel().addBackendChannel(); |
456 |
|
|
} |
457 |
|
|
}); |
458 |
|
|
|
459 |
|
|
m.addSeparator(); |
460 |
|
|
|
461 |
|
|
mi = new JMenuItem(a4n.createMidiDevice); |
462 |
|
|
mi.setIcon(null); |
463 |
|
|
m.add(mi); |
464 |
|
|
|
465 |
|
|
mi = new JMenuItem(a4n.createAudioDevice); |
466 |
|
|
mi.setIcon(null); |
467 |
|
|
m.add(mi); |
468 |
|
|
|
469 |
|
|
m.addSeparator(); |
470 |
|
|
|
471 |
iliev |
1285 |
mi = new JMenuItem(a4n.editPreferences); |
472 |
|
|
mi.setIcon(null); |
473 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
474 |
iliev |
1864 |
KeyEvent.VK_P, modKey | KeyEvent.SHIFT_MASK |
475 |
iliev |
1285 |
)); |
476 |
|
|
m.add(mi); |
477 |
|
|
|
478 |
iliev |
1323 |
// View |
479 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("view")); |
480 |
|
|
menuBar.add(m); |
481 |
iliev |
1285 |
|
482 |
iliev |
1323 |
m.add(cbmiToolBarVisible); |
483 |
|
|
|
484 |
|
|
cbmiToolBarVisible.addActionListener(new ActionListener() { |
485 |
|
|
public void |
486 |
|
|
actionPerformed(ActionEvent e) { |
487 |
|
|
showToolBar(cbmiToolBarVisible.getState()); |
488 |
|
|
} |
489 |
|
|
}); |
490 |
|
|
|
491 |
|
|
boolean b = preferences().getBoolProperty("toolBar.visible"); |
492 |
|
|
cbmiToolBarVisible.setSelected(b); |
493 |
|
|
showToolBar(b); |
494 |
|
|
|
495 |
iliev |
1729 |
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
496 |
iliev |
1864 |
KeyEvent.VK_L, modKey | KeyEvent.SHIFT_MASK |
497 |
iliev |
1323 |
)); |
498 |
iliev |
1729 |
m.add(cbmiLeftSidePaneVisible); |
499 |
iliev |
1323 |
|
500 |
iliev |
1729 |
cbmiLeftSidePaneVisible.addActionListener(new ActionListener() { |
501 |
iliev |
1323 |
public void |
502 |
|
|
actionPerformed(ActionEvent e) { |
503 |
iliev |
1729 |
showSidePane(cbmiLeftSidePaneVisible.getState()); |
504 |
iliev |
1323 |
} |
505 |
|
|
}); |
506 |
|
|
|
507 |
iliev |
1729 |
b = preferences().getBoolProperty("leftSidePane.visible"); |
508 |
|
|
cbmiLeftSidePaneVisible.setSelected(b); |
509 |
iliev |
1323 |
showSidePane(b); |
510 |
|
|
|
511 |
iliev |
1729 |
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
512 |
iliev |
1864 |
KeyEvent.VK_R, modKey | KeyEvent.SHIFT_MASK |
513 |
iliev |
1323 |
)); |
514 |
iliev |
1729 |
m.add(cbmiRightSidePaneVisible); |
515 |
iliev |
1323 |
|
516 |
iliev |
1729 |
cbmiRightSidePaneVisible.addActionListener(new ActionListener() { |
517 |
iliev |
1323 |
public void |
518 |
|
|
actionPerformed(ActionEvent e) { |
519 |
iliev |
1729 |
showDevicesPane(cbmiRightSidePaneVisible.getState()); |
520 |
iliev |
1323 |
} |
521 |
|
|
}); |
522 |
|
|
|
523 |
iliev |
1729 |
b = preferences().getBoolProperty("rightSidePane.visible"); |
524 |
|
|
cbmiRightSidePaneVisible.setSelected(b); |
525 |
iliev |
1323 |
showDevicesPane(b); |
526 |
|
|
|
527 |
iliev |
1776 |
m.addSeparator(); |
528 |
iliev |
1323 |
|
529 |
iliev |
1776 |
m.add(cbmiMidiKeyboardVisible); |
530 |
|
|
|
531 |
|
|
cbmiMidiKeyboardVisible.addActionListener(new ActionListener() { |
532 |
|
|
public void |
533 |
|
|
actionPerformed(ActionEvent e) { |
534 |
iliev |
1778 |
setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState()); |
535 |
iliev |
1776 |
} |
536 |
|
|
}); |
537 |
|
|
|
538 |
|
|
b = preferences().getBoolProperty("midiKeyboard.visible"); |
539 |
|
|
cbmiMidiKeyboardVisible.setSelected(b); |
540 |
iliev |
1778 |
setMidiKeyboardVisible(b); |
541 |
iliev |
1776 |
|
542 |
|
|
|
543 |
iliev |
1818 |
// Channels |
544 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("channels")); |
545 |
|
|
|
546 |
|
|
mi = new JMenuItem(i18n.getMenuLabel("channels.newChannel")); |
547 |
|
|
mi.addActionListener(new ActionListener() { |
548 |
|
|
public void |
549 |
|
|
actionPerformed(ActionEvent e) { |
550 |
|
|
CC.getSamplerModel().addBackendChannel(); |
551 |
|
|
} |
552 |
|
|
}); |
553 |
|
|
m.add(mi); |
554 |
|
|
|
555 |
|
|
m.addSeparator(); |
556 |
|
|
|
557 |
|
|
MenuManager.ChannelViewGroup group = new MenuManager.ChannelViewGroup(); |
558 |
|
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
559 |
|
|
|
560 |
|
|
for(JMenuItem menuItem : group.getMenuItems()) m.add(menuItem); |
561 |
|
|
|
562 |
|
|
m.addSeparator(); |
563 |
|
|
|
564 |
|
|
m.add(new JMenuItem(a4n.moveChannelsOnTop)); |
565 |
|
|
m.add(new JMenuItem(a4n.moveChannelsUp)); |
566 |
|
|
m.add(new JMenuItem(a4n.moveChannelsDown)); |
567 |
|
|
m.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
568 |
|
|
|
569 |
|
|
m.add(new ToPanelMenu()); |
570 |
|
|
|
571 |
|
|
m.addSeparator(); |
572 |
|
|
|
573 |
|
|
mi = new JMenuItem(a4n.selectAllChannels); |
574 |
|
|
mi.setIcon(null); |
575 |
iliev |
1864 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, modKey)); |
576 |
iliev |
1818 |
m.add(mi); |
577 |
|
|
|
578 |
|
|
mi = new JMenuItem(a4n.deselectChannels); |
579 |
|
|
mi.setIcon(null); |
580 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
581 |
iliev |
1864 |
KeyEvent.VK_A, modKey | KeyEvent.SHIFT_MASK |
582 |
iliev |
1818 |
)); |
583 |
|
|
m.add(mi); |
584 |
|
|
|
585 |
|
|
menuBar.add(m); |
586 |
|
|
|
587 |
iliev |
1285 |
// Window |
588 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
589 |
|
|
menuBar.add(m); |
590 |
|
|
|
591 |
|
|
mi = new JMenuItem(a4n.windowLSConsole); |
592 |
|
|
mi.setIcon(null); |
593 |
|
|
m.add(mi); |
594 |
|
|
|
595 |
|
|
mi = new JMenuItem(a4n.windowInstrumentsDb); |
596 |
|
|
mi.setIcon(null); |
597 |
|
|
m.add(mi); |
598 |
|
|
|
599 |
iliev |
1786 |
m.addSeparator(); |
600 |
iliev |
1285 |
|
601 |
iliev |
1786 |
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
602 |
|
|
m.add(mi2); |
603 |
|
|
mi2.addActionListener(new ActionListener() { |
604 |
|
|
public void |
605 |
|
|
actionPerformed(ActionEvent e) { |
606 |
|
|
if(getBackendLogFrame().isVisible()) { |
607 |
|
|
getBackendLogFrame().setVisible(false); |
608 |
|
|
} |
609 |
|
|
|
610 |
|
|
getBackendLogFrame().setVisible(true); |
611 |
|
|
} |
612 |
|
|
}); |
613 |
|
|
|
614 |
|
|
mi2.setEnabled(CC.getBackendProcess() != null); |
615 |
|
|
|
616 |
|
|
CC.addBackendProcessListener(new ActionListener() { |
617 |
|
|
public void |
618 |
|
|
actionPerformed(ActionEvent e) { |
619 |
|
|
mi2.setEnabled(CC.getBackendProcess() != null); |
620 |
|
|
} |
621 |
|
|
}); |
622 |
|
|
|
623 |
|
|
|
624 |
iliev |
1285 |
// Help |
625 |
|
|
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
626 |
|
|
|
627 |
iliev |
1496 |
mi = new JMenuItem(a4n.browseOnlineTutorial); |
628 |
|
|
mi.setIcon(null); |
629 |
|
|
m.add(mi); |
630 |
|
|
|
631 |
|
|
m.addSeparator(); |
632 |
|
|
|
633 |
iliev |
1285 |
mi = new JMenuItem(a4n.helpAbout); |
634 |
|
|
mi.setIcon(null); |
635 |
|
|
m.add(mi); |
636 |
|
|
|
637 |
|
|
menuBar.add(m); |
638 |
iliev |
912 |
} |
639 |
|
|
|
640 |
iliev |
1818 |
public static class ToPanelMenu extends FantasiaMenu implements ListSelectionListener { |
641 |
|
|
public |
642 |
|
|
ToPanelMenu() { |
643 |
|
|
super(i18n.getMenuLabel("channels.toPanel")); |
644 |
|
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
645 |
|
|
|
646 |
|
|
CC.getMainFrame().addChannelsPaneSelectionListener(this); |
647 |
|
|
|
648 |
|
|
for(int i = 0; i < CC.getMainFrame().getChannelsPaneCount(); i++) { |
649 |
|
|
JSChannelsPane p = CC.getMainFrame().getChannelsPane(i); |
650 |
|
|
add(new JMenuItem(new A4n.MoveChannelsToPanel(p))); |
651 |
|
|
p.addListSelectionListener(this); |
652 |
|
|
} |
653 |
|
|
} |
654 |
|
|
|
655 |
|
|
@Override |
656 |
|
|
public void |
657 |
|
|
valueChanged(ListSelectionEvent e) { |
658 |
|
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
659 |
|
|
} |
660 |
|
|
} |
661 |
|
|
|
662 |
iliev |
1767 |
public RightSidePane |
663 |
|
|
getRightSidePane() { return rightSidePane; } |
664 |
|
|
|
665 |
iliev |
1818 |
@Override |
666 |
|
|
public A4n |
667 |
|
|
getA4n() { return A4n.a4n; } |
668 |
|
|
|
669 |
iliev |
912 |
/** |
670 |
iliev |
1785 |
* This method does nothing, because <b>Fantasia</b> has constant |
671 |
|
|
* number of panes containing sampler channels, which can not be changed. |
672 |
iliev |
912 |
*/ |
673 |
iliev |
1778 |
@Override |
674 |
iliev |
912 |
public void |
675 |
|
|
insertChannelsPane(JSChannelsPane pane, int idx) { |
676 |
iliev |
1285 |
|
677 |
iliev |
912 |
} |
678 |
|
|
|
679 |
iliev |
1778 |
@Override |
680 |
iliev |
912 |
public JSChannelsPane |
681 |
iliev |
1785 |
getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); } |
682 |
iliev |
912 |
|
683 |
iliev |
1778 |
@Override |
684 |
iliev |
912 |
public void |
685 |
iliev |
1785 |
setSelectedChannelsPane(JSChannelsPane pane) { |
686 |
|
|
mainPane.setSelectedChannelsPane(pane); |
687 |
|
|
fireChannelsPaneSelectionChanged(); |
688 |
|
|
} |
689 |
iliev |
912 |
|
690 |
iliev |
1778 |
@Override |
691 |
iliev |
1285 |
public void |
692 |
|
|
installJSamplerHome() { |
693 |
|
|
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
694 |
|
|
chooser.setVisible(true); |
695 |
|
|
if(chooser.isCancelled()) return; |
696 |
iliev |
912 |
|
697 |
iliev |
1915 |
JSUtils.changeJSamplerHome(chooser.getJSamplerHome()); |
698 |
iliev |
912 |
} |
699 |
|
|
|
700 |
iliev |
1778 |
@Override |
701 |
iliev |
1143 |
public void |
702 |
iliev |
1204 |
showDetailedErrorMessage(Frame owner, String err, String details) { |
703 |
iliev |
1355 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
704 |
|
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
705 |
|
|
); |
706 |
|
|
dlg.setVisible(true); |
707 |
iliev |
1204 |
} |
708 |
|
|
|
709 |
iliev |
1778 |
@Override |
710 |
iliev |
1204 |
public void |
711 |
|
|
showDetailedErrorMessage(Dialog owner, String err, String details) { |
712 |
iliev |
1355 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
713 |
|
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
714 |
|
|
); |
715 |
|
|
dlg.setVisible(true); |
716 |
iliev |
1204 |
} |
717 |
iliev |
912 |
|
718 |
iliev |
1688 |
/** |
719 |
|
|
* Gets the server address to which to connect. If the server should be |
720 |
|
|
* manually selected, a dialog asking the user to choose a server is displayed. |
721 |
|
|
*/ |
722 |
iliev |
1778 |
@Override |
723 |
iliev |
1688 |
public Server |
724 |
|
|
getServer() { |
725 |
|
|
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
726 |
|
|
return getServer(b); |
727 |
|
|
} |
728 |
|
|
|
729 |
|
|
/** |
730 |
|
|
* Gets the server address to which to connect. If the server should be |
731 |
|
|
* manually selected, a dialog asking the user to choose a server is displayed. |
732 |
|
|
* @param manualSelect Determines whether the server should be manually selected. |
733 |
|
|
*/ |
734 |
iliev |
1778 |
@Override |
735 |
iliev |
1688 |
public Server |
736 |
|
|
getServer(boolean manualSelect) { |
737 |
|
|
if(manualSelect) { |
738 |
|
|
JSConnectDlg dlg = new JSConnectDlg(); |
739 |
|
|
dlg.setVisible(true); |
740 |
iliev |
1786 |
|
741 |
iliev |
1688 |
return dlg.getSelectedServer(); |
742 |
|
|
} |
743 |
|
|
|
744 |
|
|
int i = preferences().getIntProperty(SERVER_INDEX); |
745 |
|
|
int size = CC.getServerList().getServerCount(); |
746 |
|
|
if(size == 0) return null; |
747 |
|
|
if(i >= size) return CC.getServerList().getServer(0); |
748 |
|
|
|
749 |
|
|
return CC.getServerList().getServer(i); |
750 |
|
|
} |
751 |
|
|
|
752 |
iliev |
1734 |
public Timer |
753 |
|
|
getGuiTimer() { return guiTimer; } |
754 |
|
|
|
755 |
iliev |
1883 |
@Override |
756 |
|
|
public LSConsoleModel |
757 |
iliev |
1285 |
getLSConsoleModel() { return getLSConsolePane().getModel(); } |
758 |
|
|
|
759 |
|
|
protected LSConsolePane |
760 |
|
|
getLSConsolePane() { |
761 |
|
|
return getLSConsoleFrame().getLSConsolePane(); |
762 |
|
|
} |
763 |
|
|
|
764 |
|
|
protected LSConsoleFrame |
765 |
iliev |
1311 |
getLSConsoleFrame() { return lsConsoleFrame; } |
766 |
iliev |
1285 |
|
767 |
iliev |
1786 |
public JSBackendLogFrame |
768 |
|
|
getBackendLogFrame() { return backendLogFrame; } |
769 |
|
|
|
770 |
iliev |
1688 |
protected boolean |
771 |
iliev |
1285 |
runScript() { |
772 |
iliev |
1871 |
File f = StdUtils.showOpenLscpFileChooser(); |
773 |
|
|
if(f == null) return false; |
774 |
|
|
runScript(f); |
775 |
iliev |
912 |
|
776 |
iliev |
1688 |
return true; |
777 |
iliev |
1285 |
} |
778 |
|
|
|
779 |
iliev |
1786 |
@Override |
780 |
|
|
public void |
781 |
iliev |
1285 |
runScript(String script) { runScript(new File(script)); } |
782 |
|
|
|
783 |
|
|
private void |
784 |
|
|
runScript(File script) { |
785 |
|
|
FileReader fr; |
786 |
|
|
try { fr = new FileReader(script); } |
787 |
|
|
catch(FileNotFoundException e) { |
788 |
iliev |
1919 |
HF.showErrorMessage(i18n.getError("fileNotFound!", script.getAbsolutePath())); |
789 |
iliev |
1285 |
return; |
790 |
iliev |
912 |
} |
791 |
|
|
|
792 |
iliev |
1818 |
String prefix = "#jsampler.fantasia: "; |
793 |
|
|
Vector<String> v = new Vector<String>(); |
794 |
iliev |
1285 |
BufferedReader br = new BufferedReader(fr); |
795 |
|
|
|
796 |
|
|
try { |
797 |
|
|
String s = br.readLine(); |
798 |
|
|
while(s != null) { |
799 |
|
|
getLSConsoleModel().setCommandLineText(s); |
800 |
|
|
getLSConsoleModel().execCommand(); |
801 |
iliev |
1818 |
if(s.startsWith(prefix)) v.add(s.substring(prefix.length())); |
802 |
iliev |
1285 |
s = br.readLine(); |
803 |
|
|
} |
804 |
|
|
} catch(Exception e) { |
805 |
|
|
HF.showErrorMessage(e); |
806 |
|
|
return; |
807 |
iliev |
912 |
} |
808 |
iliev |
1285 |
|
809 |
|
|
String s = script.getAbsolutePath(); |
810 |
|
|
recentScripts.remove(s); |
811 |
|
|
recentScripts.insertElementAt(s, 0); |
812 |
|
|
|
813 |
|
|
updateRecentScriptsMenu(); |
814 |
iliev |
1818 |
|
815 |
|
|
CC.getViewConfig().setSessionViewConfig( |
816 |
|
|
new SessionViewConfig(v.toArray(new String[v.size()])) |
817 |
|
|
); |
818 |
iliev |
1285 |
} |
819 |
iliev |
912 |
|
820 |
iliev |
1285 |
protected void |
821 |
|
|
clearRecentScripts() { |
822 |
|
|
recentScripts.removeAllElements(); |
823 |
|
|
updateRecentScriptsMenu(); |
824 |
|
|
} |
825 |
|
|
|
826 |
|
|
protected void |
827 |
|
|
updateRecentScriptsMenu() { |
828 |
|
|
int size = preferences().getIntProperty(RECENT_LSCP_SCRIPTS_SIZE); |
829 |
|
|
while(recentScripts.size() > size) { |
830 |
|
|
recentScripts.removeElementAt(recentScripts.size() - 1); |
831 |
|
|
} |
832 |
|
|
|
833 |
|
|
recentScriptsMenu.removeAll(); |
834 |
|
|
|
835 |
|
|
for(String script : recentScripts) { |
836 |
|
|
JMenuItem mi = new JMenuItem(script); |
837 |
|
|
recentScriptsMenu.add(mi); |
838 |
|
|
mi.addActionListener(new RecentScriptHandler(script)); |
839 |
|
|
} |
840 |
|
|
|
841 |
|
|
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
842 |
|
|
} |
843 |
|
|
|
844 |
iliev |
1323 |
private void |
845 |
|
|
showToolBar(boolean b) { |
846 |
|
|
preferences().setBoolProperty("toolBar.visible", b); |
847 |
|
|
standardBar.setVisible(b); |
848 |
|
|
} |
849 |
|
|
|
850 |
|
|
private void |
851 |
|
|
showSidePane(boolean b) { |
852 |
iliev |
1729 |
preferences().setBoolProperty("leftSidePane.visible", b); |
853 |
iliev |
1323 |
rootPane.remove(rightPane); |
854 |
|
|
rootPane.remove(hSplitPane); |
855 |
|
|
|
856 |
|
|
if(b) { |
857 |
|
|
hSplitPane.setRightComponent(rightPane); |
858 |
|
|
rootPane.add(hSplitPane); |
859 |
|
|
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
860 |
|
|
|
861 |
|
|
hSplitPane.setDividerLocation(i); |
862 |
|
|
hSplitPane.validate(); |
863 |
|
|
} else { |
864 |
|
|
rootPane.add(rightPane); |
865 |
|
|
|
866 |
|
|
} |
867 |
|
|
|
868 |
|
|
int w = getPreferredSize().width; |
869 |
|
|
int h = getSize().height; |
870 |
|
|
setSize(new Dimension(w, h)); |
871 |
|
|
|
872 |
|
|
rootPane.revalidate(); |
873 |
|
|
rootPane.validate(); |
874 |
|
|
rootPane.repaint(); |
875 |
|
|
|
876 |
|
|
SwingUtilities.invokeLater(new Runnable() { |
877 |
|
|
public void |
878 |
|
|
run() { sidePanesVisibilityChanged(); } |
879 |
|
|
}); |
880 |
|
|
} |
881 |
|
|
|
882 |
|
|
private void |
883 |
|
|
showDevicesPane(boolean b) { |
884 |
iliev |
1729 |
preferences().setBoolProperty("rightSidePane.visible", b); |
885 |
iliev |
1323 |
|
886 |
iliev |
1729 |
int width = leftSidePane.getWidth(); |
887 |
|
|
int height = leftSidePane.getPreferredSize().height; |
888 |
|
|
if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height)); |
889 |
iliev |
1323 |
|
890 |
|
|
if(b) { |
891 |
|
|
int w = preferences().getIntProperty("devicesPane.width", 200); |
892 |
|
|
|
893 |
iliev |
1729 |
int h = rightSidePane.getPreferredSize().height; |
894 |
|
|
rightSidePane.setPreferredSize(new Dimension(w, h)); |
895 |
iliev |
1323 |
} else { |
896 |
iliev |
1729 |
int w = rightSidePane.getWidth(); |
897 |
iliev |
1323 |
if(w > 0 && w < 200) w = 200; |
898 |
|
|
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
899 |
|
|
} |
900 |
|
|
|
901 |
|
|
hSplitPane.setResizeWeight(0.0); |
902 |
iliev |
1729 |
rightSidePane.setVisible(b); |
903 |
iliev |
1323 |
hSplitPane.resetToPreferredSizes(); |
904 |
|
|
|
905 |
|
|
int w = getPreferredSize().width; |
906 |
|
|
int h = getSize().height; |
907 |
|
|
setSize(new Dimension(w, h)); |
908 |
|
|
|
909 |
|
|
rootPane.validate(); |
910 |
|
|
rootPane.repaint(); |
911 |
|
|
//hSplitPane.validate(); |
912 |
|
|
|
913 |
|
|
SwingUtilities.invokeLater(new Runnable() { |
914 |
|
|
public void |
915 |
|
|
run() { sidePanesVisibilityChanged(); } |
916 |
|
|
}); |
917 |
|
|
} |
918 |
|
|
|
919 |
iliev |
1778 |
public void |
920 |
|
|
setMidiKeyboardVisible(boolean b) { |
921 |
iliev |
1776 |
preferences().setBoolProperty("midiKeyboard.visible", b); |
922 |
iliev |
1778 |
pianoKeyboardPane.setVisible(b); |
923 |
|
|
|
924 |
|
|
if(cbmiMidiKeyboardVisible.isSelected() != b) { |
925 |
|
|
cbmiMidiKeyboardVisible.setSelected(b); |
926 |
iliev |
1776 |
} |
927 |
|
|
|
928 |
iliev |
1778 |
if(standardBar.btnMidiKeyboard.isSelected() != b) { |
929 |
|
|
standardBar.btnMidiKeyboard.setSelected(b); |
930 |
|
|
} |
931 |
|
|
|
932 |
|
|
if(pianoKeyboardPane.btnPower.isSelected() != b) { |
933 |
|
|
pianoKeyboardPane.btnPower.setSelected(b); |
934 |
|
|
} |
935 |
|
|
|
936 |
|
|
rootPane.validate(); |
937 |
|
|
rootPane.repaint(); |
938 |
iliev |
1776 |
} |
939 |
|
|
|
940 |
iliev |
1778 |
public void |
941 |
|
|
setMidiKeyboardHeight(int height) { |
942 |
|
|
Dimension d = pianoKeyboardPane.getPreferredSize(); |
943 |
|
|
d = new Dimension(d.width, height); |
944 |
|
|
pianoKeyboardPane.setPreferredSize(d); |
945 |
|
|
pianoKeyboardPane.setMinimumSize(d); |
946 |
|
|
pianoKeyboardPane.revalidate(); |
947 |
|
|
pianoKeyboardPane.repaint(); |
948 |
|
|
} |
949 |
|
|
|
950 |
iliev |
1776 |
private void |
951 |
iliev |
1323 |
sidePanesVisibilityChanged() { |
952 |
iliev |
1729 |
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
953 |
|
|
boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected(); |
954 |
iliev |
1323 |
|
955 |
iliev |
1729 |
if(leftSidePaneVisible && rightSidePaneVisible) { |
956 |
iliev |
1323 |
hSplitPane.setResizeWeight(0.5); |
957 |
iliev |
1729 |
} else if(leftSidePaneVisible && !rightSidePaneVisible) { |
958 |
iliev |
1323 |
hSplitPane.setResizeWeight(1.0); |
959 |
|
|
} |
960 |
|
|
|
961 |
iliev |
1729 |
if(!leftSidePaneVisible && !rightSidePaneVisible) { |
962 |
iliev |
1323 |
standardBar.showFantasiaLogo(false); |
963 |
|
|
if(isResizable()) setResizable(false); |
964 |
|
|
} else { |
965 |
|
|
standardBar.showFantasiaLogo(true); |
966 |
|
|
if(!isResizable()) setResizable(true); |
967 |
|
|
} |
968 |
|
|
} |
969 |
|
|
|
970 |
iliev |
1285 |
private class RecentScriptHandler implements ActionListener { |
971 |
|
|
private String script; |
972 |
|
|
|
973 |
|
|
RecentScriptHandler(String script) { this.script = script; } |
974 |
|
|
|
975 |
iliev |
1778 |
@Override |
976 |
iliev |
912 |
public void |
977 |
iliev |
1285 |
actionPerformed(ActionEvent e) { |
978 |
|
|
runScript(script); |
979 |
|
|
if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) { |
980 |
|
|
a4n.windowLSConsole.actionPerformed(null); |
981 |
|
|
} |
982 |
iliev |
912 |
} |
983 |
iliev |
1285 |
} |
984 |
iliev |
912 |
|
985 |
iliev |
1285 |
private static class FantasiaMenu extends JMenu { |
986 |
|
|
FantasiaMenu(String s) { |
987 |
|
|
super(s); |
988 |
|
|
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
989 |
|
|
setOpaque(false); |
990 |
iliev |
1776 |
setContentAreaFilled(false); |
991 |
iliev |
912 |
} |
992 |
|
|
} |
993 |
iliev |
1285 |
|
994 |
iliev |
1323 |
private class FantasiaMenuBar extends JMenuBar { |
995 |
iliev |
1285 |
FantasiaMenuBar() { |
996 |
|
|
setOpaque(false); |
997 |
iliev |
1778 |
setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0)); |
998 |
iliev |
1285 |
} |
999 |
|
|
|
1000 |
iliev |
1778 |
@Override |
1001 |
iliev |
1285 |
protected void |
1002 |
|
|
paintComponent(Graphics g) { |
1003 |
iliev |
1778 |
//super.paintComponent(g); |
1004 |
|
|
Graphics2D g2 = (Graphics2D)g; |
1005 |
|
|
|
1006 |
|
|
Paint oldPaint = g2.getPaint(); |
1007 |
|
|
Composite oldComposite = g2.getComposite(); |
1008 |
|
|
|
1009 |
|
|
double h = getSize().getHeight(); |
1010 |
|
|
double w = getSize().getWidth(); |
1011 |
|
|
|
1012 |
|
|
FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5); |
1013 |
|
|
|
1014 |
|
|
FantasiaPainter.Border b; |
1015 |
|
|
|
1016 |
|
|
|
1017 |
iliev |
1323 |
if(standardBar.isVisible()) { |
1018 |
iliev |
1778 |
b = new FantasiaPainter.Border(true, true, false, true); |
1019 |
|
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b); |
1020 |
iliev |
1323 |
} else { |
1021 |
iliev |
1778 |
b = new FantasiaPainter.Border(true, true, true, true); |
1022 |
|
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b); |
1023 |
iliev |
1323 |
} |
1024 |
iliev |
1778 |
|
1025 |
|
|
g2.setPaint(oldPaint); |
1026 |
|
|
g2.setComposite(oldComposite); |
1027 |
iliev |
1285 |
} |
1028 |
|
|
} |
1029 |
iliev |
1778 |
|
1030 |
|
|
class RootPane extends FantasiaSubPanel { |
1031 |
|
|
private final Color color1 = new Color(0x454545); |
1032 |
|
|
private final Color color2 = new Color(0x2e2e2e); |
1033 |
|
|
|
1034 |
|
|
RootPane() { |
1035 |
|
|
setLayout(new BorderLayout()); |
1036 |
|
|
setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10)); |
1037 |
|
|
setOpaque(false); |
1038 |
|
|
|
1039 |
|
|
} |
1040 |
|
|
|
1041 |
|
|
@Override |
1042 |
|
|
public void |
1043 |
|
|
paintComponent(Graphics g) { |
1044 |
|
|
Graphics2D g2 = (Graphics2D)g; |
1045 |
|
|
|
1046 |
|
|
Paint oldPaint = g2.getPaint(); |
1047 |
|
|
Composite oldComposite = g2.getComposite(); |
1048 |
|
|
|
1049 |
|
|
double h = getSize().getHeight(); |
1050 |
|
|
double w = getSize().getWidth(); |
1051 |
|
|
|
1052 |
|
|
FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false); |
1053 |
|
|
paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2); |
1054 |
|
|
|
1055 |
|
|
g2.setPaint(oldPaint); |
1056 |
|
|
g2.setComposite(oldComposite); |
1057 |
|
|
} |
1058 |
|
|
} |
1059 |
|
|
|
1060 |
|
|
class BottomPane extends FantasiaPanel { |
1061 |
|
|
BottomPane() { |
1062 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
1063 |
|
|
setOpaque(false); |
1064 |
|
|
add(pianoKeyboardPane); |
1065 |
|
|
|
1066 |
|
|
} |
1067 |
|
|
} |
1068 |
iliev |
912 |
} |