com.bluemarsh.jswat.view
Class SourceView

java.lang.Object
  |
  +--com.bluemarsh.jswat.view.JSwatView
        |
        +--com.bluemarsh.jswat.view.BasicView
              |
              +--com.bluemarsh.jswat.view.SourceView
All Implemented Interfaces:
com.bluemarsh.config.ConfigureListener, ContextListener, java.util.EventListener, SessionListener

public class SourceView
extends BasicView
implements ContextListener, com.bluemarsh.config.ConfigureListener, SessionListener

Defines the SourceView class which will be responsible for displaying the source file on the screen. This class displays a row header down the left side of the source view, indicating the line numbers. A popup menu is attached to the view for managing breakpoints.

Author:
Nathan Fiedler

Field Summary
protected  com.bluemarsh.jswat.view.BreakpointDrawLayer breakpointDrawLayer
          Gutter draw layer for showing breakpoint locations and states.
protected  java.util.List classLines
          Classlines of the parsed source file.
protected  char[] contentWithTabs
          Original view content, with any tab characters.
protected  JavaDrawLayer javaDrawLayer
          Draw layer responsible for colorizing Java code.
protected  Session owningSession
          Session to which we belong.
protected  SourceViewPopup popupMenu
          Popup menu for managing breakpoints.
protected  int tabSize
          Width of tabs in characters.
protected  javax.swing.JScrollPane viewScroller
          Scrollable component for text component.
 
Fields inherited from class com.bluemarsh.jswat.view.BasicView
lineHighlighter, logCategory, textComponent, viewContent, viewTitle
 
Constructor Summary
SourceView(java.lang.String name)
          Creates a SourceView object.
 
Method Summary
 void activate(Session session)
          Called when the Session is about to begin an active debugging session.
 void close(Session session)
          Called when the Session is about to close down.
 void configurationChanged()
          Called then the prefernces change.
 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.
 javax.swing.JComponent getUI()
          Returns a reference to the UI component.
 void init(Session session)
          Called after the Session has added this listener to the Session listener list.
protected  boolean matches(com.sun.jdi.Location location)
          Check if the Location is in the same source file as the file we are displaying.
protected  void parseClassDefs()
          Reads the class definition information from the source file using the JavaParser class.
 boolean refresh(java.io.InputStream input, int line)
          Read the input stream text into the text component.
protected  void setPreferences()
          Called to update this view's preferences, either when this object is constructed or when the preferences change.
protected  void setTextContent()
          Set the content of the text component using the text defined by viewContent.
 
Methods inherited from class com.bluemarsh.jswat.view.BasicView
findString, foundString, getLineEndOffset, getLineOfOffset, getLineStartOffset, removeHighlight, scrollToLine, showHighlight
 
Methods inherited from class com.bluemarsh.jswat.view.JSwatView
refresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewScroller

protected javax.swing.JScrollPane viewScroller
Scrollable component for text component.

popupMenu

protected SourceViewPopup popupMenu
Popup menu for managing breakpoints. Listens to text component.

owningSession

protected Session owningSession
Session to which we belong. Set in init().

tabSize

protected int tabSize
Width of tabs in characters. Defaults to 8.

classLines

protected java.util.List classLines
Classlines of the parsed source file.

javaDrawLayer

protected JavaDrawLayer javaDrawLayer
Draw layer responsible for colorizing Java code.

breakpointDrawLayer

protected com.bluemarsh.jswat.view.BreakpointDrawLayer breakpointDrawLayer
Gutter draw layer for showing breakpoint locations and states.

contentWithTabs

protected char[] contentWithTabs
Original view content, with any tab characters. XXX - waste of space, ought to have text area deal with the tabs
Constructor Detail

SourceView

public SourceView(java.lang.String name)
Creates a SourceView object.
Parameters:
name - name of the file to display.
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.
Specified by:
activate in interface SessionListener
Parameters:
session - Session being activated.

close

public void close(Session session)
Called when the Session is about to close down. Closes this view, detaching it from all other objects and preparing it for finalization.
Specified by:
close in interface SessionListener
Parameters:
session - Session being closed.

configurationChanged

public void configurationChanged()
Called then the prefernces change.
Specified by:
configurationChanged in interface com.bluemarsh.config.ConfigureListener

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.
Specified by:
deactivate in interface SessionListener
Parameters:
session - Session being deactivated.

getUI

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

init

public void init(Session session)
Called after the Session has added this listener to the Session listener list.
Specified by:
init in interface SessionListener
Parameters:
session - Session adding this listener.

matches

protected boolean matches(com.sun.jdi.Location location)
Check if the Location is in the same source file as the file we are displaying.
Parameters:
location - Location to check.
Returns:
True if breakpoint source name same as our filename.

parseClassDefs

protected void parseClassDefs()
Reads the class definition information from the source file using the JavaParser class. Give this information to the text component and row header popup menus.

refresh

public boolean refresh(java.io.InputStream input,
                       int line)
Read the input stream text into the text component. The view must be added to the Session as a session listener before calling this method.
Parameters:
input - input stream providing source.
line - line to make visible.
Returns:
true if successful, false if error.

setPreferences

protected void setPreferences()
Called to update this view's preferences, either when this object is constructed or when the preferences change.

setTextContent

protected void setTextContent()
Set the content of the text component using the text defined by viewContent. This implementation applies styles to the Java source to colorize it syntactically.