Storing preferences programmatically [message #63316] |
Thu, 05 June 2003 07:53 |
Eclipse User |
|
|
|
Originally posted by: ute.buehler.sap.com
Hi,
I have to add some file extensions to the ignored resources in the team
view of the preferences programmatically when a file of a special
extension is created. Before creating this file I check whether the
current preferences contain this extension otherwise I will add them in
the following way:
// get the files to be ignored
Plugin plugin = Platform.getPlugin("org.eclipse.team.core");
Preferences pref = plugin.getPluginPreferences();
String sPref = plugin.getPluginPreferences().getString("ignore_files");
// create the new sPref, containing an additional file extension
...
// set the changed value
pref.setValue("ignore_files", sPref);
But now I have the problem that these new preferences are not stored
before restarting the workspace. Is there any possibility to store the
preferences directly?
Kind regards
Ute Buehler
|
|
|
|
Re: Storing preferences programmatically [message #68919 is a reply to message #63725] |
Tue, 10 June 2003 08:24 |
Eclipse User |
|
|
|
Originally posted by: ute.buehler.sap.com
Thank you for your help. After plugin.savePluginPreferences() the file
pref_store.ini is updated (date and content), but when choosing window ->
preferences I can't see the changes. After restarting the workspace, I can
see them. Maybe this works as designed.
Regards, Ute
Rafael Chaves wrote:
> Ute,
> You can save a preferences store at any time by calling
> plugin.savePluginPreferences().
> Is that what you are looking for?
> Rafael
|
|
|
Re: Storing preferences programmatically [message #69173 is a reply to message #68919] |
Tue, 10 June 2003 12:49 |
Eclipse User |
|
|
|
Originally posted by: Rafael_Chaves.ca.ibm.com
Preference stores are public - but their use by other plug-ins should be
restricted to cases where it is expected by the plug-in implementation.
Ideally, clients should rely on other plug-in's preferences only if the
property id is available in the plug-in API (and in your case, it is:
org.eclipse.team.core.PREF_TEAM_IGNORES, although there is no description
of its use). In those cases, plug-ins should be prepared to update their
internal state in response to changes in their own preference stores made
by other plug-ins (which seems that is not happening in this particular
case). So, I would say that except when a property key is available and
properly advertised in a plug-in's API, you should avoid accessing
(changing is more problematic) directly other plug-ins preference stores.
So, that being said, I believe that there is API for doing what you want:
package org.eclipse.team.core;
...
public final class Team {
...
public static boolean isIgnoredHint(IResource resource) {...}
public static void setAllIgnores(String[] patterns, boolean[]
enabled) {...}
public synchronized static IIgnoreInfo[] getAllIgnores() {...}
...
}
The spec for setAllIgnores says that it adds patterns to the list of
global ignores, but actually it seems that it replaces the existing user
configuration (there are also ignored entries contributed by other
plug-ins). If that is true, you may have to retrieve all, add yours, and
set it back.
HTH,
Rafael
|
|
|
Powered by
FUDForum. Page generated in 0.04477 seconds