简体   繁体   English

org.eclipse.jface.wizard.WizardDialog的更新按钮

[英]Update buttons of org.eclipse.jface.wizard.WizardDialog

I know I could use createButtonsForButtonBar() to add/remove the new buttons for WizardDialog when invoking the dialog. 我知道可以在调用对话框时使用createButtonsForButtonBar()添加/删除WizardDialog的新按钮。 However, I would like the buttons of dialog could change according to the current displayed WizardPage . 但是,我希望对话框的按钮可以根据当前显示的WizardPage更改。

For example, for page1, I have one new button called "edit". 例如,对于第1页,我有一个名为“编辑”的新按钮。 For page2, I have one new button called "move". 对于第2页,我有一个名为“移动”的新按钮。 "edit" should not be displayed when page2 is shown and "move" should be not be displayed when page1 is shown. 显示第2页时不应显示“编辑”,而显示第1页时不应显示“移动”。 Any hints about how could I achieve this? 关于如何实现此目标的任何提示? Thank you. 谢谢。

createButtonsForButtonBar uses GridLayout to layout the buttons with GridData set for each button. createButtonsForButtonBar使用GridLayout来布局按钮,并为每个按钮设置GridData So should be able to use the GridData.exclude flag to exclude buttons for the layout. 因此,应该能够使用GridData.exclude标志排除布局按钮。

To stop displaying a button use something like: 要停止显示按钮,请使用以下命令:

Button button = getButton(button id);
GridData data = (GridData)button.getLayoutData();
data.exclude = true;
button.setVisible(false);

You will then have to call layout(true) on the button bar composite. 然后,您将必须在按钮栏组合上调用layout(true) You may also have to adjust the numColumns field of the GridLayout for the button bar composite. 您可能还需要调整按钮栏组合的GridLayoutnumColumns字段。

You could do this in the setVisible method of the wizard pages. 您可以在向导页面的setVisible方法中执行此操作。

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

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