|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
edu.rice.cs.util.text.SwingDocument
public class SwingDocument
A swing implementation of the toolkit-independent EditDocumentInterface. This document must use the readers/writers locking protocol established in its superclasses. TODO: create a separate DummySwingDocument class for testing and make SwingDocument abstract.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument |
|---|
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement |
| Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
|---|
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement |
| Field Summary | |
|---|---|
protected DocumentEditCondition |
_condition
Determines which edits are legal on this document. |
protected boolean |
_isModifiedSinceSave
The modified state. |
protected HashMap<String,AttributeSet> |
_styles
Maps names to attribute sets |
protected static Object |
_wrappedPosListLock
Lock that protects _wrappedPosListLock in DefinitionsDocument. |
| Fields inherited from class javax.swing.text.DefaultStyledDocument |
|---|
buffer, BUFFER_SIZE_DEFAULT |
| Fields inherited from class javax.swing.text.AbstractDocument |
|---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
| Fields inherited from interface javax.swing.text.Document |
|---|
StreamDescriptionProperty, TitleProperty |
| Constructor Summary | |
|---|---|
SwingDocument()
Creates a new document adapter for a Swing StyledDocument. |
|
| Method Summary | |
|---|---|
String |
_getText(int pos,
int len)
Sanitized version of getText(int, int) that converts BadLocationException to UnexpectedException. |
void |
addColoring(int start,
int end,
String style)
Adds the given coloring style to the styles list. |
void |
append(String str)
Appends given string with default style to end of this document. |
void |
append(String str,
AttributeSet set)
Appends given string with specified attributes to end of this document. |
void |
append(String str,
String style)
Appends given string with specified named style to end of this document. |
void |
clear()
|
Position |
createUnwrappedPosition(int offs)
Performs the default behavior for createPosition in DefaultStyledDocument. |
void |
forceInsertText(int offs,
String str,
String style)
Inserts a string into the document at the given offset and style, regardless of the edit condition. |
void |
forceRemoveText(int offs,
int len)
Removes a portion of the document, regardless of the edit condition. |
String |
getDefaultStyle()
A SwingDocument instance does not have a default style |
AttributeSet |
getDocStyle(String name)
Returns the style with the given name, or null if no such named style exists. |
String |
getDocText(int offs,
int len)
Returns a portion of the document. |
DocumentEditCondition |
getEditCondition()
Gets the object which can determine whether an insert or remove edit should be applied, based on the inputs. |
Pageable |
getPageable()
Returns the Pageable object for printing. |
String |
getText()
Gets the document text; this method is threadsafe. |
void |
insertString(int offs,
String str,
AttributeSet set)
Overrides superclass's insertString to impose the edit condition. |
void |
insertText(int offs,
String str,
String style)
Inserts a string into the document at the given offset and style, if the edit condition allows it. |
void |
print()
Prints the given console document |
void |
remove(int offs,
int len)
Overrides superclass's remove to impose the edit condition. |
void |
removeText(int offs,
int len)
Removes a portion of the document, if the edit condition allows it. |
void |
setDocStyle(String name,
AttributeSet s)
Adds the given AttributeSet as a style with the given name. |
void |
setEditCondition(DocumentEditCondition condition)
Provides an object which can determine whether an insert or remove edit should be applied, based on the inputs. |
| Methods inherited from class javax.swing.text.DefaultStyledDocument |
|---|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface edu.rice.cs.util.text.EditDocumentInterface |
|---|
getLength |
| Methods inherited from interface edu.rice.cs.util.text.AbstractDocumentInterface |
|---|
createPosition, getLength, getText |
| Methods inherited from interface javax.swing.text.Document |
|---|
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeUndoableEditListener, render |
| Field Detail |
|---|
protected volatile boolean _isModifiedSinceSave
protected final HashMap<String,AttributeSet> _styles
protected DocumentEditCondition _condition
protected static final Object _wrappedPosListLock
| Constructor Detail |
|---|
public SwingDocument()
| Method Detail |
|---|
public void setDocStyle(String name,
AttributeSet s)
name - Name of the style, to be passed to insertStrings - AttributeSet to use for the stylepublic AttributeSet getDocStyle(String name)
public void addColoring(int start,
int end,
String style)
public DocumentEditCondition getEditCondition()
getEditCondition in interface EditDocumentInterfacepublic void setEditCondition(DocumentEditCondition condition)
setEditCondition in interface EditDocumentInterfacecondition - Object to determine legality of inputspublic void clear()
public void insertText(int offs,
String str,
String style)
insertText in interface EditDocumentInterfaceoffs - Offset into the documentstr - String to be insertedstyle - Name of the style to use. Must have been added using addStyle.
EditDocumentException - if the offset is illegal
public void forceInsertText(int offs,
String str,
String style)
forceInsertText in interface EditDocumentInterfaceoffs - Offset into the documentstr - String to be insertedstyle - Name of the style to use. Must have been added using addStyle.
EditDocumentException - if the offset is illegal
public void insertString(int offs,
String str,
AttributeSet set)
throws BadLocationException
insertString in interface AbstractDocumentInterfaceinsertString in interface DocumentinsertString in class AbstractDocumentBadLocationException
public void removeText(int offs,
int len)
removeText in interface EditDocumentInterfaceoffs - Offset to start deleting fromlen - Number of characters to remove
EditDocumentException - if the offset or length are illegal
public void forceRemoveText(int offs,
int len)
forceRemoveText in interface EditDocumentInterfaceoffs - Offset to start deleting fromlen - Number of characters to remove
EditDocumentException - if the offset or length are illegal
public void remove(int offs,
int len)
throws BadLocationException
remove in interface AbstractDocumentInterfaceremove in interface Documentremove in class AbstractDocumentBadLocationException
public String getDocText(int offs,
int len)
getDocText in interface EditDocumentInterfaceoffs - First offset of the desired textlen - Number of characters to return
EditDocumentException - if the offset or length are illegalpublic String getText()
getText in interface AbstractDocumentInterface
public String _getText(int pos,
int len)
public void append(String str,
AttributeSet set)
append in interface AbstractDocumentInterface
public void append(String str,
String style)
append in interface EditDocumentInterfacestr - String to be insertedstyle - Name of the style to use. Must have been added using addStyle.public void append(String str)
public String getDefaultStyle()
getDefaultStyle in interface EditDocumentInterfacepublic void print()
EditDocumentInterface
print in interface EditDocumentInterfacepublic Pageable getPageable()
EditDocumentInterface
getPageable in interface EditDocumentInterface
public Position createUnwrappedPosition(int offs)
throws BadLocationException
BadLocationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||