|
Re: Migrate Preferences to pure e4 application [message #1239526 is a reply to message #1239097] |
Tue, 04 February 2014 11:28 |
Mateusz Malinowski Messages: 36 Registered: March 2013 Location: Bristol |
Member |
|
|
Hi!
Unfortunately I have never used RCP 3, but in e4 I initialise default preferences in addon, where I call:
@Inject
public PrefsAddon(@Preference(nodePath = "/default/" + Activator.PLUGIN_ID)
IEclipsePreferences preferences) throws BackingStoreException
{
preferences.put(..., ...);
preferences.flush();
}
Then whenever I click "set default" in preference page, or I want to get this preference from my PLUGIN_ID node, which is not set there, the default value is returned. As I said, I'm not entirely sure whether this is what you are looking for, but maybe it will help you somehow.
[Updated on: Thu, 06 February 2014 08:58] Report message to a moderator
|
|
|
|
Re: Migrate Preferences to pure e4 application [message #1240347 is a reply to message #1239827] |
Thu, 06 February 2014 09:15 |
Mateusz Malinowski Messages: 36 Registered: March 2013 Location: Bristol |
Member |
|
|
Divya,
Sorry, I was thinking about Preference Pages. When you restore to default, it will take values from pref1.
I believe, that because when you inject IEclipsePreferences, whenever you want to get value from them, you need to specify default value in case the one that you want to obtain doesn't exist. What you can try to do, is to create your own Preference class as singleton, which will provide functions to get and set values. It that class you can have something like:
public String get(String key)
{
return pref2.get(key, pref1.get(key, ""));
}
You would have to initiate this class at your application's start-up and inject both scopes of preferences.
Other way would be to create this class and put it into you application's context, so you can inject it whenever you want. But that would be possible only for view component of your application.
But these are just my thoughts, so perhaps someone more experienced would provide you a better solution
|
|
|
|
Re: Migrate Preferences to pure e4 application [message #1257439 is a reply to message #1240426] |
Wed, 26 February 2014 12:28 |
|
Hi,
To manage default values of your preferences, you can use an IPreferenceStore or call directly the getXXX methods on IEclipsePreferences with the default value. But your problem is not solved with preference pages... How do you manage and display your pages ?
There are several problems in the preference code in E3 to use it in a pure E4 application :
- The ScopedPreferenceStore is managed by org.eclipse.ui (-> forbidden to use it in pure E4)
- The preferencePage extension point expects an IWorkbenchPreferencePage (also defined in E3) instead of a preferencePage
- E4 do not provide any code to compute a PreferenceManager (used by PreferenceDialog), because no extension is available.
So I separated those three problems in a specific plugin which provides :
- an e4PreferencePages extension point, expecting the same values as old E3 extension point, but the preference page class must extends FieldEditorPreferencePage
- an automatic binding with the ScopedPreferenceStore when the page is created (could be upgraded to other scopes)
- a copy of ScopedPreferenceStore to remove E3 coupling !!
- an E4PreferencesHandler which reads this extension point and display the face preference dialog.
To use it, just depend on it, and create your preference pages with the new extension point. Then add the E4Preference command and handlers in your application.
Of course, preference dialogs should be UI agnostic and this solution is bound to JFace, and it does not use the Dialog concept in the Luna application model (when it will be ready and the bug on fragment will be fixed, this solution will be obsolete). But today, the main migration issues on this problem concern JFace.
You can get this plugin and its test sample on github (I can not put url on this forum !! So search for opcoach and the repository is e4Preferences (opcoach/e4Preferences)
Feel free to post any remark about it...
[Updated on: Wed, 26 February 2014 12:47] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03448 seconds