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

NbDocument.WriteLockable (NetBeans Text API) - NetBeans API Javadoc 5.5.1

org.openide.text 6.9.32

org.openide.text
Interface NbDocument.WriteLockable

All Superinterfaces:
Document
Enclosing class:
NbDocument

public static interface NbDocument.WriteLockable
extends Document

Specialized version of document that knows how to lock the document for complex modifications.


Field Summary
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Method Summary
 void runAtomic(Runnable r)
          Executes given runnable in lock mode of the document.
 void runAtomicAsUser(Runnable r)
          Executes given runnable in "user mode" does not allowing any modifications to parts of text marked as guarded.
 
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
 

Method Detail

runAtomic

void runAtomic(Runnable r)
Executes given runnable in lock mode of the document. In this mode, all redrawing is stopped and the caller has exclusive access to all modifications to the document.

By definition there should be only one locker at a time. Sample implementation, if you are extending AbstractDocument:

writeLock();
try {
  r.run();
} finally {
  writeUnlock();
}

Parameters:
r - runnable to run while locked
See Also:
NbDocument.runAtomic(javax.swing.text.StyledDocument, java.lang.Runnable)

runAtomicAsUser

void runAtomicAsUser(Runnable r)
                     throws BadLocationException
Executes given runnable in "user mode" does not allowing any modifications to parts of text marked as guarded. The actions should be run as "atomic" so either happen all at once or none at all (if a guarded block should be modified).

Parameters:
r - runnable to run in user mode that will have exclusive access to modify the document
Throws:
BadLocationException - if a modification of guarded text occured and that is why no changes to the document has been done.

org.openide.text 6.9.32

Built on March 26 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.