/[svn]/jsampler/trunk/src/org/jsampler/view/classic/PrefsDlg.java
ViewVC logotype

Annotation of /jsampler/trunk/src/org/jsampler/view/classic/PrefsDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (hide annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 5 months ago) by iliev
File size: 20530 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

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

  ViewVC Help
Powered by ViewVC