Bug 20706 - Start replace fails if it is not a text or Java editor
Summary: Start replace fails if it is not a text or Java editor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Search (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 critical (vote)
Target Milestone: 2.0 F4   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-20 05:17 EDT by Dani Megert CLA
Modified: 2002-06-21 06:01 EDT (History)
0 users

See Also:


Attachments
Patch that fixes the problem (14.38 KB, patch)
2002-06-20 09:57 EDT, Dirk Baeumer CLA
no flags Details | Diff
Final patch (12.82 KB, patch)
2002-06-21 06:01 EDT, Dirk Baeumer 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 2002-06-20 05:17:58 EDT
Build 20020619

The replace action does not start if the editor is not a text or Java editor.
The results are
1) NPE or CCE written to the log
2) The replace dialog does not come up - only the editor opens
Comment 1 Dirk Baeumer CLA 2002-06-20 06:15:04 EDT
Fix is to always open the text editor independent from the registry. We can't 
do better since text search can't make any assumptions about which editor is 
registered for file type. The only assumption it can do is that a text editor 
is appropriate since it was a text search.

If the default text editor can't be opened than an error message is shown an 
replace is stopped.
Comment 2 Dirk Baeumer CLA 2002-06-20 08:02:30 EDT
Note that this bug has nothing to do with replace in text editor. It is global 
replace provided by Search.

Coded fix looks like follows:

- before we executed replace it checks if all files that will be manipulated
  are either closed or opened in an editor that is supported by replace (e.g.
  instanceof ITextEditor). If not replace operation shows a dialog asking
  the user to close the editor.
- when performing a replace the operation always opens the editor in the 
  default text editor. It remembers the previous default editor and restores
  this setting to not change the setting of Open->With...
 
  If the replace operation can't open a default text editor the replace 
  operation gets aborted and a dialog is shown to the user. Since we open the 
  editor before doing the first change the user will not loose any work by 
  this.

Risk of fix: local to Search. Affected files are ReplaceAction and 
  ReplaceDialog and SearchMessages.properties. Risk of code changes: middle.

Consequences of not fixing: we end up having NPE or CCE when the user starts
  a replace operation on files that have an external editor or an incompatible
  internal editor assigned.
  Candidates are plugin.xml file, HTML files, ....

Comment 3 Dirk Baeumer CLA 2002-06-20 09:57:25 EDT
Created attachment 1529 [details]
Patch that fixes the problem
Comment 4 Nick Edgar CLA 2002-06-20 11:58:44 EDT
Does this change only affect replace?  That is, when browsing through search 
results in .java files, I'll still get the CU editor?
Comment 5 Dirk Baeumer CLA 2002-06-20 12:16:21 EDT
Yes, it only affects replace. You still get a Java editor when browsing through 
search results.
Comment 6 Dirk Baeumer CLA 2002-06-21 04:47:07 EDT
Reviewed by Daniel Megert
Comment 7 Dirk Baeumer CLA 2002-06-21 06:00:32 EDT
Reviewed by Adam Kiezun
Comment 8 Dirk Baeumer CLA 2002-06-21 06:01:18 EDT
Created attachment 1543 [details]
Final patch
Comment 9 Dirk Baeumer CLA 2002-06-21 06:01:45 EDT
Marked as fixed