[英]How to link a parent preference page to a child preference page in Eclipse RCP?
I have a preference page in Eclipse that contains a checkbox. 我在Eclipse中有一个首选项页面,其中包含一个复选框。 This is the parent preference page.
这是父母首选项页面。
The child preference page should contain different field editors based on some checkboxes values in the parent page. 子首选项页面应基于父页面中的某些复选框值包含不同的字段编辑器。
Example: If checkbox in parent checked then create a text field in child. 示例:如果选中了父级中的复选框,则在子级中创建一个文本字段。
I want to update/redraw the child page when I press apply. 当我按应用时,我想更新/重绘子页面。
I was trying to do this in the following way: 我试图通过以下方式做到这一点:
My child page class looks like this: 我的子页面类如下所示:
public class MyChildPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
Overwritting setVisible method: 覆盖setVisible方法:
@Override
public void setVisible(final boolean visible)
{
super.setVisible(visible);
if (visible)
createFieldEditors();
}
My createFieldEditors method creates the fields using the same Composite everytime. 我的createFieldEditors方法每次都使用相同的Composite来创建字段。
Still, no update is happening. 仍然没有更新发生。
Is there a way to re-trigger preference page creation when changing the focus/visibility ? 更改焦点/可见性时,是否可以重新触发偏好页面的创建?
This question was not answered and it is similar: Refresh the contents of an eclipse preference page 这个问题没有得到回答,它很相似: 刷新Eclipse首选项页面的内容
You could try calling FieldEditorPreferencePage#initialize()
instead? 您可以尝试调用
FieldEditorPreferencePage#initialize()
吗? That calls load()
on each of the field editors. 在每个字段编辑器上调用
load()
。
You should only create the field editors once. 您只应创建一次字段编辑器。
You can override the propertyChange
method of FieldEditorPreferencePage
to be told about each preference property change: 您可以重写
FieldEditorPreferencePage
的propertyChange
方法,以了解每个首选项属性的更改:
@Override
public void propertyChange(PropertyChangeEvent event) {
String propertyId = event.getProperty();
...
super.propertyChange();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.