sdeboy      2003/06/08 09:20:49

  Modified:    src/java/org/apache/log4j/chainsaw
                        TableColorizingRenderer.java LogUI.java
                        ChainsawCyclicBufferTableModel.java
                        AbstractChainsawTableModel.java
  Log:
  Corrected tablemodel event firing (was previously de-selecting the last selected row 
when new rows were added and scroll to bottom was disabled)
  Jalopyized
  
  Revision  Changes    Path
  1.12      +27 -17    
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
  
  Index: TableColorizingRenderer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TableColorizingRenderer.java      4 Jun 2003 05:02:34 -0000       1.11
  +++ TableColorizingRenderer.java      8 Jun 2003 16:20:46 -0000       1.12
  @@ -49,10 +49,18 @@
   
   package org.apache.log4j.chainsaw;
   
  +import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  +import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SettingsListener;
  +import org.apache.log4j.helpers.ISO8601DateFormat;
  +
   import java.awt.Color;
   import java.awt.Component;
   import java.awt.Image;
  +
   import java.text.DateFormat;
  +
   import java.util.Calendar;
   import java.util.Date;
   import java.util.HashMap;
  @@ -68,12 +76,6 @@
   import javax.swing.table.DefaultTableCellRenderer;
   import javax.swing.table.TableModel;
   
  -import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  -import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SettingsListener;
  -import org.apache.log4j.helpers.ISO8601DateFormat;
  -
   
   /**
    * A specific TableCellRenderer that colourizes a particular cell based on
  @@ -81,7 +83,8 @@
    *
    * @author Claude Duguay
    */
  -public class TableColorizingRenderer extends DefaultTableCellRenderer implements 
SettingsListener, FilterChangedListener {
  +public class TableColorizingRenderer extends DefaultTableCellRenderer
  +  implements SettingsListener, FilterChangedListener {
     private static final DateFormat DATE_FORMATTER =
       new ISO8601DateFormat(Calendar.getInstance().getTimeZone());
     private Map iconMap = new HashMap();
  @@ -107,8 +110,9 @@
       levelComponent.setHorizontalAlignment(JLabel.CENTER);
   
       //    Image warningImage = 
((IconUIResource)UIManager.getIcon("OptionPane.warningIcon")).getImage().getScaledInstance(16,16,
 Image.SCALE_FAST);
  -    String[] iconFileNames = new String[] { "Warn.gif", "Inform.gif", "Error.gif"};
  -    String[] iconLabels = new String[] { "WARN", "INFO", "ERROR"};
  +    String[] iconFileNames =
  +      new String[] { "Warn.gif", "Inform.gif", "Error.gif" };
  +    String[] iconLabels = new String[] { "WARN", "INFO", "ERROR" };
   
       for (int i = 0; i < iconLabels.length; i++) {
         final ImageIcon icon =
  @@ -124,7 +128,7 @@
             newWidth, newHeight, Image.SCALE_SMOOTH);
         iconMap.put(iconLabels[i], new ImageIcon(iconImage));
       }
  -    
  +
       /**
        * finally, add the debug icon...
        */
  @@ -143,10 +147,11 @@
     }
   
     public void loadSettings(LoadSettingsEvent event) {
  -     levelDisplay = event.getSetting(ChainsawConstants.LEVEL_DISPLAY);
  +    levelDisplay = event.getSetting(ChainsawConstants.LEVEL_DISPLAY);
  +  }
  +
  +  public void saveSettings(SaveSettingsEvent event) {
     }
  -  
  -  public void saveSettings(SaveSettingsEvent event) {}
   
     /**
      *TODO
  @@ -181,7 +186,7 @@
       value = formatField(value);
   
       Color color = null;
  -     
  +
       Component c =
         super.getTableCellRendererComponent(
           table, value, isSelected, hasFocus, row, col);
  @@ -200,14 +205,18 @@
   
         Icon icon = (Icon) iconMap.get(value.toString());
   
  -      if ((levelDisplay != null && 
levelDisplay.equals(ChainsawConstants.LEVEL_DISPLAY_ICONS)) && icon != null) {
  +      if (
  +        ((levelDisplay != null)
  +          && levelDisplay.equals(ChainsawConstants.LEVEL_DISPLAY_ICONS))
  +          && (icon != null)) {
           levelComponent.setIcon(icon);
           levelComponent.setText("");
  -         levelComponent.setToolTipText(value.toString());
  +        levelComponent.setToolTipText(value.toString());
         } else {
           levelComponent.setIcon(null);
           levelComponent.setText(value.toString());
         }
  +
         levelComponent.setBackground(c.getBackground());
         levelComponent.setForeground(c.getForeground());
         c = levelComponent;
  @@ -217,8 +226,9 @@
       default:
         break;
       }
  +
       if (isSelected) {
  -             return c;
  +      return c;
       }
   
       this.table = table;
  
  
  
  1.89      +32 -23    
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- LogUI.java        8 Jun 2003 07:41:55 -0000       1.88
  +++ LogUI.java        8 Jun 2003 16:20:47 -0000       1.89
  @@ -151,27 +151,28 @@
    * that is used to display a Welcome panel, and any other panels that
    * are generated because Logging Events are streamed via a Receiver, or other
    * mechanism.
  - * 
  + *
    * If a system property 'chainsaw.usecyclicbuffer' is set to 'true', each panel 
will use a cyclic
    * buffer for displaying events and once events reach the buffer limit, the oldest 
events
    * are removed from the table.
  - * 
  + *
    * If the property is not provided, there is no limit on the table's buffer size.
  - * 
  - * If 'chainsaw.usecyclicbuffer' is set to 'true' and a system 
  + *
  + * If 'chainsaw.usecyclicbuffer' is set to 'true' and a system
    * property 'chainsaw.cyclicbuffersize' is set to some integer value, that value 
will
  - * be used as the buffer size - if the buffersize is not provided, a default 
  + * be used as the buffer size - if the buffersize is not provided, a default
    * size of 500 is used.
  - * 
  + *
    *
    * @author Scott Deboy <[EMAIL PROTECTED]>
    * @author Paul Smith <[EMAIL PROTECTED]>
    *
    */
   public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
  -     
  -  private static final String USE_CYCLIC_BUFFER_PROP_NAME = 
"chainsaw.usecyclicbuffer";
  -  private static final String CYCLIC_BUFFER_SIZE_PROP_NAME = 
"chainsaw.cyclicbuffersize";
  +  private static final String USE_CYCLIC_BUFFER_PROP_NAME =
  +    "chainsaw.usecyclicbuffer";
  +  private static final String CYCLIC_BUFFER_SIZE_PROP_NAME =
  +    "chainsaw.cyclicbuffersize";
     private static final String MAIN_WINDOW_HEIGHT = "main.window.height";
     private static final String MAIN_WINDOW_WIDTH = "main.window.width";
     private static final String MAIN_WINDOW_Y = "main.window.y";
  @@ -796,12 +797,19 @@
         final String eventType =
           ((ChainsawEventBatch.Entry) eventBatchEntrys.get(0)).getEventType();
   
  -             int bufferSize = 500;
  -             //if buffer size not provided, set default buffer size to 500 (only 
used if usecyclicbuffer true)
  -             if (System.getProperty(CYCLIC_BUFFER_SIZE_PROP_NAME) != null) {
  -                     bufferSize = 
Integer.valueOf(System.getProperty(CYCLIC_BUFFER_SIZE_PROP_NAME)).intValue();
  -             }
  -        tableModel = new 
ChainsawCyclicBufferTableModel(Boolean.valueOf(System.getProperty(USE_CYCLIC_BUFFER_PROP_NAME)).booleanValue(),
 bufferSize);
  +      int bufferSize = 500;
  +
  +      //if buffer size not provided, set default buffer size to 500 (only used if 
usecyclicbuffer true)
  +      if (System.getProperty(CYCLIC_BUFFER_SIZE_PROP_NAME) != null) {
  +        bufferSize =
  +          Integer.valueOf(System.getProperty(CYCLIC_BUFFER_SIZE_PROP_NAME))
  +                 .intValue();
  +      }
  +
  +      tableModel =
  +        new ChainsawCyclicBufferTableModel(
  +          Boolean.valueOf(System.getProperty(USE_CYCLIC_BUFFER_PROP_NAME))
  +                 .booleanValue(), bufferSize);
   
         map = new HashMap();
         table = new JSortTable(tableModel);
  @@ -1278,7 +1286,9 @@
         table.getSelectionModel().addListSelectionListener(
           new ListSelectionListener() {
             public void valueChanged(ListSelectionEvent evt) {
  -            if ((evt.getFirstIndex() == evt.getLastIndex()) || 
(evt.getValueIsAdjusting())) {
  +            if (
  +              (evt.getFirstIndex() == evt.getLastIndex())
  +                || (evt.getValueIsAdjusting())) {
                 return;
               }
   
  @@ -1595,18 +1605,16 @@
        * Find from the top
        * @param text
        */
  -
  -     void findFromTop(String text) {
  -             find(0, text);
  -     }
  -             
  +    void findFromTop(String text) {
  +      find(0, text);
  +    }
   
       /**
        * Finds the row with the specified text, and ensures it is made visible
        * @param text
        */
       void find(String text) {
  -     find(table.getSelectedRow(), text);
  +      find(table.getSelectedRow(), text);
       }
   
       /**
  @@ -1614,7 +1622,7 @@
        * @param text
        */
       void findNext(String text) {
  -     find(table.getSelectedRow() + 1, text);
  +      find(table.getSelectedRow() + 1, text);
       }
   
       /**
  @@ -1633,6 +1641,7 @@
         table.scrollToRow(
           newRow, table.columnAtPoint(table.getVisibleRect().getLocation()));
       }
  +
       /**
        * Docks this DockablePanel by hiding the JFrame and placing the
        * Panel back inside the LogUI window.
  
  
  
  1.10      +1 -1      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
  
  Index: ChainsawCyclicBufferTableModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ChainsawCyclicBufferTableModel.java       8 Jun 2003 07:15:57 -0000       1.9
  +++ ChainsawCyclicBufferTableModel.java       8 Jun 2003 16:20:48 -0000       1.10
  @@ -320,7 +320,7 @@
       if (!valueIsAdjusting) {
         notifyCountListeners();
       }
  -
  +     fireTableRowsInserted(filteredList.size() -1 , filteredList.size());
       return rowAdded;
     }
   }
  
  
  
  1.6       +0 -4      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/AbstractChainsawTableModel.java
  
  Index: AbstractChainsawTableModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/AbstractChainsawTableModel.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractChainsawTableModel.java   8 Jun 2003 04:58:00 -0000       1.5
  +++ AbstractChainsawTableModel.java   8 Jun 2003 16:20:48 -0000       1.6
  @@ -113,10 +113,6 @@
         ((EventCountListener) countListeners.get(i)).eventCountChanged(
           getRowCount(), getUnfilteredRowCount());
       }
  -
  -    TableModelEvent event = new TableModelEvent(this);
  -
  -    fireTableChanged(event);
     }
   
     public void setCurrentSortColumn(int col, boolean ascending) {
  
  
  

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

Reply via email to