Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 62862 - [painting] Reusing Editors does not fully reset editor
Summary: [painting] Reusing Editors does not fully reset editor
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 67046
Blocks:
  Show dependency tree
 
Reported: 2004-05-19 06:10 EDT by Dani Megert CLA
Modified: 2004-09-02 05:04 EDT (History)
0 users

See Also:


Attachments
AbstractReconciler.java.diff (1.17 KB, patch)
2004-07-28 10:03 EDT, Tom Hofmann CLA
no flags Details | Diff
AnnotationPainter.java.diff (916 bytes, patch)
2004-07-28 10:07 EDT, Tom Hofmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2004-05-19 06:10:37 EDT
I200405190010

0. set to have at most 1 editor and set folding off for new editors
1. open a file from CVS Repository view
2. open a normal CU
3. add an error
Observe: no error shown (reconciler not started?)

4. close all
5. open a normal CU which has errors and/or warnings
6. enable folding for this CU
7. open a file from repository
Observe: folding annotations, errors and warnings hang around
Comment 1 Dani Megert CLA 2004-07-12 11:57:17 EDT
For 3.0.1 we should fix at least the dangling projection annotations.

Important Note: Update of some actions depends on the scenario: if the reused
editor is opened via a view (e.g. PackageExplorer) then partChanged gets
triggered which updates the action contributions i.e.
EditorActionBarContributor.setActiveEditor(...) gets called. However, if the
reused editor is opened while this editor is already active and opening is done
via global action (e.g. Open Type or Open External File...) then
EditorActionBarContributor.setActiveEditor(...) isn't called.
Comment 2 Tom Hofmann CLA 2004-07-28 04:41:51 EDT
Also, when using the editor navigation history, setActiveEditor is not called.
Comment 3 Tom Hofmann CLA 2004-07-28 07:07:15 EDT
A partial fix does the following:

- in JavaEditor.doSetInput, call SourceViewerDecorationSupport.dispose(), not
uninstall()
- at the same place, move the call to SourceViewerDecorationSupport.install
after internalDoSetInput to make sure the AnnotationPainter picks up the correct
annotation model
- in AbstractReconciler::install(), we assume that the document will be set on
the viewer after install. This may not be the case with editor re-use, so we
have to make sure we register the reconciler as document listener on the
viewer's document, if already there.

This does not fix the action enablement, but it does remove the old annotations
and ensures that the correct annotation model gets used.
Comment 4 Tom Hofmann CLA 2004-07-28 10:01:19 EDT
after review by Christof, we changed the following: 

- JavaEditor stays as is
- Instead, we make sure that AnnotationPainter clears its internal cache of
drawn annotations (decorations) when its model is set to null.
Comment 5 Tom Hofmann CLA 2004-07-28 10:03:47 EDT
Created attachment 13641 [details]
AbstractReconciler.java.diff

Patch for AbstractReconciler.java

In install(), when the supplied ITextViewer already has a document, we register
as document listener with the document. With this, a reconciler can be
installed on a live viewer and gives up the requirement that the document must
be set after its installation.
Comment 6 Tom Hofmann CLA 2004-07-28 10:07:00 EDT
Created attachment 13642 [details]
AnnotationPainter.java.diff

Patch for AnnotationPainter.java

In catchUpWithModel, if the supplied annotation model is null, we don't just
exit but instead make sure that any of the internally cached annotations get
cleared. Otherwise a painter that gets deactivated may still draw the set of
annotations it stored before it was deactivated.
Comment 7 Tom Hofmann CLA 2004-07-28 10:30:18 EDT
released into 3.1. HEAD, awaiting review for 3.0.1
Comment 8 Dani Megert CLA 2004-07-29 10:36:33 EDT
Fixes reviewed and approved.
Released to R3_0_maintenance branch

Filed bug 71081 about the general editor reuse problem
Comment 9 Dani Megert CLA 2004-09-02 05:04:43 EDT
Verified in M200409010800.