Search in sources :

Example 1 with DruidTableModel

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

the class DruidDataSourcePanel method addTable.

private void addTable(ColumnData columnData) {
    ArrayList<ArrayList<LinkedHashMap<String, Object>>> data = columnData.getTableData();
    int i = 0;
    ArrayList<String> ids = columnData.getNames();
    for (ArrayList<LinkedHashMap<String, Object>> listNow : data) {
        JTable table = new JTable();
        tableModel = new DruidTableModel(listNow);
        table.setModel(tableModel);
        String id = ids.get(i);
        JPanel panelNow = new JPanel(new BorderLayout());
        panelNow.setBorder((TitledBorder) BorderFactory.createTitledBorder(KEY_WORD_IDENTITY + ":" + id));
        contentPanel.add(panelNow);
        panelNow.add(table.getTableHeader(), BorderLayout.NORTH);
        panelNow.add(table);
        table.getColumnModel().getColumn(0).setCellRenderer(new DruidTableCellRenderer());
        i++;
    }
}
Also used : JPanel(javax.swing.JPanel) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) DruidTableModel(com.alibaba.druid.support.jconsole.model.DruidTableModel) DruidTableCellRenderer(com.alibaba.druid.support.jconsole.model.DruidTableCellRenderer)

Example 2 with DruidTableModel

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

the class DruidDriverPanel method tableDataProcess.

@Override
protected void tableDataProcess(ArrayList<LinkedHashMap<String, Object>> data) {
    ColumnData columnData = TableDataProcessor.row2col(data);
    tableModel = new DruidTableModel(columnData.getData());
    table.setModel(tableModel);
    table.getColumnModel().getColumn(0).setCellRenderer(new DruidTableCellRenderer());
    scrollPane.setViewportView(table);
}
Also used : ColumnData(com.alibaba.druid.support.jconsole.util.TableDataProcessor.ColumnData) DruidTableModel(com.alibaba.druid.support.jconsole.model.DruidTableModel) DruidTableCellRenderer(com.alibaba.druid.support.jconsole.model.DruidTableCellRenderer)

Example 3 with DruidTableModel

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

the class DruidSqlDetailFrame method addTable.

/**
     * 将表格添加到contentPanel对象内部。
     * 
     * @param contentPanel JPanel对象
     * @param 当前表格的标题
     * @param data 当前表格的数据
     */
private void addTable(JPanel contentPanel, String title, ArrayList<LinkedHashMap<String, Object>> data) {
    final JPanel content1 = new JPanel();
    content1.setLayout(new BorderLayout());
    content1.setBorder((TitledBorder) BorderFactory.createTitledBorder(title));
    contentPanel.add(content1);
    ColumnData colData = TableDataProcessor.row2col(data);
    JTable table = new JTable();
    DruidTableModel tableModel = new DruidTableModel(colData.getData());
    table.setModel(tableModel);
    TableColumn col = table.getColumnModel().getColumn(0);
    col.setCellRenderer(new DruidTableCellRenderer());
    final JTableHeader header1 = table.getTableHeader();
    content1.add(header1, BorderLayout.NORTH);
    content1.add(table);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) JTableHeader(javax.swing.table.JTableHeader) ColumnData(com.alibaba.druid.support.jconsole.util.TableDataProcessor.ColumnData) DruidTableModel(com.alibaba.druid.support.jconsole.model.DruidTableModel) DruidTableCellRenderer(com.alibaba.druid.support.jconsole.model.DruidTableCellRenderer) TableColumn(javax.swing.table.TableColumn)

Example 4 with DruidTableModel

use of com.alibaba.druid.support.jconsole.model.DruidTableModel 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

DruidTableModel (com.alibaba.druid.support.jconsole.model.DruidTableModel)4 DruidTableCellRenderer (com.alibaba.druid.support.jconsole.model.DruidTableCellRenderer)3 JTable (javax.swing.JTable)3 ColumnData (com.alibaba.druid.support.jconsole.util.TableDataProcessor.ColumnData)2 BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 JTableHeader (javax.swing.table.JTableHeader)2 GroupableTableHeader (com.alibaba.druid.support.jconsole.model.GroupableTableHeader)1 RowHeaderTable (com.alibaba.druid.support.jconsole.model.RowHeaderTable)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 JLabel (javax.swing.JLabel)1 BevelBorder (javax.swing.border.BevelBorder)1 TableColumn (javax.swing.table.TableColumn)1