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