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