Eclipse RCP - how to retrieve preferences stored by RadioGroupFieldEditor programmatically from PreferenceStore?

StackOverflow https://stackoverflow.com/questions/11205872

Pregunta

I have a preferences page, where some radio buttons are controlled by a RadioGroupFieldEditor.

setPreferenceStore(Activator.getDefault().getPreferenceStore());
....

addField(new RadioGroupFieldEditor("CHOICE",
    "An example of a multiple-choice preference", 1,
    new String[][] { { "&Choice 1", "choice1" },
            { "C&hoice 2", "choice2" } }, getFieldEditorParent()));

Question:
How can I retrieve the data (stored by the fieldEditor) from the PreferenceStore programmatically? How does the storage structure look like?

¿Fue útil?

Solución

The RadioGroupFieldEditor is going to store a single string for you. It will be the string associated with the radio button in the group that was selected, and it will be keyed off of the name you gave to the group itself.

In other words, given your example, calling:

Activator.getDefault().getPreferenceStore().getString("CHOICE");

...will return either "choice1" or "choice2", depending on which radio button was selected on your preference page when the preferences were saved.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top