use of alma.acs.logging.table.renderer.InfoRenderer in project ACS by ACS-Community.
the class LogEntryTable method initialize.
/**
* Setup the table
*
* @param shortDateFormat The format to show the date (if <code>true</code> is short, otherwise complete)
* @param logTypeformat The way to show the log type (if <code>true</code> the description is shown)
*/
private void initialize(boolean shortDateFormat, boolean logTypeformat) {
createDefaultColumnsFromModel();
setShowHorizontalLines(false);
TableColumnModel tcm = getColumnModel();
// Setup the first col
TableColumn tc;
// Setup the first col
tc = tcm.getColumn(0);
tc.setCellRenderer(new InfoRenderer());
tc.setWidth(18);
tc.setMaxWidth(18);
tc.setResizable(false);
tc = tcm.getColumn(LogField.ENTRYTYPE.ordinal() + 1);
logTypeRenderer = new EntryTypeRenderer(logTypeformat);
tc.setCellRenderer(logTypeRenderer);
tc = tcm.getColumn(LogField.TIMESTAMP.ordinal() + 1);
dateRenderer = new DateRenderer(shortDateFormat);
tc.setCellRenderer(dateRenderer);
int n = tcm.getColumnCount();
columnsList = new TableColumn[n];
visibleColumns = new boolean[n];
for (int i = 0; i < n; i++) {
columnsList[i] = tcm.getColumn(i);
visibleColumns[i] = true;
if (i == LogField.LOGMESSAGE.ordinal() + 1) {
columnsList[i].setPreferredWidth(250);
}
}
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
sizeColumnsToFit(JTable.AUTO_RESIZE_OFF);
// Hide some columns (default at startup)
hideColumn(LogField.LINE.ordinal() + 1);
hideColumn(LogField.ROUTINE.ordinal() + 1);
hideColumn(LogField.HOST.ordinal() + 1);
hideColumn(LogField.PROCESS.ordinal() + 1);
hideColumn(LogField.CONTEXT.ordinal() + 1);
hideColumn(LogField.THREAD.ordinal() + 1);
hideColumn(LogField.LOGID.ordinal() + 1);
hideColumn(LogField.PRIORITY.ordinal() + 1);
hideColumn(LogField.URI.ordinal() + 1);
hideColumn(LogField.STACKID.ordinal() + 1);
hideColumn(LogField.FILE.ordinal() + 1);
hideColumn(LogField.STACKLEVEL.ordinal() + 1);
hideColumn(LogField.AUDIENCE.ordinal() + 1);
hideColumn(LogField.ARRAY.ordinal() + 1);
hideColumn(LogField.ANTENNA.ordinal() + 1);
// Build and set the selection model
selectionModel = new DefaultListSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
setSelectionModel(selectionModel);
addMouseListener(new TableMouseAdapter());
}
use of alma.acs.logging.table.renderer.InfoRenderer in project ACS by ACS-Community.
the class ErrorTab method initialize.
/**
* Init the GUI
*/
private void initialize() {
// Init the table
table.createDefaultColumnsFromModel();
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setAutoCreateRowSorter(true);
TableColumnModel tcm = table.getColumnModel();
TableColumn tc;
// Setup the first col
tc = tcm.getColumn(0);
tc.setCellRenderer(new InfoRenderer());
tc.setWidth(18);
tc.setMaxWidth(18);
tc.setResizable(false);
tc = tcm.getColumn(LogField.ENTRYTYPE.ordinal() + 1);
tc.setCellRenderer(new EntryTypeRenderer(false));
tc = tcm.getColumn(LogField.TIMESTAMP.ordinal() + 1);
tc.setCellRenderer(new DateRenderer(true));
for (int t = 1; t < tcm.getColumnCount(); t++) {
tc = tcm.getColumn(t);
tc.setMinWidth(50);
tc.setPreferredWidth(100);
tc.setResizable(true);
tc.setIdentifier(LogField.values()[t - 1]);
columns[t - 1] = tc;
}
// Set the visible columns
boolean[] visCols = new boolean[LogField.values().length];
for (int t = 0; t < visCols.length; t++) {
visCols[t] = false;
}
visCols[LogField.TIMESTAMP.ordinal()] = true;
visCols[LogField.ENTRYTYPE.ordinal()] = true;
visCols[LogField.SOURCEOBJECT.ordinal()] = true;
visCols[LogField.LOGMESSAGE.ordinal()] = true;
visCols[LogField.STACKLEVEL.ordinal()] = true;
setupTableCols(visCols);
// Add the tabs
setRightComponent(new JScrollPane(detailedLogTable));
setLeftComponent(new JScrollPane(table));
setDividerLocation(table.getPreferredSize().width);
// Init the popup menu
JMenuItem menuItem = new JMenuItem("Select columns...");
menuItem.addActionListener(this);
popmenu = new JPopupMenu();
popmenu.add(menuItem);
// Add the listener to the table header
table.getTableHeader().addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
popmenu.show(ErrorTab.this.table, e.getX(), e.getY());
}
}
});
// Add the listener to the table
table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (!e.isPopupTrigger()) {
// Get the index of the row and the column below
// the mouse pointer
int row = ErrorTab.this.table.rowAtPoint(e.getPoint());
ILogEntry log = model.getVisibleLogEntry(table.convertRowIndexToModel(row));
ErrorTab.this.detailedLogTable.setupContent(log);
}
}
});
}
Aggregations