1 |
iliev |
787 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
1204 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
787 |
* |
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.classic; |
24 |
|
|
|
25 |
|
|
import java.awt.BorderLayout; |
26 |
iliev |
911 |
import java.awt.Color; |
27 |
iliev |
1204 |
import java.awt.Dialog; |
28 |
iliev |
787 |
import java.awt.Dimension; |
29 |
iliev |
1204 |
import java.awt.Frame; |
30 |
iliev |
787 |
|
31 |
|
|
import java.awt.event.ActionEvent; |
32 |
|
|
import java.awt.event.ActionListener; |
33 |
|
|
import java.awt.event.KeyEvent; |
34 |
|
|
|
35 |
iliev |
911 |
import java.io.BufferedReader; |
36 |
|
|
import java.io.File; |
37 |
|
|
import java.io.FileNotFoundException; |
38 |
|
|
import java.io.FileReader; |
39 |
|
|
import java.io.StringReader; |
40 |
|
|
|
41 |
iliev |
842 |
import java.util.logging.Level; |
42 |
iliev |
787 |
import java.util.Vector; |
43 |
|
|
|
44 |
|
|
import javax.swing.Action; |
45 |
|
|
import javax.swing.ImageIcon; |
46 |
|
|
import javax.swing.JCheckBoxMenuItem; |
47 |
iliev |
911 |
import javax.swing.JFileChooser; |
48 |
iliev |
787 |
import javax.swing.JMenu; |
49 |
|
|
import javax.swing.JMenuBar; |
50 |
|
|
import javax.swing.JMenuItem; |
51 |
|
|
import javax.swing.JPanel; |
52 |
|
|
import javax.swing.JSplitPane; |
53 |
|
|
import javax.swing.JTabbedPane; |
54 |
|
|
import javax.swing.KeyStroke; |
55 |
|
|
|
56 |
|
|
import javax.swing.event.ChangeEvent; |
57 |
|
|
import javax.swing.event.ChangeListener; |
58 |
|
|
import javax.swing.event.ListSelectionEvent; |
59 |
|
|
import javax.swing.event.ListSelectionListener; |
60 |
|
|
|
61 |
|
|
import net.sf.juife.NavigationPage; |
62 |
|
|
import net.sf.juife.NavigationPane; |
63 |
|
|
|
64 |
|
|
import org.jsampler.CC; |
65 |
iliev |
911 |
import org.jsampler.HF; |
66 |
|
|
import org.jsampler.LSConsoleModel; |
67 |
|
|
import org.jsampler.OrchestraModel; |
68 |
iliev |
842 |
import org.jsampler.Prefs; |
69 |
iliev |
1688 |
import org.jsampler.Server; |
70 |
iliev |
787 |
|
71 |
|
|
import org.jsampler.view.JSChannel; |
72 |
|
|
import org.jsampler.view.JSChannelsPane; |
73 |
iliev |
911 |
import org.jsampler.view.LscpFileFilter; |
74 |
iliev |
787 |
|
75 |
iliev |
1688 |
import org.jsampler.view.std.JSConnectDlg; |
76 |
iliev |
1355 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
77 |
iliev |
1567 |
import org.jsampler.view.std.JSQuitDlg; |
78 |
iliev |
1285 |
import org.jsampler.view.std.JSamplerHomeChooser; |
79 |
|
|
|
80 |
|
|
import static org.jsampler.view.classic.A4n.a4n; |
81 |
iliev |
787 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
82 |
iliev |
1285 |
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
83 |
iliev |
787 |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
84 |
iliev |
1285 |
import static org.jsampler.view.std.StdPrefs.*; |
85 |
iliev |
787 |
|
86 |
|
|
/** |
87 |
|
|
* |
88 |
|
|
* @author Grigor Iliev |
89 |
|
|
*/ |
90 |
|
|
public class |
91 |
|
|
MainFrame extends org.jsampler.view.JSMainFrame implements ChangeListener, ListSelectionListener { |
92 |
iliev |
1204 |
public static ImageIcon applicationIcon = Res.appIcon; |
93 |
iliev |
787 |
|
94 |
iliev |
1143 |
private final ChannelsBar channelsBar = new ChannelsBar(); |
95 |
iliev |
787 |
private final Statusbar statusbar = new Statusbar(); |
96 |
|
|
private final JMenuBar menuBar = new JMenuBar(); |
97 |
iliev |
911 |
private final JMenu recentScriptsMenu = |
98 |
|
|
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
99 |
|
|
private final JMenu tabsMenu = new JMenu(i18n.getMenuLabel("channels.MoveToTab")); |
100 |
iliev |
787 |
|
101 |
iliev |
911 |
private final JSplitPane vSplitPane; |
102 |
|
|
private final JSplitPane hSplitPane; |
103 |
iliev |
787 |
|
104 |
|
|
private final JPanel mainPane = new JPanel(); |
105 |
iliev |
1143 |
private final StandardBar standardBar = new StandardBar(); |
106 |
iliev |
787 |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
107 |
iliev |
911 |
private final JPanel rightPane = new JPanel(); |
108 |
|
|
private final JPanel bottomPane = new JPanel(); |
109 |
|
|
private final LSConsolePane lsConsolePane = new LSConsolePane(this); |
110 |
|
|
private LSConsoleDlg lsConsoleDlg = null; |
111 |
iliev |
787 |
|
112 |
|
|
private final JTabbedPane tabbedPane = |
113 |
|
|
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
114 |
|
|
private final Vector<JMenuItem> miList = new Vector<JMenuItem>(); |
115 |
|
|
|
116 |
iliev |
911 |
private final JCheckBoxMenuItem cbmiLeftPaneVisible = |
117 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
118 |
|
|
|
119 |
iliev |
1143 |
private final JCheckBoxMenuItem cbmiStandardBarVisible = |
120 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.standard")); |
121 |
|
|
|
122 |
iliev |
911 |
private final JCheckBoxMenuItem cbmiLSConsoleShown = |
123 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.lsconsole")); |
124 |
|
|
|
125 |
|
|
private boolean lsConsolePopOut; |
126 |
|
|
|
127 |
|
|
private final Vector<String> recentScripts = new Vector<String>(); |
128 |
|
|
|
129 |
|
|
|
130 |
iliev |
1143 |
/** Creates a new instance of <code>MainFrame</code>. */ |
131 |
iliev |
787 |
public |
132 |
|
|
MainFrame() { |
133 |
|
|
setTitle(i18n.getLabel("MainFrame.title")); |
134 |
|
|
|
135 |
iliev |
1143 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
136 |
iliev |
787 |
getContentPane().add(mainPane); |
137 |
|
|
|
138 |
|
|
mainPane.setLayout(new BorderLayout()); |
139 |
|
|
mainPane.add(statusbar, BorderLayout.SOUTH); |
140 |
|
|
|
141 |
|
|
ChannelsPane p = new ChannelsPane("Untitled"); |
142 |
|
|
p.addListSelectionListener(this); |
143 |
|
|
getChannelsPaneList().add(p); |
144 |
|
|
miList.add(new JMenuItem(new A4n.MoveChannelsTo(p))); |
145 |
|
|
|
146 |
|
|
channelsPane.add(getChannelsPane(0)); |
147 |
|
|
|
148 |
iliev |
911 |
bottomPane.setLayout(new BorderLayout()); |
149 |
|
|
|
150 |
|
|
rightPane.setLayout(new BorderLayout()); |
151 |
iliev |
1143 |
|
152 |
|
|
rightPane.add(channelsBar, BorderLayout.NORTH); |
153 |
iliev |
911 |
rightPane.add(channelsPane); |
154 |
|
|
|
155 |
|
|
hSplitPane = new JSplitPane ( |
156 |
iliev |
787 |
JSplitPane.HORIZONTAL_SPLIT, |
157 |
|
|
true, // continuousLayout |
158 |
|
|
getLeftPane(), |
159 |
iliev |
911 |
rightPane |
160 |
iliev |
787 |
); |
161 |
|
|
|
162 |
iliev |
911 |
hSplitPane.setOneTouchExpandable(true); |
163 |
|
|
if(ClassicPrefs.getSaveWindowProperties()) { |
164 |
|
|
hSplitPane.setDividerLocation(ClassicPrefs.getHSplitDividerLocation()); |
165 |
|
|
} |
166 |
iliev |
787 |
|
167 |
iliev |
911 |
mainPane.add(hSplitPane); |
168 |
iliev |
787 |
|
169 |
iliev |
911 |
|
170 |
|
|
vSplitPane = new JSplitPane ( |
171 |
|
|
JSplitPane.VERTICAL_SPLIT, |
172 |
|
|
true, // continuousLayout |
173 |
|
|
channelsPane, |
174 |
|
|
bottomPane |
175 |
|
|
); |
176 |
|
|
|
177 |
|
|
vSplitPane.setDividerSize(3); |
178 |
|
|
vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation()); |
179 |
|
|
|
180 |
|
|
rightPane.add(vSplitPane); |
181 |
|
|
|
182 |
iliev |
787 |
if(applicationIcon != null) setIconImage(applicationIcon.getImage()); |
183 |
|
|
|
184 |
iliev |
842 |
initMainFrame(); |
185 |
iliev |
911 |
|
186 |
iliev |
787 |
pack(); |
187 |
|
|
|
188 |
iliev |
911 |
if(ClassicPrefs.getSaveWindowProperties()) setSavedSize(); |
189 |
iliev |
842 |
else setDefaultSize(); |
190 |
iliev |
911 |
|
191 |
|
|
if(ClassicPrefs.getSaveLeftPaneState()) { |
192 |
|
|
NavigationPage page = |
193 |
|
|
getLeftPane().getPages()[ClassicPrefs.getLeftPanePageIndex()]; |
194 |
|
|
|
195 |
|
|
getLeftPane().getModel().addPage(page); |
196 |
|
|
getLeftPane().getModel().clearHistory(); |
197 |
|
|
|
198 |
|
|
int idx = ClassicPrefs.getCurrentOrchestraIndex(); |
199 |
|
|
if(idx >= 0 && idx < CC.getOrchestras().getOrchestraCount()) { |
200 |
|
|
OrchestraModel om = CC.getOrchestras().getOrchestra(idx); |
201 |
|
|
getLeftPane().getOrchestrasPage().setSelectedOrchestra(om); |
202 |
|
|
} |
203 |
|
|
} |
204 |
iliev |
1204 |
|
205 |
|
|
//CC.getInstrumentsDbTreeModel(); // used to initialize the db tree model |
206 |
iliev |
842 |
} |
207 |
|
|
|
208 |
iliev |
911 |
/** Invoked when this window is about to close. */ |
209 |
|
|
protected void |
210 |
|
|
onWindowClose() { |
211 |
iliev |
1688 |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
212 |
|
|
if(b && CC.getSamplerModel().isModified()) { |
213 |
iliev |
1567 |
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
214 |
|
|
dlg.setVisible(true); |
215 |
|
|
if(dlg.isCancelled()) return; |
216 |
|
|
} |
217 |
|
|
|
218 |
iliev |
911 |
if(ClassicPrefs.getSaveWindowProperties()) { |
219 |
|
|
ClassicPrefs.setWindowMaximized ( |
220 |
iliev |
1204 |
"Mainframe", (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
221 |
iliev |
911 |
); |
222 |
|
|
|
223 |
|
|
setVisible(false); |
224 |
iliev |
1204 |
if(ClassicPrefs.getWindowMaximized("Mainframe")) { |
225 |
iliev |
911 |
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
226 |
|
|
CC.cleanExit(); |
227 |
|
|
return; |
228 |
|
|
} |
229 |
|
|
|
230 |
|
|
java.awt.Point p = getLocation(); |
231 |
|
|
Dimension d = getSize(); |
232 |
|
|
StringBuffer sb = new StringBuffer(); |
233 |
|
|
sb.append(p.x).append(',').append(p.y).append(','); |
234 |
|
|
sb.append(d.width).append(',').append(d.height); |
235 |
iliev |
1204 |
ClassicPrefs.setWindowSizeAndLocation("Mainframe", sb.toString()); |
236 |
iliev |
911 |
|
237 |
|
|
ClassicPrefs.setHSplitDividerLocation(hSplitPane.getDividerLocation()); |
238 |
|
|
} |
239 |
|
|
|
240 |
|
|
if(ClassicPrefs.getSaveLeftPaneState()) { |
241 |
|
|
int idx = 0; |
242 |
|
|
for(int i = 0; i < getLeftPane().getPages().length; i++) { |
243 |
|
|
if(getLeftPane().getPages()[i] == getLeftPane().getCurrentPage()) { |
244 |
|
|
idx = i; |
245 |
|
|
break; |
246 |
|
|
} |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
ClassicPrefs.setLeftPanePageIndex(idx); |
250 |
|
|
|
251 |
|
|
idx = getLeftPane().getOrchestrasPage().getCurrentOrchestraIndex(); |
252 |
|
|
|
253 |
|
|
if(idx >= 0 && idx < CC.getOrchestras().getOrchestraCount()) |
254 |
|
|
ClassicPrefs.setCurrentOrchestraIndex(idx); |
255 |
|
|
} |
256 |
|
|
|
257 |
iliev |
1327 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
258 |
|
|
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
259 |
iliev |
911 |
|
260 |
iliev |
1285 |
if(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY)) { |
261 |
|
|
lsConsolePane.saveConsoleHistory(); |
262 |
|
|
} |
263 |
iliev |
911 |
|
264 |
|
|
ClassicPrefs.setShowLSConsole(isLSConsoleShown()); |
265 |
|
|
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
266 |
|
|
|
267 |
|
|
ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
268 |
|
|
super.onWindowClose(); |
269 |
|
|
} |
270 |
|
|
|
271 |
iliev |
842 |
private void |
272 |
|
|
initMainFrame() { |
273 |
|
|
addMenu(); |
274 |
|
|
handleEvents(); |
275 |
|
|
} |
276 |
|
|
|
277 |
|
|
private void |
278 |
|
|
setDefaultSize() { |
279 |
iliev |
787 |
Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); |
280 |
|
|
double width = dimension.getWidth(); |
281 |
|
|
double height = dimension.getHeight(); |
282 |
|
|
setBounds(50, 100, (int) width - 100, (int) height - 200); |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
private void |
286 |
iliev |
842 |
setSavedSize() { |
287 |
iliev |
1204 |
String s = ClassicPrefs.getWindowSizeAndLocation("Mainframe"); |
288 |
iliev |
842 |
if(s == null) { |
289 |
|
|
setDefaultSize(); |
290 |
|
|
return; |
291 |
|
|
} |
292 |
|
|
|
293 |
|
|
try { |
294 |
|
|
int i = s.indexOf(','); |
295 |
|
|
int x = Integer.parseInt(s.substring(0, i)); |
296 |
|
|
|
297 |
|
|
s = s.substring(i + 1); |
298 |
|
|
i = s.indexOf(','); |
299 |
|
|
int y = Integer.parseInt(s.substring(0, i)); |
300 |
|
|
|
301 |
|
|
s = s.substring(i + 1); |
302 |
|
|
i = s.indexOf(','); |
303 |
|
|
int width = Integer.parseInt(s.substring(0, i)); |
304 |
|
|
|
305 |
|
|
s = s.substring(i + 1); |
306 |
|
|
int height = Integer.parseInt(s); |
307 |
|
|
|
308 |
|
|
setBounds(x, y, width, height); |
309 |
|
|
} catch(Exception x) { |
310 |
|
|
String msg = "Parsing of window size and location string failed"; |
311 |
|
|
CC.getLogger().log(Level.INFO, msg, x); |
312 |
|
|
setDefaultSize(); |
313 |
|
|
} |
314 |
|
|
|
315 |
iliev |
1204 |
if(ClassicPrefs.getWindowMaximized("Mainframe")) |
316 |
iliev |
842 |
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
317 |
iliev |
787 |
} |
318 |
|
|
|
319 |
|
|
private void |
320 |
|
|
addMenu() { |
321 |
|
|
JMenu m; |
322 |
|
|
JMenuItem mi; |
323 |
|
|
|
324 |
|
|
setJMenuBar(menuBar); |
325 |
|
|
|
326 |
|
|
// Actions |
327 |
|
|
m = new JMenu(i18n.getMenuLabel("actions")); |
328 |
|
|
menuBar.add(m); |
329 |
|
|
|
330 |
iliev |
1285 |
mi = new JMenuItem(a4n.refresh); |
331 |
iliev |
787 |
mi.setIcon(null); |
332 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
333 |
|
|
m.add(mi); |
334 |
|
|
|
335 |
iliev |
1688 |
mi = new JMenuItem(A4n.samplerInfo); |
336 |
iliev |
787 |
mi.setIcon(null); |
337 |
|
|
m.add(mi); |
338 |
|
|
|
339 |
iliev |
1688 |
mi = new JMenuItem(a4n.resetSampler); |
340 |
iliev |
787 |
mi.setIcon(null); |
341 |
|
|
m.add(mi); |
342 |
|
|
|
343 |
iliev |
1143 |
JMenu midiInstrMenu = new JMenu(i18n.getMenuLabel("actions.midiInstruments")); |
344 |
|
|
m.add(midiInstrMenu); |
345 |
|
|
|
346 |
|
|
mi = new JMenuItem(A4n.addMidiInstrumentMap); |
347 |
|
|
mi.setIcon(null); |
348 |
|
|
midiInstrMenu.add(mi); |
349 |
|
|
|
350 |
|
|
mi = new JMenuItem(A4n.removeMidiInstrumentMap); |
351 |
|
|
mi.setIcon(null); |
352 |
|
|
midiInstrMenu.add(mi); |
353 |
|
|
|
354 |
|
|
mi = new JMenuItem(A4n.addMidiInstrumentWizard); |
355 |
|
|
mi.setIcon(null); |
356 |
|
|
midiInstrMenu.add(mi); |
357 |
|
|
|
358 |
iliev |
787 |
m.addSeparator(); |
359 |
|
|
|
360 |
iliev |
1143 |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
361 |
|
|
m.add(exportMenu); |
362 |
|
|
|
363 |
iliev |
1285 |
mi = new JMenuItem(a4n.exportSamplerConfig); |
364 |
iliev |
1143 |
mi.setIcon(null); |
365 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
366 |
|
|
exportMenu.add(mi); |
367 |
|
|
|
368 |
iliev |
1285 |
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
369 |
iliev |
1143 |
mi.setIcon(null); |
370 |
|
|
exportMenu.add(mi); |
371 |
|
|
|
372 |
|
|
m.addSeparator(); |
373 |
|
|
|
374 |
|
|
mi = new JMenuItem(A4n.loadScript); |
375 |
iliev |
1688 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)); |
376 |
iliev |
1143 |
mi.setIcon(null); |
377 |
iliev |
911 |
m.add(mi); |
378 |
|
|
|
379 |
iliev |
1327 |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
380 |
|
|
for(String s : list) recentScripts.add(s); |
381 |
iliev |
911 |
|
382 |
|
|
updateRecentScriptsMenu(); |
383 |
|
|
|
384 |
|
|
m.add(recentScriptsMenu); |
385 |
|
|
|
386 |
|
|
m.addSeparator(); |
387 |
|
|
|
388 |
iliev |
1688 |
mi = new JMenuItem(a4n.changeBackend); |
389 |
|
|
mi.setIcon(null); |
390 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)); |
391 |
|
|
m.add(mi); |
392 |
|
|
|
393 |
|
|
m.addSeparator(); |
394 |
|
|
|
395 |
iliev |
787 |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
396 |
|
|
m.add(mi); |
397 |
|
|
mi.addActionListener(new ActionListener() { |
398 |
|
|
public void |
399 |
iliev |
1285 |
actionPerformed(ActionEvent e) { onWindowClose(); } |
400 |
iliev |
787 |
}); |
401 |
|
|
|
402 |
|
|
// Edit |
403 |
|
|
m = new JMenu(i18n.getMenuLabel("edit")); |
404 |
|
|
menuBar.add(m); |
405 |
|
|
|
406 |
iliev |
911 |
mi = new JMenuItem(i18n.getMenuLabel("edit.audioDevices")); |
407 |
|
|
m.add(mi); |
408 |
|
|
mi.addActionListener(new ActionListener() { |
409 |
|
|
public void |
410 |
|
|
actionPerformed(ActionEvent e) { |
411 |
|
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
412 |
|
|
LeftPane.getLeftPane().showAudioDevicesPage(); |
413 |
|
|
} |
414 |
|
|
}); |
415 |
|
|
|
416 |
|
|
mi = new JMenuItem(i18n.getMenuLabel("edit.midiDevices")); |
417 |
|
|
m.add(mi); |
418 |
|
|
mi.addActionListener(new ActionListener() { |
419 |
|
|
public void |
420 |
|
|
actionPerformed(ActionEvent e) { |
421 |
|
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
422 |
|
|
LeftPane.getLeftPane().showMidiDevicesPage(); |
423 |
|
|
} |
424 |
|
|
}); |
425 |
|
|
|
426 |
|
|
mi = new JMenuItem(i18n.getMenuLabel("edit.orchestras")); |
427 |
|
|
m.add(mi); |
428 |
|
|
mi.addActionListener(new ActionListener() { |
429 |
|
|
public void |
430 |
|
|
actionPerformed(ActionEvent e) { |
431 |
|
|
if(!isLeftPaneVisible()) cbmiLeftPaneVisible.doClick(0); |
432 |
|
|
LeftPane.getLeftPane().showManageOrchestrasPage(); |
433 |
|
|
} |
434 |
|
|
}); |
435 |
|
|
|
436 |
iliev |
787 |
m.addSeparator(); |
437 |
|
|
|
438 |
|
|
mi = new JMenuItem(A4n.preferences); |
439 |
|
|
mi.setIcon(null); |
440 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
441 |
|
|
KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
442 |
|
|
)); |
443 |
|
|
m.add(mi); |
444 |
|
|
|
445 |
|
|
// View |
446 |
|
|
m = new JMenu(i18n.getMenuLabel("view")); |
447 |
|
|
menuBar.add(m); |
448 |
|
|
|
449 |
iliev |
1143 |
JMenu toolbarsMenu = new JMenu(i18n.getMenuLabel("view.toolbars")); |
450 |
|
|
m.add(toolbarsMenu); |
451 |
|
|
|
452 |
|
|
toolbarsMenu.add(cbmiStandardBarVisible); |
453 |
|
|
cbmiStandardBarVisible.addActionListener(new ActionListener() { |
454 |
|
|
public void |
455 |
|
|
actionPerformed(ActionEvent e) { |
456 |
|
|
showStandardBar(cbmiStandardBarVisible.getState()); |
457 |
|
|
} |
458 |
|
|
}); |
459 |
|
|
|
460 |
|
|
boolean b = ClassicPrefs.shouldShowStandardBar(); |
461 |
|
|
cbmiStandardBarVisible.setSelected(b); |
462 |
|
|
showStandardBar(b); |
463 |
|
|
|
464 |
iliev |
787 |
final JCheckBoxMenuItem cbmi = |
465 |
iliev |
1143 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.channels")); |
466 |
iliev |
787 |
|
467 |
iliev |
1143 |
toolbarsMenu.add(cbmi); |
468 |
iliev |
787 |
cbmi.addActionListener(new ActionListener() { |
469 |
|
|
public void |
470 |
iliev |
1143 |
actionPerformed(ActionEvent e) { showChannelsBar(cbmi.getState()); } |
471 |
iliev |
787 |
}); |
472 |
|
|
|
473 |
iliev |
1143 |
b = ClassicPrefs.shouldShowChannelsBar(); |
474 |
iliev |
842 |
cbmi.setSelected(b); |
475 |
iliev |
1143 |
showChannelsBar(b); |
476 |
iliev |
842 |
|
477 |
iliev |
911 |
m.add(cbmiLeftPaneVisible); |
478 |
|
|
cbmiLeftPaneVisible.addActionListener(new ActionListener() { |
479 |
iliev |
787 |
public void |
480 |
iliev |
911 |
actionPerformed(ActionEvent e) { |
481 |
|
|
showLeftPane(cbmiLeftPaneVisible.getState()); |
482 |
|
|
} |
483 |
iliev |
787 |
}); |
484 |
|
|
|
485 |
iliev |
842 |
b = ClassicPrefs.shouldShowLeftPane(); |
486 |
iliev |
911 |
cbmiLeftPaneVisible.setSelected(b); |
487 |
iliev |
842 |
showLeftPane(b); |
488 |
|
|
|
489 |
iliev |
787 |
final JCheckBoxMenuItem cbmi2 = |
490 |
|
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.statusbar")); |
491 |
|
|
|
492 |
|
|
m.add(cbmi2); |
493 |
|
|
cbmi2.addActionListener(new ActionListener() { |
494 |
|
|
public void |
495 |
iliev |
842 |
actionPerformed(ActionEvent e) { showStatusbar(cbmi2.getState()); } |
496 |
iliev |
787 |
}); |
497 |
iliev |
842 |
b = ClassicPrefs.shouldShowStatusbar(); |
498 |
|
|
cbmi2.setSelected(b); |
499 |
|
|
showStatusbar(b); |
500 |
iliev |
787 |
|
501 |
iliev |
911 |
m.addSeparator(); |
502 |
|
|
|
503 |
|
|
setLSConsolePopOut(ClassicPrefs.isLSConsolePopOut()); |
504 |
|
|
cbmiLSConsoleShown.setSelected(ClassicPrefs.shouldShowLSConsole()); |
505 |
|
|
showLSConsole(ClassicPrefs.shouldShowLSConsole()); |
506 |
|
|
|
507 |
|
|
cbmiLSConsoleShown.addActionListener(new ActionListener() { |
508 |
|
|
public void |
509 |
|
|
actionPerformed(ActionEvent e) { |
510 |
|
|
showLSConsole(cbmiLSConsoleShown.isSelected()); |
511 |
|
|
} |
512 |
|
|
}); |
513 |
|
|
m.add(cbmiLSConsoleShown); |
514 |
|
|
|
515 |
|
|
lsConsolePane.updateLSConsoleViewMode(); |
516 |
|
|
|
517 |
iliev |
787 |
// Channels |
518 |
|
|
m = new JMenu(i18n.getMenuLabel("channels")); |
519 |
|
|
menuBar.add(m); |
520 |
|
|
|
521 |
|
|
mi = new JMenuItem(A4n.newChannel); |
522 |
|
|
mi.setIcon(null); |
523 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); |
524 |
|
|
m.add(mi); |
525 |
|
|
|
526 |
|
|
mi = new JMenuItem(A4n.newChannelWizard); |
527 |
|
|
mi.setIcon(null); |
528 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
529 |
|
|
KeyEvent.VK_N, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK) |
530 |
|
|
); |
531 |
|
|
m.add(mi); |
532 |
|
|
|
533 |
|
|
mi = new JMenuItem(A4n.duplicateChannels); |
534 |
|
|
mi.setIcon(null); |
535 |
|
|
m.add(mi); |
536 |
|
|
|
537 |
|
|
m.addSeparator(); |
538 |
|
|
|
539 |
|
|
mi = new JMenuItem(A4n.moveChannelsOnTop); |
540 |
|
|
mi.setIcon(null); |
541 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
542 |
|
|
KeyEvent.VK_UP, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK |
543 |
|
|
)); |
544 |
|
|
m.add(mi); |
545 |
|
|
|
546 |
|
|
mi = new JMenuItem(A4n.moveChannelsUp); |
547 |
|
|
mi.setIcon(null); |
548 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK)); |
549 |
|
|
m.add(mi); |
550 |
|
|
|
551 |
|
|
mi = new JMenuItem(A4n.moveChannelsDown); |
552 |
|
|
mi.setIcon(null); |
553 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.ALT_MASK)); |
554 |
|
|
m.add(mi); |
555 |
|
|
|
556 |
|
|
mi = new JMenuItem(A4n.moveChannelsAtBottom); |
557 |
|
|
mi.setIcon(null); |
558 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
559 |
|
|
KeyEvent.VK_DOWN, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK |
560 |
|
|
)); |
561 |
|
|
m.add(mi); |
562 |
|
|
|
563 |
|
|
tabsMenu.setEnabled(false); |
564 |
|
|
m.add(tabsMenu); |
565 |
|
|
|
566 |
|
|
m.addSeparator(); |
567 |
|
|
|
568 |
|
|
mi = new JMenuItem(A4n.selectAllChannels); |
569 |
|
|
mi.setIcon(null); |
570 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)); |
571 |
|
|
m.add(mi); |
572 |
|
|
|
573 |
|
|
mi = new JMenuItem(A4n.deselectChannels); |
574 |
|
|
mi.setIcon(null); |
575 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
576 |
|
|
KeyEvent.VK_A, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
577 |
|
|
)); |
578 |
|
|
m.add(mi); |
579 |
|
|
|
580 |
|
|
m.addSeparator(); |
581 |
|
|
|
582 |
|
|
mi = new JMenuItem(A4n.removeChannels); |
583 |
|
|
mi.setIcon(null); |
584 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.SHIFT_MASK)); |
585 |
|
|
m.add(mi); |
586 |
|
|
|
587 |
|
|
|
588 |
|
|
// Tabs |
589 |
|
|
m = new JMenu(i18n.getMenuLabel("tabs")); |
590 |
|
|
menuBar.add(m); |
591 |
|
|
|
592 |
|
|
mi = new JMenuItem(A4n.newChannelsTab); |
593 |
|
|
mi.setIcon(null); |
594 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK)); |
595 |
|
|
m.add(mi); |
596 |
|
|
|
597 |
|
|
mi = new JMenuItem(A4n.editTabTitle); |
598 |
|
|
mi.setIcon(null); |
599 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); |
600 |
|
|
m.add(mi); |
601 |
|
|
|
602 |
|
|
m.addSeparator(); |
603 |
|
|
|
604 |
|
|
mi = new JMenuItem(A4n.moveTab2Beginning); |
605 |
|
|
mi.setIcon(null); |
606 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
607 |
|
|
KeyEvent.VK_LEFT, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK |
608 |
|
|
)); |
609 |
|
|
m.add(mi); |
610 |
|
|
|
611 |
|
|
mi = new JMenuItem(A4n.moveTab2Left); |
612 |
|
|
mi.setIcon(null); |
613 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK)); |
614 |
|
|
m.add(mi); |
615 |
|
|
|
616 |
|
|
mi = new JMenuItem(A4n.moveTab2Right); |
617 |
|
|
mi.setIcon(null); |
618 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK)); |
619 |
|
|
m.add(mi); |
620 |
|
|
|
621 |
|
|
mi = new JMenuItem(A4n.moveTab2End); |
622 |
|
|
mi.setIcon(null); |
623 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
624 |
|
|
KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK |
625 |
|
|
)); |
626 |
|
|
m.add(mi); |
627 |
|
|
|
628 |
|
|
m.addSeparator(); |
629 |
|
|
|
630 |
|
|
mi = new JMenuItem(A4n.closeChannelsTab); |
631 |
|
|
mi.setIcon(null); |
632 |
|
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK)); |
633 |
|
|
m.add(mi); |
634 |
|
|
|
635 |
|
|
|
636 |
iliev |
1204 |
// Window |
637 |
|
|
m = new JMenu(i18n.getMenuLabel("window")); |
638 |
|
|
menuBar.add(m); |
639 |
|
|
|
640 |
|
|
mi = new JMenuItem(A4n.windowInstrumentsDb); |
641 |
|
|
mi.setIcon(null); |
642 |
|
|
m.add(mi); |
643 |
|
|
|
644 |
|
|
|
645 |
iliev |
787 |
// Help |
646 |
|
|
m = new JMenu(i18n.getMenuLabel("help")); |
647 |
|
|
|
648 |
|
|
mi = new JMenuItem(A4n.helpAbout); |
649 |
|
|
mi.setIcon(null); |
650 |
|
|
m.add(mi); |
651 |
iliev |
1496 |
|
652 |
|
|
m.addSeparator(); |
653 |
|
|
|
654 |
|
|
mi = new JMenuItem(a4n.browseOnlineTutorial); |
655 |
|
|
mi.setIcon(null); |
656 |
|
|
m.add(mi); |
657 |
|
|
|
658 |
|
|
menuBar.add(m); |
659 |
iliev |
787 |
} |
660 |
|
|
|
661 |
iliev |
911 |
private class RecentScriptHandler implements ActionListener { |
662 |
|
|
private String script; |
663 |
|
|
|
664 |
|
|
RecentScriptHandler(String script) { this.script = script; } |
665 |
|
|
|
666 |
|
|
public void |
667 |
|
|
actionPerformed(ActionEvent e) { runScript(script); } |
668 |
|
|
} |
669 |
|
|
|
670 |
iliev |
787 |
private void |
671 |
iliev |
842 |
handleEvents() { |
672 |
|
|
tabbedPane.addChangeListener(this); |
673 |
|
|
} |
674 |
|
|
|
675 |
|
|
private void |
676 |
iliev |
1143 |
showChannelsBar(boolean b) { |
677 |
|
|
channelsBar.setVisible(b); |
678 |
|
|
ClassicPrefs.setShowChannelsBar(b); |
679 |
iliev |
842 |
|
680 |
|
|
validate(); |
681 |
|
|
repaint(); |
682 |
|
|
} |
683 |
|
|
|
684 |
|
|
private void |
685 |
|
|
showStatusbar(boolean b) { |
686 |
|
|
ClassicPrefs.setShowStatusbar(b); |
687 |
|
|
statusbar.setVisible(b); |
688 |
|
|
} |
689 |
|
|
|
690 |
iliev |
911 |
protected boolean |
691 |
|
|
isLeftPaneVisible() { return cbmiLeftPaneVisible.isSelected(); } |
692 |
|
|
|
693 |
|
|
protected void |
694 |
|
|
setLeftPaneVisible(boolean b) { |
695 |
|
|
if(b != cbmiLeftPaneVisible.isSelected()) cbmiLeftPaneVisible.doClick(0); |
696 |
|
|
} |
697 |
|
|
|
698 |
|
|
protected boolean |
699 |
|
|
isLSConsoleVisible() { return cbmiLSConsoleShown.isSelected(); } |
700 |
|
|
|
701 |
|
|
protected void |
702 |
|
|
setLSConsoleVisible(boolean b) { |
703 |
|
|
if(b != cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0); |
704 |
|
|
} |
705 |
|
|
|
706 |
iliev |
842 |
private void |
707 |
iliev |
787 |
showLeftPane(boolean b) { |
708 |
iliev |
842 |
ClassicPrefs.setShowLeftPane(b); |
709 |
|
|
|
710 |
iliev |
911 |
mainPane.remove(hSplitPane); |
711 |
|
|
mainPane.remove(rightPane); |
712 |
iliev |
787 |
|
713 |
|
|
if(b) { |
714 |
iliev |
911 |
hSplitPane.setRightComponent(rightPane); |
715 |
|
|
mainPane.add(hSplitPane); |
716 |
|
|
if(ClassicPrefs.getSaveWindowProperties()) { |
717 |
|
|
int i = ClassicPrefs.getHSplitDividerLocation(); |
718 |
|
|
hSplitPane.setDividerLocation(i); |
719 |
|
|
} |
720 |
iliev |
787 |
} else { |
721 |
iliev |
911 |
mainPane.add(rightPane); |
722 |
iliev |
787 |
} |
723 |
|
|
|
724 |
|
|
validate(); |
725 |
|
|
repaint(); |
726 |
|
|
} |
727 |
|
|
|
728 |
iliev |
911 |
private void |
729 |
iliev |
1143 |
showStandardBar(boolean b) { |
730 |
|
|
ClassicPrefs.setShowStandardBar(b); |
731 |
|
|
standardBar.setVisible(b); |
732 |
|
|
validate(); |
733 |
|
|
repaint(); |
734 |
|
|
} |
735 |
|
|
|
736 |
|
|
private void |
737 |
iliev |
911 |
showBottomPane(boolean b) { |
738 |
|
|
if(!b) ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
739 |
|
|
|
740 |
|
|
rightPane.remove(vSplitPane); |
741 |
|
|
rightPane.remove(channelsPane); |
742 |
|
|
|
743 |
|
|
if(b) { |
744 |
|
|
vSplitPane.setTopComponent(channelsPane); |
745 |
|
|
rightPane.add(vSplitPane); |
746 |
|
|
vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation()); |
747 |
|
|
} else { |
748 |
|
|
rightPane.add(channelsPane); |
749 |
|
|
} |
750 |
|
|
|
751 |
|
|
validate(); |
752 |
|
|
repaint(); |
753 |
|
|
} |
754 |
|
|
|
755 |
|
|
protected void |
756 |
|
|
setLSConsolePopOut(boolean b) { |
757 |
|
|
if(b == lsConsolePopOut) return; |
758 |
|
|
|
759 |
|
|
lsConsolePopOut = b; |
760 |
|
|
|
761 |
|
|
if(isLSConsoleShown()) setLSConsolePopOut0(b); |
762 |
|
|
} |
763 |
|
|
|
764 |
|
|
/** |
765 |
|
|
* Changes the pop-out state of the LS Console. |
766 |
|
|
* Invoke this method only when LS Console is shown. |
767 |
|
|
*/ |
768 |
|
|
private void |
769 |
|
|
setLSConsolePopOut0(boolean b) { |
770 |
|
|
if(b) { |
771 |
|
|
bottomPane.remove(lsConsolePane); |
772 |
|
|
showBottomPane(false); |
773 |
|
|
|
774 |
|
|
lsConsoleDlg = new LSConsoleDlg(this, lsConsolePane); |
775 |
|
|
lsConsoleDlg.setVisible(true); |
776 |
|
|
} else { |
777 |
|
|
if(lsConsoleDlg != null) lsConsoleDlg.setVisible(false); |
778 |
|
|
lsConsoleDlg = null; |
779 |
|
|
bottomPane.add(lsConsolePane); |
780 |
|
|
showBottomPane(true); |
781 |
|
|
} |
782 |
|
|
} |
783 |
|
|
|
784 |
|
|
protected boolean |
785 |
|
|
isLSConsolePopOut() { return lsConsolePopOut; } |
786 |
|
|
|
787 |
|
|
protected boolean |
788 |
|
|
isLSConsoleShown() { return cbmiLSConsoleShown.isSelected(); } |
789 |
|
|
|
790 |
|
|
protected void |
791 |
|
|
setLSConsoleShown(boolean b) { cbmiLSConsoleShown.setSelected(b); } |
792 |
|
|
|
793 |
|
|
protected LSConsoleModel |
794 |
|
|
getLSConsoleModel() { return lsConsolePane.getModel(); } |
795 |
|
|
|
796 |
|
|
/** |
797 |
|
|
* Sets the text color of the LS Console. |
798 |
|
|
* @param c The text color of the LS Console. |
799 |
|
|
*/ |
800 |
|
|
protected void |
801 |
|
|
setLSConsoleTextColor(Color c) { lsConsolePane.setTextColor(c); } |
802 |
|
|
|
803 |
|
|
/** |
804 |
|
|
* Sets the background color of the LS Console. |
805 |
|
|
* @param c The background color of the LS Console. |
806 |
|
|
*/ |
807 |
|
|
protected void |
808 |
|
|
setLSConsoleBackgroundColor(Color c) { lsConsolePane.setBackgroundColor(c); } |
809 |
|
|
|
810 |
|
|
/** |
811 |
|
|
* Sets the notification messages' color of the LS Console. |
812 |
|
|
* @param c The notification messages' color of the LS Console. |
813 |
|
|
*/ |
814 |
|
|
protected void |
815 |
|
|
setLSConsoleNotifyColor(Color c) { lsConsolePane.setNotifyColor(c); } |
816 |
|
|
|
817 |
|
|
/** |
818 |
|
|
* Sets the warning messages' color of the LS Console. |
819 |
|
|
* @param c The warning messages' color of the LS Console. |
820 |
|
|
*/ |
821 |
|
|
protected void |
822 |
|
|
setLSConsoleWarningColor(Color c) { lsConsolePane.setWarningColor(c); } |
823 |
|
|
|
824 |
|
|
/** |
825 |
|
|
* Sets the error messages' color of the LS Console. |
826 |
|
|
* @param c The error messages' color of the LS Console. |
827 |
|
|
*/ |
828 |
|
|
protected void |
829 |
|
|
setLSConsoleErrorColor(Color c) { lsConsolePane.setErrorColor(c); } |
830 |
|
|
|
831 |
|
|
protected void |
832 |
|
|
showLSConsole(boolean b) { |
833 |
|
|
if(!b) { |
834 |
|
|
showBottomPane(false); |
835 |
|
|
if(lsConsoleDlg != null) lsConsoleDlg.setVisible(false); |
836 |
|
|
lsConsolePane.hideAutoCompleteWindow(); |
837 |
|
|
return; |
838 |
|
|
} |
839 |
|
|
|
840 |
|
|
setLSConsolePopOut0(isLSConsolePopOut()); |
841 |
|
|
} |
842 |
|
|
|
843 |
|
|
/** |
844 |
|
|
* Adds the specified <code>JSChannelsPane</code> to the view. |
845 |
|
|
* @param chnPane The <code>JSChannelsPane</code> to be added. |
846 |
|
|
*/ |
847 |
iliev |
787 |
public void |
848 |
|
|
addChannelsPane(JSChannelsPane chnPane) { |
849 |
|
|
insertChannelsPane(chnPane, getChannelsPaneCount()); |
850 |
|
|
} |
851 |
|
|
|
852 |
|
|
public void |
853 |
|
|
insertChannelsPane(JSChannelsPane chnPane, int idx) { |
854 |
|
|
chnPane.addListSelectionListener(this); |
855 |
|
|
|
856 |
|
|
if(getChannelsPaneCount() == 1) { |
857 |
|
|
channelsPane.remove(getChannelsPane(0)); |
858 |
|
|
channelsPane.add(tabbedPane); |
859 |
|
|
tabbedPane.addTab(getChannelsPane(0).getTitle(), getChannelsPane(0)); |
860 |
|
|
A4n.closeChannelsTab.setEnabled(true); |
861 |
|
|
A4n.editTabTitle.setEnabled(true); |
862 |
|
|
} |
863 |
|
|
|
864 |
|
|
getChannelsPaneList().insertElementAt(chnPane, idx); |
865 |
|
|
tabbedPane.insertTab(chnPane.getTitle(), null, chnPane, null, idx); |
866 |
|
|
tabbedPane.setSelectedComponent(chnPane); |
867 |
|
|
miList.insertElementAt(new JMenuItem(new A4n.MoveChannelsTo(chnPane)), idx); |
868 |
|
|
|
869 |
|
|
updateTabsMenu(); |
870 |
|
|
} |
871 |
|
|
|
872 |
iliev |
911 |
/** |
873 |
|
|
* Gets the <code>JSChannelsPane</code> that is currently shown. |
874 |
|
|
* @return The currently shown <code>JSChannelsPane</code>. |
875 |
|
|
*/ |
876 |
iliev |
787 |
public JSChannelsPane |
877 |
|
|
getSelectedChannelsPane() { |
878 |
|
|
if(getChannelsPaneList().size() == 1) return getChannelsPane(0); |
879 |
|
|
return (JSChannelsPane)tabbedPane.getSelectedComponent(); |
880 |
|
|
} |
881 |
|
|
|
882 |
iliev |
911 |
/** |
883 |
|
|
* Sets the <code>JSChannelsPane</code> to be selected. |
884 |
|
|
* @param pane The <code>JSChannelsPane</code> to be shown. |
885 |
|
|
*/ |
886 |
iliev |
787 |
public void |
887 |
|
|
setSelectedChannelsPane(JSChannelsPane pane) { |
888 |
|
|
if(getChannelsPaneList().size() == 1) return; |
889 |
|
|
tabbedPane.setSelectedComponent(pane); |
890 |
|
|
} |
891 |
|
|
|
892 |
iliev |
911 |
/** |
893 |
|
|
* Removes the specified <code>JSChannelsPane</code> from the view. |
894 |
|
|
* @param chnPane The <code>JSChannelsPane</code> to be removed. |
895 |
|
|
* @return <code>true</code> if the specified code>JSChannelsPane</code> |
896 |
|
|
* is actually removed from the view, <code>false</code> otherwise. |
897 |
|
|
*/ |
898 |
iliev |
787 |
public boolean |
899 |
|
|
removeChannelsPane(JSChannelsPane chnPane) { |
900 |
|
|
chnPane.removeListSelectionListener(this); |
901 |
|
|
|
902 |
|
|
tabbedPane.remove(chnPane); |
903 |
|
|
boolean b = super.removeChannelsPane(chnPane); |
904 |
|
|
for(int i = 0; i < miList.size(); i++) { |
905 |
|
|
A4n.MoveChannelsTo a = (A4n.MoveChannelsTo)miList.get(i).getAction(); |
906 |
|
|
if(a.getChannelsPane().equals(chnPane)) { |
907 |
|
|
miList.remove(i); |
908 |
|
|
break; |
909 |
|
|
} |
910 |
|
|
} |
911 |
|
|
|
912 |
|
|
updateTabsMenu(); |
913 |
|
|
|
914 |
|
|
if(getChannelsPaneCount() == 1) { |
915 |
|
|
A4n.closeChannelsTab.setEnabled(false); |
916 |
|
|
A4n.editTabTitle.setEnabled(false); |
917 |
|
|
tabbedPane.remove(getChannelsPane(0)); |
918 |
|
|
channelsPane.remove(tabbedPane); |
919 |
|
|
channelsPane.add(getChannelsPane(0)); |
920 |
|
|
} |
921 |
|
|
|
922 |
|
|
return b; |
923 |
|
|
} |
924 |
|
|
|
925 |
|
|
private void |
926 |
|
|
updateTabsMenu() { |
927 |
|
|
tabsMenu.removeAll(); |
928 |
|
|
|
929 |
|
|
for(JMenuItem mi : miList) { |
930 |
|
|
A4n.MoveChannelsTo a = (A4n.MoveChannelsTo)mi.getAction(); |
931 |
|
|
if(!a.getChannelsPane().equals(getSelectedChannelsPane())) tabsMenu.add(mi); |
932 |
|
|
} |
933 |
|
|
|
934 |
|
|
} |
935 |
|
|
|
936 |
|
|
public void |
937 |
|
|
updateTabTitle(JSChannelsPane chnPane) { |
938 |
|
|
tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), chnPane.getTitle()); |
939 |
|
|
} |
940 |
|
|
|
941 |
|
|
private void |
942 |
|
|
checkChannelSelection(JSChannelsPane pane) { |
943 |
|
|
if(!pane.hasSelectedChannel()) { |
944 |
|
|
A4n.duplicateChannels.putValue ( |
945 |
|
|
Action.NAME, i18n.getMenuLabel("channels.duplicate") |
946 |
|
|
); |
947 |
|
|
A4n.duplicateChannels.setEnabled(false); |
948 |
|
|
|
949 |
|
|
A4n.removeChannels.putValue ( |
950 |
|
|
Action.NAME, i18n.getMenuLabel("channels.RemoveChannel") |
951 |
|
|
); |
952 |
|
|
A4n.removeChannels.setEnabled(false); |
953 |
|
|
|
954 |
|
|
tabsMenu.setEnabled(false); |
955 |
|
|
|
956 |
|
|
A4n.moveChannelsOnTop.setEnabled(false); |
957 |
|
|
A4n.moveChannelsUp.setEnabled(false); |
958 |
|
|
A4n.moveChannelsDown.setEnabled(false); |
959 |
|
|
A4n.moveChannelsAtBottom.setEnabled(false); |
960 |
|
|
|
961 |
|
|
return; |
962 |
|
|
} |
963 |
|
|
|
964 |
|
|
A4n.duplicateChannels.setEnabled(true); |
965 |
|
|
A4n.removeChannels.setEnabled(true); |
966 |
|
|
|
967 |
|
|
if(getChannelsPaneCount() > 1) tabsMenu.setEnabled(true); |
968 |
|
|
|
969 |
|
|
if(pane.getSelectedChannelCount() > 1) { |
970 |
|
|
A4n.duplicateChannels.putValue ( |
971 |
|
|
Action.NAME, i18n.getMenuLabel("channels.duplicateChannels") |
972 |
|
|
); |
973 |
|
|
A4n.removeChannels.putValue ( |
974 |
|
|
Action.NAME, i18n.getMenuLabel("channels.RemoveChannels") |
975 |
|
|
); |
976 |
|
|
} else { |
977 |
|
|
A4n.duplicateChannels.putValue ( |
978 |
|
|
Action.NAME, i18n.getMenuLabel("channels.duplicate") |
979 |
|
|
); |
980 |
|
|
A4n.removeChannels.putValue ( |
981 |
|
|
Action.NAME, i18n.getMenuLabel("channels.RemoveChannel") |
982 |
|
|
); |
983 |
|
|
} |
984 |
|
|
|
985 |
|
|
A4n.moveChannelsOnTop.setEnabled(false); |
986 |
|
|
A4n.moveChannelsUp.setEnabled(true); |
987 |
|
|
A4n.moveChannelsDown.setEnabled(true); |
988 |
|
|
A4n.moveChannelsAtBottom.setEnabled(false); |
989 |
|
|
|
990 |
|
|
JSChannel[] chns = pane.getSelectedChannels(); |
991 |
|
|
|
992 |
|
|
for(int i = 0; i < chns.length; i++) { |
993 |
|
|
if(pane.getChannel(i) != chns[i]) { |
994 |
|
|
A4n.moveChannelsOnTop.setEnabled(true); |
995 |
|
|
break; |
996 |
|
|
} |
997 |
|
|
} |
998 |
|
|
|
999 |
|
|
if(chns[0] == pane.getFirstChannel()) A4n.moveChannelsUp.setEnabled(false); |
1000 |
|
|
|
1001 |
|
|
if(chns[chns.length - 1] == pane.getLastChannel()) |
1002 |
|
|
A4n.moveChannelsDown.setEnabled(false); |
1003 |
|
|
|
1004 |
|
|
for(int i = chns.length - 1, j = pane.getChannelCount() - 1; i >= 0; i--, j--) { |
1005 |
|
|
if(pane.getChannel(j) != chns[i]) { |
1006 |
|
|
A4n.moveChannelsAtBottom.setEnabled(true); |
1007 |
|
|
break; |
1008 |
|
|
} |
1009 |
|
|
} |
1010 |
|
|
} |
1011 |
|
|
|
1012 |
|
|
private void |
1013 |
|
|
checkTabSelection() { |
1014 |
|
|
int si = tabbedPane.getSelectedIndex(); |
1015 |
|
|
|
1016 |
|
|
if(si > 0) { |
1017 |
|
|
A4n.moveTab2Beginning.setEnabled(true); |
1018 |
|
|
A4n.moveTab2Left.setEnabled(true); |
1019 |
|
|
} else { |
1020 |
|
|
A4n.moveTab2Beginning.setEnabled(false); |
1021 |
|
|
A4n.moveTab2Left.setEnabled(false); |
1022 |
|
|
} |
1023 |
|
|
|
1024 |
|
|
if(si != -1 && si < tabbedPane.getTabCount() - 1) { |
1025 |
|
|
A4n.moveTab2Right.setEnabled(true); |
1026 |
|
|
A4n.moveTab2End.setEnabled(true); |
1027 |
|
|
} else { |
1028 |
|
|
A4n.moveTab2Right.setEnabled(false); |
1029 |
|
|
A4n.moveTab2End.setEnabled(false); |
1030 |
|
|
} |
1031 |
|
|
} |
1032 |
|
|
|
1033 |
|
|
/*public JTabbedPane |
1034 |
|
|
getTabbedPane() { return tabbedPane; }*/ |
1035 |
|
|
|
1036 |
|
|
public JMenu |
1037 |
|
|
getTabsMenu() { return tabsMenu; } |
1038 |
|
|
|
1039 |
|
|
public void |
1040 |
|
|
stateChanged(ChangeEvent e) { |
1041 |
|
|
updateTabsMenu(); |
1042 |
|
|
checkChannelSelection(getSelectedChannelsPane()); |
1043 |
|
|
checkTabSelection(); |
1044 |
|
|
} |
1045 |
|
|
|
1046 |
|
|
public void |
1047 |
|
|
valueChanged(ListSelectionEvent e) { |
1048 |
|
|
if(e.getValueIsAdjusting()) return; |
1049 |
|
|
if(e.getSource() != getSelectedChannelsPane()) return; |
1050 |
|
|
|
1051 |
|
|
checkChannelSelection(getSelectedChannelsPane()); |
1052 |
|
|
} |
1053 |
|
|
|
1054 |
|
|
public void |
1055 |
|
|
moveTab2Beginning() { |
1056 |
|
|
int idx = tabbedPane.getSelectedIndex(); |
1057 |
|
|
if(idx < 1) { |
1058 |
|
|
CC.getLogger().info("Can't move tab to beginning"); |
1059 |
|
|
return; |
1060 |
|
|
} |
1061 |
|
|
|
1062 |
|
|
JSChannelsPane c = (JSChannelsPane)tabbedPane.getSelectedComponent(); |
1063 |
|
|
if(getChannelsPane(idx) != c) |
1064 |
|
|
CC.getLogger().warning("Channels pane indices don't match"); |
1065 |
|
|
removeChannelsPane(c); |
1066 |
|
|
insertChannelsPane(c, 0); |
1067 |
|
|
tabbedPane.setSelectedComponent(c); |
1068 |
|
|
} |
1069 |
|
|
|
1070 |
|
|
public void |
1071 |
|
|
moveTab2Left() { |
1072 |
|
|
int idx = tabbedPane.getSelectedIndex(); |
1073 |
|
|
if(idx < 1) { |
1074 |
|
|
CC.getLogger().info("Can't move tab to left"); |
1075 |
|
|
return; |
1076 |
|
|
} |
1077 |
|
|
|
1078 |
|
|
|
1079 |
|
|
JSChannelsPane c = (JSChannelsPane)tabbedPane.getSelectedComponent(); |
1080 |
|
|
if(getChannelsPane(idx) != c) |
1081 |
|
|
CC.getLogger().warning("Channels pane indices don't match"); |
1082 |
|
|
removeChannelsPane(c); |
1083 |
|
|
insertChannelsPane(c, idx - 1); |
1084 |
|
|
tabbedPane.setSelectedComponent(c); |
1085 |
|
|
} |
1086 |
|
|
|
1087 |
|
|
public void |
1088 |
|
|
moveTab2Right() { |
1089 |
|
|
int idx = tabbedPane.getSelectedIndex(); |
1090 |
|
|
if(idx == -1 && idx >= tabbedPane.getTabCount()) { |
1091 |
|
|
CC.getLogger().info("Can't move tab to right"); |
1092 |
|
|
return; |
1093 |
|
|
} |
1094 |
|
|
|
1095 |
|
|
JSChannelsPane c = (JSChannelsPane)tabbedPane.getSelectedComponent(); |
1096 |
|
|
if(getChannelsPane(idx) != c) |
1097 |
|
|
CC.getLogger().warning("Channels pane indices don't match"); |
1098 |
|
|
removeChannelsPane(c); |
1099 |
|
|
insertChannelsPane(c, idx + 1); |
1100 |
|
|
tabbedPane.setSelectedComponent(c); |
1101 |
|
|
} |
1102 |
|
|
|
1103 |
|
|
public void |
1104 |
|
|
moveTab2End() { |
1105 |
|
|
int idx = tabbedPane.getSelectedIndex(); |
1106 |
|
|
if(idx == -1 && idx >= tabbedPane.getTabCount()) { |
1107 |
|
|
CC.getLogger().info("Can't move tab to right"); |
1108 |
|
|
return; |
1109 |
|
|
} |
1110 |
|
|
|
1111 |
|
|
JSChannelsPane c = (JSChannelsPane)tabbedPane.getSelectedComponent(); |
1112 |
|
|
if(getChannelsPane(idx) != c) |
1113 |
|
|
CC.getLogger().warning("Channels pane indices don't match"); |
1114 |
|
|
removeChannelsPane(c); |
1115 |
|
|
addChannelsPane(c); |
1116 |
|
|
tabbedPane.setSelectedComponent(c); |
1117 |
|
|
} |
1118 |
iliev |
911 |
|
1119 |
|
|
protected void |
1120 |
|
|
runScript() { |
1121 |
iliev |
1285 |
String s = preferences().getStringProperty("lastScriptLocation"); |
1122 |
|
|
JFileChooser fc = new JFileChooser(s); |
1123 |
iliev |
911 |
fc.setFileFilter(new LscpFileFilter()); |
1124 |
|
|
int result = fc.showOpenDialog(this); |
1125 |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
1126 |
|
|
|
1127 |
iliev |
1143 |
String path = fc.getCurrentDirectory().getAbsolutePath(); |
1128 |
iliev |
1285 |
preferences().setStringProperty("lastScriptLocation", path); |
1129 |
iliev |
1143 |
|
1130 |
iliev |
911 |
runScript(fc.getSelectedFile()); |
1131 |
|
|
} |
1132 |
|
|
|
1133 |
|
|
private void |
1134 |
|
|
runScript(String script) { runScript(new File(script)); } |
1135 |
|
|
|
1136 |
|
|
private void |
1137 |
|
|
runScript(File script) { |
1138 |
|
|
FileReader fr; |
1139 |
|
|
try { fr = new FileReader(script); } |
1140 |
|
|
catch(FileNotFoundException e) { |
1141 |
|
|
HF.showErrorMessage(i18n.getMessage("FileNotFound!")); |
1142 |
|
|
return; |
1143 |
|
|
} |
1144 |
|
|
|
1145 |
|
|
BufferedReader br = new BufferedReader(fr); |
1146 |
|
|
|
1147 |
|
|
try { |
1148 |
|
|
String s = br.readLine(); |
1149 |
|
|
while(s != null) { |
1150 |
|
|
getLSConsoleModel().setCommandLineText(s); |
1151 |
|
|
getLSConsoleModel().execCommand(); |
1152 |
|
|
s = br.readLine(); |
1153 |
|
|
} |
1154 |
|
|
} catch(Exception e) { |
1155 |
|
|
HF.showErrorMessage(e); |
1156 |
|
|
return; |
1157 |
|
|
} |
1158 |
|
|
|
1159 |
iliev |
1285 |
if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) { |
1160 |
|
|
if(!cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0); |
1161 |
|
|
} |
1162 |
iliev |
911 |
|
1163 |
|
|
String s = script.getAbsolutePath(); |
1164 |
|
|
recentScripts.remove(s); |
1165 |
|
|
recentScripts.insertElementAt(s, 0); |
1166 |
|
|
|
1167 |
|
|
updateRecentScriptsMenu(); |
1168 |
|
|
} |
1169 |
|
|
|
1170 |
|
|
protected void |
1171 |
|
|
clearRecentScripts() { |
1172 |
|
|
recentScripts.removeAllElements(); |
1173 |
|
|
updateRecentScriptsMenu(); |
1174 |
|
|
} |
1175 |
|
|
|
1176 |
|
|
protected void |
1177 |
|
|
updateRecentScriptsMenu() { |
1178 |
iliev |
1285 |
int size = preferences().getIntProperty(RECENT_LSCP_SCRIPTS_SIZE); |
1179 |
|
|
while(recentScripts.size() > size) { |
1180 |
iliev |
911 |
recentScripts.removeElementAt(recentScripts.size() - 1); |
1181 |
|
|
} |
1182 |
|
|
|
1183 |
|
|
recentScriptsMenu.removeAll(); |
1184 |
|
|
|
1185 |
|
|
for(String script : recentScripts) { |
1186 |
|
|
JMenuItem mi = new JMenuItem(script); |
1187 |
|
|
recentScriptsMenu.add(mi); |
1188 |
|
|
mi.addActionListener(new RecentScriptHandler(script)); |
1189 |
|
|
} |
1190 |
|
|
|
1191 |
|
|
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
1192 |
|
|
} |
1193 |
iliev |
1143 |
|
1194 |
|
|
public void |
1195 |
|
|
installJSamplerHome() { |
1196 |
|
|
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
1197 |
|
|
chooser.setVisible(true); |
1198 |
|
|
if(chooser.isCancelled()) return; |
1199 |
|
|
|
1200 |
|
|
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
1201 |
|
|
} |
1202 |
iliev |
1204 |
|
1203 |
|
|
public void |
1204 |
|
|
showDetailedErrorMessage(Frame owner, String err, String details) { |
1205 |
iliev |
1355 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
1206 |
|
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
1207 |
|
|
); |
1208 |
|
|
dlg.setVisible(true); |
1209 |
iliev |
1204 |
} |
1210 |
|
|
|
1211 |
|
|
public void |
1212 |
|
|
showDetailedErrorMessage(Dialog owner, String err, String details) { |
1213 |
iliev |
1355 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
1214 |
|
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
1215 |
|
|
); |
1216 |
|
|
dlg.setVisible(true); |
1217 |
iliev |
1204 |
} |
1218 |
iliev |
1688 |
|
1219 |
|
|
/** |
1220 |
|
|
* Gets the server address to which to connect. If the server should be |
1221 |
|
|
* manually selected, a dialog asking the user to choose a server is displayed. |
1222 |
|
|
*/ |
1223 |
|
|
public Server |
1224 |
|
|
getServer() { |
1225 |
|
|
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
1226 |
|
|
return getServer(b); |
1227 |
|
|
} |
1228 |
|
|
|
1229 |
|
|
/** |
1230 |
|
|
* Gets the server address to which to connect. If the server should be |
1231 |
|
|
* manually selected, a dialog asking the user to choose a server is displayed. |
1232 |
|
|
* @param manualSelect Determines whether the server should be manually selected. |
1233 |
|
|
*/ |
1234 |
|
|
public Server |
1235 |
|
|
getServer(boolean manualSelect) { |
1236 |
|
|
if(manualSelect) { |
1237 |
|
|
JSConnectDlg dlg = new JSConnectDlg(); |
1238 |
|
|
dlg.setVisible(true); |
1239 |
|
|
return dlg.getSelectedServer(); |
1240 |
|
|
} |
1241 |
|
|
|
1242 |
|
|
int i = preferences().getIntProperty(SERVER_INDEX); |
1243 |
|
|
int size = CC.getServerList().getServerCount(); |
1244 |
|
|
if(size == 0) return null; |
1245 |
|
|
if(i >= size) return CC.getServerList().getServer(0); |
1246 |
|
|
|
1247 |
|
|
return CC.getServerList().getServer(i); |
1248 |
|
|
} |
1249 |
iliev |
787 |
} |