Hubris
Hubris

Reputation: 2022

'Restore Defaults' Preference Page Functionality in Eclipse

Is there a programmatic method of achieving the same results as clicking 'Restore Defaults' in an Eclipse preference page?

I already know how the field editor system works and preference storage works.

Thanks! :)

Upvotes: 2

Views: 1104

Answers (1)

VonC
VonC

Reputation: 1323145

The method setToDefault() of IPreferenceStore seems to be a good candidate.

You can see the EditorsUI using this function:

public static void useQuickDiffPreferencePage(IPreferenceStore store) {
  MarkerAnnotationPreferences.useQuickDiffPreferencePage(store);
  store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
  store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE);
  store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
}

Or in the method resetToDefaultSettings() of class HeapWalkingManager:

/**
 * Resets the preferences controlled by this manager to their default settings
 */
public void resetToDefaultSettings(){
  JDIDebugPlugin.getDefault().getPluginPreferences().setToDefault(JDIDebugPlugin.PREF_SHOW_REFERENCES_IN_VAR_VIEW);
  JDIDebugPlugin.getDefault().getPluginPreferences().setToDefault(JDIDebugPlugin.PREF_ALL_REFERENCES_MAX_COUNT);
  JDIDebugPlugin.getDefault().getPluginPreferences().setToDefault(JDIDebugPlugin.PREF_ALL_INSTANCES_MAX_COUNT);
}

Upvotes: 3

Related Questions