简体   繁体   English

Eclipse RCP - 如何以编程方式从PreferenceStore检索RadioGroupFieldEditor存储的首选项?

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

I have a preferences page, where some radio buttons are controlled by a RadioGroupFieldEditor . 我有一个首选项页面,其中一些单选按钮由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? 如何以编程方式从PreferenceStore检索数据(由fieldEditor存储)? How does the storage structure look like? 存储结构如何?

The RadioGroupFieldEditor is going to store a single string for you. RadioGroupFieldEditor将为您存储单个字符串。 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. ...将返回“choice1”或“choice2”,具体取决于保存首选项时首选项页面上选择的单选按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM