public final class NbDocument
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
NbDocument.Annotatable |
Enhanced version of document which is capable of
attaching/detaching of annotations.
|
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.
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
BREAKPOINT_STYLE_NAME |
Deprecated.
since 6.29. Use
Annotation instead. |
static java.lang.String |
CURRENT_STYLE_NAME |
Deprecated.
since 6.29. Use
Annotation instead. |
static java.lang.String |
ERROR_STYLE_NAME |
Deprecated.
since 6.29. Use
Annotation instead. |
static java.lang.Object |
GUARDED |
Attribute that signals that a given character is guarded (cannot
be modified).
|
static java.lang.String |
NORMAL_STYLE_NAME |
Deprecated.
since 6.29. Use
Annotation instead. |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
addAnnotation(javax.swing.text.StyledDocument doc,
javax.swing.text.Position startPos,
int length,
Annotation annotation) |
Add annotation to the document.
|
static javax.swing.text.Position |
createPosition(javax.swing.text.Document doc,
int offset,
javax.swing.text.Position.Bias bias) |
Creates position with a bias.
|
static int |
findLineColumn(javax.swing.text.StyledDocument doc,
int offset) |
Finds column number given an offset.
|
static int |
findLineNumber(javax.swing.text.StyledDocument doc,
int offset) |
For given document and an offset, find the line number.
|
static int |
findLineOffset(javax.swing.text.StyledDocument doc,
int lineNumber) |
Finds offset of the beginning of a line.
|
static javax.swing.text.Element |
findLineRootElement(javax.swing.text.StyledDocument doc) |
Find the root element of all lines.
|
static java.lang.Object |
findPageable(javax.swing.text.StyledDocument doc) |
Find a way to print a given document.
|
static javax.swing.JEditorPane |
findRecentEditorPane(EditorCookie ec) |
Gets recently selected editor pane opened by editor cookie
Can be called from AWT event thread only.
|
static javax.swing.text.StyledDocument |
getDocument(org.openide.util.Lookup.Provider provider) |
Get the document associated with a file.
|
static <T extends javax.swing.undo.UndoableEdit> |
getEditToBeRedoneOfType(EditorCookie ec,
java.lang.Class<T> type) |
Get an edit of given type that would be redone if a redo operation would be invoked
at this time for an editor cookie.
|
static <T extends javax.swing.undo.UndoableEdit> |
getEditToBeUndoneOfType(EditorCookie ec,
java.lang.Class<T> type) |
Get an edit of given type that would be undone if an undo operation would be invoked
at this time for an editor cookie.
|
static void |
insertGuarded(javax.swing.text.StyledDocument doc,
int offset,
java.lang.String txt) |
Inserts a text into given offset and marks it guarded.
|
static void |
markBreakpoint(javax.swing.text.StyledDocument doc,
int offset) |
Deprecated.
since 1.20. Use addAnnotation() instead
|
static void |
markCurrent(javax.swing.text.StyledDocument doc,
int offset) |
Deprecated.
since 1.20. Use addAnnotation() instead
|
static void |
markError(javax.swing.text.StyledDocument doc,
int offset) |
Deprecated.
since 1.20. Use addAnnotation() instead
|
static void |
markGuarded(javax.swing.text.StyledDocument doc,
int offset,
int len) |
Mark part of a document as guarded (immutable to the user).
|
static void |
markNormal(javax.swing.text.StyledDocument doc,
int offset) |
Deprecated.
since 1.20. Use addAnnotation() instead
|
static boolean |
openDocument(org.openide.util.Lookup.Provider provider,
int line,
int column,
Line.ShowOpenType openType,
Line.ShowVisibilityType visibilityType) |
Open the document associated with a file in the Editor window in a
position specified by the line and column while controlling open and visibility behavior.
|
static boolean |
openDocument(org.openide.util.Lookup.Provider provider,
int offset,
Line.ShowOpenType openType,
Line.ShowVisibilityType visibilityType) |
Open the document associated with a file in the Editor window in a
position specified by the offset while controlling open and visibility behavior.
|
static void |
removeAnnotation(javax.swing.text.StyledDocument doc,
Annotation annotation) |
Removal of added annotation.
|
static void |
runAtomic(javax.swing.text.StyledDocument doc,
java.lang.Runnable run) |
Locks the document to have exclusive access to it.
|
static void |
runAtomicAsUser(javax.swing.text.StyledDocument doc,
java.lang.Runnable run) |
Executes given runnable in "user mode" does not allowing any modifications
to parts of text marked as guarded.
|
static void |
unmarkGuarded(javax.swing.text.StyledDocument doc,
int offset,
int len) |
Remove guarded mark on a block of a document.
|
public static final java.lang.Object GUARDED
AttributeSet.CharacterAttribute to signal that
this attribute applies to characters, not paragraphs.@Deprecated public static final java.lang.String BREAKPOINT_STYLE_NAME
Annotation instead.@Deprecated public static final java.lang.String ERROR_STYLE_NAME
Annotation instead.@Deprecated public static final java.lang.String CURRENT_STYLE_NAME
Annotation instead.@Deprecated public static final java.lang.String NORMAL_STYLE_NAME
Annotation instead.public static javax.swing.text.Element findLineRootElement(javax.swing.text.StyledDocument doc)
doc - styled document (expecting NetBeans document)java.lang.NullPointerException - If the doc parameter
is null.public static int findLineNumber(javax.swing.text.StyledDocument doc,
int offset)
doc - the documentoffset - offset in the documentjava.lang.NullPointerException - If the doc parameter
is null.public static int findLineColumn(javax.swing.text.StyledDocument doc,
int offset)
doc - the documentoffset - offset in the documentjava.lang.NullPointerException - If the doc parameter
is null.public static int findLineOffset(javax.swing.text.StyledDocument doc,
int lineNumber)
doc - the documentlineNumber - number of the line to find the start of (zero-based)java.lang.NullPointerException - If the doc parameter
is null.java.lang.IndexOutOfBoundsException - when incorrect
lineNumber value is insertedpublic static javax.swing.text.Position createPosition(javax.swing.text.Document doc,
int offset,
javax.swing.text.Position.Bias bias)
throws javax.swing.text.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 createPositionPosition with the correct behavior.
doc - document to create position inoffset - the current offset for the positionbias - the bias to use for the positionjava.lang.NullPointerException - If the doc parameter
is null.javax.swing.text.BadLocationException - if the offset is invalidpublic static void markGuarded(javax.swing.text.StyledDocument doc,
int offset,
int len)
doc - styled documentoffset - offset to start atlen - length of text to mark as guardedjava.lang.NullPointerException - If the doc parameter
is null.public static void unmarkGuarded(javax.swing.text.StyledDocument doc,
int offset,
int len)
doc - styled documentoffset - offset to start atlen - length of text to mark as unguardedjava.lang.NullPointerException - If the doc parameter
is null.public static void insertGuarded(javax.swing.text.StyledDocument doc,
int offset,
java.lang.String txt)
throws javax.swing.text.BadLocationException
doc - document to insert tooffset - offset of insertiontxt - string text to insertjava.lang.NullPointerException - If the doc parameter
is null.javax.swing.text.BadLocationException@Deprecated
public static void markBreakpoint(javax.swing.text.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 tojava.lang.NullPointerException - If the doc parameter
is null.@Deprecated
public static void markError(javax.swing.text.StyledDocument doc,
int offset)
ERROR_STYLE_NAME, it is used.
Otherwise, a new style is defined.doc - the documentoffset - identifies the line to markjava.lang.NullPointerException - If the doc parameter
is null.@Deprecated
public static void markCurrent(javax.swing.text.StyledDocument doc,
int offset)
CURRENT_STYLE_NAME, it is used.
Otherwise, a new style is defined.doc - the documentoffset - identifies the line to markjava.lang.NullPointerException - If the doc parameter
is null.@Deprecated
public static void markNormal(javax.swing.text.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 unmarkjava.lang.NullPointerException - If the doc parameter
is null.public static javax.swing.JEditorPane findRecentEditorPane(EditorCookie ec)
ec - EditorCookie used to find out recently selected editor panepublic static void runAtomic(javax.swing.text.StyledDocument doc,
java.lang.Runnable run)
Lockable can specify exactly how to do this.doc - document to lockrun - the action to runjava.lang.NullPointerException - If the doc parameter
is null.public static void runAtomicAsUser(javax.swing.text.StyledDocument doc,
java.lang.Runnable run)
throws javax.swing.text.BadLocationException
doc - document to modifyrun - runnable to run in user mode that will have exclusive access to modify the documentjava.lang.NullPointerException - If the doc parameter
is null.javax.swing.text.BadLocationException - if a modification of guarded text occured
and that is why no changes to the document has been done.public static java.lang.Object findPageable(javax.swing.text.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.doc - the document to find printing support forPrintable or Pageablepublic static void addAnnotation(javax.swing.text.StyledDocument doc,
javax.swing.text.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(javax.swing.text.StyledDocument doc,
Annotation annotation)
doc - the annotated documentannotation - annotation which is going to be removedpublic static <T extends javax.swing.undo.UndoableEdit> T getEditToBeUndoneOfType(EditorCookie ec, java.lang.Class<T> type)
T - type of undoable edit to be retrieved.ec - editor cookie providing an undo/redo manager.type - class of undoable edit to be retrieved.public static <T extends javax.swing.undo.UndoableEdit> T getEditToBeRedoneOfType(EditorCookie ec, java.lang.Class<T> type)
T - type of undoable edit to be retrieved.ec - editor cookie providing an undo/redo manager.type - class of undoable edit to be retrieved.public static javax.swing.text.StyledDocument getDocument(org.openide.util.Lookup.Provider provider)
Method will throw UserQuestionException
exception if file size is too big. This exception is caught and its
method UserQuestionException.confirmed() is used
for confirmation.
provider - for example a org.openide.loaders.DataObjectpublic static boolean openDocument(org.openide.util.Lookup.Provider provider,
int offset,
Line.ShowOpenType openType,
Line.ShowVisibilityType visibilityType)
provider - for example a org.openide.loaders.DataObjectoffset - the position the document should be opened (starting at 0)openType - control open behavior, Line.ShowOpenType.OPEN
would typically be usedvisibilityType - control visibility behavior, Line.ShowVisibilityType.FOCUS
would typically be usedUserQuestionException handlingpublic static boolean openDocument(org.openide.util.Lookup.Provider provider,
int line,
int column,
Line.ShowOpenType openType,
Line.ShowVisibilityType visibilityType)
provider - for example a org.openide.loaders.DataObjectline - the line the document should be opened (starting at 0)column - the column which should be selected (starting at 0), value
-1 does not change previously selected columnopenType - control open behavior, Line.ShowOpenType.OPEN
would typically be usedvisibilityType - control visibility behavior, Line.ShowVisibilityType.FOCUS
would typically be usedUserQuestionException handlingBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.