Bug 511580 - Unable to customize initial DialogSettings
Summary: Unable to customize initial DialogSettings
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.8 M4   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-02 10:16 EST by Andrey Loskutov CLA
Modified: 2021-06-28 10:00 EDT (History)
3 users (show)

See Also:


Attachments
preference customization help update (401.10 KB, image/png)
2017-11-20 03:03 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2017-02-02 10:16:44 EST
For our lab with workspaces containing few hundreds projects we want per default enable working sets mode in package explorer. Unfortunately default value is "projects as root" so all our developers need manually change settings every time they create a workspace. 

We tried to automate it but faced the issue that we can't customize package explorer initial appearance because it uses dialog_settings.xml to read and persist the state, and NOT the preference store. So I cannot provide default settings to it neither using "preferenceCustomization" extension for products nor "-pluginCustomization" for command line arguments, nor Oomph (see discussion at https://www.eclipse.org/forums/index.php/t/1083926/). 

This is not nice, but I have a patch :-)
Comment 1 Eclipse Genie CLA 2017-02-02 10:21:00 EST
New Gerrit change created: https://git.eclipse.org/r/90192
Comment 2 Andrey Loskutov CLA 2017-02-02 10:23:23 EST
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/90192

To test, eclipse need to be started with the program argument pointing to the file below:

-pluginCustomization path/to/plugin_customization.ini

##################
# plugin_customization.ini
##################
org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.rootMode=2
org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.layout=2
org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.group_libraries=true
org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.linkWithEditor=true
##################

As a visible result, package explorer will show "other projects" node and "link with editor" will be enabled.
Comment 3 Andrey Loskutov CLA 2017-02-09 08:07:06 EST
Noopur, do you have time for a review?
Comment 4 Andrey Loskutov CLA 2017-11-12 07:33:35 EST
Quote from Dani's reply on Gerrit:

> I agree that we currently lack the feature to provide defaults for new workspaces, 
> but that applies to every dialog setting.

> Instead of making a point fix we need to find a way that dialog settings can be initialized. 
> One way could be to allow adding them to the pluginCustomization.ini with a new format, 
> e.g. by using a @ prefix for dialog settings:
> @org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.rootMode=1
> Or we introduce a new file, e.g. pluginSettingsCustomization.ini.
> Or we allow to provide a pluginsSettings folder that holds the info (similar to what is in .plugins).
> Or...
> On a quick look org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings() might be 
> a good location to read the initial state, but I didn't investigate deeply.

I will check now possible options.
Comment 5 Andrey Loskutov CLA 2017-11-12 12:22:59 EST
(In reply to Andrey Loskutov from comment #4)
> Quote from Dani's reply on Gerrit:

I've checked now possible options, see comments below.

The main issue with dialog settings (org.eclipse.jface.dialogs.DialogSettings) is that they are using xml format, and that this has always plugin specific structure, so one can't translate to/from this format without knowledge of the specific plugin preferences structure.

> > One way could be to allow adding them to the pluginCustomization.ini with a new format, 
> > e.g. by using a @ prefix for dialog settings:
> > @org.eclipse.jdt.ui/org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.rootMode=1

The contra arguments:
 - new format specification
 - extra code to translate this format into xml format of dialog settings
 - this must be done in every plugin (!)
 - extra effort for users to convert existing dialog_settings.xml into new format

> > Or we introduce a new file, e.g. pluginSettingsCustomization.ini.

In the form of an *.ini file same issues as with the point above.

In the form of an *.xml file:

The contra arguments:
 - similar to the DefaultPreferences.initializeCustomizations() it should support command line and product customization, this is a lot more effort as it could be.
 - one file to merge other xml files could be error prone, especially if they all start with same "Workbench" root element, so easy to break.
 - assuming there are more then one file merged, it requires to read all the data every time dialog settings for a single plugin are requested.

The pro arguments:
 - one file is easier to supply for deployment.

> > Or we allow to provide a pluginsSettings folder that holds the info (similar to what is in .plugins).

This is more appealing, because then one could just copy/paste some of the .plugins/*/dialog_settings.xml files to the "customization"  area.

> > Or...
> > On a quick look org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings() might be 
> > a good location to read the initial state, but I didn't investigate deeply.

Yes, this will probably be the place for the patch.

> I will check now possible options.

With the options discussed above I believe I will work in this direction:

1) Define a new *preference* key for org.eclipse.ui.workbench to define the root folder path with *initial* dialog_settings.xml files for bundles. To customize a bundle "ABC" dialog settings, this folder should contain ABC/dialog_settings.xml file in the well known format. By default the preference is not set.

2) The preference above can be specified via existing product customization.

3) If the bundle requests AbstractUIPlugin.loadDialogSettings(), the default dialog settings file for the bundle does not exist yet and the preference is specified, bundle will get a DialogSettings instance loaded from the path based on specified preference.

4) Once the dialog settings for a bundle ABC *saved* by Eclipse to the default location (.metadata/.plugins/ABC/dialog_settings.xml), the custom values are not read and not applied anymore.
Comment 6 Eclipse Genie CLA 2017-11-12 17:51:35 EST
New Gerrit change created: https://git.eclipse.org/r/111434
Comment 7 Eclipse Genie CLA 2017-11-12 17:51:36 EST
New Gerrit change created: https://git.eclipse.org/r/111433
Comment 9 Mickael Istria CLA 2017-11-15 09:34:26 EST
This is a great proposal! Thanks Andrey! Lack of customization of dialog settings is probably one reason why so many "hidden gems" are not shown in downstream RCP (including EPP). Your proposal is a good way to enable those without changing Platform's code.

I've got a question about the taken approach (a folder containing the dialog settings): how is it likely to work with .project build compared to pluginCustomization.ini? With your proposal, can it be as easy to include dialog settings than it is to include preferences in a custom product?
Comment 10 Andrey Loskutov CLA 2017-11-15 10:40:21 EST
(In reply to Mickael Istria from comment #9)
> I've got a question about the taken approach (a folder containing the dialog
> settings): how is it likely to work with .project build compared to
> pluginCustomization.ini? With your proposal, can it be as easy to include
> dialog settings than it is to include preferences in a custom product?

I don't get the point about .project build. What is it?

The problem I'm trying to solve is that customization via pluginCustomization.ini does not affect DialogSettings yet, and the support for those can be added by providing two things:

1) plugin_customization.ini  with an entry: org.eclipse.ui/default_dialog_settings_rootUrl=http://my.server/project/templates/dialog_settings_root
or 
org.eclipse.ui/default_dialog_settings_rootUrl=/etc/mycompany/project/templates/dialog_settings_root
or
org.eclipse.ui/default_dialog_settings_rootUrl=platform:/mycompany.bundle/dialog_settings_root

2) dialog_settings_root in the location specified above with similar structure:
dialog_settings_root/
-- mycompany.bundle/dialog_settings.xml
-- org.eclipse.jdt.ui/dialog_settings.xml
-- whatever_else/dialog_settings.xml

What is not *yet* implemented is the support of bundle / installation relative urls, like platform:/mycompany.bundle/dialog_settings_root, and I have no tests yet.

So for the product, the product owner provider would need to provide a bundle contained dedicated directory with all the customized dialog settings and specify this location in the plugin_customization.ini.
Comment 11 Mickael Istria CLA 2017-11-15 11:09:06 EST
(In reply to Andrey Loskutov from comment #10)
> I don't get the point about .project build. What is it?

Sorry, I meant *.product build.

> the support  for those can be added by providing two things:
> [...]
> org.eclipse.ui/default_dialog_settings_rootUrl=platform:/mycompany.bundle/
> dialog_settings_root
> [...]
> What is not *yet* implemented is the support of bundle / installation
> relative urls, like platform:/mycompany.bundle/dialog_settings_root, and I
> have no tests yet.
> So for the product, the product owner provider would need to provide a
> bundle contained dedicated directory with all the customized dialog settings
> and specify this location in the plugin_customization.ini.

Ok, that sounds to cover my concerns perfectly. Thanks!
Comment 13 Eclipse Genie CLA 2017-11-19 15:07:18 EST
New Gerrit change created: https://git.eclipse.org/r/111867
Comment 14 Eclipse Genie CLA 2017-11-20 02:55:29 EST
New Gerrit change created: https://git.eclipse.org/r/111875
Comment 15 Andrey Loskutov CLA 2017-11-20 03:03:13 EST
Created attachment 271553 [details]
preference customization help update

(In reply to Eclipse Genie from comment #14)
> New Gerrit change created: https://git.eclipse.org/r/111875

Updated help for product customization, see attachment how it looks like now.
Comment 18 Andrey Loskutov CLA 2017-11-22 09:51:48 EST
Should be done now.