public class GuardedDocument extends BaseDocument implements StyledDocument
BaseDocument.LazyPropertyMap, BaseDocument.PropertyEvaluator
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
Modifier and Type | Field and Description |
---|---|
static String |
FMT_GUARDED_INSERT_LOCALE |
static String |
FMT_GUARDED_REMOVE_LOCALE |
static String |
GUARDED_ATTRIBUTE
Guarded attribute used for specifying that the inserted block
will be guarded.
|
static SimpleAttributeSet |
guardedSet
AttributeSet with only guarded attribute
|
protected String |
normalStyleName
Name of the normal style.
|
protected StyleContext |
styles
Style context to hold the styles
|
static SimpleAttributeSet |
unguardedSet
AttributeSet with only break-guarded attribute
|
BLOCKS_FINDER_PROP, defaultRootElem, FILE_NAME_PROP, FORMATTER, ID_PROP, inited, KIT_CLASS_PROP, LINE_BATCH_SIZE, LINE_LIMIT_PROP, LS_CR, LS_CRLF, LS_LF, MIME_TYPE_PROP, modified, READ_LINE_SEPARATOR_PROP, STRING_BWD_FINDER_PROP, STRING_FINDER_PROP, UNDO_MANAGER_PROP, WRAP_SEARCH_MARK_PROP, WRITE_LINE_SEPARATOR_PROP
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
StreamDescriptionProperty, TitleProperty
Constructor and Description |
---|
GuardedDocument(Class kitClass)
Deprecated.
The use of editor kit's implementation classes is deprecated
in favor of mime types.
|
GuardedDocument(Class kitClass,
boolean addToRegistry,
StyleContext styles)
Deprecated.
The use of editor kit's implementation classes is deprecated
in favor of mime types.
|
GuardedDocument(String mimeType)
Create a new guarded document.
|
GuardedDocument(String mimeType,
boolean addToRegistry,
StyleContext styles)
Creates base document with specified style context.
|
Modifier and Type | Method and Description |
---|---|
Style |
addStyle(String styleName,
Style parent)
Adds style to the document
|
protected BaseDocumentEvent |
createDocumentEvent(int offset,
int length,
DocumentEvent.EventType type) |
Color |
getBackground(AttributeSet attr)
Takes a set of attributes and turn it into a background color
specification.
|
Element |
getCharacterElement(int pos)
Gets the element that represents the character that
is at the given offset within the document.
|
Font |
getFont(AttributeSet attr)
Takes a set of attributes and turn it into a font
specification.
|
Color |
getForeground(AttributeSet attr)
Takes a set of attributes and turn it into a foreground color
specification.
|
MarkBlockChain |
getGuardedBlockChain()
Get the chain of the guarded blocks
|
Style |
getLogicalStyle(int pos)
Get logical style for position in paragraph
|
Style |
getStyle(String styleName)
Fetches style previously added
|
Enumeration |
getStyleNames()
Fetches the list of style names
|
boolean |
isPosGuarded(int offset) |
protected void |
preInsertCheck(int offset,
String text,
AttributeSet a)
This method is called automatically before the document
is updated as result of removal.
|
protected void |
preRemoveCheck(int offset,
int len)
This method is called automatically before the document
is updated as result of removal.
|
void |
removeStyle(String styleName)
Removes style from document
|
void |
runAtomic(Runnable r)
Runs the runnable under write lock.
|
void |
runAtomicAsUser(Runnable r)
Runs the runnable under write lock.
|
void |
setCharacterAttributes(int offset,
int length,
AttributeSet attribs,
boolean replace) |
void |
setLogicalStyle(int pos,
Style s)
Sets the logical style to use for the paragraph at the
given position.
|
void |
setNormalStyleName(String normalStyleName)
Set the name for normal style.
|
void |
setParagraphAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
Change attributes for part of the text.
|
String |
toStringDetail()
Detailed debug info about the document
|
addAtomicLockListener, addAtomicLockListener, addDocumentListener, addPostModificationDocumentListener, addUndoableEdit, addUndoableEditListener, addUpdateDocumentListener, atomicLock, atomicUndo, atomicUnlock, breakAtomicLock, checkTrailingSpaces, createDocumentProperties, createPosition, extWriteLock, extWriteUnlock, find, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAnnotations, getAtomicDepth, getChars, getChars, getChars, getDefaultRootElement, getKitClass, getParagraphElement, getRootElements, getShiftWidth, getSyntaxSupport, getTabSize, getText, getText, insertString, insertUpdate, invalidateSyntaxMarks, isAtomicLock, isIdentifierPart, isModifiable, isModified, isWhitespace, postRemoveUpdate, preInsertUpdate, print, print, print, processText, read, remove, removeAtomicLockListener, removeAtomicLockListener, removeDocumentListener, removePostModificationDocumentListener, removeUpdate, removeUpdateDocumentListener, render, repaintBlock, replace, resetUndoMerge, setPostModificationDocumentListener, toString, write
createBranchElement, createLeafElement, createPosition, dump, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getStartPosition, getText, getText, getUndoableEditListeners, putProperty, readLock, readUnlock, removeUndoableEditListener, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParagraphElement
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
public static final String GUARDED_ATTRIBUTE
public static final SimpleAttributeSet guardedSet
public static final SimpleAttributeSet unguardedSet
public static final String FMT_GUARDED_INSERT_LOCALE
public static final String FMT_GUARDED_REMOVE_LOCALE
protected StyleContext styles
protected String normalStyleName
@Deprecated public GuardedDocument(Class kitClass)
kitClass
- The implementation class of the editor kit that
should be used for this document.public GuardedDocument(String mimeType)
mimeType
- The mime type for this document.@Deprecated public GuardedDocument(Class kitClass, boolean addToRegistry, StyleContext styles)
kitClass
- class used to initialize this document with proper settings
category based on the editor kit for which this document is createdaddToRegistry
- XXXstyles
- style context to usepublic GuardedDocument(String mimeType, boolean addToRegistry, StyleContext styles)
mimeType
- The mime type for this document.addToRegistry
- XXXstyles
- style context to usepublic MarkBlockChain getGuardedBlockChain()
public boolean isPosGuarded(int offset)
protected void preInsertCheck(int offset, String text, AttributeSet a) throws BadLocationException
preInsertCheck
in class BaseDocument
offset
- position where the insertion will be donetext
- string to be inserteda
- attributes of the inserted textBadLocationException
protected void preRemoveCheck(int offset, int len) throws BadLocationException
preRemoveCheck
in class BaseDocument
offset
- position where the insertion will be donelen
- length of the removalBadLocationException
public void runAtomic(Runnable r)
BaseDocument
runAtomic
in class BaseDocument
public void runAtomicAsUser(Runnable r)
BaseDocument
runAtomicAsUser
in class BaseDocument
protected BaseDocumentEvent createDocumentEvent(int offset, int length, DocumentEvent.EventType type)
createDocumentEvent
in class BaseDocument
public void setNormalStyleName(String normalStyleName)
public Enumeration getStyleNames()
public Style addStyle(String styleName, Style parent)
addStyle
in interface StyledDocument
public void removeStyle(String styleName)
removeStyle
in interface StyledDocument
public Style getStyle(String styleName)
getStyle
in interface StyledDocument
public void setCharacterAttributes(int offset, int length, AttributeSet attribs, boolean replace)
setCharacterAttributes
in interface StyledDocument
public void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
setParagraphAttributes
in interface StyledDocument
public void setLogicalStyle(int pos, Style s)
setLogicalStyle
in interface StyledDocument
pos
- the starting position >= 0s
- the style to setpublic Style getLogicalStyle(int pos)
getLogicalStyle
in interface StyledDocument
public Element getCharacterElement(int pos)
getCharacterElement
in interface StyledDocument
pos
- the offset >= 0public Color getForeground(AttributeSet attr)
getForeground
in interface StyledDocument
attr
- the set of attributespublic Color getBackground(AttributeSet attr)
getBackground
in interface StyledDocument
attr
- the set of attributespublic Font getFont(AttributeSet attr)
getFont
in interface StyledDocument
attr
- the set of attributespublic String toStringDetail()
BaseDocument
toStringDetail
in class BaseDocument