|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
oscript.swing.text.ODEEditorKit
An editor-kit for an ODE src code editor. The document used is just
a plain-old PlainDocument
. Rather than trying to integrate the
parser with the ODEEditorKit.ODEDocument
's Element
structure, the parsed
representation of the document is stored seperately as an array of tokens.
We create a View
for rendering the document that takes into account
the token that overlays a section of text, and the AttributeSet
which that token maps to, as it renders the text.
For performance reasons, parsing happens asynchronously, which means that whenever the document is mutated. So, when there is an insert, we update the (now out of date) tokens by increasing the end-offset of the current token, and the begin-offset and end-offset of all subsequent tokens by the number of characters inserted. When there is a remove, the process is essentially the reverse.
The script side of things handles creating the parsing thread, and it uses
DocumentListener
s to determine when reparsing is needed.
createDefaultDocument()
,
Serialized FormNested Class Summary | |
class |
ODEEditorKit.ODEDocument
|
Nested classes inherited from class javax.swing.text.DefaultEditorKit |
javax.swing.text.DefaultEditorKit.BeepAction, javax.swing.text.DefaultEditorKit.CopyAction, javax.swing.text.DefaultEditorKit.CutAction, javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction, javax.swing.text.DefaultEditorKit.InsertBreakAction, javax.swing.text.DefaultEditorKit.InsertContentAction, javax.swing.text.DefaultEditorKit.InsertTabAction, javax.swing.text.DefaultEditorKit.PasteAction |
Field Summary |
Fields inherited from class javax.swing.text.DefaultEditorKit |
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction |
Constructor Summary | |
ODEEditorKit()
Class Constructor. |
Method Summary | |
javax.swing.text.Document |
createDefaultDocument()
Create a uninitialized document. |
oscript.syntaxtree.NodeToken |
getToken(int off)
Given an offset into the document, find the corresponding token. |
javax.swing.text.ViewFactory |
getViewFactory()
Get a factory for producing View s for rendering ODEEditorKit.ODEDocument s
created by this editor-kit. |
java.lang.String |
offsetToNodeToken(int off)
|
void |
setAttributeSetTable(oscript.util.SymbolMap attrSetTable)
Set the attribute set table. |
static void |
setDefaultFgColor(java.awt.Color c)
|
void |
setNodeTokens(java.util.Vector v)
Called from script code after parsing is completed. |
Methods inherited from class javax.swing.text.DefaultEditorKit |
createCaret, getActions, getContentType, read, read, write, write |
Methods inherited from class javax.swing.text.EditorKit |
clone, deinstall, install |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ODEEditorKit()
Method Detail |
public void setAttributeSetTable(oscript.util.SymbolMap attrSetTable)
attrSetTable
- the table that maps NodeToken.kind to an attribute
set. This table is created and maintained from script code, but
used here while rendering the text.public void setNodeTokens(java.util.Vector v)
public javax.swing.text.ViewFactory getViewFactory()
View
s for rendering ODEEditorKit.ODEDocument
s
created by this editor-kit.
public javax.swing.text.Document createDefaultDocument()
ODEEditorKit.ODEDocument
used by this editor
kit is basically just a PlainDocument
that has been extended to
synchronously update the offsets of the tokens in response to document
mutations (insert/remove). This is important to ensure that the token's
offset maps to sensible positions in the document during the period between
when the document is edited, and when the parser has finished re-parsing it
public static void setDefaultFgColor(java.awt.Color c)
public oscript.syntaxtree.NodeToken getToken(int off)
off
- the offset into the documentpublic java.lang.String offsetToNodeToken(int off)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |