improved source info, added optional stack trace tooltip

This commit is contained in:
Fredrik Osterlind 2012-03-01 15:21:06 +01:00
parent 729a434d0f
commit 383d277277

View file

@ -198,6 +198,9 @@ public class BufferListener extends VisPlugin {
private boolean hideReads = true; private boolean hideReads = true;
private JCheckBoxMenuItem hideReadsCheckbox; private JCheckBoxMenuItem hideReadsCheckbox;
private boolean withStackTrace = false;
private JCheckBoxMenuItem withStackTraceCheckbox;
private JMenu parserMenu = new JMenu("Parser"); private JMenu parserMenu = new JMenu("Parser");
private JMenu bufferMenu = new JMenu("Buffer"); private JMenu bufferMenu = new JMenu("Buffer");
@ -336,7 +339,18 @@ public class BufferListener extends VisPlugin {
if (rowIndex < 0 || columnIndex < 0) { if (rowIndex < 0 || columnIndex < 0) {
return super.getToolTipText(e); return super.getToolTipText(e);
} }
Object v = getValueAt(rowIndex, columnIndex); Object v = getValueAt(rowIndex, columnIndex);
if (columnIndex == COLUMN_SOURCE) {
BufferAccess ba = logs.get(rowIndex);
if (ba.stackTrace != null) {
return
"<html><pre>" +
ba.stackTrace +
"</pre></html>";
}
return "No stack trace (enable in popup menu)";
}
if (v instanceof BufferAccess && parser instanceof GraphicalParser) { if (v instanceof BufferAccess && parser instanceof GraphicalParser) {
return return
"<html><font face=\"Verdana\">" + "<html><font face=\"Verdana\">" +
@ -493,6 +507,7 @@ public class BufferListener extends VisPlugin {
/* Automatically update column widths */ /* Automatically update column widths */
final TableColumnAdjuster adjuster = new TableColumnAdjuster(logTable, 0); final TableColumnAdjuster adjuster = new TableColumnAdjuster(logTable, 0);
adjuster.packColumns(); adjuster.packColumns();
logTable.getColumnModel().getColumn(COLUMN_DATA).setWidth(400);
/* Popup menu */ /* Popup menu */
JPopupMenu popupMenu = new JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu();
@ -555,7 +570,7 @@ public class BufferListener extends VisPlugin {
repaint(); repaint();
} }
}); });
hideReadsCheckbox = new JCheckBoxMenuItem("Hide READs", true); hideReadsCheckbox = new JCheckBoxMenuItem("Hide READs", hideReads);
popupMenu.add(hideReadsCheckbox); popupMenu.add(hideReadsCheckbox);
hideReadsCheckbox.addActionListener(new ActionListener() { hideReadsCheckbox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -565,7 +580,16 @@ public class BufferListener extends VisPlugin {
} }
}); });
withStackTraceCheckbox = new JCheckBoxMenuItem("Capture stack traces", withStackTrace);
popupMenu.add(withStackTraceCheckbox);
withStackTraceCheckbox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
withStackTrace = withStackTraceCheckbox.isSelected();
setFilter(getFilter());
repaint();
}
});
logTable.setComponentPopupMenu(popupMenu); logTable.setComponentPopupMenu(popupMenu);
/* Column width adjustment */ /* Column width adjustment */
@ -573,6 +597,7 @@ public class BufferListener extends VisPlugin {
public void run() { public void run() {
/* Make sure this happens *after* adding history */ /* Make sure this happens *after* adding history */
adjuster.setDynamicAdjustment(true); adjuster.setDynamicAdjustment(true);
adjuster.setAdjustColumn(COLUMN_DATA, false);
} }
}); });
@ -775,6 +800,10 @@ public class BufferListener extends VisPlugin {
element = new Element("showreads"); element = new Element("showreads");
config.add(element); config.add(element);
} }
if (withStackTrace) {
element = new Element("stacktrace");
config.add(element);
}
element = new Element("parser"); element = new Element("parser");
element.setText(parser.getClass().getName()); element.setText(parser.getClass().getName());
config.add(element); config.add(element);
@ -815,6 +844,9 @@ public class BufferListener extends VisPlugin {
} else if ("showreads".equals(name)) { } else if ("showreads".equals(name)) {
hideReads = false; hideReads = false;
hideReadsCheckbox.setSelected(false); hideReadsCheckbox.setSelected(false);
} else if ("stacktrace".equals(name)) {
withStackTrace = true;
withStackTraceCheckbox.setSelected(true);
} else if ("formatted_time".equals(name)) { } else if ("formatted_time".equals(name)) {
formatTimeString = true; formatTimeString = true;
repaintTimeColumn(); repaintTimeColumn();
@ -928,6 +960,7 @@ public class BufferListener extends VisPlugin {
public final String typeStr; public final String typeStr;
public final String sourceStr; public final String sourceStr;
public final String stackTrace;
public final byte[] mem; public final byte[] mem;
private boolean[] accessedBitpattern = null; private boolean[] accessedBitpattern = null;
@ -970,6 +1003,11 @@ public class BufferListener extends VisPlugin {
typeStr = type.toString(); typeStr = type.toString();
String s = mote.getPCString(); String s = mote.getPCString();
sourceStr = s==null?"[unknown]":s; sourceStr = s==null?"[unknown]":s;
if (withStackTrace) {
this.stackTrace = mote.getStackTrace();
} else {
this.stackTrace = null;
}
} }
public Object getParsedData() { public Object getParsedData() {
@ -1285,8 +1323,7 @@ public class BufferListener extends VisPlugin {
} }
parser = bp; parser = bp;
logTable.getColumnModel().getColumn(COLUMN_DATA).setHeaderValue( logTable.getColumnModel().getColumn(COLUMN_DATA).setHeaderValue(GUI.getDescriptionOf(bp));
GUI.getDescriptionOf(bp));
repaint(); repaint();
} }