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