online updation of content outline [message #68614] |
Tue, 10 June 2003 04:22 |
Eclipse User |
|
|
|
Originally posted by: bharatkhatri2000.yahoo.com
Hi All,
I have designed my own editor which also has the corresponding content
outline page. If the file is edited, the content outline is updated only
after it is saved, which I do by overriding the doSave() method of
TextEditor. Now I want to update the content outline while the file is
begin edited, as is done in the java environment. I can think of a simple
way of doing it, but it wont be very efficient. Is there a "best-way" to
do such a thing using some eclipse feature ?
Thanks
Bharat
|
|
|
Re: online updation of content outline [message #68741 is a reply to message #68614] |
Tue, 10 June 2003 06:35 |
Eclipse User |
|
|
|
Originally posted by: bob.objfac.com
"Bharat" <bharatkhatri2000@yahoo.com> wrote in message
news:bc3meq$hgk$1@rogue.oti.com...
> I have designed my own editor which also has the corresponding content
> outline page. If the file is edited, the content outline is updated only
> after it is saved, which I do by overriding the doSave() method of
> TextEditor. Now I want to update the content outline while the file is
> begin edited, as is done in the java environment. I can think of a simple
> way of doing it, but it wont be very efficient. Is there a "best-way" to
> do such a thing using some eclipse feature ?
The best way to find out is to look at some code. CompilationUnitEditor (the
Java editor) uses something called a JavaReconciler and a
JavaReconcilingStrategy. Open the editor and search for outline until you
find the method that updates the outline, then work backward. However, this
is all internal stuff that you can't readily use and might not even find
convenient.
The essential idea is that updating and redrawing the outline view must not
be done synchronously with every keystroke, or editing will be intolerably
slow for large files (even for relatively small ones). A simple strategy
that works is:
1. Each time the document changes (set a listener), attempt to reconcile the
outline view, as follows.
2. Set the current time as the update time. If a reconcile is in progress,
return with no action.
3. Mark reconcile in progress and start a background thread to wait until
the current time equals the update time plus some delay, usually in the
neighborhood of 500 ms. to 1 second. Note that setting and examining the
update time must be synchronized, as it will occur in different threads.
4. When the time has elapsed, call asynchExec to run step 5.
5. Check to make sure the editor and the content outline have not been
disposed. If either has, return with no action.
6. Update the content outline with current information from the editor.
7. Unmark reconcile in progress.
Note that steps 3 and 4 are done in the background thread; all others run in
the UI thread.
Also note that this simple strategy works because the document contents are
not used in the background. A more complex approach is needed for problems
like parsing in the background to produce error markers. The Java editor
still didn't have the latter right as of 2.1, so don't use it as an example.
;-}
Bob
|
|
|
Powered by
FUDForum. Page generated in 0.03206 seconds