Search in sources :

Example 1 with GroupableTableHeader

use of com.alibaba.druid.support.jconsole.model.GroupableTableHeader in project druid by alibaba.

the class DruidSQLPanel method addTableGroup.

private void addTableGroup() {
    TableColumnModel cm = table.getColumnModel();
    // System.out.println(SHOW_LIST.size());
    for (int i : listHistogram) {
        groupHistogram.add(cm.getColumn(i));
    }
    for (int j : listEffectedRowCountHistogram) {
        groupEffectedRowCountHistogram.add(cm.getColumn(j));
    }
    for (int x : listExecuteAndResultHoldTimeHistogram) {
        groupExecuteAndResultHoldTimeHistogram.add(cm.getColumn(x));
    }
    for (int y : listFetchRowCountHistogram) {
        groupFetchRowCountHistogram.add(cm.getColumn(y));
    }
    GroupableTableHeader header = (GroupableTableHeader) table.getTableHeader();
    header.addColumnGroup(groupHistogram);
    header.addColumnGroup(groupEffectedRowCountHistogram);
    header.addColumnGroup(groupExecuteAndResultHoldTimeHistogram);
    header.addColumnGroup(groupFetchRowCountHistogram);
    header.setUI(new GroupableTableHeaderUI());
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) GroupableTableHeaderUI(com.alibaba.druid.support.jconsole.model.GroupableTableHeaderUI) GroupableTableHeader(com.alibaba.druid.support.jconsole.model.GroupableTableHeader)

Example 2 with GroupableTableHeader

use of com.alibaba.druid.support.jconsole.model.GroupableTableHeader in project druid by alibaba.

the class DruidSQLPanel method tableDataProcess.

@Override
protected void tableDataProcess(ArrayList<LinkedHashMap<String, Object>> data) {
    table = new JTable() {

        private static final long serialVersionUID = 1L;

        @Override
        protected JTableHeader createDefaultTableHeader() {
            return new GroupableTableHeader(columnModel);
        }
    };
    data = preProcess(data);
    // System.out.println(SHOW_LIST);
    tableModel = new DruidTableModel(data, REAL_SHOW_LIST);
    // System.out.println(data.toString());
    table.setModel(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    addTableGroup();
    table.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                // 点击几次,这里是双击事件
                int row = table.getSelectedRow();
                String id = ids.get(row);
                new DruidSqlDetailFrame(id, conn);
            }
        }
    });
    RowHeaderTable header = new RowHeaderTable(table, 20);
    scrollPane.setRowHeaderView(header);
    scrollPane.setViewportView(table);
    JLabel jb = new JLabel("N", SwingConstants.CENTER);
    jb.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, jb);
}
Also used : MouseEvent(java.awt.event.MouseEvent) BevelBorder(javax.swing.border.BevelBorder) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) RowHeaderTable(com.alibaba.druid.support.jconsole.model.RowHeaderTable) JTable(javax.swing.JTable) DruidTableModel(com.alibaba.druid.support.jconsole.model.DruidTableModel) GroupableTableHeader(com.alibaba.druid.support.jconsole.model.GroupableTableHeader)

Aggregations

GroupableTableHeader (com.alibaba.druid.support.jconsole.model.GroupableTableHeader)2 DruidTableModel (com.alibaba.druid.support.jconsole.model.DruidTableModel)1 GroupableTableHeaderUI (com.alibaba.druid.support.jconsole.model.GroupableTableHeaderUI)1 RowHeaderTable (com.alibaba.druid.support.jconsole.model.RowHeaderTable)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JLabel (javax.swing.JLabel)1 JTable (javax.swing.JTable)1 BevelBorder (javax.swing.border.BevelBorder)1 JTableHeader (javax.swing.table.JTableHeader)1 TableColumnModel (javax.swing.table.TableColumnModel)1