|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.gui.AbstractDocument
diva.gui.tutorial.TextDocument
public class TextDocument
A example document that contains plain boring old text and saves it to ascii files. Here you can see some sample implementations of the open, save, saveAs, and close methods. You should also notice that this class adds methods for accessing the contained document's data in an application-useful format. (In this case, there are just simple getText and setText methods.) The setText properly realized that the document's data has been changed and sets the Dirty flag. This is used in the application tutorial by the StoragePolicy to prevent a user from closing the document without saving changes.
This class also contains a DocumentFactory for documents of this type. The document factory is used by an application to create documents of this type.
Nested Class Summary | |
---|---|
static class |
TextDocument.Factory
TextDocument.Factory is a factory for Text Documents |
Field Summary | |
---|---|
(package private) java.lang.String |
_text
The string contained in this document. |
Constructor Summary | |
---|---|
TextDocument(Application application)
Create an text document for the given application containing an empty string. |
Method Summary | |
---|---|
void |
close()
Close the document. |
java.lang.String |
getText()
Return the text contained in this document. |
void |
open()
Open the document from its current file or URL. |
void |
save()
Save the document to its current file or URL. |
void |
saveAs(java.io.File file)
Save the document to the given file. |
void |
saveAs(java.net.URL url)
Save the document to the given URL. |
void |
setText(java.lang.String text)
Set the text contained by this document. |
Methods inherited from class diva.gui.AbstractDocument |
---|
addPropertyChangeListener, getApplication, getEditSupport, getFile, getShortTitle, getTitle, getUndoManager, getURL, isDirty, isEditable, isWritable, removePropertyChangeListener, setDirty, setEditable, setFile, setURL, setWritable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.lang.String _text
Constructor Detail |
---|
public TextDocument(Application application)
Method Detail |
---|
public void close()
close
in interface Document
close
in class AbstractDocument
java.lang.Exception
- If the close operation fails.public java.lang.String getText()
public void open() throws java.lang.Exception
open
in interface Document
open
in class AbstractDocument
java.lang.Exception
- If the close operation fails.public void save() throws java.lang.Exception
save
in interface Document
save
in class AbstractDocument
java.lang.Exception
- If the save operation fails.public void saveAs(java.io.File file) throws java.lang.Exception
saveAs
in interface Document
saveAs
in class AbstractDocument
java.lang.Exception
- If the save-as operation fails.save()
public void saveAs(java.net.URL url) throws java.lang.Exception
saveAs
in interface Document
saveAs
in class AbstractDocument
java.lang.Exception
- If the save-as operation fails.save()
public void setText(java.lang.String text)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |