Search in sources :

Example 1 with EntryTypeRenderer

use of alma.acs.logging.table.renderer.EntryTypeRenderer 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());
}
Also used : InfoRenderer(alma.acs.logging.table.renderer.InfoRenderer) TableColumnModel(javax.swing.table.TableColumnModel) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) DateRenderer(alma.acs.logging.table.renderer.DateRenderer) EntryTypeRenderer(alma.acs.logging.table.renderer.EntryTypeRenderer) TableColumn(javax.swing.table.TableColumn)

Example 2 with EntryTypeRenderer

use of alma.acs.logging.table.renderer.EntryTypeRenderer 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);
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) InfoRenderer(alma.acs.logging.table.renderer.InfoRenderer) MouseAdapter(java.awt.event.MouseAdapter) TableColumnModel(javax.swing.table.TableColumnModel) DateRenderer(alma.acs.logging.table.renderer.DateRenderer) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) EntryTypeRenderer(alma.acs.logging.table.renderer.EntryTypeRenderer) JMenuItem(javax.swing.JMenuItem)

Aggregations

DateRenderer (alma.acs.logging.table.renderer.DateRenderer)2 EntryTypeRenderer (alma.acs.logging.table.renderer.EntryTypeRenderer)2 InfoRenderer (alma.acs.logging.table.renderer.InfoRenderer)2 TableColumn (javax.swing.table.TableColumn)2 TableColumnModel (javax.swing.table.TableColumnModel)2 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 DefaultListSelectionModel (javax.swing.DefaultListSelectionModel)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JScrollPane (javax.swing.JScrollPane)1