简体   繁体   English

JFace和FieldEditor

[英]JFace and FieldEditor

From Eclipse RCP, I'm building a preference page using Field Editors ( http://www.eclipse.org/articles/Article-Field-Editors/field_editors.html ) 在Eclipse RCP中,我正在使用字段编辑器( http://www.eclipse.org/articles/Article-Field-Editors/field_editors.html )构建首选项页面

I'm trying to use the field editor BooleanFieldEditor, subclass of FieldEditor. 我正在尝试使用FieldEditor的子类字段编辑器BooleanFieldEditor。

My issue is that in the javadoc, I don't find the function to change the state (checked/unchecked) of this field editor. 我的问题是在javadoc中,我找不到更改此字段编辑器状态(选中/未选中)的函数。

Where is the setChecked(boolean) function? setChecked(boolean)函数在哪里? :-) I missed something? :-)我错过了什么?

You do it by accessing the preference store's APIs. 您可以通过访问首选项商店的API来实现。

getPreferenceStore().setValue(preferenceID, value);

where preferenceID is the name of the boolean preference 其中preferenceID是布尔首选项的名称
(ie new BooleanFieldEditor(preferenceID, label, parent); ), and the value is true/false . (即new BooleanFieldEditor(preferenceID, label, parent); ),其值为 true / false

You get the current value for the ID with 您可以通过以下方式获取ID的当前值:

getPreferenceStore().getBoolean(preferenceID);

由于此控件正在管理首选项,因此我建议使用首选项初始化程序

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

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