Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Storing preferences programmatically
Storing preferences programmatically [message #63316] Thu, 05 June 2003 07:53 Go to next message
Eclipse UserFriend
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 #63725 is a reply to message #63316] Thu, 05 June 2003 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves.no_spam.inf.ufsc.br

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 #68919 is a reply to message #63725] Tue, 10 June 2003 08:24 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Question about code assit shortcut.
Next Topic:Cannot Debug
Goto Forum:
  


Current Time: Sat Apr 27 01:40:03 GMT 2024

Powered by FUDForum. Page generated in 0.03443 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top