UTJML

edu.utep.cs.utjml.gui
Class JmlEditor

java.lang.Object
  extended by edu.utep.cs.utjml.gui.JmlEditor
All Implemented Interfaces:
Editorable

public class JmlEditor
extends Object
implements Editorable

A simple JML/Java source code editor that supports syntax hightligting. The class is adapted from the demo programs of the package com.Ostermiller.Syntax written by Stephen Ostermiller (http://ostermiller.org).

Author:
Yoonsik Cheon

Field Summary
protected  edu.utep.cs.utjml.gui.JmlEditor.Colorer colorer
          A thread that handles the actual coloring.
protected  edu.utep.cs.utjml.gui.JmlEditor.HighLightedDocument document
          The styled document that is the model for the textPane
protected  edu.utep.cs.utjml.gui.JmlEditor.DocumentReader documentReader
          A reader wrapped around the document so that the document can be fed into the lexer.
protected  Lexer syntaxLexer
          The lexer that tells us what colors different words should be.
protected  JTextPane textPane
          The place where the text is drawn.
 
Constructor Summary
JmlEditor(Mainable utjml, edu.utep.cs.utjml.gui.ActionFactory af)
          Create a new JML editor.
 
Method Summary
 void color(int position, int adjustment)
          Color a section of the document.
 void colorAll()
          Color or recolor the entire document
 void highlight(String filename, int line)
          Highlights the specified line of the given file.
 void highlight(String filename, int line, int col)
          Highlights the specified column of the given file.
 boolean isDirty()
          Returns true if there exist unsaved edits.
 boolean newDocument()
          Creates a new empty document.
 boolean openFile(File file)
          Opens the given file file for editing.
 boolean saveFile(File file)
          Saves the contents of the editor buffer to the given file file.
 JTextPane textPane()
          Returns the text pane of this editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textPane

protected JTextPane textPane
The place where the text is drawn.


document

protected edu.utep.cs.utjml.gui.JmlEditor.HighLightedDocument document
The styled document that is the model for the textPane


documentReader

protected edu.utep.cs.utjml.gui.JmlEditor.DocumentReader documentReader
A reader wrapped around the document so that the document can be fed into the lexer.


syntaxLexer

protected Lexer syntaxLexer
The lexer that tells us what colors different words should be.


colorer

protected edu.utep.cs.utjml.gui.JmlEditor.Colorer colorer
A thread that handles the actual coloring.

Constructor Detail

JmlEditor

public JmlEditor(Mainable utjml,
                 edu.utep.cs.utjml.gui.ActionFactory af)
Create a new JML editor.

Method Detail

textPane

public JTextPane textPane()
Returns the text pane of this editor.


isDirty

public boolean isDirty()
Returns true if there exist unsaved edits.

Specified by:
isDirty in interface Editorable

newDocument

public boolean newDocument()
Creates a new empty document.

Specified by:
newDocument in interface Editorable

openFile

public boolean openFile(File file)
Opens the given file file for editing. The contents of the file are read into the editing buffer by creating a new document for that.

Specified by:
openFile in interface Editorable

saveFile

public boolean saveFile(File file)
Saves the contents of the editor buffer to the given file file.

Specified by:
saveFile in interface Editorable

highlight

public void highlight(String filename,
                      int line,
                      int col)
Highlights the specified column of the given file.

Specified by:
highlight in interface Editorable

highlight

public void highlight(String filename,
                      int line)
Highlights the specified line of the given file.

Specified by:
highlight in interface Editorable

colorAll

public void colorAll()
Color or recolor the entire document


color

public void color(int position,
                  int adjustment)
Color a section of the document. The actual coloring will start somewhere before the requested position and continue as long as needed.

Parameters:
position - the starting point for the coloring.
adjustment - amount of text inserted or removed at the starting point.

UTJML

UTJML is Copyright (C) 2004-2006 by 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. This release depends on code from the JML project.