Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 48966

Summary: [preferences] Should be able to export from 'Formatter' preference page
Product: [Eclipse Project] JDT Reporter: Dani Megert <daniel_megert>
Component: UIAssignee: Raksha Vasisht <raksha.vasisht>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: martinae
Version: 3.0   
Target Milestone: 3.6 M1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch with the fix.
daniel_megert: review-
Improved patch
daniel_megert: review-
Patch with changes daniel_megert: review+

Description Dani Megert CLA 2003-12-17 05:00:27 EST
I200312162000

I am used that I can press Export and Import on the preference dialog and get
the formatter prefs as well. We now introduced another page where the user has
to do this manually.

This might change with the new settings story.

In addition, I cannot export my formatter prefs at once: I have to export every
single profile manually.
Comment 1 Dirk Baeumer CLA 2003-12-21 11:29:11 EST
Agree that exporting/importing should consider the formatter as well. However 
having different profiles that can be managed separatly allows easy sharing of 
formatter settings. 

Comment 2 Dirk Baeumer CLA 2004-05-21 12:11:22 EDT
Nothing we can do here for 3.0 since core's preference story got postponed > 
3.0 and introducing out own implementation doesn't make to much sense.
Comment 3 Dani Megert CLA 2009-06-10 07:17:28 EDT
The page should have an Export... button.
Comment 4 Dani Megert CLA 2009-06-10 07:21:56 EDT
See also bug 279415.
Comment 5 Dani Megert CLA 2009-06-10 07:24:56 EDT
The Export... button on the 'Formatter' preference page would export ALL current profiles while the Export... button in the Edit dialog only exports the current one.
Comment 6 Dani Megert CLA 2009-06-24 06:32:42 EDT
Same applies to 'Clean Up' page.
Comment 7 Raksha Vasisht CLA 2009-07-06 09:26:06 EDT
Created attachment 140866 [details]
Patch with the fix.

Added a new Export All... button to the formatter page which exports all the current profiles to a new file. Also modified the Import... code to import multiple profiles at once.
Comment 8 Dani Megert CLA 2009-07-09 04:16:52 EDT
First time try of the patch causes a NPE and hence which is really bad. Please always try/test all the (new) options/buttons before you attach a patch.

Why do you use the term 'save' in the code for the export functionality? Either it is 'save' or it is 'export' but mixing it is not good.

I quickly glanced over the existing 'Export' buttons and all of them have 'x' as their mnemonic. What is the reason for changing this in your button?
Comment 9 Raksha Vasisht CLA 2009-07-10 09:41:44 EDT
Created attachment 141296 [details]
Improved patch
Comment 10 Raksha Vasisht CLA 2009-07-10 09:46:34 EDT
(In reply to comment #8)
> First time try of the patch causes a NPE and hence which is really bad. Please
> always try/test all the (new) options/buttons before you attach a patch.

It was NPE coming from file creation. I fixed that. 

> Why do you use the term 'save' in the code for the export functionality? Either
> it is 'save' or it is 'export' but mixing it is not good.

I saw that all of the existing import related terms named 'load' and export related terms named 'save', in methods and NLS strings. So i named Export All as 'saveAll' in all cases to maintain consistency.

> I quickly glanced over the existing 'Export' buttons and all of them have 'x'
> as their mnemonic. What is the reason for changing this in your button?
> 

Oh i overlooked that point. I have changed it back to 'x'. Thanks!
Comment 11 Dani Megert CLA 2009-07-16 04:12:07 EDT
> Either it is 'save' or it is 'export' but mixing it is not good.
It's still mixed which is bad in this case. Maybe I wasn't clear enough about this. Often there are several patterns that could be followed and it's sort of a gut feeling which one to follow. In this case when adding a button that does 'X' then all corresponding code must be named that way. The mismatch in the current code is most likely for historical reasons where it was decided to relabel the button from "Save" to "Export" but wanted to keep the code changes minimal.

You are reusing a string from the export profile functionality/dialog. This is not a good idea. Please use a new key for the overwrite message.

In addition, it is more readable if you group all the strings and constants for the new functionality together instead of spreading them all over the file:
CodingStyleConfigurationBlock_save_profile_* belongs to one functionality/dialog with its messages and CodingStyleConfigurationBlock_save_profiles_* is another. They should be kept in separate blocks.

>Oh i overlooked that point. I have changed it back to 'x'. Thanks!
OK, but my initial question was *why* you used 'e' in the first place ;-)
Comment 12 Raksha Vasisht CLA 2009-07-23 05:46:32 EDT
Created attachment 142359 [details]
Patch with changes

Changed all "save" to "export" for Export All... and grouped them together.
Comment 13 Dani Megert CLA 2009-07-31 06:05:58 EDT
Patch is good. I only removed the following code:
    dialog.setFileName("formatterprofiles"); //$NON-NLS-1$
because that code is also used to export clean up profiles and formatterprofiles" is not good there. This could be improved by getting the initial name from the subclasses.

Fixed in HEAD.
Available in builds >= N20090731-2000.
Comment 14 Dani Megert CLA 2009-08-04 03:38:43 EDT
>Verified for 3.6 M1 using I20090803-1800 on Linux-GTK.