views:

1038

answers:

3

I have a multiple user/location RCP application that currently utilizes several user configurable options. Some preferences are for specific to the station, some are specific to the user.

The options are from a preference store which saves the *.prefs files to "workspace.metadata.plugins\org.eclipse.core.runtime.settings".

This would be fine if we were only using a single machine/user. But if a user were to go to another station, then the user would be using whatever preferences were setup for that station.

Is it possible to specify another form for persistence (not files)?

+2  A: 

According the the eclipse wiki, the preferences are file-based, and stored:

  • for each installation (but this may vary for multi-user installations), in files stored in <eclipse_home>/eclipse/configuration/.settings/.
    There is typically one file per plugin, with a .prefs extension.
    Note that very few plug-ins use installation-wide preferences.
  • for each workspace, in files stored in <workspace>/.metadata/.plugin/org.eclipse.core.runtime/.settings.
    There is typically one file per plugin, with a .prefs extension.
  • for each project --for project-level settings -- in files stored in a .settings sub-directory of your project folder

So if the file option is here to stay, you may need to:

  • either export/reimport the session settings manually in a user-specific directory (tedious)
  • or make some kind of automated mechanism:
    • to export the settings to the user's registry (HKEY_CURRENT_USER/Software/MyRCP/...) at the exit of the application, and
    • to import them by reading those registry keys and overriding the .prefs files in the local workspace.metadata.plugins\org.eclipse.core.runtime.settings directory
  • or share those settings through some kind of user-specific link (a wrapper around the startup of the RCP would be in charge of making the right link, even on Windows with junctions for instance)
VonC
+1  A: 

You should read about multi-user installs

In our case we have separated the per-user preferences from the application configuration by setting the config.ini to include the following:

[email protected]/Application Data/earthrise

[email protected]/Local Settings/Application Data/earthrise/144/configuration

osgi.sharedConfiguration.area=c:/program files/earthrise/configuration

osgi.configuration.cascaded=true

The result of this is that any preferences set by the user are stored in their roaming profile, but application specific configuration data is stored in the Local Settings.

This doesn't solve the problem of having user preferences specific to a particular workstation, but does allow to have each user to have their own preferences.

A catch with this is that the eclipse error log file will be stored in the instance area and get carried around in their roaming profile - not really what you want. You can code around this in the plug-in. See the workaround at eclipse bugzilla - search for 256502

Dale
Not sure that this addresses the original question about saving elsewhere than local files, but it addressed my question with exactly the right reference and a helpful example. Thanks!
Andy Thomas-Cramer
+1  A: 

It sounds like you need to store your preferences at a central location that all users/machines can reach. This means you have to implement your own IPersistentPreferencesStore. Then you can override org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore() to use it.

The bigger question is how to implement that central preferences store, but that depends on the technologies you are using. In general, if your project uses a central server, you probably should store your preferences there. For example, if your project already uses a relational database, one solution would be to create appropriate database tables and implement IPersistentPreferencesStore to access those tables via JDBC.

FelixM