1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
23 |
package org.jsampler.view.classic; |
package org.jsampler.view.classic; |
24 |
|
|
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
|
import java.awt.Color; |
27 |
|
import java.awt.Dialog; |
28 |
import java.awt.Dimension; |
import java.awt.Dimension; |
29 |
|
import java.awt.Frame; |
30 |
|
import java.awt.Rectangle; |
31 |
|
|
32 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
34 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
35 |
|
|
36 |
import java.util.logging.Level; |
import java.io.BufferedReader; |
37 |
|
import java.io.File; |
38 |
|
import java.io.FileNotFoundException; |
39 |
|
import java.io.FileReader; |
40 |
|
|
41 |
import java.util.Vector; |
import java.util.Vector; |
42 |
|
|
43 |
import javax.swing.Action; |
import javax.swing.Action; |
44 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
45 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
46 |
|
import javax.swing.JFileChooser; |
47 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
48 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
49 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
58 |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.ListSelectionListener; |
59 |
|
|
60 |
import net.sf.juife.NavigationPage; |
import net.sf.juife.NavigationPage; |
|
import net.sf.juife.NavigationPane; |
|
61 |
|
|
62 |
import org.jsampler.CC; |
import org.jsampler.CC; |
63 |
import org.jsampler.Prefs; |
import org.jsampler.HF; |
64 |
|
import org.jsampler.LSConsoleModel; |
65 |
|
import org.jsampler.OrchestraModel; |
66 |
|
import org.jsampler.Server; |
67 |
|
|
68 |
import org.jsampler.view.JSChannel; |
import org.jsampler.view.JSChannel; |
69 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
70 |
|
import org.jsampler.view.LscpFileFilter; |
71 |
|
|
72 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
73 |
|
import org.jsampler.view.std.JSConnectDlg; |
74 |
|
import org.jsampler.view.std.JSDetailedErrorDlg; |
75 |
|
import org.jsampler.view.std.JSQuitDlg; |
76 |
|
import org.jsampler.view.std.JSamplerHomeChooser; |
77 |
|
import org.jsampler.view.std.StdUtils; |
78 |
|
|
79 |
|
import static org.jsampler.view.classic.A4n.a4n; |
80 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
81 |
|
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
82 |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
83 |
|
import static org.jsampler.view.std.StdPrefs.*; |
84 |
|
|
85 |
/** |
/** |
86 |
* |
* |
88 |
*/ |
*/ |
89 |
public class |
public class |
90 |
MainFrame extends org.jsampler.view.JSMainFrame implements ChangeListener, ListSelectionListener { |
MainFrame extends org.jsampler.view.JSMainFrame implements ChangeListener, ListSelectionListener { |
91 |
public static ImageIcon applicationIcon = null; |
public static ImageIcon applicationIcon = Res.appIcon; |
|
|
|
|
static { |
|
|
String s = "org/jsampler/view/classic/res/icons/app-icon.png"; |
|
|
java.net.URL url = ClassLoader.getSystemClassLoader().getResource(s); |
|
|
if(url != null) applicationIcon = new ImageIcon(url); |
|
|
} |
|
92 |
|
|
93 |
private final Toolbar toolbar = new Toolbar(); |
private final ChannelsBar channelsBar = new ChannelsBar(); |
94 |
private final Statusbar statusbar = new Statusbar(); |
private final Statusbar statusbar = new Statusbar(); |
95 |
private final JMenuBar menuBar = new JMenuBar(); |
private final JMenuBar menuBar = new JMenuBar(); |
96 |
|
private final JMenu recentScriptsMenu = |
97 |
|
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
98 |
|
private final JMenu tabsMenu = new JMenu(i18n.getMenuLabel("channels.MoveToTab")); |
99 |
|
|
100 |
private final JSplitPane splitPane; |
private final JSplitPane vSplitPane; |
101 |
|
private final JSplitPane hSplitPane; |
102 |
|
|
103 |
private final JPanel mainPane = new JPanel(); |
private final JPanel mainPane = new JPanel(); |
104 |
|
private final StandardBar standardBar = new StandardBar(); |
105 |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
private final JPanel channelsPane = new JPanel(new BorderLayout()); |
106 |
|
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 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
111 |
|
|
112 |
private final JTabbedPane tabbedPane = |
private final JTabbedPane tabbedPane = |
113 |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
|
private final JMenu tabsMenu = new JMenu(i18n.getMenuLabel("channels.MoveToTab")); |
|
114 |
private final Vector<JMenuItem> miList = new Vector<JMenuItem>(); |
private final Vector<JMenuItem> miList = new Vector<JMenuItem>(); |
115 |
|
|
116 |
/** Creates a new instance of JSMainFrame */ |
private final JCheckBoxMenuItem cbmiLeftPaneVisible = |
117 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
118 |
|
|
119 |
|
private final JCheckBoxMenuItem cbmiStandardBarVisible = |
120 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.standard")); |
121 |
|
|
122 |
|
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 |
|
/** Creates a new instance of <code>MainFrame</code>. */ |
131 |
public |
public |
132 |
MainFrame() { |
MainFrame() { |
133 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
134 |
|
|
135 |
getContentPane().add(toolbar, BorderLayout.NORTH); |
CC.setMainFrame(this); // TODO: |
136 |
|
|
137 |
|
getContentPane().add(standardBar, BorderLayout.NORTH); |
138 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
139 |
|
|
140 |
mainPane.setLayout(new BorderLayout()); |
mainPane.setLayout(new BorderLayout()); |
147 |
|
|
148 |
channelsPane.add(getChannelsPane(0)); |
channelsPane.add(getChannelsPane(0)); |
149 |
|
|
150 |
splitPane = new JSplitPane ( |
bottomPane.setLayout(new BorderLayout()); |
151 |
|
|
152 |
|
rightPane.setLayout(new BorderLayout()); |
153 |
|
|
154 |
|
rightPane.add(channelsBar, BorderLayout.NORTH); |
155 |
|
rightPane.add(channelsPane); |
156 |
|
|
157 |
|
hSplitPane = new JSplitPane ( |
158 |
JSplitPane.HORIZONTAL_SPLIT, |
JSplitPane.HORIZONTAL_SPLIT, |
159 |
true, // continuousLayout |
true, // continuousLayout |
160 |
getLeftPane(), |
getLeftPane(), |
161 |
channelsPane |
rightPane |
162 |
); |
); |
163 |
|
|
164 |
splitPane.setOneTouchExpandable(true); |
hSplitPane.setOneTouchExpandable(true); |
165 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
166 |
|
hSplitPane.setDividerLocation(ClassicPrefs.getHSplitDividerLocation()); |
167 |
|
} |
168 |
|
|
169 |
|
mainPane.add(hSplitPane); |
170 |
|
|
171 |
|
|
172 |
|
vSplitPane = new JSplitPane ( |
173 |
|
JSplitPane.VERTICAL_SPLIT, |
174 |
|
true, // continuousLayout |
175 |
|
channelsPane, |
176 |
|
bottomPane |
177 |
|
); |
178 |
|
|
179 |
mainPane.add(splitPane); |
vSplitPane.setDividerSize(3); |
180 |
|
vSplitPane.setDividerLocation(ClassicPrefs.getVSplitDividerLocation()); |
181 |
|
|
182 |
|
rightPane.add(vSplitPane); |
183 |
|
|
184 |
if(applicationIcon != null) setIconImage(applicationIcon.getImage()); |
if(applicationIcon != null) setIconImage(applicationIcon.getImage()); |
185 |
|
|
186 |
initMainFrame(); |
initMainFrame(); |
187 |
|
|
188 |
pack(); |
pack(); |
189 |
|
|
190 |
if(Prefs.getSaveWindowProperties()) setSavedSize(); |
if(ClassicPrefs.getSaveWindowProperties()) setSavedSize(); |
191 |
else setDefaultSize(); |
else setDefaultSize(); |
192 |
|
|
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 |
|
|
207 |
|
//CC.getInstrumentsDbTreeModel(); // used to initialize the db tree model |
208 |
|
} |
209 |
|
|
210 |
|
/** Invoked when this window is about to close. */ |
211 |
|
@Override |
212 |
|
protected void |
213 |
|
onWindowClose() { |
214 |
|
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
215 |
|
if(b && CC.getSamplerModel().isModified()) { |
216 |
|
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
217 |
|
dlg.setVisible(true); |
218 |
|
if(dlg.isCancelled()) return; |
219 |
|
} |
220 |
|
|
221 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
222 |
|
ClassicPrefs.setWindowMaximized ( |
223 |
|
"Mainframe", (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
224 |
|
); |
225 |
|
|
226 |
|
setVisible(false); |
227 |
|
if(ClassicPrefs.getWindowMaximized("MainFrame")) { |
228 |
|
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
229 |
|
CC.cleanExit(); |
230 |
|
return; |
231 |
|
} |
232 |
|
|
233 |
|
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
234 |
|
|
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 |
|
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
256 |
|
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
257 |
|
|
258 |
|
if(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY)) { |
259 |
|
lsConsolePane.saveConsoleHistory(); |
260 |
|
} |
261 |
|
|
262 |
|
ClassicPrefs.setShowLSConsole(isLSConsoleShown()); |
263 |
|
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
264 |
|
|
265 |
|
ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
266 |
|
|
267 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
268 |
|
if(lsConsolePane != null) lsConsolePane.disconnect(); |
269 |
|
super.onWindowClose(); |
270 |
|
} |
271 |
|
|
272 |
|
@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 |
private void |
private void |
297 |
|
|
298 |
private void |
private void |
299 |
setSavedSize() { |
setSavedSize() { |
300 |
String s = Prefs.getWindowSizeAndLocation(); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
301 |
if(s == null) { |
if(r == null) { |
302 |
setDefaultSize(); |
setDefaultSize(); |
303 |
return; |
return; |
304 |
} |
} |
305 |
|
|
306 |
try { |
setBounds(r); |
|
int i = s.indexOf(','); |
|
|
int x = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int y = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int width = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
int height = Integer.parseInt(s); |
|
|
|
|
|
setBounds(x, y, width, height); |
|
|
} catch(Exception x) { |
|
|
String msg = "Parsing of window size and location string failed"; |
|
|
CC.getLogger().log(Level.INFO, msg, x); |
|
|
setDefaultSize(); |
|
|
} |
|
|
|
|
|
if(Prefs.getWindowMaximized()) |
|
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
307 |
} |
} |
308 |
|
|
309 |
private void |
private void |
310 |
addMenu() { |
addMenu() { |
311 |
JMenu m; |
JMenu m; |
|
JMenu submenu; |
|
312 |
JMenuItem mi; |
JMenuItem mi; |
313 |
|
|
314 |
setJMenuBar(menuBar); |
setJMenuBar(menuBar); |
317 |
m = new JMenu(i18n.getMenuLabel("actions")); |
m = new JMenu(i18n.getMenuLabel("actions")); |
318 |
menuBar.add(m); |
menuBar.add(m); |
319 |
|
|
320 |
mi = new JMenuItem(A4n.connect); |
mi = new JMenuItem(a4n.refresh); |
321 |
mi.setIcon(null); |
mi.setIcon(null); |
322 |
//mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
323 |
m.add(mi); |
m.add(mi); |
324 |
|
|
325 |
mi = new JMenuItem(A4n.refresh); |
mi = new JMenuItem(A4n.samplerInfo); |
326 |
mi.setIcon(null); |
mi.setIcon(null); |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
|
327 |
m.add(mi); |
m.add(mi); |
328 |
|
|
329 |
mi = new JMenuItem(A4n.resetSampler); |
mi = new JMenuItem(a4n.resetSampler); |
330 |
mi.setIcon(null); |
mi.setIcon(null); |
331 |
m.add(mi); |
m.add(mi); |
332 |
|
|
333 |
mi = new JMenuItem(A4n.samplerInfo); |
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 |
|
m.addSeparator(); |
349 |
|
|
350 |
|
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
351 |
|
m.add(exportMenu); |
352 |
|
|
353 |
|
mi = new JMenuItem(a4n.exportSamplerConfig); |
354 |
|
mi.setIcon(null); |
355 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
356 |
|
exportMenu.add(mi); |
357 |
|
|
358 |
|
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
359 |
|
mi.setIcon(null); |
360 |
|
exportMenu.add(mi); |
361 |
|
|
362 |
|
m.addSeparator(); |
363 |
|
|
364 |
|
mi = new JMenuItem(A4n.loadScript); |
365 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)); |
366 |
mi.setIcon(null); |
mi.setIcon(null); |
367 |
m.add(mi); |
m.add(mi); |
368 |
|
|
369 |
|
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
370 |
|
for(String s : list) recentScripts.add(s); |
371 |
|
|
372 |
|
updateRecentScriptsMenu(); |
373 |
|
|
374 |
|
m.add(recentScriptsMenu); |
375 |
|
|
376 |
|
m.addSeparator(); |
377 |
|
|
378 |
|
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(); |
m.addSeparator(); |
384 |
|
|
385 |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
386 |
m.add(mi); |
m.add(mi); |
387 |
mi.addActionListener(new ActionListener() { |
mi.addActionListener(new ActionListener() { |
388 |
public void |
public void |
389 |
actionPerformed(ActionEvent e) { CC.cleanExit(); } |
actionPerformed(ActionEvent e) { onWindowClose(); } |
390 |
}); |
}); |
391 |
|
|
392 |
// Edit |
// Edit |
393 |
m = new JMenu(i18n.getMenuLabel("edit")); |
m = new JMenu(i18n.getMenuLabel("edit")); |
394 |
menuBar.add(m); |
menuBar.add(m); |
395 |
|
|
396 |
|
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 |
m.addSeparator(); |
m.addSeparator(); |
427 |
|
|
428 |
mi = new JMenuItem(A4n.preferences); |
mi = new JMenuItem(A4n.preferences); |
436 |
m = new JMenu(i18n.getMenuLabel("view")); |
m = new JMenu(i18n.getMenuLabel("view")); |
437 |
menuBar.add(m); |
menuBar.add(m); |
438 |
|
|
439 |
|
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 |
final JCheckBoxMenuItem cbmi = |
final JCheckBoxMenuItem cbmi = |
455 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbar")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolbars.channels")); |
456 |
|
|
457 |
m.add(cbmi); |
toolbarsMenu.add(cbmi); |
458 |
cbmi.addActionListener(new ActionListener() { |
cbmi.addActionListener(new ActionListener() { |
459 |
public void |
public void |
460 |
actionPerformed(ActionEvent e) { showToolbar(cbmi.getState()); } |
actionPerformed(ActionEvent e) { showChannelsBar(cbmi.getState()); } |
461 |
}); |
}); |
462 |
|
|
463 |
boolean b = ClassicPrefs.shouldShowToolbar(); |
b = ClassicPrefs.shouldShowChannelsBar(); |
464 |
cbmi.setSelected(b); |
cbmi.setSelected(b); |
465 |
showToolbar(b); |
showChannelsBar(b); |
466 |
|
|
467 |
final JCheckBoxMenuItem cbmi1 = |
m.add(cbmiLeftPaneVisible); |
468 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftPane")); |
cbmiLeftPaneVisible.addActionListener(new ActionListener() { |
|
|
|
|
m.add(cbmi1); |
|
|
cbmi1.addActionListener(new ActionListener() { |
|
469 |
public void |
public void |
470 |
actionPerformed(ActionEvent e) { showLeftPane(cbmi1.getState()); } |
actionPerformed(ActionEvent e) { |
471 |
|
showLeftPane(cbmiLeftPaneVisible.getState()); |
472 |
|
} |
473 |
}); |
}); |
474 |
|
|
475 |
b = ClassicPrefs.shouldShowLeftPane(); |
b = ClassicPrefs.shouldShowLeftPane(); |
476 |
cbmi1.setSelected(b); |
cbmiLeftPaneVisible.setSelected(b); |
477 |
showLeftPane(b); |
showLeftPane(b); |
478 |
|
|
479 |
final JCheckBoxMenuItem cbmi2 = |
final JCheckBoxMenuItem cbmi2 = |
488 |
cbmi2.setSelected(b); |
cbmi2.setSelected(b); |
489 |
showStatusbar(b); |
showStatusbar(b); |
490 |
|
|
491 |
|
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 |
// Channels |
// Channels |
508 |
m = new JMenu(i18n.getMenuLabel("channels")); |
m = new JMenu(i18n.getMenuLabel("channels")); |
509 |
menuBar.add(m); |
menuBar.add(m); |
623 |
m.add(mi); |
m.add(mi); |
624 |
|
|
625 |
|
|
626 |
|
// 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 |
|
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 |
|
|
647 |
|
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 |
// Help |
// Help |
658 |
m = new JMenu(i18n.getMenuLabel("help")); |
m = new JMenu(i18n.getMenuLabel("help")); |
|
menuBar.add(m); |
|
659 |
|
|
660 |
mi = new JMenuItem(A4n.helpAbout); |
mi = new JMenuItem(A4n.helpAbout); |
661 |
mi.setIcon(null); |
mi.setIcon(null); |
662 |
m.add(mi); |
m.add(mi); |
663 |
|
|
664 |
|
m.addSeparator(); |
665 |
|
|
666 |
|
mi = new JMenuItem(a4n.browseOnlineTutorial); |
667 |
|
mi.setIcon(null); |
668 |
|
m.add(mi); |
669 |
|
|
670 |
|
menuBar.add(m); |
671 |
|
} |
672 |
|
|
673 |
|
private class RecentScriptHandler implements ActionListener { |
674 |
|
private String script; |
675 |
|
|
676 |
|
RecentScriptHandler(String script) { this.script = script; } |
677 |
|
|
678 |
|
@Override |
679 |
|
public void |
680 |
|
actionPerformed(ActionEvent e) { runScript(script); } |
681 |
} |
} |
682 |
|
|
683 |
private void |
private void |
686 |
} |
} |
687 |
|
|
688 |
private void |
private void |
689 |
showToolbar(boolean b) { |
showChannelsBar(boolean b) { |
690 |
if(b) getContentPane().add(toolbar, BorderLayout.NORTH); |
channelsBar.setVisible(b); |
691 |
else getContentPane().remove(toolbar); |
ClassicPrefs.setShowChannelsBar(b); |
|
|
|
|
ClassicPrefs.setShowToolbar(b); |
|
692 |
|
|
693 |
validate(); |
validate(); |
694 |
repaint(); |
repaint(); |
700 |
statusbar.setVisible(b); |
statusbar.setVisible(b); |
701 |
} |
} |
702 |
|
|
703 |
|
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 |
private void |
private void |
720 |
showLeftPane(boolean b) { |
showLeftPane(boolean b) { |
721 |
ClassicPrefs.setShowLeftPane(b); |
ClassicPrefs.setShowLeftPane(b); |
722 |
|
|
723 |
mainPane.remove(splitPane); |
mainPane.remove(hSplitPane); |
724 |
mainPane.remove(channelsPane); |
mainPane.remove(rightPane); |
725 |
|
|
726 |
if(b) { |
if(b) { |
727 |
splitPane.setRightComponent(channelsPane); |
hSplitPane.setRightComponent(rightPane); |
728 |
mainPane.add(splitPane); |
mainPane.add(hSplitPane); |
729 |
|
if(ClassicPrefs.getSaveWindowProperties()) { |
730 |
|
int i = ClassicPrefs.getHSplitDividerLocation(); |
731 |
|
hSplitPane.setDividerLocation(i); |
732 |
|
} |
733 |
} else { |
} else { |
734 |
mainPane.add(channelsPane); |
mainPane.add(rightPane); |
735 |
} |
} |
736 |
|
|
737 |
validate(); |
validate(); |
738 |
repaint(); |
repaint(); |
739 |
} |
} |
740 |
|
|
741 |
|
private void |
742 |
|
showStandardBar(boolean b) { |
743 |
|
ClassicPrefs.setShowStandardBar(b); |
744 |
|
standardBar.setVisible(b); |
745 |
|
validate(); |
746 |
|
repaint(); |
747 |
|
} |
748 |
|
|
749 |
|
private void |
750 |
|
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 |
|
protected JSBackendLogFrame |
810 |
|
getBackendLogFrame() { return backendLogFrame; } |
811 |
|
|
812 |
|
/** |
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 |
|
@Override |
864 |
public void |
public void |
865 |
addChannelsPane(JSChannelsPane chnPane) { |
addChannelsPane(JSChannelsPane chnPane) { |
866 |
insertChannelsPane(chnPane, getChannelsPaneCount()); |
insertChannelsPane(chnPane, getChannelsPaneCount()); |
867 |
} |
} |
868 |
|
|
869 |
|
@Override |
870 |
public void |
public void |
871 |
insertChannelsPane(JSChannelsPane chnPane, int idx) { |
insertChannelsPane(JSChannelsPane chnPane, int idx) { |
872 |
chnPane.addListSelectionListener(this); |
chnPane.addListSelectionListener(this); |
887 |
updateTabsMenu(); |
updateTabsMenu(); |
888 |
} |
} |
889 |
|
|
890 |
|
/** |
891 |
|
* Gets the <code>JSChannelsPane</code> that is currently shown. |
892 |
|
* @return The currently shown <code>JSChannelsPane</code>. |
893 |
|
*/ |
894 |
|
@Override |
895 |
public JSChannelsPane |
public JSChannelsPane |
896 |
getSelectedChannelsPane() { |
getSelectedChannelsPane() { |
897 |
if(getChannelsPaneList().size() == 1) return getChannelsPane(0); |
if(getChannelsPaneList().size() == 1) return getChannelsPane(0); |
898 |
return (JSChannelsPane)tabbedPane.getSelectedComponent(); |
return (JSChannelsPane)tabbedPane.getSelectedComponent(); |
899 |
} |
} |
900 |
|
|
901 |
|
/** |
902 |
|
* Sets the <code>JSChannelsPane</code> to be selected. |
903 |
|
* @param pane The <code>JSChannelsPane</code> to be shown. |
904 |
|
*/ |
905 |
|
@Override |
906 |
public void |
public void |
907 |
setSelectedChannelsPane(JSChannelsPane pane) { |
setSelectedChannelsPane(JSChannelsPane pane) { |
908 |
if(getChannelsPaneList().size() == 1) return; |
if(getChannelsPaneList().size() == 1) return; |
909 |
tabbedPane.setSelectedComponent(pane); |
tabbedPane.setSelectedComponent(pane); |
910 |
|
fireChannelsPaneSelectionChanged(); |
911 |
} |
} |
912 |
|
|
913 |
|
/** |
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 |
|
@Override |
920 |
public boolean |
public boolean |
921 |
removeChannelsPane(JSChannelsPane chnPane) { |
removeChannelsPane(JSChannelsPane chnPane) { |
922 |
chnPane.removeListSelectionListener(this); |
chnPane.removeListSelectionListener(this); |
1058 |
public JMenu |
public JMenu |
1059 |
getTabsMenu() { return tabsMenu; } |
getTabsMenu() { return tabsMenu; } |
1060 |
|
|
1061 |
|
@Override |
1062 |
public void |
public void |
1063 |
stateChanged(ChangeEvent e) { |
stateChanged(ChangeEvent e) { |
1064 |
updateTabsMenu(); |
updateTabsMenu(); |
1066 |
checkTabSelection(); |
checkTabSelection(); |
1067 |
} |
} |
1068 |
|
|
1069 |
|
@Override |
1070 |
public void |
public void |
1071 |
valueChanged(ListSelectionEvent e) { |
valueChanged(ListSelectionEvent e) { |
1072 |
if(e.getValueIsAdjusting()) return; |
if(e.getValueIsAdjusting()) return; |
1139 |
addChannelsPane(c); |
addChannelsPane(c); |
1140 |
tabbedPane.setSelectedComponent(c); |
tabbedPane.setSelectedComponent(c); |
1141 |
} |
} |
1142 |
|
|
1143 |
|
protected void |
1144 |
|
runScript() { |
1145 |
|
String s = preferences().getStringProperty("lastScriptLocation"); |
1146 |
|
JFileChooser fc = new JFileChooser(s); |
1147 |
|
fc.setFileFilter(new LscpFileFilter()); |
1148 |
|
int result = fc.showOpenDialog(this); |
1149 |
|
if(result != JFileChooser.APPROVE_OPTION) return; |
1150 |
|
|
1151 |
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
1152 |
|
preferences().setStringProperty("lastScriptLocation", path); |
1153 |
|
|
1154 |
|
runScript(fc.getSelectedFile()); |
1155 |
|
} |
1156 |
|
|
1157 |
|
@Override |
1158 |
|
public void |
1159 |
|
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 |
|
if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) { |
1185 |
|
if(!cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0); |
1186 |
|
} |
1187 |
|
|
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 |
|
int size = preferences().getIntProperty(RECENT_LSCP_SCRIPTS_SIZE); |
1204 |
|
while(recentScripts.size() > size) { |
1205 |
|
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 |
|
|
1219 |
|
@Override |
1220 |
|
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 |
|
|
1229 |
|
@Override |
1230 |
|
public void |
1231 |
|
showDetailedErrorMessage(Frame owner, String err, String details) { |
1232 |
|
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
1233 |
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
1234 |
|
); |
1235 |
|
dlg.setVisible(true); |
1236 |
|
} |
1237 |
|
|
1238 |
|
@Override |
1239 |
|
public void |
1240 |
|
showDetailedErrorMessage(Dialog owner, String err, String details) { |
1241 |
|
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
1242 |
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
1243 |
|
); |
1244 |
|
dlg.setVisible(true); |
1245 |
|
} |
1246 |
|
|
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 |
|
@Override |
1252 |
|
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 |
|
@Override |
1264 |
|
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 |
} |
} |