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++;
}
}
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);
}
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);
}
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);
}
Aggregations