psmith      2003/06/24 15:35:31

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  If the Cyclic buffer is in use, added an EventCountListener so that
  warning messages could be displayed when the buffer is taken over
  the 75%, and 100% markers.
  
  This message is displayed in the status bar regardless of the currently selected tab.
  
  I would also like to add a small progress-bar-ish type thing to the status bar
  to display the stats of the buffer for the currently selected tab.
  
  Revision  Changes    Path
  1.114     +36 -5     
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.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- LogUI.java        23 Jun 2003 02:50:11 -0000      1.113
  +++ LogUI.java        24 Jun 2003 22:35:30 -0000      1.114
  @@ -101,6 +101,8 @@
   import java.io.ObjectOutputStream;
   import java.io.Serializable;
   
  +import java.text.NumberFormat;
  +
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.HashMap;
  @@ -283,7 +285,7 @@
      *
      */
     private void initGUI() {
  -     statusBar = new ChainsawStatusBar();
  +    statusBar = new ChainsawStatusBar();
       receiversPanel = new ReceiversPanel(this);
       tbms = new ChainsawToolBarAndMenus(this);
       toolbar = tbms.getToolbar();
  @@ -350,7 +352,6 @@
           }
         });
   
  -
       if (
         PluginRegistry.getPlugins(
             LogManager.getLoggerRepository(), Receiver.class).size() == 0) {
  @@ -590,12 +591,12 @@
   
             getContentPane().invalidate();
             getContentPane().validate();
  -          
  +
             tbms.stateChange();
           }
         });
     }
  -  
  +
     boolean isReceiverPanelVisible() {
       return getContentPane().isAncestorOf(receiversPanel);
     }
  @@ -1073,7 +1074,6 @@
       try {
         UIManager.setLookAndFeel(lookAndFeelClassName);
         SwingUtilities.updateComponentTreeUI(this);
  -
       } catch (Exception e) {
         LogLog.error("Failed to change L&F", e);
       }
  @@ -1753,6 +1753,37 @@
                 " Events " + currentCount + " of " + totalCount);
             }
           });
  +
  +      if (tableModel.isCyclic()) {
  +        final ChainsawCyclicBufferTableModel cyclicModel =
  +          (ChainsawCyclicBufferTableModel) tableModel;
  +        tableModel.addEventCountListener(
  +          new EventCountListener() {
  +            final NumberFormat formatter = NumberFormat.getPercentInstance();
  +
  +            public void eventCountChanged(int currentCount, int totalCount) {
  +              double percent =
  +                ((double) totalCount) / cyclicModel.getMaxSize();
  +              String msg = null;
  +
  +              if ((percent > 0.75) && (percent < 1.0)) {
  +                msg =
  +                  "Warning :: " + formatter.format(percent) + " of the '"
  +                  + getIdentifier() + "' buffer has been used";
  +              } else if (percent >= 1.0) {
  +                msg =
  +                  "Warning :: " + formatter.format(percent) + " of the '"
  +                  + getIdentifier()
  +                  + "' buffer has been used.  Older events are being discarded.";
  +              }
  +
  +              if (msg != null) {
  +                getStatusBar().setMessage(msg);
  +              }
  +            }
  +          });
  +      }
  +
         tableModel.addEventCountListener(new TabIconHandler(ident));
         f.pack();
       }
  
  
  

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

Reply via email to