if (realColumnIndex == COLUMN_FILELINE) {
Watchpoint[] allBreakpoints = BreakpointsUI.this.mote.getBreakpoints();
if (rowIndex < 0 || rowIndex >= allBreakpoints.length) {
return null;
}
Watchpoint watchpoint = allBreakpoints[rowIndex];
File file = watchpoint.getCodeFile();
if (file == null) {
return String.format("[unknown @ 0x%04x]", watchpoint.getExecutableAddress());
}
Integer line = watchpoint.getLineNumber();
if (line == null) {
return file.getPath() + ":?";
}
return file.getPath() + ":" + line;
}
if (realColumnIndex == COLUMN_INFO) {
return "Optional watchpoint info: description and color";
}
if (realColumnIndex == COLUMN_STOP) {
return "Indicates whether the watchpoint will stop the simulation when triggered";
}
return null;
}
};
table.getColumnModel().getColumn(COLUMN_INFO).setCellRenderer(new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
if (column != COLUMN_INFO) {
return c;
}
Watchpoint[] allBreakpoints = BreakpointsUI.this.mote.getBreakpoints();
if (row < 0 || row >= allBreakpoints.length) {
return c;
}
Watchpoint breakpoint = allBreakpoints[row];
if (breakpoint.getColor() == null) {
return c;
}
/* Use watchpoint color */
c.setBackground(Color.WHITE);
c.setForeground(breakpoint.getColor());
return c;
}
});
/* Popup menu: register on all motes */
final JPopupMenu popupMenu = new JPopupMenu();
popupMenu.add(new JMenuItem(gotoCodeAction));
popupMenu.add(new JSeparator());
popupMenu.add(new JMenuItem(removeWatchpointAction));
popupMenu.add(new JMenuItem(configureWatchpointAction));
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = table.rowAtPoint(p);
int colIndex = table.columnAtPoint(p);
int realColumnIndex = table.convertColumnIndexToModel(colIndex);
if (realColumnIndex != COLUMN_ADDRESS
&& realColumnIndex != COLUMN_FILELINE
&& realColumnIndex != COLUMN_INFO) {
return;
}
Watchpoint[] allBreakpoints = BreakpointsUI.this.mote.getBreakpoints();
if (rowIndex < 0 || rowIndex >= allBreakpoints.length) {
return;
}
Watchpoint breakpoint = allBreakpoints[rowIndex];
if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) {
selectedWatchpoint = breakpoint;
popupMenu.show(table, e.getX(), e.getY());
return;