/[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 910 by iliev, Thu Mar 16 18:08:34 2006 UTC revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC
# Line 57  import javax.swing.JLabel; Line 57  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;  import javax.swing.event.ChangeEvent;
66  import javax.swing.event.ChangeListener;  import javax.swing.event.ChangeListener;
# Line 72  import org.jsampler.CC; Line 74  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;  import org.jsampler.task.SetServerAddress;
# Line 84  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 108  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 165  public class PrefsDlg extends EnhancedDi Line 170  public class PrefsDlg extends EnhancedDi
170          onApply() {          onApply() {
171                  genPane.apply();                  genPane.apply();
172                  viewPane.apply();                  viewPane.apply();
173                    consolePane.apply();
174                                    
175                  // CONNECTION                  // CONNECTION
176                  Prefs.setLSAddress(getLSAddress());                  Prefs.setLSAddress(getLSAddress());
# Line 193  public class PrefsDlg extends EnhancedDi Line 199  public class PrefsDlg extends EnhancedDi
199                          return;                          return;
200                  }                  }
201                                    
                 //CC.getClient().setServerAddress(Prefs.getLSAddress());  
                 //CC.getClient().setServerPort(Prefs.getLSPort());  
202                  CC.getTaskQueue().add (                  CC.getTaskQueue().add (
203                          new SetServerAddress(Prefs.getLSAddress(), Prefs.getLSPort())                          new SetServerAddress(Prefs.getLSAddress(), Prefs.getLSPort())
204                  );                  );
# Line 216  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          private final JCheckBox checkWindowSizeAndLocation =          private final JCheckBox checkWindowSizeAndLocation =
348                  new JCheckBox(i18n.getLabel("GeneralPane.checkWindowSizeAndLocation"));                  new JCheckBox(i18n.getLabel("GeneralPane.checkWindowSizeAndLocation"));
349                    
350          public          private final JCheckBox checkLeftPaneState =
351          GeneralPane() { initGeneralPane(); }                  new JCheckBox(i18n.getLabel("GeneralPane.checkLeftPaneState"));
352                    
353          private void          private final JCheckBox checkShowLSConsoleWhenRunScript =
354          initGeneralPane() {                  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));                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
                 add(checkWindowSizeAndLocation);  
366                                    
367                  checkWindowSizeAndLocation.setSelected(Prefs.getSaveWindowProperties());                  checkWindowSizeAndLocation.setAlignmentX(JPanel.LEFT_ALIGNMENT);
368                                    
369                    checkWindowSizeAndLocation.setSelected(ClassicPrefs.getSaveWindowProperties());
370                  checkWindowSizeAndLocation.addItemListener(new ItemListener() {                  checkWindowSizeAndLocation.addItemListener(new ItemListener() {
371                          public void                          public void
372                          itemStateChanged(ItemEvent e) {                          itemStateChanged(ItemEvent e) {
373                                  boolean b = e.getStateChange() == e.SELECTED;                                  boolean b = e.getStateChange() == e.SELECTED;
374                                  checkWindowSizeAndLocation.setEnabled(b);                                  //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          protected void
436          apply() {          apply() {
437                  Prefs.setSaveWindowProperties(checkWindowSizeAndLocation.isSelected());                  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 260  class ViewPane extends JPanel { Line 457  class ViewPane extends JPanel {
457                    
458          private final JCheckBox checkBorderColor =          private final JCheckBox checkBorderColor =
459                  new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor"));                  new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor"));
460          private final ColorButton btnBorderColor = new ColorButton(Color.WHITE);          private final PrefsDlg.ColorButton btnBorderColor =
461                    new PrefsDlg.ColorButton(Color.WHITE);
462                    
463          public          public
464          ViewPane() { initViewPane(); }          ViewPane() { initViewPane(); }
# Line 345  class ViewPane extends JPanel { Line 543  class ViewPane extends JPanel {
543                          }                          }
544                  });                  });
545                                    
                 /*btnBorderColor.addActionListener(new ActionListener() {  
                         public void  
                         actionPerformed(ActionEvent e) {  
                                 ClassicPrefs.setChannelBorderColor(btnBorderColor.getColor());  
                         }  
                 });*/  
                   
546                  ccp.add(p);                  ccp.add(p);
547                                    
548                  JButton btnDefaults = new JButton("Reset to defaults");                  JButton btnDefaults = new JButton("Reset to defaults");
# Line 379  class ViewPane extends JPanel { Line 570  class ViewPane extends JPanel {
570                          BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane"))                          BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane"))
571                  );                  );
572                                    
573                  ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));                  ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, ccp.getPreferredSize().height));
574                                    
575                  return ccp;                  return ccp;
576          }          }
# Line 451  class ViewPane extends JPanel { Line 642  class ViewPane extends JPanel {
642                  public String                  public String
643                  toString() { return locale.getDisplayLanguage(JSI18n.i18n.getCurrentLocale()); }                  toString() { return locale.getDisplayLanguage(JSI18n.i18n.getCurrentLocale()); }
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 class ColorButton extends JPanel {          private final JLabel lNotifyColor = new JLabel(i18n.getLabel("ConsolePane.lNotifyColor"));
662                  private Color color;          private final PrefsDlg.ColorButton btnNotifyColor = new PrefsDlg.ColorButton();
663                  private final Vector<ActionListener> listeners = new Vector<ActionListener>();          
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                  ColorButton(Color c) {                  int i = ClassicPrefs.getLSConsoleHistSize();
676                          color = c;                  spCmdHistorySize = new JSpinner(new SpinnerNumberModel(i, 0, 20000, 1));
677                                            spCmdHistorySize.setMaximumSize(spCmdHistorySize.getPreferredSize());
678                          //setBorderPainted(false);                  
679                          setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));                  JPanel p = new JPanel();
680                          setPreferredSize(new Dimension(42, 16));                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
681                          setMaximumSize(new Dimension(42, 16));                  p.add(lCmdHistorySize);
682                          setBorder(BorderFactory.createLineBorder(Color.BLACK));                  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                          addMouseListener(new MouseAdapter() {                  btnClearCmdHistory.setAlignmentX(JPanel.CENTER_ALIGNMENT);
702                                  public void                  add(btnClearCmdHistory);
                                 mouseClicked(MouseEvent e) {  
                                         if(!isEnabled()) return;  
                                         if(e.getButton() == e.BUTTON1) showColorChooser();  
                                 }  
                         });  
                 }  
703                                    
704                  /**                  add(Box.createRigidArea(new Dimension(0, 6)));
705                   * Registers the specified listener to be                  
706                   * notified when the current color is changed.                  p = createConsoleColorsPane();
707                   * @param l The <code>ActionListener</code> to register.                  p.setAlignmentX(JPanel.CENTER_ALIGNMENT);
708                   */                  add(p);
709                  public void                  
710                  addActionListener(ActionListener l) { listeners.add(l); }                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
711            }
712                    
713                  /**          private JPanel
714                   * Removes the specified listener.          createConsoleColorsPane() {
715                   * @param l The <code>ActionListener</code> to remove.                  JPanel ccp = new JPanel();
716                   */                  ccp.setAlignmentX(CENTER_ALIGNMENT);
                 public void  
                 removeActionListener(ActionListener l) { listeners.remove(l); }  
717                                    
718                  /** Notifies listeners that the current color is changed. */                  GridBagLayout gridbag = new GridBagLayout();
719                  private void                  GridBagConstraints c = new GridBagConstraints();
                 fireActionPerformed() {  
                         ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null);  
                         for(ActionListener l : listeners) l.actionPerformed(e);  
                 }  
720                    
721                  public void                  ccp.setLayout(gridbag);
                 setEnabled(boolean b) {  
                         setOpaque(b);  
                         if(b) setBorder(BorderFactory.createLineBorder(Color.BLACK));  
                         else setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));  
                         //setBorderPainted(!b);  
                         super.setEnabled(b);  
                 }  
722                                    
723                  private void                  c.fill = GridBagConstraints.NONE;
724                  showColorChooser() {          
725                          ColorDlg dlg = new ColorDlg(getColor());                  c.gridx = 0;
726                          dlg.setVisible(true);                  c.gridy = 0;
727                          if(!dlg.isCancelled()) {                  c.anchor = GridBagConstraints.EAST;
728                                  setColor(dlg.getColor());                  c.insets = new Insets(3, 3, 3, 3);
729                                  fireActionPerformed();                  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                  public Color                  JPanel p = new JPanel();
809                  getColor() { return color; }                  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                  public void                  p.add(Box.createGlue());
815                  setColor(Color c) {                  p.add(btnDefaults);
816                          color = c;                  p.add(Box.createGlue());
817                          setBackground(color);                  
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          private class ColorDlg extends OkCancelDialog {          protected void
834                  private final JColorChooser colorChooser = new JColorChooser();          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                  ColorDlg() { this(Color.WHITE); }                  ///***///
841                                    
842                  ColorDlg(Color c) {                  MainFrame mainFrame = (MainFrame)CC.getMainFrame();
                         super((Dialog)JuifeUtils.getWindow(ViewPane.this));  
                           
                         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()); }  
                         });  
                 }  
843                                    
844                  protected void                  ClassicPrefs.setLSConsoleTextColor(btnTextColor.getColor());
845                  onOk() { setVisible(false); }                  mainFrame.setLSConsoleTextColor(btnTextColor.getColor());
846                                    
847                  protected void                  ClassicPrefs.setLSConsoleBackgroundColor(btnBGColor.getColor());
848                  onCancel() { setVisible(false); }                  mainFrame.setLSConsoleBackgroundColor(btnBGColor.getColor());
849                                    
850                  public Color                  ClassicPrefs.setLSConsoleNotifyColor(btnNotifyColor.getColor());
851                  getColor() { return colorChooser.getColor(); }                  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 {

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

  ViewVC Help
Powered by ViewVC