This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 409996 - 'Restore Defaults' does not work properly on Project Properties > Resource tab
Summary: 'Restore Defaults' does not work properly on Project Properties > Resource tab
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M1   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-05 14:30 EDT by Nobody - feel free to take it CLA
Modified: 2014-06-04 09:13 EDT (History)
2 users (show)

See Also:


Attachments
Patch (1.10 KB, patch)
2013-06-24 05:09 EDT, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Resources patch (4.02 KB, patch)
2013-06-25 12:25 EDT, Nobody - feel free to take it CLA
no flags Details | Diff
UI patch (2.39 KB, patch)
2013-06-25 12:26 EDT, Nobody - feel free to take it CLA
daniel_megert: review-
Details | Diff
Resources patch (5.83 KB, patch)
2013-06-26 17:54 EDT, Nobody - feel free to take it CLA
no flags Details | Diff
UI patch (3.70 KB, patch)
2013-06-26 17:55 EDT, Nobody - feel free to take it CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nobody - feel free to take it CLA 2013-06-05 14:30:42 EDT
The option 'Store the encoding of derived resources separately' only restores to whatever the last saved state was. It should restore to false, since that is the default. The relevant code is ResourceEncodingFieldEditor.doLoadDefault(), which should look like this:

protected void doLoadDefault() {
	super.doLoadDefault();
	if (separateDerivedEncodingsButton != null)
		separateDerivedEncodingsButton.setSelection(false);
}
Comment 1 Dani Megert CLA 2013-06-06 04:29:16 EDT
Can reproduce using 4.3 RC3.
Comment 2 Szymon Ptaszkiewicz CLA 2013-06-24 05:09:41 EDT
Created attachment 232692 [details]
Patch
Comment 3 Szymon Ptaszkiewicz CLA 2013-06-24 05:10:53 EDT
Dani, can you please push this?
Comment 4 Dani Megert CLA 2013-06-25 10:16:58 EDT
(In reply to comment #3)
> Dani, can you please push this?

Ideally, Platform Resources would provide a constant for the default which could then be used in the UI. If we decide to change the default in the future, we currently have to update several places in Core and UI.

If you think it's too much work, then we can go ahead with the suggested change, but to be correct, Tom should attach a patch (with copyright addition), since he suggested the fix.
Comment 5 Dani Megert CLA 2013-06-25 10:17:12 EDT
.
Comment 6 Szymon Ptaszkiewicz CLA 2013-06-25 10:45:12 EDT
(In reply to comment #4)
> Ideally, Platform Resources would provide a constant for the default which
> could then be used in the UI. If we decide to change the default in the
> future, we currently have to update several places in Core and UI.

It makes sense, although I think there are also many other places where defaults are hard-coded in UI instead of being exposed as API from core plugins. See for example performDefaults methods for ResourceInfoPage or JavaCompilerPropertyPage. Do you think we should fix all of them?
Comment 7 Dani Megert CLA 2013-06-25 10:49:15 EDT
(In reply to comment #6)
> (In reply to comment #4)
> > Ideally, Platform Resources would provide a constant for the default which
> > could then be used in the UI. If we decide to change the default in the
> > future, we currently have to update several places in Core and UI.
> 
> It makes sense, although I think there are also many other places where
> defaults are hard-coded in UI instead of being exposed as API from core
> plugins. See for example performDefaults methods for ResourceInfoPage or
> JavaCompilerPropertyPage. Do you think we should fix all of them?

I would fix as we go i.e. if a problem arises in such an area, fix it, but don't spend time too touch something that works fine.
Comment 8 Nobody - feel free to take it CLA 2013-06-25 11:00:15 EDT
I'm working on a patch, including the suggested constant.
Comment 9 Nobody - feel free to take it CLA 2013-06-25 12:25:46 EDT
Created attachment 232744 [details]
Resources patch
Comment 10 Nobody - feel free to take it CLA 2013-06-25 12:26:15 EDT
Created attachment 232745 [details]
UI patch
Comment 11 Dani Megert CLA 2013-06-26 08:50:48 EDT
(In reply to comment #9)
> Created attachment 232744 [details] [diff]
> Resources patch

Thanks for the patch Tom. Unfortunately, the patch does not apply via IDE:  EGit does not (always) like git am patches, see bug 368358. After manually cutting away the non-patch related stuff, I got a conflict in the copyright date because the patch was probably not made against R4.3, but some older branch.

The fix looks good in general but it needs some minor polish:
- make the patch against 'master'
- since it adds new API to Luna, the bundle version needs to be increased to 3.9
  ==> pom.xml and MANIFEST.MF need to be updated
  ==> the new constant gets 3.9
- the copyright date is wrong: it has to be yearOfFirstChange,  yearOfThisChange


You need to confirm that you wrote the code. I suggest you do this using the "new way" i.e. sign the CLA and write in this bug report that you contribute the patches under that CLA. For more details see:
http://mmilinkov.wordpress.com/2013/06/17/eclipse-clas-are-live/

Alternatively, you can answer the 3 questions.
Comment 12 Dani Megert CLA 2013-06-26 09:00:19 EDT
Comment on attachment 232745 [details]
UI patch

(In reply to comment #10)
> Created attachment 232745 [details] [diff]
> UI patch

Thanks for the patch Tom. The fix is not complete as there are other places in that class that assume the default being 'false'.

Test Case:
1. set the default (constant) to 'true'
2. start a target workspace
3. create a project
4. open its properties
   ==> good: option is checked
5. disable the option and click 'OK'
6. open its properties
   ==> bug: option is still checked
Comment 13 Nobody - feel free to take it CLA 2013-06-26 17:54:58 EDT
Created attachment 232811 [details]
Resources patch
Comment 14 Nobody - feel free to take it CLA 2013-06-26 17:55:25 EDT
Created attachment 232812 [details]
UI patch
Comment 15 Nobody - feel free to take it CLA 2013-06-26 17:57:28 EDT
I signed the CLA. I'm not familiar with pom's, so hopefully my guess for the fix is correct.
Comment 16 Dani Megert CLA 2013-06-27 10:01:24 EDT
(In reply to comment #15)
> I signed the CLA. I'm not familiar with pom's, so hopefully my guess for the
> fix is correct.

Looks all good!

Pushed with
http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=7482f74653c7df762431dab80ad7bb6adbcd1984

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=59911823d58de77541ca51edf6b03ee3d1be86a0
Comment 17 Dani Megert CLA 2013-06-27 10:54:41 EDT
There was one scenario that was still broken:

1. set the default (constant) to 'true'
2. start a target workspace
3. create a project
4. open its properties
   ==> good: option is checked
5. create a derived file with custom encoding
   ==> good: stored in special pref file
6. disable the option and click 'OK'
   ==> good: encoding moved to "normal" pref file
7. enable the option and click 'OK'
   ==> bug: encoding not moved to special pref file


Fixed with http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=33aeb3fd6360a63c8fb96d20a071435fb1d0dbbb
Comment 18 Wojciech Sudol CLA 2014-06-04 09:13:06 EDT
Verified in I20140528-2000.