JET

edu.utep.cs.et.gui
Class AbstractSourceCodeViewer

java.lang.Object
  extended by edu.utep.cs.et.gui.AbstractSourceCodeViewer
All Implemented Interfaces:
SourceCodeViewer
Direct Known Subclasses:
Main.OutputSourceCodeViewer, WorkingPane.TesterSourceCodeViewer

abstract class AbstractSourceCodeViewer
extends Object
implements SourceCodeViewer

An abstract class that turns an editor into a source code viewer. A source code viewer can to hightlight the source code line corresponding to an error message.

Author:
Yoonsik Cheon

Field Summary
protected  ActionFactory actionFactory
          The action factory to store unsaved edits if any.
protected  Editor editor
          The editor to be used as a source code viewer.
 
Constructor Summary
AbstractSourceCodeViewer(ActionFactory af, Editor editor)
          Creates a source code viewer that uses the given action factory and the editor.
 
Method Summary
 Action getPasteAction()
          Returns a paste action that should be enabled when a copy action is performed.
 void highlight(String file, int line)
          Highlights the given line of the given file, if necessary, by first bringing in the file into the source code viewer.
 void highlight(String file, int line, int column)
          Highlights the given line and column of the given file, if necessary, by first bringing in the file into the source code viewer.
protected abstract  File locateFile(String fileName)
          Locates the file whose name is given as the argument.
private  boolean openFile(String fileName)
          Opens the given file using the editor given to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actionFactory

protected ActionFactory actionFactory
The action factory to store unsaved edits if any.


editor

protected Editor editor
The editor to be used as a source code viewer.

Constructor Detail

AbstractSourceCodeViewer

public AbstractSourceCodeViewer(ActionFactory af,
                                Editor editor)
Creates a source code viewer that uses the given action factory and the editor.

Method Detail

getPasteAction

public Action getPasteAction()
Returns a paste action that should be enabled when a copy action is performed. It returns the paste action of the editor given to the constructor.

Specified by:
getPasteAction in interface SourceCodeViewer

highlight

public void highlight(String file,
                      int line,
                      int column)
Highlights the given line and column of the given file, if necessary, by first bringing in the file into the source code viewer. The file name is a relative pathname (e.g., T.java and ../T.java) identified from the error messages of external tools such as javac and jmlc.

Specified by:
highlight in interface SourceCodeViewer

highlight

public void highlight(String file,
                      int line)
Highlights the given line of the given file, if necessary, by first bringing in the file into the source code viewer. The file name is a relative pathname (e.g., T.java and ../T.java) identified from the error messages of external tools such as javac and jmlc.

Specified by:
highlight in interface SourceCodeViewer

locateFile

protected abstract File locateFile(String fileName)
Locates the file whose name is given as the argument. This method should by overridden by a subclass to locate the file by using contextual information appropriate to the subclass.


openFile

private boolean openFile(String fileName)
Opens the given file using the editor given to the constructor.


JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.