sdeboy      2003/06/18 22:50:12

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
                        ChainsawTabbedPane.java
  Log:
  Updated code which changes each tab's icons:
  - new events are currently being delivered to the tab (light bulb)
  - events have been delivered to the tab since the tab was last active (info icon)
  - the tab is active or no events have been delivered since last active (no icon)
  
  Tabs are now constructed with a 'new events' icon
  A listener was added to remove the icon of the active tab through the tabpane's 
changelistener
  
  Revision  Changes    Path
  1.109     +12 -3     
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.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- LogUI.java        19 Jun 2003 02:37:32 -0000      1.108
  +++ LogUI.java        19 Jun 2003 05:50:12 -0000      1.109
  @@ -144,6 +144,7 @@
   import javax.swing.SwingUtilities;
   import javax.swing.UIManager;
   import javax.swing.event.ChangeEvent;
  +import javax.swing.event.ChangeListener;
   import javax.swing.event.DocumentEvent;
   import javax.swing.event.DocumentListener;
   import javax.swing.event.ListSelectionEvent;
  @@ -412,6 +413,12 @@
   
       tabbedPane = new ChainsawTabbedPane();
       tabbedPane.addChangeListener(tbms);
  +    tabbedPane.addChangeListener(new ChangeListener() {
  +     //received a statechange event - selection changed - remove icon from selected 
index
  +     public void stateChanged(ChangeEvent e) {
  +                     tabbedPane.setIconAt(tabbedPane.getSelectedIndex(), null);     
         
  +     }
  +    });
   
       KeyStroke ksRight =
         KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK);
  @@ -937,7 +944,7 @@
         SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
  -            tabbedPane.addANewTab(ident, thisPanel);
  +            tabbedPane.addANewTab(ident, thisPanel, new 
ImageIcon(ChainsawIcons.TOOL_TIP));
             }
           });
   
  @@ -1853,7 +1860,7 @@
         removeAll();
         add(lowerPanel, BorderLayout.CENTER);
         panelMap.put(getIdentifier(), LogPanel.this);
  -      tabbedPane.addANewTab(getIdentifier(), LogPanel.this);
  +      tabbedPane.addANewTab(getIdentifier(), LogPanel.this, null);
         externalPanel.setDocked(true);
         setDocked(true);
         dockingAction.putValue(Action.NAME, "Undock");
  @@ -2202,7 +2209,9 @@
       private final String ident;
       private int lastCount;
       private int currentCount;
  -    private boolean hasNewEvents = false;
  +    //the tabIconHandler is associated with a new tab, and a new tab always
  +    //has new events
  +    private boolean hasNewEvents = true;
       ImageIcon NEW_EVENTS = new ImageIcon(ChainsawIcons.TOOL_TIP);
       ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.INFO);
   
  
  
  
  1.2       +2 -2      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
  
  Index: ChainsawTabbedPane.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChainsawTabbedPane.java   14 Jun 2003 16:48:14 -0000      1.1
  +++ ChainsawTabbedPane.java   19 Jun 2003 05:50:12 -0000      1.2
  @@ -68,9 +68,9 @@
      * @param name
      * @param component
      */
  -  public void addANewTab(String name, JComponent component) {
  +  public void addANewTab(String name, JComponent component, Icon icon) {
       int selectedIndex = getSelectedIndex();
  -    super.insertTab(name, null, component, null, 0);
  +    super.insertTab(name, icon, component, null, 0);
       setSelectedIndex(selectedIndex+1);
       super.fireStateChanged();
     }
  
  
  

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

Reply via email to