views:

241

answers:

1

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! :)

+2  A: 

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);
}
VonC
Ah, I must of just missed that, the usual set default doesn't work. You're a life saver! Thx!!
Hubris
+1 for you (partly because of your plug-in spy comment to my answer, that feature rules)
Rich Seller