[Mc4j-cvs] mc4j/src/org/mc4j/jre15/components ThreadsViewComponent.java,1.4,1.5
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-05-23 05:18:28
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/jre15/components In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26215/src/org/mc4j/jre15/components Modified Files: ThreadsViewComponent.java Log Message: That split pane did not update well Index: ThreadsViewComponent.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/jre15/components/ThreadsViewComponent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ThreadsViewComponent.java 22 May 2006 02:38:52 -0000 1.4 --- ThreadsViewComponent.java 23 May 2006 05:18:19 -0000 1.5 *************** *** 47,51 **** public class ThreadsViewComponent extends JPanel implements DashboardComponent, BeanComponent { - private EmsBean emsThreadBean; private ThreadMXBean threadBean; private JXTable table; --- 47,50 ---- *************** *** 55,59 **** private JEditorPane threadInfo; private JTextPane threadStack; - private JSplitPane splitPane; --- 54,57 ---- *************** *** 90,126 **** ! table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { ! public void valueChanged(ListSelectionEvent e) { ! if (!table.getSelectionModel().isSelectionEmpty()) { ! ThreadsTableModel.ThreadData d = model.getData(table.convertRowIndexToModel(e.getFirstIndex())); ! StringBuilder b = new StringBuilder(); ! ThreadInfo ti = threadBean.getThreadInfo(d.getLastData().getThreadId(), Integer.MAX_VALUE); ! if (ti != null) { ! for (StackTraceElement el : ti.getStackTrace()) { ! b.append(el); ! b.append("\n"); ! } ! ! String threadInfoString = ! "<html><b>Name: </b> " + ti.getThreadName() + " (" + ti.getThreadId() + ")<br>" + ! "<b>State: </b> " + ti.getThreadState() + "<br>" + ! "<b>Total Blocked: </b>" + ti.getBlockedCount() + " (" + ti.getBlockedTime() + "ms)<br>" + ! "<b>Total Waits: </b> " + ti.getWaitedCount() + " (" + ti.getWaitedTime() + "ms)<br>" + ! "<b>Lock: </b> " + ti.getLockName() + "<br>" + ! "<b>Lock Owner: </b>" + ti.getLockOwnerName() + " (" + ti.getLockOwnerId() + ")" + ! "</html>"; ! ! ! threadInfo.setText(threadInfoString); ! threadStack.setText(b.toString()); ! splitPane.setDividerLocation(splitPane.getHeight() - 250); ! } else { ! threadStack.setText("<unknown>"); ! } ! } else { ! splitPane.setDividerLocation(splitPane.getHeight()); ! } ! } ! }); --- 88,92 ---- ! table.getSelectionModel().addListSelectionListener(new TableSelectionListener()); *************** *** 137,146 **** detail.add(threadInfo); detail.add(new JScrollPane(threadStack)); ! splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, new JScrollPane(table), detail); ! splitPane.setResizeWeight(1); ! splitPane.setDividerLocation(1d); ! add(splitPane, BorderLayout.CENTER); } --- 103,114 ---- detail.add(threadInfo); detail.add(new JScrollPane(threadStack)); + detail.setPreferredSize(new Dimension(1000,250)); ! // splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, new JScrollPane(table), detail); ! // splitPane.setResizeWeight(1); ! // splitPane.setDividerLocation(1d); ! add(new JScrollPane(table), BorderLayout.CENTER); ! add(detail, BorderLayout.SOUTH); } *************** *** 159,164 **** public void setBean(EmsBean emsBean) { ! this.emsThreadBean = emsBean; ! threadBean = emsBean.getProxy(ThreadMXBean.class); // TODO: This is a little nasty, what if someone connects to a production system? --- 127,131 ---- public void setBean(EmsBean emsBean) { ! threadBean = (ThreadMXBean) emsBean.getProxy(ThreadMXBean.class); // TODO: This is a little nasty, what if someone connects to a production system? *************** *** 540,542 **** --- 507,549 ---- } } + + private class TableSelectionListener implements ListSelectionListener { + public void valueChanged(ListSelectionEvent e) { + if (!table.getSelectionModel().isSelectionEmpty()) { + ThreadsTableModel.ThreadData d = model.getData(table.convertRowIndexToModel(e.getFirstIndex())); + StringBuilder b = new StringBuilder(); + ThreadInfo ti = threadBean.getThreadInfo(d.getLastData().getThreadId(), Integer.MAX_VALUE); + if (ti != null) { + for (StackTraceElement el : ti.getStackTrace()) { + b.append(el); + b.append("\n"); + } + + String threadInfoString = + "<html><b>Name: </b> " + ti.getThreadName() + " (" + ti.getThreadId() + ")<br>" + + "<b>State: </b> " + ti.getThreadState() + "<br>" + + "<b>Total Blocked: </b>" + ti.getBlockedCount() + " (" + ti.getBlockedTime() + "ms)<br>" + + "<b>Total Waits: </b> " + ti.getWaitedCount() + " (" + ti.getWaitedTime() + "ms)<br>" + + "<b>Lock: </b> " + ti.getLockName() + "<br>" + + "<b>Lock Owner: </b>" + ti.getLockOwnerName() + " (" + ti.getLockOwnerId() + ")" + + "</html>"; + + + threadInfo.setText(threadInfoString); + String st = b.toString(); + if (!threadStack.getText().equals(st)) + threadStack.setText(b.toString()); + + // if (!(splitPane.getDividerLocation() < splitPane.getHeight() - 20)) + // splitPane.setDividerLocation(splitPane.getHeight() - 250); + } else { + threadStack.setText("<unknown>"); + } + } else { + threadInfo.setText(""); + threadStack.setText(""); + // splitPane.setDividerLocation(splitPane.getHeight()); + } + } + } } |