Bug 20114

Summary: Quickfix modifies Read-Only files
Product: [Eclipse Project] JDT Reporter: Eric Lamontagne <DogbertTheRuler>
Component: UIAssignee: Dirk Baeumer <dirk_baeumer>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P1    
Version: 2.0   
Target Milestone: 2.0 F4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Patch that fixes the problem none

Description Eric Lamontagne CLA 2002-06-12 23:16:02 EDT
Using quickfix to add a method to a Read-Only class file should not be 
possible (Or it would be great to ask for Team VCM to checkout the file).
Comment 1 Dirk Baeumer CLA 2002-06-13 04:48:22 EDT
This only happens when clicking on the light bulp. Ctrl+1 is diabled for read 
only files. We should disable clicking on the light bulp in this case as well.

Low risk to fix.

Candidate for F4
Comment 2 Erich Gamma CLA 2002-06-13 07:54:16 EDT
increased priority
Comment 3 Erich Gamma CLA 2002-06-15 04:45:03 EDT
consequences if not fixed: a modified read-only file cannot be saved and is a 
serious problem. Fix is simple.
Comment 4 Dirk Baeumer CLA 2002-06-17 05:38:22 EDT
Enclosed the patch that fixes the problem

Index: JavaSelectMarkerRulerAction.java
===================================================================
RCS 
file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor
/JavaSelectMarkerRulerAction.java,v
retrieving revision 1.1
diff -u -r1.1 JavaSelectMarkerRulerAction.java
--- JavaSelectMarkerRulerAction.java	1 Jun 2002 09:58:56 -0000	1.1
+++ JavaSelectMarkerRulerAction.java	17 Jun 2002 09:37:34 -0000
@@ -24,6 +24,7 @@
 
 import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
 import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
 import org.eclipse.ui.texteditor.MarkerUtilities;
 import org.eclipse.ui.texteditor.SelectMarkerRulerAction;
 
@@ -66,6 +67,13 @@
 	}
 	
 	public void update() {
+		// Begin Fix for http://dev.eclipse.org/bugs/show_bug.cgi?
id=20114
+		if (fMyTextEditor instanceof ITextEditorExtension && 
((ITextEditorExtension)fMyTextEditor).isEditorInputReadOnly()) {
+			fPosition= null;
+			super.update();
+			return;
+		}
+		// End Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20114
 		fPosition= getProblemPosition();
 		if (fPosition != null)
 			setEnabled(true);
Comment 5 Dirk Baeumer CLA 2002-06-17 08:49:34 EDT
Created attachment 1446 [details]
Patch that fixes the problem
Comment 6 Kevin McGuire CLA 2002-06-17 11:42:29 EDT
Shouldn't it call validateEdit() and rely on that, instead of just not doing 
anything for read-only?  This way a quick fix to a Clearcase controlled file 
(not checked out, read-only) will do the right thing.

That is, it should be behaviourly equivalent to typing the quick-fix inserted 
text at the keyboard.
Comment 7 Kai-Uwe Maetzel CLA 2002-06-17 11:53:07 EDT
For 2.0, all text modification actions are disabled on read-only files. Post 
2.0, we need to ensure that validateEdit is called. This requires a broader 
architectural approach than the one we've taken so far.
Comment 8 Dirk Baeumer CLA 2002-06-18 03:42:21 EDT
First review by Daniel Megert
Comment 9 Dirk Baeumer CLA 2002-06-18 05:37:52 EDT
Final fix is 

		// Begin Fix for http://dev.eclipse.org/bugs/show_bug.cgi?
id=20114
		if (!(fMyTextEditor instanceof ITextEditorExtension) || 
((ITextEditorExtension)fMyTextEditor).isEditorInputReadOnly()) {
			fPosition= null;
			super.update();
			return;
		}
		// End Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20114

Second review by Martin Aeschliemann
Comment 10 Dirk Baeumer CLA 2002-06-18 06:51:33 EDT
Third review by Adam Kiezun since code got changed in second review.