1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
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 |
import java.awt.Color; |
27 |
import java.awt.Container; |
28 |
import java.awt.Dimension; |
29 |
import java.awt.GraphicsEnvironment; |
30 |
import java.awt.Font; |
31 |
import java.awt.Frame; |
32 |
import java.awt.GridBagConstraints; |
33 |
import java.awt.GridBagLayout; |
34 |
import java.awt.Insets; |
35 |
|
36 |
import java.awt.event.ActionEvent; |
37 |
import java.awt.event.ActionListener; |
38 |
import java.awt.event.ItemEvent; |
39 |
import java.awt.event.ItemListener; |
40 |
|
41 |
import java.util.Locale; |
42 |
|
43 |
import javax.swing.BorderFactory; |
44 |
import javax.swing.Box; |
45 |
import javax.swing.BoxLayout; |
46 |
import javax.swing.DefaultButtonModel; |
47 |
import javax.swing.JButton; |
48 |
import javax.swing.JCheckBox; |
49 |
import javax.swing.JComboBox; |
50 |
import javax.swing.JLabel; |
51 |
import javax.swing.JOptionPane; |
52 |
import javax.swing.JPanel; |
53 |
import javax.swing.JTabbedPane; |
54 |
import javax.swing.JTextField; |
55 |
|
56 |
import net.sf.juife.EnhancedDialog; |
57 |
import net.sf.juife.JuifeUtils; |
58 |
import net.sf.juife.LinkButton; |
59 |
|
60 |
import org.jsampler.CC; |
61 |
import org.jsampler.HF; |
62 |
import org.jsampler.JSI18n; |
63 |
import org.jsampler.JSampler; |
64 |
import org.jsampler.LSConsoleModel; |
65 |
import org.jsampler.Prefs; |
66 |
|
67 |
import org.jsampler.view.std.JSColorButton; |
68 |
import org.jsampler.view.std.JSConnectionPropsPane; |
69 |
import org.jsampler.view.std.JSDefaultsPropsPane; |
70 |
import org.jsampler.view.std.JSGeneralProps; |
71 |
import org.jsampler.view.std.JSLSConsolePropsPane; |
72 |
|
73 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
74 |
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
75 |
import static org.jsampler.view.std.StdPrefs.*; |
76 |
|
77 |
|
78 |
/** |
79 |
* |
80 |
* @author Grigor Iliev |
81 |
*/ |
82 |
public class PrefsDlg extends EnhancedDialog { |
83 |
private final GeneralPane genPane = new GeneralPane(); |
84 |
private final ViewPane viewPane = new ViewPane(); |
85 |
private final ConsolePane consolePane = new ConsolePane(); |
86 |
private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane(); |
87 |
private final JSDefaultsPropsPane defaultsPane; |
88 |
|
89 |
private final JButton btnApply = new JButton(i18n.getButtonLabel("apply")); |
90 |
private final JButton btnClose = new JButton(i18n.getButtonLabel("close")); |
91 |
|
92 |
|
93 |
public |
94 |
PrefsDlg(Frame frm) { |
95 |
super(frm, i18n.getLabel("PrefsDlg"), true); |
96 |
|
97 |
defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16); |
98 |
|
99 |
initPrefsDlg(); |
100 |
installListeners(); |
101 |
|
102 |
setLocation(JuifeUtils.centerLocation(this, frm)); |
103 |
|
104 |
connectionPane.setLSAddress(Prefs.getLSAddress()); |
105 |
connectionPane.setLSPort(String.valueOf(Prefs.getLSPort())); |
106 |
} |
107 |
|
108 |
private void |
109 |
initPrefsDlg() { |
110 |
JTabbedPane tp = new JTabbedPane(); |
111 |
tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane); |
112 |
tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane); |
113 |
tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane); |
114 |
|
115 |
JPanel p = new JPanel(); |
116 |
p.setLayout(new BorderLayout()); |
117 |
p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
118 |
p.add(connectionPane, BorderLayout.NORTH); |
119 |
tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), p); |
120 |
tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane); |
121 |
|
122 |
tp.setAlignmentX(RIGHT_ALIGNMENT); |
123 |
|
124 |
// Set preferred size for Apply & Exit buttons |
125 |
Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose); |
126 |
btnApply.setPreferredSize(d); |
127 |
btnClose.setPreferredSize(d); |
128 |
|
129 |
JPanel btnPane = new JPanel(); |
130 |
btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS)); |
131 |
btnPane.add(btnApply); |
132 |
btnPane.add(Box.createRigidArea(new Dimension(5, 0))); |
133 |
btnPane.add(btnClose); |
134 |
btnPane.setAlignmentX(RIGHT_ALIGNMENT); |
135 |
|
136 |
JPanel mainPane = new JPanel(); |
137 |
mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
138 |
mainPane.add(tp); |
139 |
mainPane.add(Box.createRigidArea(new Dimension(0, 12))); |
140 |
mainPane.add(btnPane); |
141 |
mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12)); |
142 |
|
143 |
getContentPane().add(mainPane); |
144 |
|
145 |
pack(); |
146 |
setResizable(false); |
147 |
} |
148 |
|
149 |
private void |
150 |
installListeners() { |
151 |
btnApply.addActionListener(new ActionListener() { |
152 |
public void |
153 |
actionPerformed(ActionEvent e) { onApply(); } |
154 |
}); |
155 |
|
156 |
btnClose.addActionListener(new ActionListener() { |
157 |
public void |
158 |
actionPerformed(ActionEvent e) { onExit(); } |
159 |
}); |
160 |
} |
161 |
|
162 |
protected void |
163 |
onOk() { onApply(); } |
164 |
|
165 |
protected void |
166 |
onCancel() { onExit(); } |
167 |
|
168 |
private void |
169 |
onApply() { |
170 |
genPane.apply(); |
171 |
viewPane.apply(); |
172 |
consolePane.apply(); |
173 |
connectionPane.apply(); |
174 |
defaultsPane.apply(); |
175 |
|
176 |
setVisible(false); |
177 |
} |
178 |
|
179 |
private void |
180 |
onExit() { setVisible(false); } |
181 |
} |
182 |
|
183 |
class GeneralPane extends JPanel { |
184 |
private final JCheckBox checkWindowSizeAndLocation = |
185 |
new JCheckBox(i18n.getLabel("GeneralPane.checkWindowSizeAndLocation")); |
186 |
|
187 |
private final JCheckBox checkLeftPaneState = |
188 |
new JCheckBox(i18n.getLabel("GeneralPane.checkLeftPaneState")); |
189 |
|
190 |
private final JCheckBox checkShowLSConsoleWhenRunScript = |
191 |
new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript")); |
192 |
|
193 |
private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane(); |
194 |
|
195 |
private final JSGeneralProps.JSamplerHomePane jSamplerHomePane = |
196 |
new JSGeneralProps.JSamplerHomePane(); |
197 |
|
198 |
private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane(); |
199 |
|
200 |
|
201 |
public |
202 |
GeneralPane() { |
203 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
204 |
|
205 |
checkWindowSizeAndLocation.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
206 |
|
207 |
checkWindowSizeAndLocation.setSelected(ClassicPrefs.getSaveWindowProperties()); |
208 |
checkWindowSizeAndLocation.addItemListener(new ItemListener() { |
209 |
public void |
210 |
itemStateChanged(ItemEvent e) { |
211 |
boolean b = e.getStateChange() == e.SELECTED; |
212 |
//checkWindowSizeAndLocation.setEnabled(b); |
213 |
} |
214 |
}); |
215 |
|
216 |
add(checkWindowSizeAndLocation); |
217 |
|
218 |
checkLeftPaneState.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
219 |
checkLeftPaneState.setSelected(ClassicPrefs.getSaveLeftPaneState()); |
220 |
add(checkLeftPaneState); |
221 |
|
222 |
checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
223 |
|
224 |
boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT); |
225 |
checkShowLSConsoleWhenRunScript.setSelected(b); |
226 |
|
227 |
add(checkShowLSConsoleWhenRunScript); |
228 |
|
229 |
add(Box.createRigidArea(new Dimension(0, 6))); |
230 |
|
231 |
add(maxVolPane); |
232 |
|
233 |
add(Box.createRigidArea(new Dimension(0, 6))); |
234 |
|
235 |
add(jSamplerHomePane); |
236 |
|
237 |
add(Box.createRigidArea(new Dimension(0, 6))); |
238 |
|
239 |
add(recentScriptsPane); |
240 |
add(Box.createGlue()); |
241 |
|
242 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
243 |
} |
244 |
|
245 |
protected void |
246 |
apply() { |
247 |
maxVolPane.apply(); |
248 |
|
249 |
ClassicPrefs.setSaveWindowProperties(checkWindowSizeAndLocation.isSelected()); |
250 |
ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected()); |
251 |
|
252 |
boolean b = checkShowLSConsoleWhenRunScript.isSelected(); |
253 |
preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b); |
254 |
|
255 |
int size = recentScriptsPane.getRecentScriptsSize(); |
256 |
preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size); |
257 |
((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu(); |
258 |
|
259 |
String s = jSamplerHomePane.getJSamplerHome(); |
260 |
if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) { |
261 |
CC.changeJSamplerHome(s); |
262 |
} |
263 |
} |
264 |
|
265 |
private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane { |
266 |
protected void |
267 |
clearRecentScripts() { |
268 |
((MainFrame)CC.getMainFrame()).clearRecentScripts(); |
269 |
} |
270 |
} |
271 |
} |
272 |
|
273 |
class ViewPane extends JPanel { |
274 |
private final JLabel lIfaceLanguage = |
275 |
new JLabel(i18n.getLabel("ViewPane.lIfaceLanguage")); |
276 |
private final JComboBox cbIfaceLanguage = new JComboBox(); |
277 |
|
278 |
private final JLabel lIfaceFont = |
279 |
new JLabel(i18n.getLabel("ViewPane.lIfaceFont")); |
280 |
private final JComboBox cbIfaceFont = new JComboBox(); |
281 |
|
282 |
private final JCheckBox checkBorderColor = |
283 |
new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor")); |
284 |
private final JSColorButton btnBorderColor = new JSColorButton(Color.WHITE); |
285 |
|
286 |
private final JCheckBox checkHlChnBorderColor = |
287 |
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBorderColor")); |
288 |
private final JSColorButton btnHlChnBorderColor = new JSColorButton(Color.WHITE); |
289 |
|
290 |
private final JCheckBox checkSelChnBgColor = |
291 |
new JCheckBox(i18n.getLabel("ViewPane.checkSelChnBgColor")); |
292 |
private final JSColorButton btnSelChnBgColor = new JSColorButton(Color.WHITE); |
293 |
|
294 |
private final JCheckBox checkHlChnBgColor = |
295 |
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBgColor")); |
296 |
private final JSColorButton btnHlChnBgColor = new JSColorButton(Color.WHITE); |
297 |
|
298 |
public |
299 |
ViewPane() { initViewPane(); } |
300 |
|
301 |
private void |
302 |
initViewPane() { |
303 |
cbIfaceLanguage.setMaximumSize ( |
304 |
new Dimension(Short.MAX_VALUE, cbIfaceLanguage.getPreferredSize().height) |
305 |
); |
306 |
|
307 |
for(Locale l : JSI18n.getAvailableLocales()) { |
308 |
LocaleBox box = new LocaleBox(l); |
309 |
cbIfaceLanguage.addItem(box); |
310 |
if ( l.getLanguage().equals(Prefs.getInterfaceLanguage()) && |
311 |
l.getCountry().equals(Prefs.getInterfaceCountry()) |
312 |
) cbIfaceLanguage.setSelectedItem(box); |
313 |
} |
314 |
|
315 |
cbIfaceFont.setMaximumSize ( |
316 |
new Dimension(Short.MAX_VALUE, cbIfaceFont.getPreferredSize().height) |
317 |
); |
318 |
|
319 |
cbIfaceFont.addItem("[Default]"); |
320 |
|
321 |
String[] fontS = |
322 |
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); |
323 |
|
324 |
for(String f : fontS) cbIfaceFont.addItem(f); |
325 |
|
326 |
if(Prefs.getInterfaceFont() == null) cbIfaceFont.setSelectedItem("[Default]"); |
327 |
else cbIfaceFont.setSelectedItem(Prefs.getInterfaceFont()); |
328 |
|
329 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
330 |
|
331 |
JPanel ifacePane = new JPanel(); |
332 |
ifacePane.setLayout(new BoxLayout(ifacePane, BoxLayout.X_AXIS)); |
333 |
ifacePane.add(lIfaceLanguage); |
334 |
ifacePane.add(Box.createRigidArea(new Dimension(5, 0))); |
335 |
ifacePane.add(cbIfaceLanguage); |
336 |
|
337 |
add(ifacePane); |
338 |
|
339 |
add(Box.createRigidArea(new Dimension(0, 6))); |
340 |
|
341 |
JPanel fontPane = new JPanel(); |
342 |
fontPane.setLayout(new BoxLayout(fontPane, BoxLayout.X_AXIS)); |
343 |
fontPane.add(lIfaceFont); |
344 |
fontPane.add(Box.createRigidArea(new Dimension(5, 0))); |
345 |
fontPane.add(cbIfaceFont); |
346 |
|
347 |
add(fontPane); |
348 |
add(Box.createRigidArea(new Dimension(0, 6))); |
349 |
add(createCustomColorsPane()); |
350 |
|
351 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
352 |
} |
353 |
|
354 |
private JPanel |
355 |
createCustomColorsPane() { |
356 |
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
357 |
btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor()); |
358 |
|
359 |
checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor()); |
360 |
|
361 |
checkBorderColor.addItemListener(new ItemListener() { |
362 |
public void |
363 |
itemStateChanged(ItemEvent e) { |
364 |
boolean b = e.getStateChange() == e.SELECTED; |
365 |
btnBorderColor.setEnabled(b); |
366 |
} |
367 |
}); |
368 |
|
369 |
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
370 |
btnHlChnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderHlColor()); |
371 |
|
372 |
checkHlChnBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderHlColor()); |
373 |
|
374 |
checkHlChnBorderColor.addItemListener(new ItemListener() { |
375 |
public void |
376 |
itemStateChanged(ItemEvent e) { |
377 |
boolean b = e.getStateChange() == e.SELECTED; |
378 |
btnHlChnBorderColor.setEnabled(b); |
379 |
} |
380 |
}); |
381 |
|
382 |
Color color = ClassicPrefs.getSelectedChannelBgColor(); |
383 |
if(color == null) color = new Color(getBackground().getRGB()); |
384 |
btnSelChnBgColor.setColor(color); |
385 |
btnSelChnBgColor.setEnabled(ClassicPrefs.getCustomSelectedChannelBgColor()); |
386 |
|
387 |
checkSelChnBgColor.setSelected(ClassicPrefs.getCustomSelectedChannelBgColor()); |
388 |
|
389 |
checkSelChnBgColor.addItemListener(new ItemListener() { |
390 |
public void |
391 |
itemStateChanged(ItemEvent e) { |
392 |
boolean b = e.getStateChange() == e.SELECTED; |
393 |
btnSelChnBgColor.setEnabled(b); |
394 |
} |
395 |
}); |
396 |
|
397 |
color = ClassicPrefs.getHighlightedChannelBgColor(); |
398 |
if(color == null) color = new Color(getBackground().getRGB()); |
399 |
btnHlChnBgColor.setColor(color); |
400 |
btnHlChnBgColor.setEnabled(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
401 |
|
402 |
checkHlChnBgColor.setSelected(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
403 |
|
404 |
checkHlChnBgColor.addItemListener(new ItemListener() { |
405 |
public void |
406 |
itemStateChanged(ItemEvent e) { |
407 |
boolean b = e.getStateChange() == e.SELECTED; |
408 |
btnHlChnBgColor.setEnabled(b); |
409 |
} |
410 |
}); |
411 |
|
412 |
JButton btnDefaults = new JButton("Reset to defaults"); |
413 |
btnDefaults.addActionListener(new ActionListener() { |
414 |
public void |
415 |
actionPerformed(ActionEvent e) { |
416 |
ClassicPrefs.setChannelBorderColor(null); |
417 |
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
418 |
|
419 |
ClassicPrefs.setChannelBorderHlColor(null); |
420 |
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
421 |
|
422 |
ClassicPrefs.setSelectedChannelBgColor(null); |
423 |
btnSelChnBgColor.setColor(ClassicPrefs.getSelectedChannelBgColor()); |
424 |
|
425 |
ClassicPrefs.setHighlightedChannelBgColor(null); |
426 |
btnHlChnBgColor.setColor(ClassicPrefs.getHighlightedChannelBgColor()); |
427 |
} |
428 |
}); |
429 |
|
430 |
GridBagLayout gridbag = new GridBagLayout(); |
431 |
GridBagConstraints c = new GridBagConstraints(); |
432 |
|
433 |
JPanel ccp = new JPanel(); |
434 |
ccp.setLayout(gridbag); |
435 |
|
436 |
c.fill = GridBagConstraints.NONE; |
437 |
|
438 |
c.gridx = 0; |
439 |
c.gridy = 0; |
440 |
c.anchor = GridBagConstraints.WEST; |
441 |
c.insets = new Insets(0, 3, 3, 3); |
442 |
gridbag.setConstraints(checkBorderColor, c); |
443 |
ccp.add(checkBorderColor); |
444 |
|
445 |
|
446 |
c.gridx = 1; |
447 |
c.gridy = 0; |
448 |
gridbag.setConstraints(btnBorderColor, c); |
449 |
ccp.add(btnBorderColor); |
450 |
|
451 |
c.gridx = 0; |
452 |
c.gridy = 1; |
453 |
gridbag.setConstraints(checkHlChnBorderColor, c); |
454 |
ccp.add(checkHlChnBorderColor); |
455 |
|
456 |
c.gridx = 1; |
457 |
c.gridy = 1; |
458 |
gridbag.setConstraints(btnHlChnBorderColor, c); |
459 |
ccp.add(btnHlChnBorderColor); |
460 |
|
461 |
c.gridx = 0; |
462 |
c.gridy = 2; |
463 |
gridbag.setConstraints(checkSelChnBgColor, c); |
464 |
ccp.add(checkSelChnBgColor); |
465 |
|
466 |
c.gridx = 1; |
467 |
c.gridy = 2; |
468 |
gridbag.setConstraints(btnSelChnBgColor, c); |
469 |
ccp.add(btnSelChnBgColor); |
470 |
|
471 |
c.gridx = 0; |
472 |
c.gridy = 3; |
473 |
gridbag.setConstraints(checkHlChnBgColor, c); |
474 |
ccp.add(checkHlChnBgColor); |
475 |
|
476 |
c.gridx = 1; |
477 |
c.gridy = 3; |
478 |
gridbag.setConstraints(btnHlChnBgColor, c); |
479 |
ccp.add(btnHlChnBgColor); |
480 |
|
481 |
JPanel p = new JPanel(); |
482 |
p.setAlignmentX(LEFT_ALIGNMENT); |
483 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
484 |
p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6)); |
485 |
p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); |
486 |
|
487 |
p.add(Box.createGlue()); |
488 |
p.add(btnDefaults); |
489 |
p.add(Box.createGlue()); |
490 |
|
491 |
c.fill = GridBagConstraints.HORIZONTAL; |
492 |
c.gridx = 0; |
493 |
c.gridy = 4; |
494 |
c.gridwidth = 2; |
495 |
c.weightx = 1.0; |
496 |
c.anchor = GridBagConstraints.CENTER; |
497 |
gridbag.setConstraints(p, c); |
498 |
ccp.add(p); |
499 |
|
500 |
ccp.setBorder ( |
501 |
BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane")) |
502 |
); |
503 |
|
504 |
ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, ccp.getPreferredSize().height)); |
505 |
|
506 |
return ccp; |
507 |
} |
508 |
|
509 |
private String |
510 |
getInterfaceLanguage() { |
511 |
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
512 |
if(box == null) return null; |
513 |
return box.getLocale().getLanguage(); |
514 |
} |
515 |
|
516 |
private String |
517 |
getInterfaceCountry() { |
518 |
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
519 |
if(box == null) return null; |
520 |
return box.getLocale().getCountry(); |
521 |
} |
522 |
|
523 |
private String |
524 |
getInterfaceFontName() { return cbIfaceFont.getSelectedItem().toString(); } |
525 |
|
526 |
protected void |
527 |
apply() { |
528 |
boolean b = Prefs.setInterfaceLanguage(getInterfaceLanguage()); |
529 |
boolean b2 = Prefs.setInterfaceCountry(getInterfaceCountry()); |
530 |
if (b || b2) JOptionPane.showMessageDialog ( |
531 |
this, |
532 |
i18n.getMessage("PrefsDlg.ifaceChangeInfo", "JS Classic"), |
533 |
null, |
534 |
JOptionPane.INFORMATION_MESSAGE |
535 |
); |
536 |
|
537 |
b = false; |
538 |
String fontName = getInterfaceFontName(); |
539 |
if(fontName.equals("[Default]")) { |
540 |
b = Prefs.setInterfaceFont(null); |
541 |
} else if(Prefs.setInterfaceFont(fontName)) { |
542 |
HF.setUIDefaultFont(fontName); |
543 |
b = true; |
544 |
} |
545 |
|
546 |
if(b) JOptionPane.showMessageDialog ( |
547 |
this, |
548 |
i18n.getMessage("PrefsDlg.ifaceFontChangeInfo", "JS Classic"), |
549 |
null, |
550 |
JOptionPane.INFORMATION_MESSAGE |
551 |
); |
552 |
|
553 |
///***/// |
554 |
|
555 |
b = checkBorderColor.isSelected(); |
556 |
ClassicPrefs.setCustomChannelBorderColor(b); |
557 |
if(b) ClassicPrefs.setChannelBorderColor(btnBorderColor.getColor()); |
558 |
|
559 |
Color c; |
560 |
if(b) c = ClassicPrefs.getChannelBorderColor(); |
561 |
else c = ClassicPrefs.getDefaultChannelBorderColor(); |
562 |
Channel.setBorderColor(c); |
563 |
|
564 |
b = checkHlChnBorderColor.isSelected(); |
565 |
ClassicPrefs.setCustomChannelBorderHlColor(b); |
566 |
if(b) ClassicPrefs.setChannelBorderHlColor(btnHlChnBorderColor.getColor()); |
567 |
|
568 |
if(b) c = ClassicPrefs.getChannelBorderHlColor(); |
569 |
else c = ClassicPrefs.getDefaultChannelBorderHlColor(); |
570 |
Channel.setBorderHighlightedColor(c); |
571 |
|
572 |
b = checkSelChnBgColor.isSelected(); |
573 |
ClassicPrefs.setCustomSelectedChannelBgColor(b); |
574 |
if(b) ClassicPrefs.setSelectedChannelBgColor(btnSelChnBgColor.getColor()); |
575 |
|
576 |
if(b) c = ClassicPrefs.getSelectedChannelBgColor(); |
577 |
else c = new Color(getBackground().getRGB()); |
578 |
if(c == null) c = new Color(getBackground().getRGB()); |
579 |
Channel.setSelectedChannelBgColor(c); |
580 |
|
581 |
b = checkHlChnBgColor.isSelected(); |
582 |
ClassicPrefs.setCustomHighlightedChannelBgColor(b); |
583 |
if(b) ClassicPrefs.setHighlightedChannelBgColor(btnHlChnBgColor.getColor()); |
584 |
|
585 |
if(b) c = ClassicPrefs.getHighlightedChannelBgColor(); |
586 |
else c = new Color(getBackground().getRGB()); |
587 |
if(c == null) c = new Color(getBackground().getRGB()); |
588 |
Channel.setHighlightedChannelBgColor(c); |
589 |
} |
590 |
|
591 |
class LocaleBox { |
592 |
private Locale locale; |
593 |
|
594 |
LocaleBox(Locale locale) { this.locale = locale; } |
595 |
|
596 |
public Locale |
597 |
getLocale() { return locale; } |
598 |
|
599 |
public String |
600 |
toString() { return locale.getDisplayLanguage(JSI18n.i18n.getCurrentLocale()); } |
601 |
} |
602 |
} |
603 |
|
604 |
class ConsolePane extends JSLSConsolePropsPane { |
605 |
protected void |
606 |
clearConsoleHistory() { |
607 |
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
608 |
mainFrame.getLSConsoleModel().clearCommandHistory(); |
609 |
} |
610 |
|
611 |
protected void |
612 |
apply() { |
613 |
super.apply(); |
614 |
|
615 |
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
616 |
|
617 |
LSConsoleModel model = mainFrame.getLSConsoleModel(); |
618 |
model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE)); |
619 |
|
620 |
int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR); |
621 |
mainFrame.setLSConsoleTextColor(new Color(c)); |
622 |
|
623 |
c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR); |
624 |
mainFrame.setLSConsoleBackgroundColor(new Color(c)); |
625 |
|
626 |
c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR); |
627 |
mainFrame.setLSConsoleNotifyColor(new Color(c)); |
628 |
|
629 |
c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR); |
630 |
mainFrame.setLSConsoleWarningColor(new Color(c)); |
631 |
|
632 |
c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR); |
633 |
mainFrame.setLSConsoleErrorColor(new Color(c)); |
634 |
} |
635 |
} |