站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

GuardedDocument (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

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, EventListener, Document, StyledDocument, AtomicLockDocument, SettingsChangeListener

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
protected  Hashtable stylesToLayers
          Style to layer name mapping
static SimpleAttributeSet unguardedSet
          AttributeSet with only break-guarded attribute
 
Fields inherited from class org.netbeans.editor.BaseDocument
BLOCKS_FINDER_PROP, defaultRootElem, FILE_NAME_PROP, ID_PROP, inited, KIT_CLASS_PROP, LINE_BATCH_SIZE, LINE_LIMIT_PROP, lineRootElement, LS_CR, LS_CRLF, LS_LF, modified, READ_LINE_SEPARATOR_PROP, STRING_BWD_FINDER_PROP, STRING_FINDER_PROP, THREAD_LOCAL_LOCK_DEPTH, 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)
           
GuardedDocument(Class kitClass, boolean addToRegistry, StyleContext styles)
          Create base document with a specified syntax and style context.
 
Method Summary
 Style addStyle(String styleName, Style parent)
          Adds style to the document
protected  DrawLayer addStyledLayer(String layerName, Style style)
          Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.
 void addStyleToLayerMapping(String styleName, String layerName)
           
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 pos)
           
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 s, 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, addLayer, atomicLock, atomicUndo, atomicUnlock, breakAtomicLock, checkTrailingSpaces, createDocumentProperties, createPosition, extWriteLock, extWriteUnlock, find, findLayer, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAnnotations, getAtomicDepth, getChars, getChars, getChars, getDefaultRootElement, getFormatter, getKitClass, getParagraphElement, getRootElements, getShiftWidth, getSyntaxSupport, getTabSize, getText, getText, insertString, insertUpdate, invalidateSyntaxMarks, isAtomicLock, isIdentifierPart, isModified, isWhitespace, postRemoveUpdate, preInsertUpdate, print, print, print, processText, read, remove, removeAtomicLockListener, removeDocumentListener, removeUpdate, render, repaintBlock, resetUndoMerge, setPostModificationDocumentListener, settingsChange, toString, write
 
Methods inherited from class javax.swing.text.AbstractDocument
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getStartPosition, getText, getText, getUndoableEditListeners, putProperty, readLock, readUnlock, removeUndoableEditListener, replace, 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


stylesToLayers

protected Hashtable stylesToLayers
Style to layer name mapping


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)

GuardedDocument

public GuardedDocument(Class kitClass,
                       boolean addToRegistry,
                       StyleContext styles)
Create base document with a specified syntax and 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
syntax - syntax scanner to use with this document
styles - style context to use
Method Detail

getGuardedBlockChain

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


isPosGuarded

public boolean isPosGuarded(int pos)

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

setCharacterAttributes

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

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

addStyle

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

Specified by:
addStyle in interface StyledDocument

addStyleToLayerMapping

public void addStyleToLayerMapping(String styleName,
                                   String layerName)

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

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


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

addStyledLayer

protected DrawLayer addStyledLayer(String layerName,
                                   Style style)
Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.

Using of DrawLayers has been deprecated.


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/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.