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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC revision 1285 by iliev, Fri Aug 10 19:55:03 2007 UTC
# Line 1  Line 1 
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-2007 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 25  package org.jsampler.view.classic; Line 25  package org.jsampler.view.classic;
25  import java.awt.BorderLayout;  import java.awt.BorderLayout;
26  import java.awt.Color;  import java.awt.Color;
27  import java.awt.Container;  import java.awt.Container;
 import java.awt.Cursor;  
 import java.awt.Dialog;  
28  import java.awt.Dimension;  import java.awt.Dimension;
29  import java.awt.GraphicsEnvironment;  import java.awt.GraphicsEnvironment;
30  import java.awt.Font;  import java.awt.Font;
# Line 39  import java.awt.event.ActionEvent; Line 37  import java.awt.event.ActionEvent;
37  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
38  import java.awt.event.ItemEvent;  import java.awt.event.ItemEvent;
39  import java.awt.event.ItemListener;  import java.awt.event.ItemListener;
 import java.awt.event.MouseAdapter;  
 import java.awt.event.MouseEvent;  
40    
41  import java.util.Locale;  import java.util.Locale;
 import java.util.Vector;  
42    
43  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
44  import javax.swing.Box;  import javax.swing.Box;
# Line 51  import javax.swing.BoxLayout; Line 46  import javax.swing.BoxLayout;
46  import javax.swing.DefaultButtonModel;  import javax.swing.DefaultButtonModel;
47  import javax.swing.JButton;  import javax.swing.JButton;
48  import javax.swing.JCheckBox;  import javax.swing.JCheckBox;
 import javax.swing.JColorChooser;  
49  import javax.swing.JComboBox;  import javax.swing.JComboBox;
50  import javax.swing.JLabel;  import javax.swing.JLabel;
51  import javax.swing.JOptionPane;  import javax.swing.JOptionPane;
52  import javax.swing.JPanel;  import javax.swing.JPanel;
 import javax.swing.JPasswordField;  
 import javax.swing.JSpinner;  
53  import javax.swing.JTabbedPane;  import javax.swing.JTabbedPane;
54  import javax.swing.JTextField;  import javax.swing.JTextField;
 import javax.swing.SpinnerNumberModel;  
   
 import javax.swing.event.ChangeEvent;  
 import javax.swing.event.ChangeListener;  
55    
56  import net.sf.juife.EnhancedDialog;  import net.sf.juife.EnhancedDialog;
57  import net.sf.juife.JuifeUtils;  import net.sf.juife.JuifeUtils;
58  import net.sf.juife.LinkButton;  import net.sf.juife.LinkButton;
 import net.sf.juife.OkCancelDialog;  
59    
60  import org.jsampler.CC;  import org.jsampler.CC;
61  import org.jsampler.HF;  import org.jsampler.HF;
# Line 77  import org.jsampler.JSampler; Line 64  import org.jsampler.JSampler;
64  import org.jsampler.LSConsoleModel;  import org.jsampler.LSConsoleModel;
65  import org.jsampler.Prefs;  import org.jsampler.Prefs;
66    
67  import org.jsampler.task.SetServerAddress;  import org.jsampler.view.std.JSColorButton;
68    import org.jsampler.view.std.JSConnectionPropsPane;
69    import org.jsampler.view.std.JSGeneralProps;
70    import org.jsampler.view.std.JSLSConsolePropsPane;
71    
72  import static org.jsampler.view.classic.ClassicI18n.i18n;  import static org.jsampler.view.classic.ClassicI18n.i18n;
73    import static org.jsampler.view.classic.ClassicPrefs.preferences;
74    import static org.jsampler.view.std.StdPrefs.*;
75    
76    
77  /**  /**
# Line 90  public class PrefsDlg extends EnhancedDi Line 82  public class PrefsDlg extends EnhancedDi
82          private final GeneralPane genPane = new GeneralPane();          private final GeneralPane genPane = new GeneralPane();
83          private final ViewPane viewPane = new ViewPane();          private final ViewPane viewPane = new ViewPane();
84          private final ConsolePane consolePane = new ConsolePane();          private final ConsolePane consolePane = new ConsolePane();
85          private final ConnectionPane conPane = new ConnectionPane();          private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
86                    
87          private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));          private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
88          private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));          private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));
# Line 101  public class PrefsDlg extends EnhancedDi Line 93  public class PrefsDlg extends EnhancedDi
93                  super(frm, i18n.getLabel("PrefsDlg"), true);                  super(frm, i18n.getLabel("PrefsDlg"), true);
94                                    
95                  initPrefsDlg();                  initPrefsDlg();
96                  handleEvents();                  installListeners();
                 initPrefs();  
97                                    
98                  setLocation(JuifeUtils.centerLocation(this, frm));                  setLocation(JuifeUtils.centerLocation(this, frm));
99                    
100                    connectionPane.setLSAddress(Prefs.getLSAddress());
101                    connectionPane.setLSPort(String.valueOf(Prefs.getLSPort()));
102          }          }
103                    
104          private void          private void
# Line 113  public class PrefsDlg extends EnhancedDi Line 107  public class PrefsDlg extends EnhancedDi
107                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
108                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
109                  tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
110                  tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), conPane);                  
111                    JPanel p = new JPanel();
112                    p.setLayout(new BorderLayout());
113                    p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
114                    p.add(connectionPane, BorderLayout.NORTH);
115                    tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), p);
116                    
117                  tp.setAlignmentX(RIGHT_ALIGNMENT);                  tp.setAlignmentX(RIGHT_ALIGNMENT);
118                                    
119                  // Set preferred size for Apply & Exit buttons                  // Set preferred size for Apply & Exit buttons
# Line 142  public class PrefsDlg extends EnhancedDi Line 142  public class PrefsDlg extends EnhancedDi
142          }          }
143                    
144          private void          private void
145          handleEvents() {          installListeners() {
146                  btnApply.addActionListener(new ActionListener() {                  btnApply.addActionListener(new ActionListener() {
147                          public void                          public void
148                          actionPerformed(ActionEvent e) { onApply(); }                          actionPerformed(ActionEvent e) { onApply(); }
# Line 159  public class PrefsDlg extends EnhancedDi Line 159  public class PrefsDlg extends EnhancedDi
159                    
160          protected void          protected void
161          onCancel() { onExit(); }          onCancel() { onExit(); }
                   
         private void  
         initPrefs() {  
                 setLSAddress(Prefs.getLSAddress());  
                 setLSPort(Prefs.getLSPort());  
         }  
162                    
163          private void          private void
164          onApply() {          onApply() {
165                  genPane.apply();                  genPane.apply();
166                  viewPane.apply();                  viewPane.apply();
167                  consolePane.apply();                  consolePane.apply();
168                                    connectionPane.apply();
                 // CONNECTION  
                 Prefs.setLSAddress(getLSAddress());  
                   
                 boolean b = true;  
                 String s = getLSPort();  
                 try {  
                         if(s.length() > 0) {  
                                 int port = Integer.parseInt(s);  
                                 if(port > 0 && port < 0xffff)  
                                         Prefs.setLSPort(port);  
                                 else b = false;  
                         } else Prefs.setLSPort(-1);     // -1 resets to default value  
                 } catch(NumberFormatException x) {  
                         b = false;  
                 }  
                   
                 if(!b) {  
                         JOptionPane.showMessageDialog (  
                                 this,  
                                 i18n.getError("PrefsDlg.invalidPort", s),  
                                 i18n.getError("error"),  
                                 JOptionPane.ERROR_MESSAGE  
                         );  
                           
                         return;  
                 }  
                   
                 CC.getTaskQueue().add (  
                         new SetServerAddress(Prefs.getLSAddress(), Prefs.getLSPort())  
                 );  
169                                    
170                  setVisible(false);                  setVisible(false);
171          }          }
172                    
173          private void          private void
174          onExit() { setVisible(false); }          onExit() { setVisible(false); }
           
         private String  
         getLSAddress() { return conPane.getLSAddress().trim(); }  
           
         private void  
         setLSAddress(String s) { conPane.setLSAddress(s); }  
           
         private String  
         getLSPort() { return conPane.getLSPort().trim(); }  
           
         private void  
         setLSPort(int port) { conPane.setLSPort(String.valueOf(port)); }  
           
         protected static class ColorButton extends JPanel {  
                 private Color color;  
                 private final Vector<ActionListener> listeners = new Vector<ActionListener>();  
                   
                 ColorButton() { this(Color.WHITE); }  
                   
                 ColorButton(Color c) {  
                         color = c;  
                           
                         //setBorderPainted(false);  
                         setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
                         setPreferredSize(new Dimension(42, 16));  
                         setMaximumSize(new Dimension(42, 16));  
                         setBorder(BorderFactory.createLineBorder(Color.BLACK));  
                           
                         addMouseListener(new MouseAdapter() {  
                                 public void  
                                 mouseClicked(MouseEvent e) {  
                                         if(!isEnabled()) return;  
                                         if(e.getButton() == e.BUTTON1) showColorChooser();  
                                 }  
                         });  
                 }  
                   
                 /**  
                  * Registers the specified listener to be  
                  * notified when the current color is changed.  
                  * @param l The <code>ActionListener</code> to register.  
                  */  
                 public void  
                 addActionListener(ActionListener l) { listeners.add(l); }  
           
                 /**  
                  * Removes the specified listener.  
                  * @param l The <code>ActionListener</code> to remove.  
                  */  
                 public void  
                 removeActionListener(ActionListener l) { listeners.remove(l); }  
                   
                 /** Notifies listeners that the current color is changed. */  
                 private void  
                 fireActionPerformed() {  
                         ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null);  
                         for(ActionListener l : listeners) l.actionPerformed(e);  
                 }  
           
                 public void  
                 setEnabled(boolean b) {  
                         setOpaque(b);  
                         if(b) setBorder(BorderFactory.createLineBorder(Color.BLACK));  
                         else setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));  
                         //setBorderPainted(!b);  
                         super.setEnabled(b);  
                 }  
                   
                 private void  
                 showColorChooser() {  
                         ColorDlg dlg = new ColorDlg (  
                                 (Dialog)JuifeUtils.getWindow(this), getColor()  
                         );  
                           
                         dlg.setVisible(true);  
                         if(!dlg.isCancelled()) {  
                                 setColor(dlg.getColor());  
                                 fireActionPerformed();  
                         }  
                 }  
                   
                 public Color  
                 getColor() { return color; }  
                   
                 public void  
                 setColor(Color c) {  
                         color = c;  
                         setBackground(color);  
                 }  
         }  
           
         protected static class ColorDlg extends OkCancelDialog {  
                 private final JColorChooser colorChooser = new JColorChooser();  
                   
                 ColorDlg(Dialog owner) { this(owner, Color.WHITE); }  
                   
                 ColorDlg(Dialog owner, Color c) {  
                         super(owner);  
                           
                         colorChooser.setPreviewPanel(new JPanel());  
                         colorChooser.setColor(c);  
                           
                         JPanel mainPane = new JPanel();  
                         mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));  
                         mainPane.add(colorChooser);  
                           
                         mainPane.add(Box.createRigidArea(new Dimension(0, 6)));  
                           
                         final JPanel p = new JPanel();  
                         p.setBackground(c);  
                         p.setBorder(BorderFactory.createLineBorder(Color.BLACK));  
                         mainPane.add(p);  
                           
                         p.setPreferredSize(new Dimension(48, 8));  
                         p.setMaximumSize(new Dimension(Short.MAX_VALUE, 8));  
                           
                         setMainPane(mainPane);  
                           
                         colorChooser.getSelectionModel().addChangeListener(new ChangeListener() {  
                                 public void  
                                 stateChanged(ChangeEvent e) { p.setBackground(getColor()); }  
                         });  
                 }  
                   
                 protected void  
                 onOk() { setVisible(false); }  
                   
                 protected void  
                 onCancel() { setVisible(false); }  
                   
                 public Color  
                 getColor() { return colorChooser.getColor(); }  
         }  
175  }  }
176    
177  class GeneralPane extends JPanel {  class GeneralPane extends JPanel {
# Line 353  class GeneralPane extends JPanel { Line 184  class GeneralPane extends JPanel {
184          private final JCheckBox checkShowLSConsoleWhenRunScript =          private final JCheckBox checkShowLSConsoleWhenRunScript =
185                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
186                    
187          private final JLabel lRecentScriptsSize =          private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
188                  new JLabel(i18n.getLabel("GeneralPane.lRecentScriptsSize"));                  new JSGeneralProps.JSamplerHomePane();
189          private final JSpinner spRecentScriptsSize;          
190          private final JButton btnClearRecentScriptList =          private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
                 new JButton(i18n.getButtonLabel("GeneralPane.btnClearRecentScriptList"));  
191                    
192                    
193          public          public
# Line 383  class GeneralPane extends JPanel { Line 213  class GeneralPane extends JPanel {
213                                    
214                  checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);                  checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
215                                    
216                  boolean b = ClassicPrefs.getShowLSConsoleWhenRunScript();                  boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
217                  checkShowLSConsoleWhenRunScript.setSelected(b);                  checkShowLSConsoleWhenRunScript.setSelected(b);
218                                    
219                  add(checkShowLSConsoleWhenRunScript);                  add(checkShowLSConsoleWhenRunScript);
220                                    
221                  add(Box.createRigidArea(new Dimension(0, 6)));                  add(Box.createRigidArea(new Dimension(0, 6)));
222                                    
223                  JPanel rsp = new JPanel();                  add(jSamplerHomePane);
                 rsp.setLayout(new BoxLayout(rsp, BoxLayout.Y_AXIS));  
224                                    
225                  int i = ClassicPrefs.getRecentScriptsSize();                  add(Box.createRigidArea(new Dimension(0, 6)));
                 spRecentScriptsSize = new JSpinner(new SpinnerNumberModel(i, 0, 100, 1));  
                 spRecentScriptsSize.setMaximumSize(spRecentScriptsSize.getPreferredSize());  
                   
                 JPanel p = new JPanel();  
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                 p.add(lRecentScriptsSize);  
                 p.add(Box.createRigidArea(new Dimension(5, 0)));  
                 p.add(spRecentScriptsSize);  
                   
                 p.setAlignmentX(JPanel.CENTER_ALIGNMENT);  
                 rsp.add(p);  
                   
                 rsp.add(Box.createRigidArea(new Dimension(0, 6)));  
                   
                 btnClearRecentScriptList.addActionListener(new ActionListener() {  
                         public void  
                         actionPerformed(ActionEvent e) {  
                                 ClassicPrefs.setRecentScripts(null);  
                                 ((MainFrame)CC.getMainFrame()).clearRecentScripts();  
                         }  
                 });  
                   
                 btnClearRecentScriptList.setAlignmentX(JPanel.CENTER_ALIGNMENT);  
                 rsp.add(btnClearRecentScriptList);  
                 rsp.add(Box.createRigidArea(new Dimension(0, 6)));  
                   
                 rsp.setMaximumSize(new Dimension(Short.MAX_VALUE, rsp.getPreferredSize().height));  
                 rsp.setAlignmentX(JPanel.LEFT_ALIGNMENT);  
                 rsp.setBorder (  
                         BorderFactory.createTitledBorder(i18n.getLabel("GeneralPane.recentScripts"))  
                 );  
226                                    
227                  add(rsp);                  add(recentScriptsPane);
228                  add(Box.createGlue());                  add(Box.createGlue());
229                                    
230                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
# Line 438  class GeneralPane extends JPanel { Line 236  class GeneralPane extends JPanel {
236                  ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected());                  ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected());
237                                    
238                  boolean b = checkShowLSConsoleWhenRunScript.isSelected();                  boolean b = checkShowLSConsoleWhenRunScript.isSelected();
239                  ClassicPrefs.setShowLSConsoleWhenRunScript(b);                  preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
240                                    
241                  int size = Integer.parseInt(spRecentScriptsSize.getValue().toString());                  int size = recentScriptsPane.getRecentScriptsSize();
242                  ClassicPrefs.setRecentScriptstSize(size);                  preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
243                  ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();                  ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
244                    
245                    String s = jSamplerHomePane.getJSamplerHome();
246                    if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
247                            CC.changeJSamplerHome(s);
248                    }
249            }
250            
251            private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
252                    protected void
253                    clearRecentScripts() {
254                            ((MainFrame)CC.getMainFrame()).clearRecentScripts();
255                    }
256          }          }
257  }  }
258    
# Line 457  class ViewPane extends JPanel { Line 267  class ViewPane extends JPanel {
267                    
268          private final JCheckBox checkBorderColor =          private final JCheckBox checkBorderColor =
269                  new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor"));                  new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor"));
270          private final PrefsDlg.ColorButton btnBorderColor =          private final JSColorButton btnBorderColor = new JSColorButton(Color.WHITE);
271                  new PrefsDlg.ColorButton(Color.WHITE);          
272            private final JCheckBox checkHlChnBorderColor =
273                    new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBorderColor"));
274            private final JSColorButton btnHlChnBorderColor = new JSColorButton(Color.WHITE);
275            
276            private final JCheckBox checkSelChnBgColor =
277                    new JCheckBox(i18n.getLabel("ViewPane.checkSelChnBgColor"));
278            private final JSColorButton btnSelChnBgColor = new JSColorButton(Color.WHITE);
279            
280            private final JCheckBox checkHlChnBgColor =
281                    new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBgColor"));
282            private final JSColorButton btnHlChnBgColor = new JSColorButton(Color.WHITE);
283                    
284          public          public
285          ViewPane() { initViewPane(); }          ViewPane() { initViewPane(); }
# Line 518  class ViewPane extends JPanel { Line 339  class ViewPane extends JPanel {
339                    
340          private JPanel          private JPanel
341          createCustomColorsPane() {          createCustomColorsPane() {
                 JPanel ccp = new JPanel();  
                 ccp.setAlignmentX(CENTER_ALIGNMENT);  
                 ccp.setLayout(new BoxLayout(ccp, BoxLayout.Y_AXIS));  
                   
                 JPanel p = new JPanel();  
                 p.setAlignmentX(LEFT_ALIGNMENT);  
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                 p.add(checkBorderColor);  
                   
                 p.add(Box.createRigidArea(new Dimension(6, 0)));  
                   
342                  btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());                  btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());
343                  btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor());                  btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor());
                 p.add(btnBorderColor);  
344                                    
345                  checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor());                  checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor());
346                                    
# Line 543  class ViewPane extends JPanel { Line 352  class ViewPane extends JPanel {
352                          }                          }
353                  });                  });
354                                    
355                  ccp.add(p);                  btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor());
356                    btnHlChnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderHlColor());
357                    
358                    checkHlChnBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderHlColor());
359                    
360                    checkHlChnBorderColor.addItemListener(new ItemListener() {
361                            public void
362                            itemStateChanged(ItemEvent e) {
363                                    boolean b = e.getStateChange() == e.SELECTED;
364                                    btnHlChnBorderColor.setEnabled(b);
365                            }
366                    });
367                    
368                    Color color = ClassicPrefs.getSelectedChannelBgColor();
369                    if(color == null) color = new Color(getBackground().getRGB());
370                    btnSelChnBgColor.setColor(color);
371                    btnSelChnBgColor.setEnabled(ClassicPrefs.getCustomSelectedChannelBgColor());
372                    
373                    checkSelChnBgColor.setSelected(ClassicPrefs.getCustomSelectedChannelBgColor());
374                    
375                    checkSelChnBgColor.addItemListener(new ItemListener() {
376                            public void
377                            itemStateChanged(ItemEvent e) {
378                                    boolean b = e.getStateChange() == e.SELECTED;
379                                    btnSelChnBgColor.setEnabled(b);
380                            }
381                    });
382                    
383                    color = ClassicPrefs.getHighlightedChannelBgColor();
384                    if(color == null) color = new Color(getBackground().getRGB());
385                    btnHlChnBgColor.setColor(color);
386                    btnHlChnBgColor.setEnabled(ClassicPrefs.getCustomHighlightedChannelBgColor());
387                    
388                    checkHlChnBgColor.setSelected(ClassicPrefs.getCustomHighlightedChannelBgColor());
389                    
390                    checkHlChnBgColor.addItemListener(new ItemListener() {
391                            public void
392                            itemStateChanged(ItemEvent e) {
393                                    boolean b = e.getStateChange() == e.SELECTED;
394                                    btnHlChnBgColor.setEnabled(b);
395                            }
396                    });
397                                    
398                  JButton btnDefaults = new JButton("Reset to defaults");                  JButton btnDefaults = new JButton("Reset to defaults");
399                  btnDefaults.addActionListener(new ActionListener() {                  btnDefaults.addActionListener(new ActionListener() {
# Line 551  class ViewPane extends JPanel { Line 401  class ViewPane extends JPanel {
401                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
402                                  ClassicPrefs.setChannelBorderColor(null);                                  ClassicPrefs.setChannelBorderColor(null);
403                                  btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());                                  btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());
404                                    
405                                    ClassicPrefs.setChannelBorderHlColor(null);
406                                    btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor());
407                                    
408                                    ClassicPrefs.setSelectedChannelBgColor(null);
409                                    btnSelChnBgColor.setColor(ClassicPrefs.getSelectedChannelBgColor());
410                                    
411                                    ClassicPrefs.setHighlightedChannelBgColor(null);
412                                    btnHlChnBgColor.setColor(ClassicPrefs.getHighlightedChannelBgColor());
413                          }                          }
414                  });                  });
415                                    
416                  p = new JPanel();                  GridBagLayout gridbag = new GridBagLayout();
417                    GridBagConstraints c = new GridBagConstraints();
418                    
419                    JPanel ccp = new JPanel();
420                    ccp.setLayout(gridbag);
421                    
422                    c.fill = GridBagConstraints.NONE;
423                    
424                    c.gridx = 0;
425                    c.gridy = 0;
426                    c.anchor = GridBagConstraints.WEST;
427                    c.insets = new Insets(0, 3, 3, 3);
428                    gridbag.setConstraints(checkBorderColor, c);
429                    ccp.add(checkBorderColor);
430                    
431                    
432                    c.gridx = 1;
433                    c.gridy = 0;
434                    gridbag.setConstraints(btnBorderColor, c);
435                    ccp.add(btnBorderColor);
436                    
437                    c.gridx = 0;
438                    c.gridy = 1;
439                    gridbag.setConstraints(checkHlChnBorderColor, c);
440                    ccp.add(checkHlChnBorderColor);
441                    
442                    c.gridx = 1;
443                    c.gridy = 1;
444                    gridbag.setConstraints(btnHlChnBorderColor, c);
445                    ccp.add(btnHlChnBorderColor);
446                    
447                    c.gridx = 0;
448                    c.gridy = 2;
449                    gridbag.setConstraints(checkSelChnBgColor, c);
450                    ccp.add(checkSelChnBgColor);
451                    
452                    c.gridx = 1;
453                    c.gridy = 2;
454                    gridbag.setConstraints(btnSelChnBgColor, c);
455                    ccp.add(btnSelChnBgColor);
456                    
457                    c.gridx = 0;
458                    c.gridy = 3;
459                    gridbag.setConstraints(checkHlChnBgColor, c);
460                    ccp.add(checkHlChnBgColor);
461                    
462                    c.gridx = 1;
463                    c.gridy = 3;
464                    gridbag.setConstraints(btnHlChnBgColor, c);
465                    ccp.add(btnHlChnBgColor);
466                    
467                    JPanel p = new JPanel();
468                  p.setAlignmentX(LEFT_ALIGNMENT);                  p.setAlignmentX(LEFT_ALIGNMENT);
469                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
470                  p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));                  p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));
# Line 564  class ViewPane extends JPanel { Line 474  class ViewPane extends JPanel {
474                  p.add(btnDefaults);                  p.add(btnDefaults);
475                  p.add(Box.createGlue());                  p.add(Box.createGlue());
476                                    
477                    c.fill = GridBagConstraints.HORIZONTAL;
478                    c.gridx = 0;
479                    c.gridy = 4;
480                    c.gridwidth = 2;
481                    c.weightx = 1.0;
482                    c.anchor = GridBagConstraints.CENTER;
483                    gridbag.setConstraints(p, c);
484                  ccp.add(p);                  ccp.add(p);
485                                            
486                  ccp.setBorder (                  ccp.setBorder (
487                          BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane"))                          BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane"))
488                  );                  );
# Line 629  class ViewPane extends JPanel { Line 546  class ViewPane extends JPanel {
546                  if(b) c = ClassicPrefs.getChannelBorderColor();                  if(b) c = ClassicPrefs.getChannelBorderColor();
547                  else c = ClassicPrefs.getDefaultChannelBorderColor();                  else c = ClassicPrefs.getDefaultChannelBorderColor();
548                  Channel.setBorderColor(c);                  Channel.setBorderColor(c);
549                    
550                    b = checkHlChnBorderColor.isSelected();
551                    ClassicPrefs.setCustomChannelBorderHlColor(b);
552                    if(b) ClassicPrefs.setChannelBorderHlColor(btnHlChnBorderColor.getColor());
553                    
554                    if(b) c = ClassicPrefs.getChannelBorderHlColor();
555                    else c = ClassicPrefs.getDefaultChannelBorderHlColor();
556                    Channel.setBorderHighlightedColor(c);
557                    
558                    b = checkSelChnBgColor.isSelected();
559                    ClassicPrefs.setCustomSelectedChannelBgColor(b);
560                    if(b) ClassicPrefs.setSelectedChannelBgColor(btnSelChnBgColor.getColor());
561                    
562                    if(b) c = ClassicPrefs.getSelectedChannelBgColor();
563                    else c = new Color(getBackground().getRGB());
564                    if(c == null) c = new Color(getBackground().getRGB());
565                    Channel.setSelectedChannelBgColor(c);
566                    
567                    b = checkHlChnBgColor.isSelected();
568                    ClassicPrefs.setCustomHighlightedChannelBgColor(b);
569                    if(b) ClassicPrefs.setHighlightedChannelBgColor(btnHlChnBgColor.getColor());
570                    
571                    if(b) c = ClassicPrefs.getHighlightedChannelBgColor();
572                    else c = new Color(getBackground().getRGB());
573                    if(c == null) c = new Color(getBackground().getRGB());
574                    Channel.setHighlightedChannelBgColor(c);
575          }          }
576                    
577          class LocaleBox {          class LocaleBox {
# Line 644  class ViewPane extends JPanel { Line 587  class ViewPane extends JPanel {
587          }          }
588  }  }
589    
590  class ConsolePane extends JPanel {  class ConsolePane extends JSLSConsolePropsPane {
591          private final JLabel lCmdHistorySize =          protected void
592                  new JLabel(i18n.getLabel("ConsolePane.lCmdHistorySize"));          clearConsoleHistory() {
593          private final JSpinner spCmdHistorySize;                  MainFrame mainFrame = (MainFrame)CC.getMainFrame();
594          private final JLabel lLines = new JLabel(i18n.getLabel("ConsolePane.lLines"));                  mainFrame.getLSConsoleModel().clearCommandHistory();
         private final JButton btnClearCmdHistory =  
                 new JButton(i18n.getButtonLabel("ConsolePane.btnClearCmdHistory"));  
           
         private final JLabel lTextColor = new JLabel(i18n.getLabel("ConsolePane.lTextColor"));  
         private final PrefsDlg.ColorButton btnTextColor = new PrefsDlg.ColorButton();  
           
         private final JLabel lBGColor = new JLabel(i18n.getLabel("ConsolePane.lBGColor"));  
         private final PrefsDlg.ColorButton btnBGColor = new PrefsDlg.ColorButton();  
           
         private final JLabel lNotifyColor = new JLabel(i18n.getLabel("ConsolePane.lNotifyColor"));  
         private final PrefsDlg.ColorButton btnNotifyColor = new PrefsDlg.ColorButton();  
           
         private final JLabel lWarningColor = new JLabel(i18n.getLabel("ConsolePane.lWarningColor"));  
         private final PrefsDlg.ColorButton btnWarningColor = new PrefsDlg.ColorButton();  
           
         private final JLabel lErrorColor = new JLabel(i18n.getLabel("ConsolePane.lErrorColor"));  
         private final PrefsDlg.ColorButton btnErrorColor = new PrefsDlg.ColorButton();  
           
           
         public  
         ConsolePane() {  
                 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));  
                   
                 int i = ClassicPrefs.getLSConsoleHistSize();  
                 spCmdHistorySize = new JSpinner(new SpinnerNumberModel(i, 0, 20000, 1));  
                 spCmdHistorySize.setMaximumSize(spCmdHistorySize.getPreferredSize());  
                   
                 JPanel p = new JPanel();  
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                 p.add(lCmdHistorySize);  
                 p.add(Box.createRigidArea(new Dimension(5, 0)));  
                 p.add(spCmdHistorySize);  
                 p.add(Box.createRigidArea(new Dimension(5, 0)));  
                 p.add(lLines);  
                   
                 p.setAlignmentX(JPanel.CENTER_ALIGNMENT);  
                 add(p);  
                   
                 add(Box.createRigidArea(new Dimension(0, 6)));  
                   
                 btnClearCmdHistory.addActionListener(new ActionListener() {  
                         public void  
                         actionPerformed(ActionEvent e) {  
                                 ClassicPrefs.setLSConsoleHistory(null);  
                                 MainFrame mainFrame = (MainFrame)CC.getMainFrame();  
                                 mainFrame.getLSConsoleModel().clearCommandHistory();  
                         }  
                 });  
                           
                 btnClearCmdHistory.setAlignmentX(JPanel.CENTER_ALIGNMENT);  
                 add(btnClearCmdHistory);  
                   
                 add(Box.createRigidArea(new Dimension(0, 6)));  
                   
                 p = createConsoleColorsPane();  
                 p.setAlignmentX(JPanel.CENTER_ALIGNMENT);  
                 add(p);  
                   
                 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));  
         }  
           
         private JPanel  
         createConsoleColorsPane() {  
                 JPanel ccp = new JPanel();  
                 ccp.setAlignmentX(CENTER_ALIGNMENT);  
                   
                 GridBagLayout gridbag = new GridBagLayout();  
                 GridBagConstraints c = new GridBagConstraints();  
           
                 ccp.setLayout(gridbag);  
                   
                 c.fill = GridBagConstraints.NONE;  
           
                 c.gridx = 0;  
                 c.gridy = 0;  
                 c.anchor = GridBagConstraints.EAST;  
                 c.insets = new Insets(3, 3, 3, 3);  
                 gridbag.setConstraints(lTextColor, c);  
                 ccp.add(lTextColor);  
   
                 c.gridx = 0;  
                 c.gridy = 1;  
                 gridbag.setConstraints(lBGColor, c);  
                 ccp.add(lBGColor);  
           
                 c.gridx = 0;  
                 c.gridy = 2;  
                 gridbag.setConstraints(lNotifyColor, c);  
                 ccp.add(lNotifyColor);  
           
                 c.gridx = 0;  
                 c.gridy = 3;  
                 gridbag.setConstraints(lWarningColor, c);  
                 ccp.add(lWarningColor);  
           
                 c.gridx = 0;  
                 c.gridy = 4;  
                 gridbag.setConstraints(lErrorColor, c);  
                 ccp.add(lErrorColor);  
           
                 c.fill = GridBagConstraints.HORIZONTAL;  
                 c.gridx = 1;  
                 c.gridy = 0;  
                 //c.weightx = 1.0;  
                 c.anchor = GridBagConstraints.WEST;  
                 gridbag.setConstraints(btnTextColor, c);  
                 ccp.add(btnTextColor);  
                   
                 c.gridx = 1;  
                 c.gridy = 1;  
                 gridbag.setConstraints(btnBGColor, c);  
                 ccp.add(btnBGColor);  
                   
                 c.gridx = 1;  
                 c.gridy = 2;  
                 gridbag.setConstraints(btnNotifyColor, c);  
                 ccp.add(btnNotifyColor);  
                   
                 c.gridx = 1;  
                 c.gridy = 3;  
                 gridbag.setConstraints(btnWarningColor, c);  
                 ccp.add(btnWarningColor);  
                   
                 c.gridx = 1;  
                 c.gridy = 4;  
                 gridbag.setConstraints(btnErrorColor, c);  
                 ccp.add(btnErrorColor);  
                   
                 btnTextColor.setColor(ClassicPrefs.getLSConsoleTextColor());  
                 btnBGColor.setColor(ClassicPrefs.getLSConsoleBackgroundColor());  
                 btnNotifyColor.setColor(ClassicPrefs.getLSConsoleNotifyColor());  
                 btnWarningColor.setColor(ClassicPrefs.getLSConsoleWarningColor());  
                 btnErrorColor.setColor(ClassicPrefs.getLSConsoleErrorColor());  
                   
                 JButton btnDefaults = new JButton("Reset to defaults");  
                   
                 btnDefaults.addActionListener(new ActionListener() {  
                         public void  
                         actionPerformed(ActionEvent e) {  
                                 ClassicPrefs.setLSConsoleTextColor(null);  
                                 btnTextColor.setColor(ClassicPrefs.getLSConsoleTextColor());  
                                   
                                 ClassicPrefs.setLSConsoleBackgroundColor(null);  
                                 btnBGColor.setColor(ClassicPrefs.getLSConsoleBackgroundColor());  
                                   
                                 ClassicPrefs.setLSConsoleNotifyColor(null);  
                                 btnNotifyColor.setColor(ClassicPrefs.getLSConsoleNotifyColor());  
                                   
                                 ClassicPrefs.setLSConsoleWarningColor(null);  
                                 btnWarningColor.setColor(ClassicPrefs.getLSConsoleWarningColor());  
                                   
                                 ClassicPrefs.setLSConsoleErrorColor(null);  
                                 btnErrorColor.setColor(ClassicPrefs.getLSConsoleErrorColor());  
                         }  
                 });  
                   
                 JPanel p = new JPanel();  
                 p.setAlignmentX(LEFT_ALIGNMENT);  
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                 p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));  
                 p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));  
                   
                 p.add(Box.createGlue());  
                 p.add(btnDefaults);  
                 p.add(Box.createGlue());  
                   
                 c.gridx = 0;  
                 c.gridy = 5;  
                 c.gridwidth = 2;  
                 gridbag.setConstraints(p, c);  
                 ccp.add(p);  
                   
                 ccp.setBorder (  
                         BorderFactory.createTitledBorder(i18n.getLabel("ConsolePane.consoleColors"))  
                 );  
                   
                 ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));  
                   
                 return ccp;  
595          }          }
596                    
597          protected void          protected void
598          apply() {          apply() {
599                  int size = Integer.parseInt(spCmdHistorySize.getValue().toString());                  super.apply();
                 ClassicPrefs.setLSConsoleHistSize(size);  
                 LSConsoleModel model = ((MainFrame)CC.getMainFrame()).getLSConsoleModel();  
                 model.setCommandHistorySize(size);  
                   
                 ///***///  
600                                    
601                  MainFrame mainFrame = (MainFrame)CC.getMainFrame();                  MainFrame mainFrame = (MainFrame)CC.getMainFrame();
602                                    
603                  ClassicPrefs.setLSConsoleTextColor(btnTextColor.getColor());                  LSConsoleModel model = mainFrame.getLSConsoleModel();
604                  mainFrame.setLSConsoleTextColor(btnTextColor.getColor());                  model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
                   
                 ClassicPrefs.setLSConsoleBackgroundColor(btnBGColor.getColor());  
                 mainFrame.setLSConsoleBackgroundColor(btnBGColor.getColor());  
                   
                 ClassicPrefs.setLSConsoleNotifyColor(btnNotifyColor.getColor());  
                 mainFrame.setLSConsoleNotifyColor(btnNotifyColor.getColor());  
605                                    
606                  ClassicPrefs.setLSConsoleWarningColor(btnWarningColor.getColor());                  int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
607                  mainFrame.setLSConsoleWarningColor(btnWarningColor.getColor());                  mainFrame.setLSConsoleTextColor(new Color(c));
                   
                 ClassicPrefs.setLSConsoleErrorColor(btnErrorColor.getColor());  
                 mainFrame.setLSConsoleErrorColor(btnErrorColor.getColor());  
         }  
           
           
 }  
   
 class ConnectionPane extends JPanel {  
         final LSPrefsPane lsPrefsPane = new LSPrefsPane();  
           
         public  
         ConnectionPane() { initConnectionPane(); }  
           
         private void  
         initConnectionPane() {  
                 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));  
608                                    
609                  add(lsPrefsPane);                  c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
610                  add(Box.createGlue());                  mainFrame.setLSConsoleBackgroundColor(new Color(c));
                 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));  
         }  
           
         public String  
         getLSAddress() { return lsPrefsPane.getLSAddress(); }  
           
         public void  
         setLSAddress(String address) { lsPrefsPane.setLSAddress(address); }  
           
         public String  
         getLSPort() { return lsPrefsPane.getLSPort(); }  
           
         public void  
         setLSPort(String port) { lsPrefsPane.setLSPort(port); }  
 }  
   
 class LSPrefsPane extends JPanel {  
         private final JLabel lAddress = new JLabel(i18n.getLabel("LSPrefsPane.Address"));  
         private final JLabel lPort = new JLabel(i18n.getLabel("LSPrefsPane.Port"));  
         private final JTextField tfAddress = new JTextField();  
         private final JTextField tfPort = new JTextField();  
   
   
         public  
         LSPrefsPane() { initLSPrefsPane(); }  
   
         private void  
         initLSPrefsPane() {  
                 GridBagLayout gridbag = new GridBagLayout();  
                 GridBagConstraints c = new GridBagConstraints();  
           
                 setLayout(gridbag);  
611                                    
612                  // Set preferred size for username & password fields                  c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
613                  int w1 = (int) tfAddress.getMinimumSize().getWidth();                  mainFrame.setLSConsoleNotifyColor(new Color(c));
                 int h1 = (int) tfAddress.getMinimumSize().getHeight();  
                 Dimension d = new Dimension(w1 > 150 ? w1 : 150, h1);  
                 tfAddress.setMinimumSize(d);  
                 tfAddress.setPreferredSize(d);  
           
                 w1 = (int) tfPort.getMinimumSize().getWidth();  
                 h1 = (int) tfPort.getMinimumSize().getHeight();  
                 d = new Dimension(w1 > 150 ? w1 : 150, h1);  
                 tfPort.setMinimumSize(d);  
                 tfPort.setPreferredSize(d);  
           
                 c.fill = GridBagConstraints.NONE;  
           
                 c.gridx = 0;  
                 c.gridy = 0;  
                 c.anchor = GridBagConstraints.EAST;  
                 c.insets = new Insets(3, 3, 3, 3);  
                 gridbag.setConstraints(lAddress, c);  
                 add(lAddress);  
   
                 c.gridx = 0;  
                 c.gridy = 1;  
                 gridbag.setConstraints(lPort, c);  
                 add(lPort);  
           
                 c.fill = GridBagConstraints.HORIZONTAL;  
                 c.gridx = 1;  
                 c.gridy = 0;  
                 c.weightx = 1.0;  
                 c.anchor = GridBagConstraints.WEST;  
                 gridbag.setConstraints(tfAddress, c);  
                 add(tfAddress);  
614                                    
615                  c.gridx = 1;                  c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
616                  c.gridy = 1;                  mainFrame.setLSConsoleWarningColor(new Color(c));
                 gridbag.setConstraints(tfPort, c);  
                 add(tfPort);  
617                                    
618                  setBorder(BorderFactory.createTitledBorder(i18n.getLabel("LSPrefsPane")));                  c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
619                  setMaximumSize(new Dimension(Short.MAX_VALUE, getPreferredSize().height));                  mainFrame.setLSConsoleErrorColor(new Color(c));
620          }          }
           
         public String  
         getLSAddress() { return tfAddress.getText(); }  
           
         public void  
         setLSAddress(String address) { tfAddress.setText(address); }  
           
         public String  
         getLSPort() { return tfPort.getText(); }  
           
         public void  
         setLSPort(String port) { tfPort.setText(port); }  
621  }  }

Legend:
Removed from v.911  
changed lines
  Added in v.1285

  ViewVC Help
Powered by ViewVC