| javax.swing.text.DefaultStyledDocument edu.rice.cs.util.text.SwingDocument
All known Subclasses: edu.rice.cs.drjava.model.AbstractDJDocument,
SwingDocument | public class SwingDocument extends DefaultStyledDocument implements EditDocumentInterface,AbstractDocumentInterface(Code) | | 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.
version: $Id: SwingDocument.java 4255 2007-08-28 19:17:37Z mgricken $ |
Constructor Summary | |
public | SwingDocument() Creates a new document adapter for a Swing StyledDocument. |
Method Summary | |
public void | _forceInsertText(int offs, String str, String style) Behaves exactly like forceInsertText except for assuming that WriteLock is already held. | public void | _insertText(int offs, String str, String style) | public void | _removeText(int offs, int len) Removes a portion of the document, if the edit condition allows it, as above. | public void | acquireReadLock() | public void | acquireWriteLock() Swing-style writeLock(). | public void | addColoring(int start, int end, String style) Adds the given coloring style to the styles list. | public void | append(String str, AttributeSet set) Appends given string with specified attributes to end of this document. | public void | append(String str, String style) Appends given string with specified named style to end of this document. | public void | clear() | public Position | createUnwrappedPosition(int offs) Performs the default behavior for createPosition in DefaultStyledDocument. | public 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.
Parameters: offs - Offset into the document Parameters: str - String to be inserted Parameters: style - Name of the style to use. | public void | forceRemoveText(int offs, int len) Removes a portion of the document, regardless of the edit condition. | public String | getDefaultStyle() | public AttributeSet | getDocStyle(String name) Returns the style with the given name, or null if no such named style exists. | public String | getDocText(int offs, int len) Returns a portion of the document. | public DocumentEditCondition | getEditCondition() Gets the object which can determine whether an insert or remove edit should be applied, based on the inputs. | public Pageable | getPageable() | public String | getText() Returns entire text of this document. | public void | insertString(int offs, String str, AttributeSet set) Overrides superclass's insertString to impose the edit condition. | public 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.
Parameters: offs - Offset into the document Parameters: str - String to be inserted Parameters: style - Name of the style to use. | public void | print() | public void | releaseReadLock() | public void | releaseWriteLock() Swing-style writeUnlock(). | public void | remove(int offs, int len) Overrides superclass's remove to impose the edit condition. | public void | removeText(int offs, int len) Removes a portion of the document, if the edit condition allows it. | public void | setDocStyle(String name, AttributeSet s) Adds the given AttributeSet as a style with the given name. | public void | setEditCondition(DocumentEditCondition condition) Provides an object which can determine whether an insert or remove edit should be applied, based on the inputs. |
_wrappedPosListLock | final protected static Object _wrappedPosListLock(Code) | | Lock used to protect _wrappedPosListLock in DefinitionsDocument. Placed here to ensure that it initialized before
use!
|
SwingDocument | public SwingDocument()(Code) | | Creates a new document adapter for a Swing StyledDocument. TODO: convert _styles and _condition to lazily
initialized volatiles as soon as support for Java 1.4 is dropped and the double-check idiom is safe.
|
_forceInsertText | public void _forceInsertText(int offs, String str, String style)(Code) | | Behaves exactly like forceInsertText except for assuming that WriteLock is already held.
|
_removeText | public void _removeText(int offs, int len)(Code) | | Removes a portion of the document, if the edit condition allows it, as above. Assume sthat WriteLock is held
|
acquireReadLock | public void acquireReadLock()(Code) | | |
acquireWriteLock | public void acquireWriteLock()(Code) | | Swing-style writeLock(). Must be renamed because inherited writeLock is final.
|
addColoring | public void addColoring(int start, int end, String style)(Code) | | Adds the given coloring style to the styles list. Not supported in SwingDocument.
|
append | public void append(String str, AttributeSet set)(Code) | | Appends given string with specified attributes to end of this document.
|
append | public void append(String str, String style)(Code) | | Appends given string with specified named style to end of this document.
|
clear | public void clear()(Code) | | |
createUnwrappedPosition | public Position createUnwrappedPosition(int offs) throws BadLocationException(Code) | | Performs the default behavior for createPosition in DefaultStyledDocument.
|
forceInsertText | public void forceInsertText(int offs, String str, String style)(Code) | | Inserts a string into the document at the given offset and style, regardless of the edit condition.
Parameters: offs - Offset into the document Parameters: str - String to be inserted Parameters: style - Name of the style to use. Must have been added using addStyle. throws: EditDocumentException - if the offset is illegal |
forceRemoveText | public void forceRemoveText(int offs, int len)(Code) | | Removes a portion of the document, regardless of the edit condition.
Parameters: offs - Offset to start deleting from Parameters: len - Number of characters to remove throws: EditDocumentException - if the offset or length are illegal |
getDefaultStyle | public String getDefaultStyle()(Code) | | A SwingDocument instance does not have a default style
|
getDocStyle | public AttributeSet getDocStyle(String name)(Code) | | Returns the style with the given name, or null if no such named style exists.
|
getDocText | public String getDocText(int offs, int len)(Code) | | Returns a portion of the document.
Parameters: offs - First offset of the desired text Parameters: len - Number of characters to return throws: EditDocumentException - if the offset or length are illegal |
getEditCondition | public DocumentEditCondition getEditCondition()(Code) | | Gets the object which can determine whether an insert or remove edit should be applied, based on the inputs.
an Object to determine legality of inputs |
getText | public String getText()(Code) | | Returns entire text of this document.
|
insertString | public void insertString(int offs, String str, AttributeSet set) throws BadLocationException(Code) | | Overrides superclass's insertString to impose the edit condition. The AttributeSet is ignored in the condition,
which sees a null style name.
|
insertText | public void insertText(int offs, String str, String style)(Code) | | Inserts a string into the document at the given offset and style, if the edit condition allows it.
Parameters: offs - Offset into the document Parameters: str - String to be inserted Parameters: style - Name of the style to use. Must have been added using addStyle. throws: EditDocumentException - if the offset is illegal |
print | public void print()(Code) | | |
releaseReadLock | public void releaseReadLock()(Code) | | |
releaseWriteLock | public void releaseWriteLock()(Code) | | Swing-style writeUnlock(). Must be renamed because inherited writeUnlock is final.
|
remove | public void remove(int offs, int len) throws BadLocationException(Code) | | Overrides superclass's remove to impose the edit condition.
|
removeText | public void removeText(int offs, int len)(Code) | | Removes a portion of the document, if the edit condition allows it.
Parameters: offs - Offset to start deleting from Parameters: len - Number of characters to remove throws: EditDocumentException - if the offset or length are illegal |
setDocStyle | public void setDocStyle(String name, AttributeSet s)(Code) | | Adds the given AttributeSet as a style with the given name. It can then be used in insertString.
Parameters: name - Name of the style, to be passed to insertString Parameters: s - AttributeSet to use for the style |
setEditCondition | public void setEditCondition(DocumentEditCondition condition)(Code) | | Provides an object which can determine whether an insert or remove edit should be applied, based on the inputs.
Parameters: condition - Object to determine legality of inputs |
Fields inherited from javax.swing.text.DefaultStyledDocument | final public static int BUFFER_SIZE_DEFAULT(Code)(Java Doc) protected ElementBuffer buffer(Code)(Java Doc)
|
Methods inherited from javax.swing.text.DefaultStyledDocument | public void addDocumentListener(DocumentListener listener)(Code)(Java Doc) public Style addStyle(String nm, Style parent)(Code)(Java Doc) protected void create(ElementSpec[] data)(Code)(Java Doc) protected AbstractElement createDefaultRoot()(Code)(Java Doc) public Color getBackground(AttributeSet attr)(Code)(Java Doc) public Element getCharacterElement(int pos)(Code)(Java Doc) public Element getDefaultRootElement()(Code)(Java Doc) public Font getFont(AttributeSet attr)(Code)(Java Doc) public Color getForeground(AttributeSet attr)(Code)(Java Doc) public Style getLogicalStyle(int p)(Code)(Java Doc) public Element getParagraphElement(int pos)(Code)(Java Doc) public Style getStyle(String nm)(Code)(Java Doc) public Enumeration> getStyleNames()(Code)(Java Doc) protected void insert(int offset, ElementSpec[] data) throws BadLocationException(Code)(Java Doc) protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr)(Code)(Java Doc) public void removeDocumentListener(DocumentListener listener)(Code)(Java Doc) public void removeElement(Element elem)(Code)(Java Doc) public void removeStyle(String nm)(Code)(Java Doc) protected void removeUpdate(DefaultDocumentEvent chng)(Code)(Java Doc) public void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)(Code)(Java Doc) public void setLogicalStyle(int pos, Style s)(Code)(Java Doc) public void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)(Code)(Java Doc) protected void styleChanged(Style style)(Code)(Java Doc)
|
|
|