Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328641 - [actions] Format Element formats (marks dirty) read-only file
Summary: [actions] Format Element formats (marks dirty) read-only file
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Rajesh CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-25 13:40 EDT by Rajesh CLA
Modified: 2011-02-04 08:19 EST (History)
3 users (show)

See Also:
daniel_megert: review+


Attachments
Patch (1.40 KB, patch)
2011-01-20 00:57 EST, Rajesh CLA
daniel_megert: review-
Details | Diff
Patch (1.40 KB, patch)
2011-01-24 01:31 EST, Rajesh CLA
daniel_megert: review-
Details | Diff
Patch (3.26 KB, patch)
2011-01-25 00:41 EST, Rajesh CLA
daniel_megert: review-
Details | Diff
Patch (7.79 KB, patch)
2011-02-03 12:55 EST, Rajesh CLA
daniel_megert: iplog+
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rajesh CLA 2010-10-25 13:40:45 EDT
Current behavior is as follows -
Step 1: Open Read only file in Java editor
Step 2: Select Source > Format Element from the main menu
Step 3: The read-only file is formatted and marked dirty

Expected behavior is as follows -
Step 1: Open Read only file in Java editor
Step 2: Select Source > Format Element from the main menu
Step 3: A dialog appears asking the user if they would like to make the file writable.
Step 4: If user selects 'yes' the file is made writable and selected element formatted else Format Element operation is aborted.

This expected behavior is currently implemented by 'Format' accessed through Source > Format main menu item.
Comment 1 Deepak Azad CLA 2010-10-26 02:16:40 EDT
(In reply to comment #0)
> Current behavior is as follows -
> Step 1: Open Read only file in Java editor
> Step 2: Select Source > Format Element from the main menu
> Step 3: The read-only file is formatted and marked dirty
Before step 2 focus should be in Java Editor.

Plus I see this (funny ?) behavior
- On GTK the action is not enabled for a read only file, focus can be in JE or
Outline view
- On Win XP the action is sometimes enabled sometimes disabled

Steps for Win
- Open a file and focus in JE => Action is enabled
- Make it read only, focus in JE => Action is enabled
- Now try to edit it and save - a dialog comes up asking to make it writable =>
action is disabled now.

Is this expected ?
Comment 2 Dani Megert CLA 2010-10-26 02:20:26 EDT
>Outline view
>- On Win XP the action is sometimes enabled sometimes disabled
"sometimes" is not very specific. Steps?
Comment 3 Deepak Azad CLA 2010-10-26 02:22:49 EDT
(In reply to comment #2)
> >Outline view
> >- On Win XP the action is sometimes enabled sometimes disabled
> "sometimes" is not very specific. Steps?

They are there...
(In reply to comment #1)
> Steps for Win
> - Open a file and focus in JE => Action is enabled
> - Make it read only, focus in JE => Action is enabled
> - Now try to edit it and save - a dialog comes up asking to make it writable =>
> action is disabled now.
Comment 4 Dani Megert CLA 2010-10-26 02:27:11 EDT
> They are there...
Yep. I was confused since you talked about outline and editor (I think in the Outline the action is always enabled except for class files) and you write "the action" but actually, those are two different actions hooked up to the same command by different parts ;-).

The action enable state is not consistent: some actions update their state when the read-only state changes and some stay enabled and do the check each time. We don't plan to invest time to change this.

Important is that we don't change read-only files and that before changing we call validateEdit.
Comment 5 Rajesh CLA 2011-01-20 00:57:49 EST
Created attachment 187166 [details]
Patch
Comment 6 Dani Megert CLA 2011-01-21 03:35:03 EST
Comment on attachment 187166 [details]
Patch

The direction is OK, but the '&' in the dialog title after pressing 'No' is not good.
Comment 7 Rajesh CLA 2011-01-24 01:31:45 EST
Created attachment 187404 [details]
Patch
Comment 8 Dani Megert CLA 2011-01-24 07:13:02 EST
Comment on attachment 187404 [details]
Patch

This is exactly the same patch as before - how can it then fix the problem mentioned in comment 6?
Comment 9 Rajesh CLA 2011-01-25 00:41:08 EST
Created attachment 187495 [details]
Patch

Oops!! Apologies. Didn't realize I had mistakenly named the new patch differently and so managed to upload the old patch again.
Comment 10 Dani Megert CLA 2011-01-25 11:20:07 EST
You already added ActionMessages.FormatElementAction_label for the same thing in the JavaOutlinePage. We should only have 1 message for it (in JavaEditorMessages). Otherwise the patch looks fine.
Comment 11 Rajesh CLA 2011-02-03 12:55:35 EST
Created attachment 188258 [details]
Patch

Removed the duplicate message from ActionMessages.
Comment 12 Dani Megert CLA 2011-02-04 08:19:14 EST
Patch is good!
Committed to HEAD.
Available in builds >= N20110204-2000.