-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce 'user' preference scope located in <user.home>/.eclipse #446
Conversation
I wonder why that wasn't provided from very beginning. @tjwatson : any clue? Some questions :
|
Just wanted to note that Java already has support for system/user global settings: |
Me too.
Yes, I will add them.
Currently the default implementation for writes is Lines 285 to 293 in 9658936
But one can also provide an As it can be seen in the default implementation it already has some basic considerations of parallel writes, but for example overwrites/ignores changes done to the preferences since the file was read and until it is written by one application. But the Configuration-Scope already faces the concurrency problem and while the instance-scope (aka workspace) is guarded by the workspace lock, theoretically even the project scope could have that problem if a project is at the same time imported into multiple workspaces (which is of course a questionable usage). If a more advanced mechanism that handles concurrent writes more precisely a new set of questions arise, especially:
I'm not saying concurrent changes should be handled in a more precise way, it just will be more complex.
For each preference it the store scope can be chosen individually. Most often it is the INSTANCE (aka workspace) scope, that is, depending on the way/API chosen to manage preferences, is even the default. In your example it might be a solution to have additional means to filter incompatible workspaces.
Yes, but I would say it should be integrated into the known Eclipse preferences mechanism, which is based on the |
The backing store for |
Sorry, I don't have any recollection of a user scope concept for Eclipse preferences. The Eclipse preferences predated OSGi preferences usages in the Eclipse project and then the Eclipse team at the time merged the two into what we have today. IIRC they simply took the existing concepts of what they had and kept them in the new implementation and tried to rebase them as much as they could on the OSGi preferences service. One thing that I find confusing is that OSGi does have a concept of "user" preferences also: https://docs.osgi.org/specification/osgi.cmpn/8.1.0/service.prefs.html#org.osgi.service.prefs.PreferencesService.getUserPreferences-String- But I believe that is in name-only when compared to what is proposed here. |
The spec says this:
So the "user" preferences are still local to the framework or more formally the storage, while this here is more to select where it is stored, I think similar to what Oomph does. |
@merks : FYI. |
Yes, I'm watching. With Oomph's preference tasks recorded in the user.setup, one can copy any preferences to every workspace, thereby achieving a similar effect, when desired. One consideration here when deciding on the user's behalf to make some specific preference user-scoped in some specific framework component, it will no longer be possible to set the preference differently in different workspaces or even differently in different applications that the reuse some underlying framework component that has decided its preferences should be user-scoped... |
Yes, the intention to provide a new scope for the existing Eclipse preferences system. While it is (at least from an interface POV) based on the OSGi preferences I would not like to try to combine both in this change, especially as you mentioned the OSGi preferences don't specify the exact was.
Yes and this is even inspired by the great and handy Oomph user-setup. The main difference is that it obviously works without Oomph and the plugin developer can decide where to store the value and it has not (and cannot be decided by the user). My first use case for this is the 'Windows Defender Auto-fix' development effort of the the Eclipse IDE WG I'm currently working on where I would like to add a
It still can be overridden in narrower scopes if the same qualifier (usually the bundle-id) and key are used. When using the Lines 39 to 42 in 9658936
|
In order to simplify the review of this PR, I have now created #449, that only contains the refactoring done in this first commit. |
Product customization still supported, I assume? Where is it in this order above? Default scope? |
Yes the default Scope looks up in the product customization. But as before, when using the |
I just wanted to say thanks to you @HannesWell for addressing so many things in platform and elsewhere, very impressive |
One very useful thing might be to have a way to move all instance scope to user scope in the preference. I would guess in 80% of the cases I know people would like to use the same settings for all their workspaces and installations. So having a easy way to move everything out of instance scope to the new user scope would IMHO be very nice. Of course having the option to have different settings in different WS is also very important to get compliant and support the other % of use cases. |
That's exact why I have my concerns regarding different (incompatible) application settings for different applications running for same user. There should be no such "thing" by default and if it would be added, it should be possible for applications to disable that "thing". |
Yes @iloveeclipse that for repeating that |
2a1f74b
to
0edec5a
Compare
0edec5a
to
68c2fab
Compare
For those interested there is now a PR
In general I would say that the decision to save a preference in the user-scope should be done with great care. So yes, there is indeed some potential for confusion, some people might not even know that their application is based on Eclipse and yes there could definitely be desire to handle different products groups differently. For example ignore all Eclipse installations (which ever product it is exactly) but consider my custom product. With the current architecture the user-scoped value can be overwritten with a configuration/installation- or instance/workspace-scoped entry, but in the preferences accessible through the UI menu Window -> Preferences (at least by default/usually) only instance/workspace entries are set. To set a configuration/installation-entry the preference page has to be programmed to set that value explicitly, at least that's what I have done in my use-case mentioned above.
With that, but without checking all usages of the configuration/installation-scope exhaustively, I have the impression that the config/installation scope is already used only in specific ways and the user-scope would be used similarly. Alternatively the difference could be made more visible and the different scope levels could be made accessible through the UI explicitly, similar to Oomph which provides a workspace, installation and user scoped setup. |
I do a lot of testing the installer and of Oomph in general. For that purpose (to replicate a new-user experience) I often use
This would potentially allow other applications/products to configure a different location in the product itself. Such a property might be documented here: I'm not sure if there would be a reason/advantage to use |
Are you suggesting to use |
Hopefully everybody had relaxing holidays and a good start into this new year. I would like to complete this PR soon, so are all concerns addressed or do you still have things that should be changed? |
Can I interpret no answers as silent consent? We can later have a discussion if and how this could be generallized to for example give users more control on which level preferences are stored, similar to how one can do it for example in Oomph with the |
Yes, silence is consent. |
Good, then this can be submitted :) An interesting issue in which a generalization might be discussed is eclipse-platform/eclipse.platform#89. |
I just added the requested tests that check if the scope-nodes are written to the expected location. |
@HannesWell can you add this new feature and its usage also to the N&N worthy page? Otherwise it is really hard for users to discover this new feature. I assume most RCP clients would be very happy to start using user scope instead of instance scope preferences. (sorry if it is already added to the N&N, but a quick check did not reveal them in the 4.31 notes for me). https://eclipse.dev/eclipse/news/4.31/ |
This PR introduces a
user
preferences scope API to provide a unified way to store and read per-user-global preferences under<user.home>/.eclipse
.At the moment plugins that want to store settings in a user-global scope need their own implementations to write and read those preferences.
With this PR a new
UserScope
is introduced to store user-preferences in a standard way and the user scope is added to thePreferencesService.DEFAULT_DEFAULT_LOOKUP_ORDER
in order to read from the user location if the instance or configuration scopes don't provide any value for a key out of the box.In the first of the two commits in this PR the existing
ConfigurationPreferences
andInstancePreferences
have their common code moved into a new super-classSingletonEclipsePreferences
, that is then also used by the newUserPreferences
.