com.bluemarsh.jswat.panel
Class WatchPanel

java.lang.Object
  |
  +--com.bluemarsh.jswat.panel.JSwatPanel
        |
        +--com.bluemarsh.jswat.panel.WatchPanel
All Implemented Interfaces:
ContextListener, java.util.EventListener, SessionListener, javax.swing.event.TableModelListener, VMEventListener

public class WatchPanel
extends JSwatPanel
implements ContextListener, javax.swing.event.TableModelListener, VMEventListener

Class WatchPanel watches the modification events of variables and displays the changed values in a table.

This works by maintaining a blank row in the watch table for the user to add new watchpoints. That is, the user will type the name of a variable to watch into the blank row. To remove a watchpoint, the user must clear the name from that row.

Author:
Nathan Fiedler

Inner Class Summary
protected  class WatchPanel.WatchpointListEntry
          Class WatchpointListEntry represents any type of watchpoint the user has specified.
 
Field Summary
protected  Session session
          Reference to the session.
protected  javax.swing.JTable table
          Table displaying the threads.
protected  javax.swing.JScrollPane uicomp
          Our UI component - scrollable panel
protected  java.util.List watchpointList
          List of the existing watchpoint requests.
 
Fields inherited from class com.bluemarsh.jswat.panel.JSwatPanel
swat
 
Fields inherited from interface com.bluemarsh.jswat.event.VMEventListener
PRIORITY_BREAKPOINT, PRIORITY_DEFAULT, PRIORITY_HIGH, PRIORITY_HIGHEST, PRIORITY_LOW, PRIORITY_LOWEST, PRIORITY_SESSION
 
Constructor Summary
WatchPanel()
          Constructs a WatchPanel with the default table.
 
Method Summary
 void activate(Session session)
          Called when the Session is about to begin an active debugging session.
protected  int addBlankRow()
          Adds the blank row to the model, to allow entry of a new watchpoint.
protected  void addWatchpoint(java.lang.String expr, int row, boolean addBlank)
          Add the named variable to the watch list.
 void contextChanged(ContextChangeEvent cce)
          Invoked when the current context has changed.
 void deactivate(Session session)
          Called when the Session is about to end an active debugging session.
 boolean eventOccurred(com.sun.jdi.event.Event e)
          Invoked when a VM event has occurred.
 javax.swing.JComponent getPeer()
          Returns a reference to the peer UI component.
 javax.swing.JComponent getUI()
          Returns a reference to the UI component.
 void refresh(Session session)
          Update the display on the screen.
protected  void resolveWatchpoint(int row, WatchPanel.WatchpointListEntry entry)
          Try to resolve a watchpoint.
protected  void resolveWatchpoints()
          Iterate the list of watchpoints and try to resolve any unresolved entries.
 void tableChanged(javax.swing.event.TableModelEvent e)
          Invoked whenever the table model changes.
 
Methods inherited from class com.bluemarsh.jswat.panel.JSwatPanel
close, getParentWindow, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected javax.swing.JTable table
Table displaying the threads.

uicomp

protected javax.swing.JScrollPane uicomp
Our UI component - scrollable panel

session

protected Session session
Reference to the session.

watchpointList

protected java.util.List watchpointList
List of the existing watchpoint requests.
Constructor Detail

WatchPanel

public WatchPanel()
Constructs a WatchPanel with the default table.
Method Detail

activate

public void activate(Session session)
Called when the Session is about to begin an active debugging session. That is, JSwat is about to debug a debuggee VM. Panels are not activated in any particular order.
Overrides:
activate in class JSwatPanel
Parameters:
session - Session being activated.

addBlankRow

protected int addBlankRow()
Adds the blank row to the model, to allow entry of a new watchpoint.
Returns:
new row number.

addWatchpoint

protected void addWatchpoint(java.lang.String expr,
                             int row,
                             boolean addBlank)
Add the named variable to the watch list. This may or may not display a value for the variable immediately.
Parameters:
expr - name of variable to watch.
row - row to add to.
addBlank - true to add a blank row as needed.

contextChanged

public void contextChanged(ContextChangeEvent cce)
Invoked when the current context has changed. The context change event identifies which aspect of the context has changed.
Specified by:
contextChanged in interface ContextListener
Parameters:
cce - context change event

deactivate

public void deactivate(Session session)
Called when the Session is about to end an active debugging session. That is, JSwat is about to terminate the connection with the debuggee VM. Panels are not deactivated in any particular order.
Overrides:
deactivate in class JSwatPanel
Parameters:
session - Session being deactivated.

eventOccurred

public boolean eventOccurred(com.sun.jdi.event.Event e)
Invoked when a VM event has occurred.
Specified by:
eventOccurred in interface VMEventListener
Parameters:
e - VM event
Returns:
true if debuggee VM should be resumed, false otherwise.

getPeer

public javax.swing.JComponent getPeer()
Returns a reference to the peer UI component. In many cases this is a JList, JTree, or JTable, depending on the type of data being displayed in the panel.
Returns:
peer ui component object

getUI

public javax.swing.JComponent getUI()
Returns a reference to the UI component.
Overrides:
getUI in class JSwatPanel
Returns:
ui component object

refresh

public void refresh(Session session)
Update the display on the screen. Use the given VM to fetch the desired data.
Overrides:
refresh in class JSwatPanel
Parameters:
session - Debugging Session object.

resolveWatchpoint

protected void resolveWatchpoint(int row,
                                 WatchPanel.WatchpointListEntry entry)
Try to resolve a watchpoint.
Parameters:
row - row number in table.
entry - watchpoint list entry.

resolveWatchpoints

protected void resolveWatchpoints()
Iterate the list of watchpoints and try to resolve any unresolved entries.

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Invoked whenever the table model changes.
Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Parameters:
e - Table model event.