Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 189804 - [preferences] Imported formatter preferences do not get automatically recognized
Summary: [preferences] Imported formatter preferences do not get automatically recognized
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.6 M2   Edit
Assignee: Noopur Gupta CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 410940 473156 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-29 20:11 EDT by James Leone CLA
Modified: 2015-08-10 09:56 EDT (History)
5 users (show)

See Also:
daniel_megert: review+


Attachments
preference file for reproducing (21.00 KB, text/plain)
2007-05-29 20:11 EDT, James Leone CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Leone CLA 2007-05-29 20:11:27 EDT
To reproduce:
1. Create a new workspace
2. Import the preference file attached
3. Create a new Java project (without enabling project specific settings)
4. Create a HelloWorld class with method braces on same line as method signature
5. Select all the code and run the code formatter

Expected:
Braces are moved to line below signature since this is what the code formatter is setup to do

Actual:
The custom code formatting is not applied

Work-around:
Open the General Preferences windows and navigate to the code formatter option
Notice that the SJM custom code formatter is selected in the drop down
Select another code formatter then reselect the SJM code formatter
Hit OK on the preferences window
Now the code will format correctly
Comment 1 James Leone CLA 2007-05-29 20:11:55 EDT
Created attachment 69195 [details]
preference file for reproducing
Comment 2 Benno Baumgartner CLA 2007-05-30 04:08:28 EDT
Reproduced in I20070529-0010

Seams to be related to the old version of the profile/profile is not updated
Comment 3 Martin Aeschlimann CLA 2007-05-30 04:47:08 EDT
I think its because the preference file only contains the profiles, but not the actual jdt.core settings. I assume you handcrafted that preference file.
So either leave a way the '/instance/org.eclipse.jdt.ui/formatter_profile=_SJM' key and manually switch the profile or include all jdt.core formatter settings in the profile as well.
Comment 4 Martin Aeschlimann CLA 2007-05-30 05:13:00 EDT
setting to invalid. please reopen if you didn't handcraft that file.
Comment 5 Dani Megert CLA 2013-06-18 11:01:20 EDT
It works fine when exporting and importing all preferences. The problem is, that we have a 'Java Code Style Preferences' category which claims to contain all the Java > Code Style preferences. However, it does not export the formatter settings of the compiler along with it. When importing, we do set all the code style settings, including the formatter ones, but this does not get transferred to the compiler.

Possible workarounds:
- export all (or at least also the compiler) preferences
- export and import the profiles directly via preference page
- open the preference page, switch to another profile and back, click 'OK'
Comment 6 Dani Megert CLA 2013-06-18 11:02:29 EDT
*** Bug 410940 has been marked as a duplicate of this bug. ***
Comment 7 Noopur Gupta CLA 2015-08-07 09:35:09 EDT
*** Bug 473156 has been marked as a duplicate of this bug. ***
Comment 8 Noopur Gupta CLA 2015-08-07 09:40:53 EDT
From bug 473156 comment #11:

> I did some more testing and found that those extra entries are added in Mars
> only if you check "Export all" (which is checked by default) in the Export
> Preferences wizard page. If you check only "Java Code Style Preference" or
> check all preference types manually / using "Select All" button, then those
> entries are missing in the exported file and the bug can be reproduced on
> import.
> 
> The above behavior can be seen in Eclipse 3.8.1 also.
> 
> So looks like the bug is that those entries are not being added to exported
> file on checking only "Java Code Style Preference" or on checking all
> preference types manually / using "Select All" button.
Comment 9 Eclipse Genie CLA 2015-08-10 08:02:25 EDT
New Gerrit change created: https://git.eclipse.org/r/53472
Comment 10 Noopur Gupta CLA 2015-08-10 08:14:04 EDT
(In reply to Eclipse Genie from comment #9)
> New Gerrit change created: https://git.eclipse.org/r/53472

We should export the org.eclipse.jdt.core.formatter entries ("/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter...") also while exporting "Java Code Style Preferences".

Tested that the attached patch works fine when preferences are exported and imported with either all or only "Java Code Style Preferences" checked.

Dani, please have a look.
Comment 12 Dani Megert CLA 2015-08-10 09:56:01 EDT
(In reply to Eclipse Genie from comment #11)
> Gerrit change https://git.eclipse.org/r/53472 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=293f3f755aad8908bfde33a4572731aa16333221
> 

Thanks Noopur!