|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.text.NbDocument
Dummy class holding utility methods for working with NetBeans document conventions.
Nested Class Summary | |
static interface |
NbDocument.Annotatable
Enhanced version of document which is capable of attaching/detaching of annotations. |
static class |
NbDocument.Colors
Deprecated. Not useful for anything. |
static interface |
NbDocument.CustomEditor
Enabled documents to add special UI components to their Editor pane. |
static interface |
NbDocument.CustomToolbar
Enabled documents to add special UI toolbar components to their Editor pane. |
static interface |
NbDocument.PositionBiasable
Enhanced version of document that provides better support for holding and working with biased positions. |
static interface |
NbDocument.Printable
Document which may support styled text printing. |
static interface |
NbDocument.WriteLockable
Specialized version of document that knows how to lock the document for complex modifications. |
Field Summary | |
static String |
BREAKPOINT_STYLE_NAME
Name of style attached to documents to mark a paragraph (line) as a (debugger) breakpoint. |
static NbDocument.Colors |
COLORS
Deprecated. Not useful for anything. |
static String |
CURRENT_STYLE_NAME
Name of style attached to documents to mark a paragraph (line) as current (in a debugger). |
static String |
ERROR_STYLE_NAME
Name of style attached to documents to mark a paragraph (line) as erroneous. |
static Object |
GUARDED
Attribute that signals that a given character is guarded (cannot be modified). |
static String |
NORMAL_STYLE_NAME
Name of style attached to documents to unmark a paragraph (line) as anything special. |
Method Summary | |
static void |
addAnnotation(StyledDocument doc,
Position startPos,
int length,
Annotation annotation)
Add annotation to the document. |
static Position |
createPosition(Document doc,
int offset,
Position.Bias bias)
Creates position with a bias. |
static int |
findLineColumn(StyledDocument doc,
int offset)
Finds column number given an offset. |
static int |
findLineNumber(StyledDocument doc,
int offset)
For given document and an offset, find the line number. |
static int |
findLineOffset(StyledDocument doc,
int lineNumber)
Finds offset of the beginning of a line. |
static Element |
findLineRootElement(StyledDocument doc)
Find the root element of all lines. |
static Object |
findPageable(StyledDocument doc)
Find a way to print a given document. |
static void |
insertGuarded(StyledDocument doc,
int offset,
String txt)
Inserts a text into given offset and marks it guarded. |
static void |
markBreakpoint(StyledDocument doc,
int offset)
Deprecated. since 1.20. Use addAnnotation() instead |
static void |
markCurrent(StyledDocument doc,
int offset)
Deprecated. since 1.20. Use addAnnotation() instead |
static void |
markError(StyledDocument doc,
int offset)
Deprecated. since 1.20. Use addAnnotation() instead |
static void |
markGuarded(StyledDocument doc,
int offset,
int len)
Mark part of a document as guarded (immutable to the user). |
static void |
markNormal(StyledDocument doc,
int offset)
Deprecated. since 1.20. Use addAnnotation() instead |
static void |
removeAnnotation(StyledDocument doc,
Annotation annotation)
Removal of added annotation. |
static void |
runAtomic(StyledDocument doc,
Runnable run)
Locks the document to have exclusive access to it. |
static void |
runAtomicAsUser(StyledDocument doc,
Runnable run)
Executes given runnable in "user mode" does not allowing any modifications to parts of text marked as guarded. |
static void |
unmarkGuarded(StyledDocument doc,
int offset,
int len)
Remove guarded mark on a block of a document. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Object GUARDED
AttributeSet.CharacterAttribute
to signal that
this attribute applies to characters, not paragraphs.
public static final String BREAKPOINT_STYLE_NAME
public static final String ERROR_STYLE_NAME
public static final String CURRENT_STYLE_NAME
public static final String NORMAL_STYLE_NAME
public static final NbDocument.Colors COLORS
Method Detail |
public static Element findLineRootElement(StyledDocument doc)
doc
- styled document (expecting NetBeans document)
NullPointerException
- If the doc
parameter
is null
.public static int findLineNumber(StyledDocument doc, int offset)
doc
- the documentoffset
- offset in the document
NullPointerException
- If the doc
parameter
is null
.public static int findLineColumn(StyledDocument doc, int offset)
doc
- the documentoffset
- offset in the document
NullPointerException
- If the doc
parameter
is null
.public static int findLineOffset(StyledDocument doc, int lineNumber)
doc
- the documentlineNumber
- number of the line to find the start of (zero-based)
NullPointerException
- If the doc
parameter
is null
.
IndexOutOfBoundsException
- when incorrect
lineNumber
value is insertedpublic static Position createPosition(Document doc, int offset, Position.Bias bias) throws BadLocationException
Position.Bias.Backward
then if an insert occures at the position, the text is inserted
after the position. If the bias is Forward
, then the text is
inserted before the position.
The method checks if the document implements NbDocument.PositionBiasable
,
and if so,
is called.
Otherwise an attempt is made to provide a createPosition
Position
with the correct behavior.
doc
- document to create position inoffset
- the current offset for the positionbias
- the bias to use for the position
NullPointerException
- If the doc
parameter
is null
.
BadLocationException
- if the offset is invalidpublic static void markGuarded(StyledDocument doc, int offset, int len)
doc
- styled documentoffset
- offset to start atlen
- length of text to mark as guarded
NullPointerException
- If the doc
parameter
is null
.public static void unmarkGuarded(StyledDocument doc, int offset, int len)
doc
- styled documentoffset
- offset to start atlen
- length of text to mark as unguarded
NullPointerException
- If the doc
parameter
is null
.public static void insertGuarded(StyledDocument doc, int offset, String txt) throws BadLocationException
doc
- document to insert tooffset
- offset of insertiontxt
- string text to insert
NullPointerException
- If the doc
parameter
is null
.
BadLocationException
public static void markBreakpoint(StyledDocument doc, int offset)
BREAKPOINT_STYLE_NAME
, it is used.
Otherwise, a new style is defined.
doc
- the documentoffset
- identifies the line to set breakpoint to
NullPointerException
- If the doc
parameter
is null
.public static void markError(StyledDocument doc, int offset)
ERROR_STYLE_NAME
, it is used.
Otherwise, a new style is defined.
doc
- the documentoffset
- identifies the line to mark
NullPointerException
- If the doc
parameter
is null
.public static void markCurrent(StyledDocument doc, int offset)
CURRENT_STYLE_NAME
, it is used.
Otherwise, a new style is defined.
doc
- the documentoffset
- identifies the line to mark
NullPointerException
- If the doc
parameter
is null
.public static void markNormal(StyledDocument doc, int offset)
NORMAL_STYLE_NAME
.
This method should be used to undo the effect of markBreakpoint(javax.swing.text.StyledDocument, int)
, markError(javax.swing.text.StyledDocument, int)
and markCurrent(javax.swing.text.StyledDocument, int)
.
doc
- the documentoffset
- identified the line to unmark
NullPointerException
- If the doc
parameter
is null
.public static void runAtomic(StyledDocument doc, Runnable run)
NbDocument.WriteLockable
can specify exactly how to do this.
doc
- document to lockrun
- the action to run
NullPointerException
- If the doc
parameter
is null
.public static void runAtomicAsUser(StyledDocument doc, Runnable run) throws BadLocationException
doc
- document to modifyrun
- runnable to run in user mode that will have exclusive access to modify the document
NullPointerException
- If the doc
parameter
is null
.
BadLocationException
- if a modification of guarded text occured
and that is why no changes to the document has been done.public static Object findPageable(StyledDocument doc)
Printable
is used as a wrapper. In this last case it is useful
to implement NbDocument.Printable
to describe how to print in terms of
attributed characters, rather than specifying the complete page layout from scratch.
public static void addAnnotation(StyledDocument doc, Position startPos, int length, Annotation annotation)
doc
- the document which will be annotatedstartPos
- position which represent begining
of the annotated textlength
- length of the annotated text. If -1 is specified
the whole line will be annotatedannotation
- annotation which is attached to this textpublic static void removeAnnotation(StyledDocument doc, Annotation annotation)
doc
- the annotated documentannotation
- annotation which is going to be removed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |