capint
1/6/2017 - 4:41 PM

Eclipse >> Preference >> Initialize and access

Eclipse >> Preference >> Initialize and access

//*** By default, if a Preference Page inherits FieldEditorPreferencePage, no need to override the performOk method (which does a fieldEditor.store for all field editors)
//*** In case of customization of controls in a preference page, we need:
@Override
protected Control createContents(Composite parent) {
  //Create custo controls
}

@Override
protected void performApply() {
  preferenceStore.setValue(name, value);
  preferenceStore.save();
}

@Override
protected void performDefaults() {
  custoControls.performDefaults();
}
preferenceStore.getString(NAME);
preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_ID);
preferenceStore.setDefault(NAME, OBJECT);

public class RequirementsPreferencePage extends AbstractDefaultPreferencePage {

  public RequirementsPreferencePage() {
    setPreferenceStore(preferenceStore);
  }

  @Override
  protected IPreferenceStore doGetPreferenceStore() {
    return preferenceStore;
  }
}