org.netbeans.modules.editor.lib/3 3.23.0 19

org.netbeans.editor
Class GuardedDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by org.netbeans.editor.BaseDocument
          extended by org.netbeans.editor.GuardedDocument
All Implemented Interfaces:
Serializable, Document, StyledDocument, AtomicLockDocument

public class GuardedDocument
extends BaseDocument
implements StyledDocument

Extension to the guarded document that implements StyledDocument interface

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.netbeans.editor.BaseDocument
BaseDocument.LazyPropertyMap, BaseDocument.PropertyEvaluator
 
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
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
 
Fields inherited from class org.netbeans.editor.BaseDocument
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
 
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
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.
 
Method Summary
 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
 
Methods inherited from class org.netbeans.editor.BaseDocument
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, removeDocumentListener, removePostModificationDocumentListener, removeUpdate, removeUpdateDocumentListener, render, repaintBlock, replace, resetUndoMerge, setPostModificationDocumentListener, toString, write
 
Methods inherited from class javax.swing.text.AbstractDocument
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.text.StyledDocument
getParagraphElement
 
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
 

Field Detail

GUARDED_ATTRIBUTE

public static final String GUARDED_ATTRIBUTE
Guarded attribute used for specifying that the inserted block will be guarded.

See Also:
Constant Field Values

guardedSet

public static final SimpleAttributeSet guardedSet
AttributeSet with only guarded attribute


unguardedSet

public static final SimpleAttributeSet unguardedSet
AttributeSet with only break-guarded attribute


FMT_GUARDED_INSERT_LOCALE

public static final String FMT_GUARDED_INSERT_LOCALE
See Also:
Constant Field Values

FMT_GUARDED_REMOVE_LOCALE

public static final String FMT_GUARDED_REMOVE_LOCALE
See Also:
Constant Field Values

styles

protected StyleContext styles
Style context to hold the styles


normalStyleName

protected String normalStyleName
Name of the normal style. The normal style is used to reset the effect of all styles applied to the line.

Constructor Detail

GuardedDocument

public GuardedDocument(Class kitClass)
Deprecated. The use of editor kit's implementation classes is deprecated in favor of mime types.

Create a new guarded document.

Parameters:
kitClass - The implementation class of the editor kit that should be used for this document.

GuardedDocument

public GuardedDocument(String mimeType)
Create a new guarded document.

Parameters:
mimeType - The mime type for this document.
Since:
1.26

GuardedDocument

public GuardedDocument(Class kitClass,
                       boolean addToRegistry,
                       StyleContext styles)
Deprecated. The use of editor kit's implementation classes is deprecated in favor of mime types.

Creates base document with specified style context.

Parameters:
kitClass - class used to initialize this document with proper settings category based on the editor kit for which this document is created
addToRegistry - XXX
styles - style context to use

GuardedDocument

public GuardedDocument(String mimeType,
                       boolean addToRegistry,
                       StyleContext styles)
Creates base document with specified style context.

Parameters:
mimeType - The mime type for this document.
addToRegistry - XXX
styles - style context to use
Since:
1.26
Method Detail

getGuardedBlockChain

public MarkBlockChain getGuardedBlockChain()
Get the chain of the guarded blocks


isPosGuarded

public boolean isPosGuarded(int offset)

preInsertCheck

protected void preInsertCheck(int offset,
                              String text,
                              AttributeSet a)
                       throws BadLocationException
This method is called automatically before the document is updated as result of removal. This function can throw BadLocationException or its descendants to stop the ongoing insert from being actually done.

Overrides:
preInsertCheck in class BaseDocument
Parameters:
evt - document event containing the change including array of characters that will be inserted
Throws:
BadLocationException

preRemoveCheck

protected void preRemoveCheck(int offset,
                              int len)
                       throws BadLocationException
This method is called automatically before the document is updated as result of removal.

Overrides:
preRemoveCheck in class BaseDocument
Parameters:
offset - position where the insertion will be done
len - length of the removal
Throws:
BadLocationException

runAtomic

public void runAtomic(Runnable r)
Description copied from class: BaseDocument
Runs the runnable under write lock. This is a stronger version of the runAtomicAsUser() method, because if there any locked sections in the documents this methods breaks the modification locks and modifies the document. If there are any excpeptions thrown during the processing of the runnable, all the document modifications are rolled back automatically.

Overrides:
runAtomic in class BaseDocument

runAtomicAsUser

public void runAtomicAsUser(Runnable r)
Description copied from class: BaseDocument
Runs the runnable under write lock. If there are any excpeptions thrown during the processing of the runnable, all the document modifications are rolled back automatically.

Overrides:
runAtomicAsUser in class BaseDocument

createDocumentEvent

protected BaseDocumentEvent createDocumentEvent(int offset,
                                                int length,
                                                DocumentEvent.EventType type)
Overrides:
createDocumentEvent in class BaseDocument

setNormalStyleName

public void setNormalStyleName(String normalStyleName)
Set the name for normal style. Normal style is used to reset the effect of all aplied styles.


getStyleNames

public Enumeration getStyleNames()
Fetches the list of style names


addStyle

public Style addStyle(String styleName,
                      Style parent)
Adds style to the document

Specified by:
addStyle in interface StyledDocument

removeStyle

public void removeStyle(String styleName)
Removes style from document

Specified by:
removeStyle in interface StyledDocument

getStyle

public Style getStyle(String styleName)
Fetches style previously added

Specified by:
getStyle in interface StyledDocument

setCharacterAttributes

public void setCharacterAttributes(int offset,
                                   int length,
                                   AttributeSet attribs,
                                   boolean replace)
Specified by:
setCharacterAttributes in interface StyledDocument

setParagraphAttributes

public void setParagraphAttributes(int offset,
                                   int length,
                                   AttributeSet s,
                                   boolean replace)
Change attributes for part of the text.

Specified by:
setParagraphAttributes in interface StyledDocument

setLogicalStyle

public void setLogicalStyle(int pos,
                            Style s)
Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document.

Specified by:
setLogicalStyle in interface StyledDocument
Parameters:
pos - the starting position >= 0
s - the style to set

getLogicalStyle

public Style getLogicalStyle(int pos)
Get logical style for position in paragraph

Specified by:
getLogicalStyle in interface StyledDocument

getCharacterElement

public Element getCharacterElement(int pos)
Gets the element that represents the character that is at the given offset within the document.

Specified by:
getCharacterElement in interface StyledDocument
Parameters:
pos - the offset >= 0
Returns:
the element

getForeground

public Color getForeground(AttributeSet attr)
Takes a set of attributes and turn it into a foreground color specification. This might be used to specify things like brighter, more hue, etc.

Specified by:
getForeground in interface StyledDocument
Parameters:
attr - the set of attributes
Returns:
the color

getBackground

public Color getBackground(AttributeSet attr)
Takes a set of attributes and turn it into a background color specification. This might be used to specify things like brighter, more hue, etc.

Specified by:
getBackground in interface StyledDocument
Parameters:
attr - the set of attributes
Returns:
the color

getFont

public Font getFont(AttributeSet attr)
Takes a set of attributes and turn it into a font specification. This can be used to turn things like family, style, size, etc into a font that is available on the system the document is currently being used on.

Specified by:
getFont in interface StyledDocument
Parameters:
attr - the set of attributes
Returns:
the font

toStringDetail

public String toStringDetail()
Description copied from class: BaseDocument
Detailed debug info about the document

Overrides:
toStringDetail in class BaseDocument

org.netbeans.modules.editor.lib/3 3.23.0 19

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.