yu.ac.bg.etf.javaqx.qswing.text
Class TextDocument

java.lang.Object
  extended byyu.ac.bg.etf.javaqx.core.AbstractDisposable
      extended byyu.ac.bg.etf.javaqx.qswing.text.TextDocument
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
PlainDocument, StyledDocument

public abstract class TextDocument
extends AbstractDisposable

Abstract text document.

Version:
0.2.0
Author:
Slobodan Vrkacevic (slobodan.vrkacevic@gmail.com)

Field Summary
protected  EventListenerList listenerList
           
 
Method Summary
 void addUndoRedoListener(UndoRedoListener listener)
          Adds undo/redo listener.
 void appendText(java.lang.String text)
          Appends text to the end of the document.
 void clearText()
          Clears the text.
protected  java.lang.String disposedErrorString()
          Returns object disposed error message.
protected  void disposeObject()
          Disposes the object.
protected  void fireRedoAvailable(boolean available)
          Notifies listeners that redo operation is available.
protected  void fireUndoAvailable(boolean available)
          Notifies listeners that undo operation is available.
 TextHighlighter getHighlighter()
          Returns highlighter.
 java.lang.String getText()
          Returns text of the document.
 UndoRedoListener[] getUndoRedoListeners()
          Returns all undo/redo listeners.
 boolean isModified()
          Returns true if the document is modified.
 boolean isRedoAvailable()
          Returns true if the redo operation is available.
 boolean isUndoAvailable()
          Returns true if the undo operation is available.
 void print(Printer printer)
          Prints the document on the specified printer.
 void read(java.io.Reader reader)
          Reads text from reader.
 boolean readFrom(java.io.Reader reader)
          Reads text from reader without throwing exceptions.
 boolean readFrom(java.lang.String fileName)
          Reads text from the specified file without throwing exceptions.
 void redo()
          Redos last action.
 void removeUndoRedoListener(UndoRedoListener listener)
          Remove undo/redo listener.
 void setHighlighter(TextHighlighter highlighter)
          Sets highlighter.
 void setModified(boolean modified)
          Sets whether or not the document is modified.
 void setText(java.lang.String text)
          Sets text of the document.
 void setUndoRedoEnabled(boolean enabled)
          Sets whether or not the undo stack is enabled.
 void undo()
          Undos last action.
 void write(java.io.Writer writer)
          Writes text to writer.
 
Methods inherited from class yu.ac.bg.etf.javaqx.core.AbstractDisposable
addDisposeListener, dispose, disposedCheck, finalize, isDisposed, removeDisposeListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected final EventListenerList listenerList
Method Detail

clearText

public void clearText()
Clears the text.


getText

public java.lang.String getText()
Returns text of the document.

Returns:
text of the document

setText

public void setText(java.lang.String text)
Sets text of the document.

Parameters:
text - the text of the document

appendText

public void appendText(java.lang.String text)
Appends text to the end of the document.

Parameters:
text - the text to be appended

isUndoAvailable

public boolean isUndoAvailable()
Returns true if the undo operation is available.

Returns:
true if the undo operation is available

isRedoAvailable

public boolean isRedoAvailable()
Returns true if the redo operation is available.

Returns:
true if the redo operation is available

setUndoRedoEnabled

public void setUndoRedoEnabled(boolean enabled)
Sets whether or not the undo stack is enabled.

Parameters:
enabled - true if enabled

undo

public void undo()
Undos last action.


redo

public void redo()
Redos last action.


isModified

public boolean isModified()
Returns true if the document is modified.

Returns:
true if the document is modified

setModified

public void setModified(boolean modified)
Sets whether or not the document is modified.

Parameters:
modified - true if modified

read

public void read(java.io.Reader reader)
          throws java.io.IOException
Reads text from reader.

Parameters:
reader - the reader
Throws:
java.io.IOException - on an I/O error

readFrom

public boolean readFrom(java.io.Reader reader)
Reads text from reader without throwing exceptions.

Parameters:
reader - the reader
Returns:
true if succeed

readFrom

public boolean readFrom(java.lang.String fileName)
Reads text from the specified file without throwing exceptions.

Parameters:
fileName - the file name
Returns:
true if succeed

write

public void write(java.io.Writer writer)
           throws java.io.IOException
Writes text to writer.

Parameters:
writer - the writer
Throws:
java.io.IOException - on an I/O error

print

public void print(Printer printer)
Prints the document on the specified printer.

Parameters:
printer - the printer

getHighlighter

public TextHighlighter getHighlighter()
Returns highlighter.

Returns:
highlighter

setHighlighter

public void setHighlighter(TextHighlighter highlighter)
Sets highlighter.

Parameters:
highlighter - the highlighter

addUndoRedoListener

public void addUndoRedoListener(UndoRedoListener listener)
Adds undo/redo listener.

Parameters:
listener - the undo/redo listener

removeUndoRedoListener

public void removeUndoRedoListener(UndoRedoListener listener)
Remove undo/redo listener.

Parameters:
listener - the undo/redo listener

getUndoRedoListeners

public UndoRedoListener[] getUndoRedoListeners()
Returns all undo/redo listeners.

Returns:
the undo/redo listener array

fireUndoAvailable

protected void fireUndoAvailable(boolean available)
Notifies listeners that undo operation is available.

Parameters:
available - true if available

fireRedoAvailable

protected void fireRedoAvailable(boolean available)
Notifies listeners that redo operation is available.

Parameters:
available - true if available

disposedErrorString

protected java.lang.String disposedErrorString()
Returns object disposed error message.

Overrides:
disposedErrorString in class AbstractDisposable
Returns:
object disposed error message

disposeObject

protected final void disposeObject()
Disposes the object.

Specified by:
disposeObject in class AbstractDisposable


Copyright © 2007 ETF and contributors. All Rights Reserved.