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