Document
Hi all!
I have a bit of a problem to understand the default implementation of Document (AbstractDocument). What I would like to do is process text and determine which element it belongs to by
1. Looking in the context in which the text was inserted (e.g parentElement, siblings etc)
2. Looking at the pattern of the text.
If text is inserted into the document directly in an element, it should either be inserted into the element or it should form a new element (in which case the original element should be split in two parts). If the text is inserted in the middle of two elements, it could form a new element, or be part of one of the other two.
For instance (just an example):
int i = 1010;
If "+" would be inserted somewhere in "1010", the result is three elements, representing 10, + and 10 (eg). If 1 is inserted, it should be inserted into the element, etc.
The idea is to maintain a structure with both style information and logical information. In the case of syntax highlighting, there could be an element such as "KeywordElement" which contains style information and logical information. The style would "automatically" be associated with element, and the element would have an actual meaning in the structure, so code validation, refactoring etc could be performed on the text model.
I've looked at implementing it on my own, and that would be possible but it's quite a lot of work. Where should I start? The AbstractDocument and DefaultStyledDocument is poorly documented, so I'm looking for some online documentation or (preferable) a really quick and smooth solution (that's always good).
Thanks in advance,
Nille

