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