logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw DefaultSortTableModel.java LogUI.java
Date Tue, 20 May 2003 03:35:45 GMT
sdeboy      2003/05/19 20:35:44

  Modified:    src/java/org/apache/log4j/chainsaw
                        DefaultSortTableModel.java LogUI.java
  Log:
  Added icon switching on the tab - if new events arrive for a non-active tab, an icon is
set on the tab.  If events aren't currently being delivered but events have been received
since the last time you visited the tab, a separate icon is displayed.  Once you select the
tab, the icon is removed.
  
  Revision  Changes    Path
  1.9       +13 -16    jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DefaultSortTableModel.java
  
  Index: DefaultSortTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DefaultSortTableModel.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultSortTableModel.java	15 May 2003 18:26:03 -0000	1.8
  +++ DefaultSortTableModel.java	20 May 2003 03:35:44 -0000	1.9
  @@ -93,7 +93,7 @@
     private Vector detailColumns;
     private final FilterChangeExecutor filterExecutor =
       new FilterChangeExecutor();
  -  private EventCountListener listener;
  +  private Vector countListeners = new Vector();
     private StringBuffer detail = new StringBuffer();
     private String eventType;
   
  @@ -171,6 +171,12 @@
       return null;
     }
   
  +  private void notifyCountListeners() {
  +  	for (int i=0;i<countListeners.size();i++) {
  +  		((EventCountListener)countListeners.get(i)).eventCountChanged(getRowCount(), getUnfilteredRowCount());
  +  	}
  +  }
  +  
     public int find(int startRow, String text) {
       if (text == null) {
         text = "";
  @@ -298,9 +304,7 @@
         unfilteredEvents = newMap;
         super.setNumRows(rowCount);
   
  -      if (listener != null) {
  -        listener.eventCountChanged(getRowCount(), getUnfilteredRowCount());
  -      }
  +	  notifyCountListeners();
       }
     }
   
  @@ -521,15 +525,11 @@
             sort();
           }
   
  -        if (listener != null) {
  -          listener.eventCountChanged(getRowCount(), getUnfilteredRowCount());
  -        }
  +		notifyCountListeners();
   
           return true;
         } else {
  -        if (listener != null) {
  -          listener.eventCountChanged(getRowCount(), getUnfilteredRowCount());
  -        }
  +      	notifyCountListeners();
   
           return false;
         }
  @@ -540,8 +540,8 @@
       super.addRow(v);
     }
   
  -  public void setEventCountListener(EventCountListener listener) {
  -    this.listener = listener;
  +  public void addEventCountListener(EventCountListener listener) {
  +    countListeners.add(listener);
     }
   
     public boolean isSortable(int col) {
  @@ -638,10 +638,7 @@
           if (sortEnabled) {
             sort();
           }
  -
  -        if (listener != null) {
  -          listener.eventCountChanged(getRowCount(), getUnfilteredRowCount());
  -        }
  +		notifyCountListeners();
         }
       }
     }
  
  
  
  1.62      +47 -1     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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- LogUI.java	19 May 2003 23:36:57 -0000	1.61
  +++ LogUI.java	20 May 2003 03:35:44 -0000	1.62
  @@ -1401,13 +1401,15 @@
         panelMap.put(ident, this);
         entryMap.put(ident, map);
   
  -      tableModel.setEventCountListener(
  +      tableModel.addEventCountListener(
           new EventCountListener() {
             public void eventCountChanged(int currentCount, int totalCount) {
               statusPaneLabel.setText(
                 " Events " + currentCount + " of " + totalCount);
             }
           });
  +        
  +      tableModel.addEventCountListener(new TabIconHandler(ident));
       }
   
       String getIdentifier() {
  @@ -1730,6 +1732,50 @@
       }
     }
   
  +  class TabIconHandler implements EventCountListener {
  +  	private final String ident;
  +	private int lastCount;
  +	private int currentCount;
  +	private boolean hasNewEvents = false;
  +	ImageIcon NEW_EVENTS=new ImageIcon(ChainsawIcons.ABOUT);
  +	ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.UNDOCKED_ICON);
  +
  +	public TabIconHandler(final String ident) {
  +		this.ident = ident;
  +			
  +     	new Thread(new Runnable() {
  +      			public void run() {
  +      				while (true) {
  +      					//if this tab is active, remove the icon
  +						if (tabbedPane.getSelectedIndex() == tabbedPane.indexOfTab(ident)) {
  +      						tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), null);
  +      						hasNewEvents = false;													
  +						} else {
  +							//if the tab is not active and the counts don't match, set the new events icon
  +	      					if (lastCount != currentCount) {
  +	      						tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), NEW_EVENTS);
  +	      						lastCount = currentCount;
  +	      						hasNewEvents = true;
  +	      					} else {
  +	      						if (hasNewEvents) {
  +		      						tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), HAS_EVENTS);      			
			
  +	      						}
  +	      					}
  +      					}
  +      						
  +      					try {
  +      						Thread.sleep(1000);
  +      					} catch (InterruptedException ie){}
  +      				}
  +      			}
  +     	}).start();
  +		}
  +
  +		public void eventCountChanged(int currentCount, int totalCount) {
  +			this.currentCount=currentCount;
  +      	}
  +  }
  +  
     class ScrollToBottom extends Thread {
       boolean scrollToBottom;
       boolean bypassed;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message