psmith      2003/12/04 13:28:48

  Modified:    src/java/org/apache/log4j/chainsaw
                        LogPanelPreferencePanel.java
  Log:
  Minor tweaks to the way the custom Date Format text
  area interacts with the rest of the radio buttons
  and the area itself has been sized to something smaller
  than the behemoth that it was before.
  
  Revision  Changes    Path
  1.10      +42 -11    
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
  
  Index: LogPanelPreferencePanel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LogPanelPreferencePanel.java      4 Dec 2003 08:53:02 -0000       1.9
  +++ LogPanelPreferencePanel.java      4 Dec 2003 21:28:48 -0000       1.10
  @@ -79,6 +79,7 @@
   import javax.swing.JTextField;
   import javax.swing.JTree;
   import javax.swing.ListCellRenderer;
  +import javax.swing.SwingConstants;
   import javax.swing.UIManager;
   import javax.swing.border.Border;
   import javax.swing.event.DocumentEvent;
  @@ -325,7 +326,12 @@
           new BoxLayout(dateFormatPanel, BoxLayout.Y_AXIS));
         dateFormatPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
   
  -      final JTextField  customFormatText = new JTextField();
  +      final JTextField  customFormatText = new JTextField("",10);
  +      customFormatText.setPreferredSize(new Dimension(100,20));
  +      customFormatText.setMaximumSize(customFormatText.getPreferredSize());
  +      customFormatText.setMinimumSize(customFormatText.getPreferredSize());
  +      customFormatText.setEnabled(false);
  +      
         final JRadioButton rdCustom =
         new JRadioButton(
         "Custom Format");
  @@ -333,8 +339,31 @@
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                 customFormatText.setEnabled(rdCustom.isSelected());
  +              customFormatText.setText("");
  +              customFormatText.grabFocus();
               }
             });
  +      rdCustom.setSelected(getModel().isCustomDateFormat());
  +      
  +      getModel().addPropertyChangeListener("dateFormatPattern", new 
PropertyChangeListener() {
  +
  +        public void propertyChange(PropertyChangeEvent evt)
  +        {
  +          /**
  +           * we need to make sure we are not reacting to the user typing, so only 
do this
  +           * if the text box is not the same as the model
  +           */ 
  +          
  +          if(getModel().isCustomDateFormat() && 
!customFormatText.getText().equals(evt.getNewValue().toString()))
  +          {
  +            customFormatText.setText(getModel().getDateFormatPattern());
  +            rdCustom.setSelected(true);
  +            customFormatText.setEnabled(true);
  +          }else {
  +            rdCustom.setSelected(false);
  +          }
  +          
  +        }});
         
         ButtonGroup bgDateFormat = new ButtonGroup();
         final JRadioButton rdISO =
  @@ -347,6 +376,7 @@
               customFormatText.setEnabled(rdCustom.isSelected());
             }
           });
  +      rdISO.setAlignmentX(0);
         rdISO.setSelected(getModel().isUseISO8601Format());
         getModel().addPropertyChangeListener(
           "dateFormatPattern",
  @@ -363,6 +393,8 @@
             iter.hasNext();) {
           final String format = (String) iter.next();
           final JRadioButton rdFormat = new JRadioButton(format);
  +        rdFormat.setAlignmentX(0);
  +        
           bgDateFormat.add(rdFormat);
           rdFormat.addActionListener(
             new ActionListener() {
  @@ -387,6 +419,7 @@
         if(getModel().isCustomDateFormat())
         {
           customFormatText.setText(getModel().getDateFormatPattern());
  +        customFormatText.setEnabled(true);
         }
         customFormatText.getDocument().addDocumentListener(new DocumentListener() {
   
  @@ -414,18 +447,16 @@
             
           }});
         
  -      rdCustom.setSelected(getModel().isCustomDateFormat());
  -      getModel().addPropertyChangeListener(
  -          "dateFormatPattern",
  -          new PropertyChangeListener() {
  -            public void propertyChange(PropertyChangeEvent evt) {
  -              rdCustom.setSelected(getModel().isCustomDateFormat());
  -            }
  -          });
  +      rdCustom.setAlignmentX(0);
         bgDateFormat.add(rdCustom);
   
  -      dateFormatPanel.add(rdCustom);
  -      dateFormatPanel.add(customFormatText);
  +      Box customBox = Box.createHorizontalBox();
  +      customBox.setAlignmentX(0);
  +      customBox.add(rdCustom);
  +      customBox.add(customFormatText);
  +      customBox.add(Box.createHorizontalGlue());
  +      dateFormatPanel.add(customBox);
  +//      dateFormatPanel.add(Box.createVerticalGlue());
         
   
         add(dateFormatPanel);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to