I have made one preference page whose programming is:
public class SAML
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public SAML(
You need two parts:
To set the default, you use the following code in the Activator
:
public class Activator extends AbstractUIPlugin {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
IPreferenceStore ps = getPreferenceStore();
ps.setDefault(SHOW_IMAGE, true);
}
public static final String SHOW_IMAGE = "showImage";
}
Alternatively, you can use the org.eclipse.core.runtime.preferences
extension point...
Note that the code above assume that the type of the preference is Boolean
- there are other methods for numbers, strings, etc... A file name is a string.
To use the current value, just use
if (Activator.getDefault().getPreferenceStore().getBoolean(Activator.SHOW_IMAGE)) {
…
}
The following slides contains a little more information...