/[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 787 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC
# Line 22  Line 22 
22    
23  package org.jsampler.view.classic;  package org.jsampler.view.classic;
24    
25    import java.awt.BorderLayout;
26    import java.awt.Color;
27  import java.awt.Container;  import java.awt.Container;
28    import java.awt.Cursor;
29    import java.awt.Dialog;
30  import java.awt.Dimension;  import java.awt.Dimension;
31  import java.awt.GraphicsEnvironment;  import java.awt.GraphicsEnvironment;
32  import java.awt.Font;  import java.awt.Font;
# Line 33  import java.awt.Insets; Line 37  import java.awt.Insets;
37    
38  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
39  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
40    import java.awt.event.ItemEvent;
41    import java.awt.event.ItemListener;
42    import java.awt.event.MouseAdapter;
43    import java.awt.event.MouseEvent;
44    
45  import java.util.Locale;  import java.util.Locale;
46    import java.util.Vector;
47    
48  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
49  import javax.swing.Box;  import javax.swing.Box;
50  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
51    import javax.swing.DefaultButtonModel;
52  import javax.swing.JButton;  import javax.swing.JButton;
53    import javax.swing.JCheckBox;
54    import javax.swing.JColorChooser;
55  import javax.swing.JComboBox;  import javax.swing.JComboBox;
56  import javax.swing.JLabel;  import javax.swing.JLabel;
57  import javax.swing.JOptionPane;  import javax.swing.JOptionPane;
58  import javax.swing.JPanel;  import javax.swing.JPanel;
59  import javax.swing.JPasswordField;  import javax.swing.JPasswordField;
60    import javax.swing.JSpinner;
61  import javax.swing.JTabbedPane;  import javax.swing.JTabbedPane;
62  import javax.swing.JTextField;  import javax.swing.JTextField;
63    import javax.swing.SpinnerNumberModel;
64    
65    import javax.swing.event.ChangeEvent;
66    import javax.swing.event.ChangeListener;
67    
68  import net.sf.juife.EnhancedDialog;  import net.sf.juife.EnhancedDialog;
69  import net.sf.juife.JuifeUtils;  import net.sf.juife.JuifeUtils;
70    import net.sf.juife.LinkButton;
71    import net.sf.juife.OkCancelDialog;
72    
73    import org.jsampler.CC;
74  import org.jsampler.HF;  import org.jsampler.HF;
75  import org.jsampler.JSI18n;  import org.jsampler.JSI18n;
76  import org.jsampler.JSampler;  import org.jsampler.JSampler;
77    import org.jsampler.LSConsoleModel;
78  import org.jsampler.Prefs;  import org.jsampler.Prefs;
79    
80    import org.jsampler.task.SetServerAddress;
81    
82  import static org.jsampler.view.classic.ClassicI18n.i18n;  import static org.jsampler.view.classic.ClassicI18n.i18n;
83    
84    
# Line 64  import static org.jsampler.view.classic. Line 87  import static org.jsampler.view.classic.
87   * @author Grigor Iliev   * @author Grigor Iliev
88   */   */
89  public class PrefsDlg extends EnhancedDialog {  public class PrefsDlg extends EnhancedDialog {
         private final ViewPane viewPane = new ViewPane();  
90          private final GeneralPane genPane = new GeneralPane();          private final GeneralPane genPane = new GeneralPane();
91            private final ViewPane viewPane = new ViewPane();
92            private final ConsolePane consolePane = new ConsolePane();
93          private final ConnectionPane conPane = new ConnectionPane();          private final ConnectionPane conPane = new ConnectionPane();
94                    
95          private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));          private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
# Line 88  public class PrefsDlg extends EnhancedDi Line 112  public class PrefsDlg extends EnhancedDi
112                  JTabbedPane tp = new JTabbedPane();                  JTabbedPane tp = new JTabbedPane();
113                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
114                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
115                    tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
116                  tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), conPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), conPane);
117                  tp.setAlignmentX(RIGHT_ALIGNMENT);                  tp.setAlignmentX(RIGHT_ALIGNMENT);
118                                    
# Line 143  public class PrefsDlg extends EnhancedDi Line 168  public class PrefsDlg extends EnhancedDi
168                    
169          private void          private void
170          onApply() {          onApply() {
171                  // GENERAL                  genPane.apply();
172                  boolean b = Prefs.setInterfaceLanguage(viewPane.getInterfaceLanguage());                  viewPane.apply();
173                  boolean b2 = Prefs.setInterfaceCountry(viewPane.getInterfaceCountry());                  consolePane.apply();
                 if (b || b2) JOptionPane.showMessageDialog (  
                         this,  
                         i18n.getMessage("PrefsDlg.ifaceChangeInfo", JSampler.NAME),  
                         null,  
                         JOptionPane.INFORMATION_MESSAGE  
                 );  
                   
                 String fontName = viewPane.getInterfaceFontName();  
                 if(fontName.equals("[Default]")) {  
                         if(Prefs.setInterfaceFont(null)) JOptionPane.showMessageDialog (  
                                 this,  
                                 i18n.getMessage("PrefsDlg.ifaceFontChangeInfo", JSampler.NAME),  
                                 null,  
                                 JOptionPane.INFORMATION_MESSAGE  
                         );  
                 } else if(Prefs.setInterfaceFont(fontName)) {  
                         HF.setUIDefaultFont(fontName);  
                 }  
174                                    
175                  // CONNECTION                  // CONNECTION
176                  Prefs.setLSAddress(getLSAddress());                  Prefs.setLSAddress(getLSAddress());
177                                    
178                  b = true;                  boolean b = true;
179                  String s = getLSPort();                  String s = getLSPort();
180                  try {                  try {
181                          if(s.length() > 0) {                          if(s.length() > 0) {
182                                  int port = Integer.parseInt(s);                                  int port = Integer.parseInt(s);
183                                  if(port > 0 && port < 0xffff)                                  if(port > 0 && port < 0xffff)
184                                          Prefs.setAuthSrvPort(port);                                          Prefs.setLSPort(port);
185                                  else b = false;                                  else b = false;
186                          } else Prefs.setAuthSrvPort(-1);        // -1 resets to default value                          } else Prefs.setLSPort(-1);     // -1 resets to default value
187                  } catch(NumberFormatException x) {                  } catch(NumberFormatException x) {
188                          b = false;                          b = false;
189                  }                  }
# Line 192  public class PrefsDlg extends EnhancedDi Line 199  public class PrefsDlg extends EnhancedDi
199                          return;                          return;
200                  }                  }
201                                    
202                    CC.getTaskQueue().add (
203                            new SetServerAddress(Prefs.getLSAddress(), Prefs.getLSPort())
204                    );
205                    
206                  setVisible(false);                  setVisible(false);
207          }          }
208                    
# Line 209  public class PrefsDlg extends EnhancedDi Line 220  public class PrefsDlg extends EnhancedDi
220                    
221          private void          private void
222          setLSPort(int port) { conPane.setLSPort(String.valueOf(port)); }          setLSPort(int port) { conPane.setLSPort(String.valueOf(port)); }
223            
224            protected static class ColorButton extends JPanel {
225                    private Color color;
226                    private final Vector<ActionListener> listeners = new Vector<ActionListener>();
227                    
228                    ColorButton() { this(Color.WHITE); }
229                    
230                    ColorButton(Color c) {
231                            color = c;
232                            
233                            //setBorderPainted(false);
234                            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
235                            setPreferredSize(new Dimension(42, 16));
236                            setMaximumSize(new Dimension(42, 16));
237                            setBorder(BorderFactory.createLineBorder(Color.BLACK));
238                            
239                            addMouseListener(new MouseAdapter() {
240                                    public void
241                                    mouseClicked(MouseEvent e) {
242                                            if(!isEnabled()) return;
243                                            if(e.getButton() == e.BUTTON1) showColorChooser();
244                                    }
245                            });
246                    }
247                    
248                    /**
249                     * Registers the specified listener to be
250                     * notified when the current color is changed.
251                     * @param l The <code>ActionListener</code> to register.
252                     */
253                    public void
254                    addActionListener(ActionListener l) { listeners.add(l); }
255            
256                    /**
257                     * Removes the specified listener.
258                     * @param l The <code>ActionListener</code> to remove.
259                     */
260                    public void
261                    removeActionListener(ActionListener l) { listeners.remove(l); }
262                    
263                    /** Notifies listeners that the current color is changed. */
264                    private void
265                    fireActionPerformed() {
266                            ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null);
267                            for(ActionListener l : listeners) l.actionPerformed(e);
268                    }
269            
270                    public void
271                    setEnabled(boolean b) {
272                            setOpaque(b);
273                            if(b) setBorder(BorderFactory.createLineBorder(Color.BLACK));
274                            else setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
275                            //setBorderPainted(!b);
276                            super.setEnabled(b);
277                    }
278                    
279                    private void
280                    showColorChooser() {
281                            ColorDlg dlg = new ColorDlg (
282                                    (Dialog)JuifeUtils.getWindow(this), getColor()
283                            );
284                            
285                            dlg.setVisible(true);
286                            if(!dlg.isCancelled()) {
287                                    setColor(dlg.getColor());
288                                    fireActionPerformed();
289                            }
290                    }
291                    
292                    public Color
293                    getColor() { return color; }
294                    
295                    public void
296                    setColor(Color c) {
297                            color = c;
298                            setBackground(color);
299                    }
300            }
301            
302            protected static class ColorDlg extends OkCancelDialog {
303                    private final JColorChooser colorChooser = new JColorChooser();
304                    
305                    ColorDlg(Dialog owner) { this(owner, Color.WHITE); }
306                    
307                    ColorDlg(Dialog owner, Color c) {
308                            super(owner);
309                            
310                            colorChooser.setPreviewPanel(new JPanel());
311                            colorChooser.setColor(c);
312                            
313                            JPanel mainPane = new JPanel();
314                            mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
315                            mainPane.add(colorChooser);
316                            
317                            mainPane.add(Box.createRigidArea(new Dimension(0, 6)));
318                            
319                            final JPanel p = new JPanel();
320                            p.setBackground(c);
321                            p.setBorder(BorderFactory.createLineBorder(Color.BLACK));
322                            mainPane.add(p);
323                            
324                            p.setPreferredSize(new Dimension(48, 8));
325                            p.setMaximumSize(new Dimension(Short.MAX_VALUE, 8));
326                            
327                            setMainPane(mainPane);
328                            
329                            colorChooser.getSelectionModel().addChangeListener(new ChangeListener() {
330                                    public void
331                                    stateChanged(ChangeEvent e) { p.setBackground(getColor()); }
332                            });
333                    }
334                    
335                    protected void
336                    onOk() { setVisible(false); }
337                    
338                    protected void
339                    onCancel() { setVisible(false); }
340                    
341                    public Color
342                    getColor() { return colorChooser.getColor(); }
343            }
344  }  }
345    
346  class GeneralPane extends JPanel {  class GeneralPane extends JPanel {
347          public          private final JCheckBox checkWindowSizeAndLocation =
348          GeneralPane() { initGeneralPane(); }                  new JCheckBox(i18n.getLabel("GeneralPane.checkWindowSizeAndLocation"));
349                    
350          private void          private final JCheckBox checkLeftPaneState =
351          initGeneralPane() {                  new JCheckBox(i18n.getLabel("GeneralPane.checkLeftPaneState"));
352            
353            private final JCheckBox checkShowLSConsoleWhenRunScript =
354                    new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
355            
356            private final JLabel lRecentScriptsSize =
357                    new JLabel(i18n.getLabel("GeneralPane.lRecentScriptsSize"));
358            private final JSpinner spRecentScriptsSize;
359            private final JButton btnClearRecentScriptList =
360                    new JButton(i18n.getButtonLabel("GeneralPane.btnClearRecentScriptList"));
361            
362            
363            public
364            GeneralPane() {
365                    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
366                    
367                    checkWindowSizeAndLocation.setAlignmentX(JPanel.LEFT_ALIGNMENT);
368                    
369                    checkWindowSizeAndLocation.setSelected(ClassicPrefs.getSaveWindowProperties());
370                    checkWindowSizeAndLocation.addItemListener(new ItemListener() {
371                            public void
372                            itemStateChanged(ItemEvent e) {
373                                    boolean b = e.getStateChange() == e.SELECTED;
374                                    //checkWindowSizeAndLocation.setEnabled(b);
375                            }
376                    });
377                    
378                    add(checkWindowSizeAndLocation);
379                    
380                    checkLeftPaneState.setAlignmentX(JPanel.LEFT_ALIGNMENT);
381                    checkLeftPaneState.setSelected(ClassicPrefs.getSaveLeftPaneState());
382                    add(checkLeftPaneState);
383                    
384                    checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
385                    
386                    boolean b = ClassicPrefs.getShowLSConsoleWhenRunScript();
387                    checkShowLSConsoleWhenRunScript.setSelected(b);
388                    
389                    add(checkShowLSConsoleWhenRunScript);
390                    
391                    add(Box.createRigidArea(new Dimension(0, 6)));
392                    
393                    JPanel rsp = new JPanel();
394                    rsp.setLayout(new BoxLayout(rsp, BoxLayout.Y_AXIS));
395                    
396                    int i = ClassicPrefs.getRecentScriptsSize();
397                    spRecentScriptsSize = new JSpinner(new SpinnerNumberModel(i, 0, 100, 1));
398                    spRecentScriptsSize.setMaximumSize(spRecentScriptsSize.getPreferredSize());
399                    
400                    JPanel p = new JPanel();
401                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
402                    p.add(lRecentScriptsSize);
403                    p.add(Box.createRigidArea(new Dimension(5, 0)));
404                    p.add(spRecentScriptsSize);
405                    
406                    p.setAlignmentX(JPanel.CENTER_ALIGNMENT);
407                    rsp.add(p);
408                    
409                    rsp.add(Box.createRigidArea(new Dimension(0, 6)));
410                    
411                    btnClearRecentScriptList.addActionListener(new ActionListener() {
412                            public void
413                            actionPerformed(ActionEvent e) {
414                                    ClassicPrefs.setRecentScripts(null);
415                                    ((MainFrame)CC.getMainFrame()).clearRecentScripts();
416                            }
417                    });
418                    
419                    btnClearRecentScriptList.setAlignmentX(JPanel.CENTER_ALIGNMENT);
420                    rsp.add(btnClearRecentScriptList);
421                    rsp.add(Box.createRigidArea(new Dimension(0, 6)));
422                    
423                    rsp.setMaximumSize(new Dimension(Short.MAX_VALUE, rsp.getPreferredSize().height));
424                    rsp.setAlignmentX(JPanel.LEFT_ALIGNMENT);
425                    rsp.setBorder (
426                            BorderFactory.createTitledBorder(i18n.getLabel("GeneralPane.recentScripts"))
427                    );
428                    
429                    add(rsp);
430                    add(Box.createGlue());
431                                    
432                    setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
433            }
434            
435            protected void
436            apply() {
437                    ClassicPrefs.setSaveWindowProperties(checkWindowSizeAndLocation.isSelected());
438                    ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected());
439                    
440                    boolean b = checkShowLSConsoleWhenRunScript.isSelected();
441                    ClassicPrefs.setShowLSConsoleWhenRunScript(b);
442                    
443                    int size = Integer.parseInt(spRecentScriptsSize.getValue().toString());
444                    ClassicPrefs.setRecentScriptstSize(size);
445                    ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
446          }          }
447  }  }
448    
# Line 230  class ViewPane extends JPanel { Line 455  class ViewPane extends JPanel {
455                  new JLabel(i18n.getLabel("ViewPane.lIfaceFont"));                  new JLabel(i18n.getLabel("ViewPane.lIfaceFont"));
456          private final JComboBox cbIfaceFont = new JComboBox();          private final JComboBox cbIfaceFont = new JComboBox();
457                    
458            private final JCheckBox checkBorderColor =
459                    new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor"));
460            private final PrefsDlg.ColorButton btnBorderColor =
461                    new PrefsDlg.ColorButton(Color.WHITE);
462            
463          public          public
464          ViewPane() { initViewPane(); }          ViewPane() { initViewPane(); }
465                    
# Line 280  class ViewPane extends JPanel { Line 510  class ViewPane extends JPanel {
510                  fontPane.add(cbIfaceFont);                  fontPane.add(cbIfaceFont);
511                                    
512                  add(fontPane);                  add(fontPane);
513                    add(Box.createRigidArea(new Dimension(0, 6)));
514                    add(createCustomColorsPane());
515                    
516                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
517          }          }
518                    
519          protected String          private JPanel
520            createCustomColorsPane() {
521                    JPanel ccp = new JPanel();
522                    ccp.setAlignmentX(CENTER_ALIGNMENT);
523                    ccp.setLayout(new BoxLayout(ccp, BoxLayout.Y_AXIS));
524                    
525                    JPanel p = new JPanel();
526                    p.setAlignmentX(LEFT_ALIGNMENT);
527                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
528                    p.add(checkBorderColor);
529                    
530                    p.add(Box.createRigidArea(new Dimension(6, 0)));
531                    
532                    btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());
533                    btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor());
534                    p.add(btnBorderColor);
535                    
536                    checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor());
537                    
538                    checkBorderColor.addItemListener(new ItemListener() {
539                            public void
540                            itemStateChanged(ItemEvent e) {
541                                    boolean b = e.getStateChange() == e.SELECTED;
542                                    btnBorderColor.setEnabled(b);
543                            }
544                    });
545                    
546                    ccp.add(p);
547                    
548                    JButton btnDefaults = new JButton("Reset to defaults");
549                    btnDefaults.addActionListener(new ActionListener() {
550                            public void
551                            actionPerformed(ActionEvent e) {
552                                    ClassicPrefs.setChannelBorderColor(null);
553                                    btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor());
554                            }
555                    });
556                    
557                    p = new JPanel();
558                    p.setAlignmentX(LEFT_ALIGNMENT);
559                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
560                    p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));
561                    p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
562                    
563                    p.add(Box.createGlue());
564                    p.add(btnDefaults);
565                    p.add(Box.createGlue());
566                    
567                    ccp.add(p);
568                    
569                    ccp.setBorder (
570                            BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane"))
571                    );
572                    
573                    ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, ccp.getPreferredSize().height));
574                    
575                    return ccp;
576            }
577            
578            private String
579          getInterfaceLanguage() {          getInterfaceLanguage() {
580                  LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem();                  LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem();
581                  if(box == null) return null;                  if(box == null) return null;
582                  return box.getLocale().getLanguage();                  return box.getLocale().getLanguage();
583          }          }
584                    
585          protected String          private String
586          getInterfaceCountry() {          getInterfaceCountry() {
587                  LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem();                  LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem();
588                  if(box == null) return null;                  if(box == null) return null;
589                  return box.getLocale().getCountry();                  return box.getLocale().getCountry();
590          }          }
591                    
592          protected String          private String
593          getInterfaceFontName() { return cbIfaceFont.getSelectedItem().toString(); }          getInterfaceFontName() { return cbIfaceFont.getSelectedItem().toString(); }
594                    
595            protected void
596            apply() {
597                    boolean b = Prefs.setInterfaceLanguage(getInterfaceLanguage());
598                    boolean b2 = Prefs.setInterfaceCountry(getInterfaceCountry());
599                    if (b || b2) JOptionPane.showMessageDialog (
600                            this,
601                            i18n.getMessage("PrefsDlg.ifaceChangeInfo", "JS Classic"),
602                            null,
603                            JOptionPane.INFORMATION_MESSAGE
604                    );
605                    
606                    b = false;
607                    String fontName = getInterfaceFontName();
608                    if(fontName.equals("[Default]")) {
609                            b = Prefs.setInterfaceFont(null);
610                    } else if(Prefs.setInterfaceFont(fontName)) {
611                            HF.setUIDefaultFont(fontName);
612                            b = true;
613                    }
614                    
615                    if(b) JOptionPane.showMessageDialog (
616                            this,
617                            i18n.getMessage("PrefsDlg.ifaceFontChangeInfo", "JS Classic"),
618                            null,
619                            JOptionPane.INFORMATION_MESSAGE
620                    );
621                    
622                    ///***///
623                    
624                    b = checkBorderColor.isSelected();
625                    ClassicPrefs.setCustomChannelBorderColor(b);
626                    if(b) ClassicPrefs.setChannelBorderColor(btnBorderColor.getColor());
627                    
628                    Color c;
629                    if(b) c = ClassicPrefs.getChannelBorderColor();
630                    else c = ClassicPrefs.getDefaultChannelBorderColor();
631                    Channel.setBorderColor(c);
632            }
633            
634          class LocaleBox {          class LocaleBox {
635                  private Locale locale;                  private Locale locale;
636                                    
# Line 313  class ViewPane extends JPanel { Line 644  class ViewPane extends JPanel {
644          }          }
645  }  }
646    
647    class ConsolePane extends JPanel {
648            private final JLabel lCmdHistorySize =
649                    new JLabel(i18n.getLabel("ConsolePane.lCmdHistorySize"));
650            private final JSpinner spCmdHistorySize;
651            private final JLabel lLines = new JLabel(i18n.getLabel("ConsolePane.lLines"));
652            private final JButton btnClearCmdHistory =
653                    new JButton(i18n.getButtonLabel("ConsolePane.btnClearCmdHistory"));
654            
655            private final JLabel lTextColor = new JLabel(i18n.getLabel("ConsolePane.lTextColor"));
656            private final PrefsDlg.ColorButton btnTextColor = new PrefsDlg.ColorButton();
657            
658            private final JLabel lBGColor = new JLabel(i18n.getLabel("ConsolePane.lBGColor"));
659            private final PrefsDlg.ColorButton btnBGColor = new PrefsDlg.ColorButton();
660            
661            private final JLabel lNotifyColor = new JLabel(i18n.getLabel("ConsolePane.lNotifyColor"));
662            private final PrefsDlg.ColorButton btnNotifyColor = new PrefsDlg.ColorButton();
663            
664            private final JLabel lWarningColor = new JLabel(i18n.getLabel("ConsolePane.lWarningColor"));
665            private final PrefsDlg.ColorButton btnWarningColor = new PrefsDlg.ColorButton();
666            
667            private final JLabel lErrorColor = new JLabel(i18n.getLabel("ConsolePane.lErrorColor"));
668            private final PrefsDlg.ColorButton btnErrorColor = new PrefsDlg.ColorButton();
669            
670            
671            public
672            ConsolePane() {
673                    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
674                    
675                    int i = ClassicPrefs.getLSConsoleHistSize();
676                    spCmdHistorySize = new JSpinner(new SpinnerNumberModel(i, 0, 20000, 1));
677                    spCmdHistorySize.setMaximumSize(spCmdHistorySize.getPreferredSize());
678                    
679                    JPanel p = new JPanel();
680                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
681                    p.add(lCmdHistorySize);
682                    p.add(Box.createRigidArea(new Dimension(5, 0)));
683                    p.add(spCmdHistorySize);
684                    p.add(Box.createRigidArea(new Dimension(5, 0)));
685                    p.add(lLines);
686                    
687                    p.setAlignmentX(JPanel.CENTER_ALIGNMENT);
688                    add(p);
689                    
690                    add(Box.createRigidArea(new Dimension(0, 6)));
691                    
692                    btnClearCmdHistory.addActionListener(new ActionListener() {
693                            public void
694                            actionPerformed(ActionEvent e) {
695                                    ClassicPrefs.setLSConsoleHistory(null);
696                                    MainFrame mainFrame = (MainFrame)CC.getMainFrame();
697                                    mainFrame.getLSConsoleModel().clearCommandHistory();
698                            }
699                    });
700                            
701                    btnClearCmdHistory.setAlignmentX(JPanel.CENTER_ALIGNMENT);
702                    add(btnClearCmdHistory);
703                    
704                    add(Box.createRigidArea(new Dimension(0, 6)));
705                    
706                    p = createConsoleColorsPane();
707                    p.setAlignmentX(JPanel.CENTER_ALIGNMENT);
708                    add(p);
709                    
710                    setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
711            }
712            
713            private JPanel
714            createConsoleColorsPane() {
715                    JPanel ccp = new JPanel();
716                    ccp.setAlignmentX(CENTER_ALIGNMENT);
717                    
718                    GridBagLayout gridbag = new GridBagLayout();
719                    GridBagConstraints c = new GridBagConstraints();
720            
721                    ccp.setLayout(gridbag);
722                    
723                    c.fill = GridBagConstraints.NONE;
724            
725                    c.gridx = 0;
726                    c.gridy = 0;
727                    c.anchor = GridBagConstraints.EAST;
728                    c.insets = new Insets(3, 3, 3, 3);
729                    gridbag.setConstraints(lTextColor, c);
730                    ccp.add(lTextColor);
731    
732                    c.gridx = 0;
733                    c.gridy = 1;
734                    gridbag.setConstraints(lBGColor, c);
735                    ccp.add(lBGColor);
736            
737                    c.gridx = 0;
738                    c.gridy = 2;
739                    gridbag.setConstraints(lNotifyColor, c);
740                    ccp.add(lNotifyColor);
741            
742                    c.gridx = 0;
743                    c.gridy = 3;
744                    gridbag.setConstraints(lWarningColor, c);
745                    ccp.add(lWarningColor);
746            
747                    c.gridx = 0;
748                    c.gridy = 4;
749                    gridbag.setConstraints(lErrorColor, c);
750                    ccp.add(lErrorColor);
751            
752                    c.fill = GridBagConstraints.HORIZONTAL;
753                    c.gridx = 1;
754                    c.gridy = 0;
755                    //c.weightx = 1.0;
756                    c.anchor = GridBagConstraints.WEST;
757                    gridbag.setConstraints(btnTextColor, c);
758                    ccp.add(btnTextColor);
759                    
760                    c.gridx = 1;
761                    c.gridy = 1;
762                    gridbag.setConstraints(btnBGColor, c);
763                    ccp.add(btnBGColor);
764                    
765                    c.gridx = 1;
766                    c.gridy = 2;
767                    gridbag.setConstraints(btnNotifyColor, c);
768                    ccp.add(btnNotifyColor);
769                    
770                    c.gridx = 1;
771                    c.gridy = 3;
772                    gridbag.setConstraints(btnWarningColor, c);
773                    ccp.add(btnWarningColor);
774                    
775                    c.gridx = 1;
776                    c.gridy = 4;
777                    gridbag.setConstraints(btnErrorColor, c);
778                    ccp.add(btnErrorColor);
779                    
780                    btnTextColor.setColor(ClassicPrefs.getLSConsoleTextColor());
781                    btnBGColor.setColor(ClassicPrefs.getLSConsoleBackgroundColor());
782                    btnNotifyColor.setColor(ClassicPrefs.getLSConsoleNotifyColor());
783                    btnWarningColor.setColor(ClassicPrefs.getLSConsoleWarningColor());
784                    btnErrorColor.setColor(ClassicPrefs.getLSConsoleErrorColor());
785                    
786                    JButton btnDefaults = new JButton("Reset to defaults");
787                    
788                    btnDefaults.addActionListener(new ActionListener() {
789                            public void
790                            actionPerformed(ActionEvent e) {
791                                    ClassicPrefs.setLSConsoleTextColor(null);
792                                    btnTextColor.setColor(ClassicPrefs.getLSConsoleTextColor());
793                                    
794                                    ClassicPrefs.setLSConsoleBackgroundColor(null);
795                                    btnBGColor.setColor(ClassicPrefs.getLSConsoleBackgroundColor());
796                                    
797                                    ClassicPrefs.setLSConsoleNotifyColor(null);
798                                    btnNotifyColor.setColor(ClassicPrefs.getLSConsoleNotifyColor());
799                                    
800                                    ClassicPrefs.setLSConsoleWarningColor(null);
801                                    btnWarningColor.setColor(ClassicPrefs.getLSConsoleWarningColor());
802                                    
803                                    ClassicPrefs.setLSConsoleErrorColor(null);
804                                    btnErrorColor.setColor(ClassicPrefs.getLSConsoleErrorColor());
805                            }
806                    });
807                    
808                    JPanel p = new JPanel();
809                    p.setAlignmentX(LEFT_ALIGNMENT);
810                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
811                    p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));
812                    p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
813                    
814                    p.add(Box.createGlue());
815                    p.add(btnDefaults);
816                    p.add(Box.createGlue());
817                    
818                    c.gridx = 0;
819                    c.gridy = 5;
820                    c.gridwidth = 2;
821                    gridbag.setConstraints(p, c);
822                    ccp.add(p);
823                    
824                    ccp.setBorder (
825                            BorderFactory.createTitledBorder(i18n.getLabel("ConsolePane.consoleColors"))
826                    );
827                    
828                    ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
829                    
830                    return ccp;
831            }
832            
833            protected void
834            apply() {
835                    int size = Integer.parseInt(spCmdHistorySize.getValue().toString());
836                    ClassicPrefs.setLSConsoleHistSize(size);
837                    LSConsoleModel model = ((MainFrame)CC.getMainFrame()).getLSConsoleModel();
838                    model.setCommandHistorySize(size);
839                    
840                    ///***///
841                    
842                    MainFrame mainFrame = (MainFrame)CC.getMainFrame();
843                    
844                    ClassicPrefs.setLSConsoleTextColor(btnTextColor.getColor());
845                    mainFrame.setLSConsoleTextColor(btnTextColor.getColor());
846                    
847                    ClassicPrefs.setLSConsoleBackgroundColor(btnBGColor.getColor());
848                    mainFrame.setLSConsoleBackgroundColor(btnBGColor.getColor());
849                    
850                    ClassicPrefs.setLSConsoleNotifyColor(btnNotifyColor.getColor());
851                    mainFrame.setLSConsoleNotifyColor(btnNotifyColor.getColor());
852                    
853                    ClassicPrefs.setLSConsoleWarningColor(btnWarningColor.getColor());
854                    mainFrame.setLSConsoleWarningColor(btnWarningColor.getColor());
855                    
856                    ClassicPrefs.setLSConsoleErrorColor(btnErrorColor.getColor());
857                    mainFrame.setLSConsoleErrorColor(btnErrorColor.getColor());
858            }
859            
860            
861    }
862    
863  class ConnectionPane extends JPanel {  class ConnectionPane extends JPanel {
864          final LSPrefsPane lsPrefsPane = new LSPrefsPane();          final LSPrefsPane lsPrefsPane = new LSPrefsPane();
865                    
# Line 399  class LSPrefsPane extends JPanel { Line 946  class LSPrefsPane extends JPanel {
946                  add(tfPort);                  add(tfPort);
947                                    
948                  setBorder(BorderFactory.createTitledBorder(i18n.getLabel("LSPrefsPane")));                  setBorder(BorderFactory.createTitledBorder(i18n.getLabel("LSPrefsPane")));
949                    setMaximumSize(new Dimension(Short.MAX_VALUE, getPreferredSize().height));
950          }          }
951                    
952          public String          public String

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

  ViewVC Help
Powered by ViewVC