The version of Apache log4j used by SoundHelix.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aEp6o
SSH:
git clone USERNAME@vervis.peers.community:aEp6o
Branches
Tags
- 1.3alpha-7
- CHAINSAW_2_SANDBOX_MERGE
- CORE_VERSION
- LEVEL_REPLACES_PRIORITY
- PREALPHA_1_3_AS_OF_2004_05_12
- PRE_CHAINSAW_MODEL_CONVERSION
- PRE_UGLI_MOVE
- TAG_CHAINSAW2_MOVE
- log4j-1.2.17
- log4j-1.2.17-rc1
- v1.3alpha8
- v1.3alpha8-temp
- v1_2_1
- v1_2_10-recalled
- v1_2_11
- v1_2_11_rc1
- v1_2_11rc3
- v1_2_12
- v1_2_12_rc1
- v1_2_12_rc2
- v1_2_12_rc3
- v1_2_12_rc4
- v1_2_12_rc5
- v1_2_12_rc6
- v1_2_13
- v1_2_13_rc1
- v1_2_13_rc2
- v1_2_13_site_update
- v1_2_14
- v1_2_14_maven
- v1_2_14_rc1
- v1_2_14_site_update
- v1_2_15
- v1_2_15_rc1
- v1_2_15_rc2
- v1_2_15_rc3
- v1_2_15_rc4
- v1_2_15_rc5
- v1_2_15_rc6
- v1_2_16
- v1_2_16_rc1
- v1_2_16_rc2
- v1_2_17
- v1_2_17-rc1
- v1_2_17_rc1
- v1_2_17_rc2
- v1_2_17_rc3
- v1_2_2
- v1_2_3
- v1_2_4
- v1_2_6
- v1_2_7
- v1_2_9
- v1_2_alpha0
- v1_2_alpha7
- v1_2beta1
- v1_2final
- v1_3alpha_1
- v1_3alpha_6
- v_1_0
- v_1_0_1
- v_1_0_4
- v_1_1
- v_1_1_1
- v_1_1_2
- v_1_1_3
- v_1_1_b1
- v_1_1b2
- v_1_1b3
- v_1_1b5
- v_1_1b6
- v_1_1b7
- v_1_2beta3
LogTable.java
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software
* License version 1.1, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*/
package org.apache.log4j.lf5.viewer;
import org.apache.log4j.lf5.util.DateFormatManager;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
/**
* LogTable.
*
* @author Michael J. Sikorsky
* @author Robert Shaw
* @author Brad Marlborough
* @author Brent Sprecher
*/
// Contributed by ThoughtWorks Inc.
public class LogTable extends JTable {
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Protected Variables:
//--------------------------------------------------------------------------
protected int _rowHeight = 30;
protected JTextArea _detailTextArea;
// For the columns:
protected int _numCols = 9;
protected TableColumn[] _tableColumns = new TableColumn[_numCols];
protected int[] _colWidths = {40, 40, 40, 70, 70, 360, 440, 200, 60};
protected LogTableColumn[] _colNames = LogTableColumn.getLogTableColumnArray();
protected int _colDate = 0;
protected int _colThread = 1;
protected int _colMessageNum = 2;
protected int _colLevel = 3;
protected int _colNDC = 4;
protected int _colCategory = 5;
protected int _colMessage = 6;
protected int _colLocation = 7;
protected int _colThrown = 8;
protected DateFormatManager _dateFormatManager = null;
//--------------------------------------------------------------------------
// Private Variables:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Constructors:
//--------------------------------------------------------------------------
public LogTable(JTextArea detailTextArea) {
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);
}
//--------------------------------------------------------------------------
// Public Methods:
//--------------------------------------------------------------------------
/**
* Get the DateFormatManager for formatting dates.
*/
public DateFormatManager getDateFormatManager() {
return _dateFormatManager;
}
/**
* Set the date format manager for formatting dates.
*/
public void setDateFormatManager(DateFormatManager dfm) {
_dateFormatManager = dfm;
}
public synchronized void clearLogRecords() {
//For JDK1.3
//((DefaultTableModel)getModel()).setRowCount(0);
// For JDK1.2.x
getFilteredLogTableModel().clear();
}
public FilteredLogTableModel getFilteredLogTableModel() {
return (FilteredLogTableModel) getModel();
}
// default view if a view is not set and saved
public void setDetailedView() {
//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 void setView(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);
}
public void setFont(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);
}
}
//--------------------------------------------------------------------------
// Protected Methods:
//--------------------------------------------------------------------------
protected void init() {
setRowHeight(_rowHeight);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
// assign a column number to a column name
protected Vector getColumnNameAndNumber() {
Vector columnNameAndNumber = new Vector();
for (int i = 0; i < _colNames.length; i++) {
columnNameAndNumber.add(i, _colNames[i]);
}
return columnNameAndNumber;
}
//--------------------------------------------------------------------------
// Private Methods:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Nested Top-Level Classes or Interfaces:
//--------------------------------------------------------------------------
class LogTableListSelectionListener implements ListSelectionListener {
protected JTable _table;
public LogTableListSelectionListener(JTable table) {
_table = table;
}
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
//no rows are selected
} else {
StringBuffer buf = new StringBuffer();
int selectedRow = lsm.getMinSelectionIndex();
for (int i = 0; i < _numCols - 1; i++) {
String value = "";
Object obj = _table.getModel().getValueAt(selectedRow, i);
if (obj != null) {
value = obj.toString();
}
buf.append(_colNames[i] + ":");
buf.append("\t");
if (i == _colThread || i == _colMessage || i == _colLevel) {
buf.append("\t"); // pad out the date.
}
if (i == _colDate || i == _colNDC) {
buf.append("\t\t"); // pad out the date.
}
// if( i == _colSequence)
// {
// buf.append("\t\t\t"); // pad out the Sequnce.
// }
buf.append(value);
buf.append("\n");
}
buf.append(_colNames[_numCols - 1] + ":\n");
Object obj = _table.getModel().getValueAt(selectedRow, _numCols - 1);
if (obj != null) {
buf.append(obj.toString());
}
_detailTextArea.setText(buf.toString());
}
}
}
}