logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw CheckListCellRenderer.java
Date Fri, 12 Dec 2003 10:30:52 GMT
psmith      2003/12/12 02:30:52

  Added:       src/java/org/apache/log4j/chainsaw
                        CheckListCellRenderer.java
  Log:
  (last commit msg included wrong file to match the comment)
  
  Log Tree panel now has a displayed ignore list with check boxes.  You can
  DBL click an entry in this list to remove the logger from the ignore list.
  
  Currently the tree expansion goes a bit nutty when you do this however
  but I think I know what to do.
  
  Revision  Changes    Path
  1.1                  jakarta-log4j/src/java/org/apache/log4j/chainsaw/CheckListCellRenderer.java
  
  Index: CheckListCellRenderer.java
  ===================================================================
  /*
   */
  package org.apache.log4j.chainsaw;
  
  import java.awt.Component;
  
  import javax.swing.BorderFactory;
  import javax.swing.JCheckBox;
  import javax.swing.JList;
  import javax.swing.ListCellRenderer;
  import javax.swing.UIManager;
  import javax.swing.border.Border;
  
  
  /**
   * A ListCellRenderer that display a check box if the value
   * has been "checked".
   * 
   * Borrowed heavily from the excellent book "Swing, 2nd Edition" by
   * Matthew Robinson  & Pavel Vorobiev.
   * 
   * @author Paul Smith
   *
   */
  public abstract class CheckListCellRenderer extends JCheckBox
    implements ListCellRenderer {
    private final Border noFocusBorder =
      BorderFactory.createEmptyBorder(1, 1, 1, 1);
  
    /**
     *
     */
    public CheckListCellRenderer() {
      super();
      setOpaque(true);
      setBorder(noFocusBorder);
    }
  
    /* (non-Javadoc)
     * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object,
int, boolean, boolean)
     */
    public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected,
      boolean cellHasFocus) {
      setText(value.toString());
      setBackground(
        isSelected ? list.getSelectionBackground() : list.getBackground());
      setForeground(
        isSelected ? list.getSelectionForeground() : list.getForeground());
      setFont(list.getFont());
      setBorder(
        cellHasFocus ? UIManager.getBorder("List.focusCellHighlightBorder")
                     : noFocusBorder);
  
      setSelected(isSelected(value));
      return this;
    }
  
  /**
   * @param value
   * @return
   */
  protected abstract boolean isSelected(Object value);
  }
  
  

---------------------------------------------------------------------
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