FileDocCategorySizeDatePackage
LogTable.javaAPI DocApache log4j 1.2.158265Sat Aug 25 00:09:38 BST 2007org.apache.log4j.lf5.viewer

LogTable

public class LogTable extends JTable
LogTable.
author
Michael J. Sikorsky
author
Robert Shaw
author
Brad Marlborough
author
Brent Sprecher

Fields Summary
private static final long
serialVersionUID
protected int
_rowHeight
protected JTextArea
_detailTextArea
protected int
_numCols
protected TableColumn[]
_tableColumns
protected int[]
_colWidths
protected LogTableColumn[]
_colNames
protected int
_colDate
protected int
_colThread
protected int
_colMessageNum
protected int
_colLevel
protected int
_colNDC
protected int
_colCategory
protected int
_colMessage
protected int
_colLocation
protected int
_colThrown
protected DateFormatManager
_dateFormatManager
Constructors Summary
public LogTable(JTextArea detailTextArea)


  //--------------------------------------------------------------------------
  //   Private Variables:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Constructors:
  //--------------------------------------------------------------------------

     
    super();

    init();

    _detailTextArea = detailTextArea;

    setModel(new FilteredLogTableModel());

    Enumeration columns = getColumnModel().getColumns();
    int i = 0;
    while (columns.hasMoreElements()) {
      TableColumn col = (TableColumn) columns.nextElement();
      col.setCellRenderer(new LogTableRowRenderer());
      col.setPreferredWidth(_colWidths[i]);

      _tableColumns[i] = col;
      i++;
    }

    ListSelectionModel rowSM = getSelectionModel();
    rowSM.addListSelectionListener(new LogTableListSelectionListener(this));

    //setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
  
Methods Summary
public synchronized voidclearLogRecords()

    //For JDK1.3
    //((DefaultTableModel)getModel()).setRowCount(0);

    // For JDK1.2.x
    getFilteredLogTableModel().clear();
  
protected java.util.VectorgetColumnNameAndNumber()

    Vector columnNameAndNumber = new Vector();
    for (int i = 0; i < _colNames.length; i++) {
      columnNameAndNumber.add(i, _colNames[i]);
    }
    return columnNameAndNumber;
  
public org.apache.log4j.lf5.util.DateFormatManagergetDateFormatManager()
Get the DateFormatManager for formatting dates.

    return _dateFormatManager;
  
public org.apache.log4j.lf5.viewer.FilteredLogTableModelgetFilteredLogTableModel()

    return (FilteredLogTableModel) getModel();
  
protected voidinit()

    setRowHeight(_rowHeight);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  
public voidsetDateFormatManager(org.apache.log4j.lf5.util.DateFormatManager dfm)
Set the date format manager for formatting dates.

    _dateFormatManager = dfm;
  
public voidsetDetailedView()

    //TODO: Defineable Views.
    TableColumnModel model = getColumnModel();
    // Remove all the columns:
    for (int f = 0; f < _numCols; f++) {
      model.removeColumn(_tableColumns[f]);
    }
    // Add them back in the correct order:
    for (int i = 0; i < _numCols; i++) {
      model.addColumn(_tableColumns[i]);
    }
    //SWING BUG:
    sizeColumnsToFit(-1);
  
public voidsetFont(java.awt.Font font)

    super.setFont(font);
    Graphics g = this.getGraphics();
    if (g != null) {
      FontMetrics fm = g.getFontMetrics(font);
      int height = fm.getHeight();
      _rowHeight = height + height / 3;
      setRowHeight(_rowHeight);
    }


  
public voidsetView(java.util.List columns)

    TableColumnModel model = getColumnModel();

    // Remove all the columns:
    for (int f = 0; f < _numCols; f++) {
      model.removeColumn(_tableColumns[f]);
    }
    Iterator selectedColumns = columns.iterator();
    Vector columnNameAndNumber = getColumnNameAndNumber();
    while (selectedColumns.hasNext()) {
      // add the column to the view
      model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
    }

    //SWING BUG:
    sizeColumnsToFit(-1);