git-svn-id: http://code.alibabatech.com/svn/druid/trunk@240 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-06-02 02:51:33 +00:00
parent d58d0aae68
commit 0d4285702d
3 changed files with 63 additions and 19 deletions
@@ -0,0 +1,12 @@
package com.alibaba.druid.jconsole;
import javax.swing.JDialog;
public class SQLDetailDialog extends JDialog {
private static final long serialVersionUID = 1L;
public SQLDetailDialog(Object[] row) {
}
}
@@ -6,4 +6,9 @@ public class SQLDetailPanel extends JPanel {
private static final long serialVersionUID = 1L;
private Object[] row;
public SQLDetailPanel(Object[] row) {
this.row = row;
}
}
@@ -1,6 +1,8 @@
package com.alibaba.druid.jconsole;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
@@ -11,6 +13,7 @@ import javax.management.openmbean.TabularData;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
public class SQLPanel extends JPanel {
@@ -22,15 +25,15 @@ public class SQLPanel extends JPanel {
private JTable table;
private String[] columns = { "ID", "DataSource", "SQL", "ExecuteCount", "ErrorCount",
"TotalTime", "LastTime", "MaxTimespan", "LastError", "EffectedRowCount",
"FetchRowCount", "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal", "ConcurrentMax",
"RunningCount", "Name", "File", "LastErrorMessage", "LastErrorClass",
"LastErrorStackTrace", "LastErrorTime", "DbType" };
private String[] columns = { "ID", "Name", "File", "SQL", "ExecuteCount",
"ErrorCount", "TotalTime", "LastTime", "MaxTimespan", "LastError",
"EffectedRowCount", "FetchRowCount", "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal",
"ConcurrentMax", "RunningCount", "LastErrorMessage", "LastErrorClass", "LastErrorStackTrace",
"LastErrorTime"};
public SQLPanel(MBeanServerConnection connection, ObjectInstance objectInstance, DataSourceInfo dataSourceInfo){
super();
@@ -45,9 +48,9 @@ public class SQLPanel extends JPanel {
for (Object item : connectionTabularData.values()) {
CompositeData rowData = (CompositeData) item;
String url = (String) rowData.get("DataSource");
if (!dataSourceInfo.getUrl().equals(url)) {
continue;
}
@@ -55,32 +58,30 @@ public class SQLPanel extends JPanel {
Object[] row = new Object[columns.length];
int columnIndex = 0;
row[columnIndex++] = rowData.get("ID");
row[columnIndex++] = rowData.get("DataSource");
row[columnIndex++] = rowData.get("Name");
row[columnIndex++] = rowData.get("File");
row[columnIndex++] = rowData.get("SQL");
row[columnIndex++] = rowData.get("ExecuteCount");
row[columnIndex++] = rowData.get("ErrorCount");
row[columnIndex++] = rowData.get("ErrorCount");
row[columnIndex++] = rowData.get("TotalTime");
row[columnIndex++] = rowData.get("LastTime");
row[columnIndex++] = rowData.get("MaxTimespan");
row[columnIndex++] = rowData.get("LastError");
row[columnIndex++] = rowData.get("EffectedRowCount");
row[columnIndex++] = rowData.get("EffectedRowCount");
row[columnIndex++] = rowData.get("FetchRowCount");
row[columnIndex++] = rowData.get("MaxTimespanOccurTime");
row[columnIndex++] = rowData.get("BatchSizeMax");
row[columnIndex++] = rowData.get("BatchSizeTotal");
row[columnIndex++] = rowData.get("ConcurrentMax");
row[columnIndex++] = rowData.get("ConcurrentMax");
row[columnIndex++] = rowData.get("RunningCount");
row[columnIndex++] = rowData.get("Name");
row[columnIndex++] = rowData.get("File");
row[columnIndex++] = rowData.get("LastErrorMessage");
row[columnIndex++] = rowData.get("LastErrorClass");
row[columnIndex++] = rowData.get("LastErrorStackTrace");
row[columnIndex++] = rowData.get("LastErrorTime");
row[columnIndex++] = rowData.get("DbType");
rowList.add(row);
}
@@ -88,6 +89,13 @@ public class SQLPanel extends JPanel {
Object[][] rows = new Object[rowList.size()][];
rowList.toArray(rows);
table = new JTable(rows, columns);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
tableMouseClicked(e);
}
});
JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
@@ -98,6 +106,25 @@ public class SQLPanel extends JPanel {
}
}
public void tableMouseClicked(MouseEvent e) {
if (e.getClickCount() < 2) {
return;
}
int rowIndex = table.getSelectedRow();
if (rowIndex < 0) {
return;
}
Object[] row = new Object[columns.length];
for (int i = 0; i < row.length; ++i) {
row[i] = table.getModel().getValueAt(rowIndex, i);
}
SQLDetailDialog dialog = new SQLDetailDialog(row);
dialog.setVisible(true);
}
public MBeanServerConnection getConnection() {
return connection;
}