Search code examples
eclipsepreferences

eclipse preferences: setting proxy bypass defaults via plugin


i'm trying to set some values into the Eclipse preferences, especially in the network connections -> Proxy bypass. I want to make some own entries. So how can I put there some values? By the

IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();

or better by

InstanceScope.INSTANCE.getNode(...   ?

How do i access it, to put some values into? Any hints would be welcome.

Thanks a lot guys!


Solution

  • You can find details about ConfigurationScope, InstanceScope and DefaultScope right here, from Vogella.

    What you want to do is create FieldEditors.

    Create preference pages like this:
    public class ProxyPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage

    You will also need a "static" class (preferably interface) to hold the preference keys IProxyPreferenceKeys -> put all your preference variables here.

    When you create the field editors, pass the preference constant to it.

    new ColorFieldEditor(IProxyPreferenceKeys.PROXY, "Proxy color:", parent);
    

    Finally, in your code, when you need the preference setting, just get it like this:

    Activator.getDefault().getPreferenceStore().getString(IProxyPreferenceKeys.PROXY)