Button button = new Button(parent, SWT.PUSH);button.setText("Open Wizard");button.addSelectionListener(new SelectionAdapter() {@Overridepublic void widgetSelected(SelectionEvent e) {WizardDialog wizardDialog = new WizardDialog(parent.getShell(),new MyWizard());if (wizardDialog.open() == Window.OK) {System.out.println("Ok pressed");} else {System.out.println("Cancel pressed");}}});
import org.eclipse.e4.core.di.annotations.Execute;import org.eclipse.ui.IWorkbench;import org.eclipse.jface.window.Window;import org.eclipse.jface.wizard.WizardDialog;import org.eclipse.swt.widgets.Shell;public class InputFilesAssistantHandle { @Execute public void execute(IWorkbench iWorkbench, Shell shell) {WizardDialog wizardDialog = new WizardDialog(shell, new MyWizard());WizardDialog.setDefaultImage(ApplicationContext.getImage(Constant.PLUGIN_ID, "icons/module/cn_icon.png"));if (wizardDialog.open() == Window.OK) {} else {} }}
效果:
文章插图
进阶:① wizardpage 的动态刷新 、 联动你的wizardpages 初始化是在wizard打开的时候,而不是点next或back时再初始化。所以,如果你想将两个wizardpage进行联动,通过上面的代码难以实现。阅读源码会发现,
private void updateForPage(IWizardPage page) {// ensure this page belongs to the current wizardif (wizard != page.getWizard()) {setWizard(page.getWizard());}// ensure that page control has been created// (this allows lazy page control creation)if (page.getControl() == null) {page.createControl(pageContainer);// the page is responsible for ensuring the created control is accessable// via getControl.Assert.isNotNull(page.getControl());// ensure the dialog is large enough for this pageupdateSize(page);}// make the new page visibleIWizardPage oldPage = currentPage;currentPage = page;currentPage.setVisible(true);if (oldPage != null) {oldPage.setVisible(false);}// update the dialog controlsupdate();}
// 对参数页必须重绘
IWizardPage page = getNextPage();
if (page.getControl() != null)
page.dispose();
并在你想要刷新的页面中重写dispose方法:
public void dispose() {
super.dispose();
setControl(null);
}
二、未完待续 。。。
【Eclipse插件RCP桌面应用开发的点点滴滴】
经验总结扩展阅读
- Windows10 + Eclipse C/C++开发环境配置极简教程
- 提高工作效率的神器:基于前端表格实现Chrome Excel扩展插件
- 苹果手机红包秒收怎么设置(苹果红包插件黑科技)
- 从0开始写一个简单的vite hmr 插件
- 钩子 【pytest官方文档】解读-插件开发之hooks 函数
- 插件化编程之WebAPI统一返回模型
- 浅谈 Golang 插件机制
- 中 ?打造企业自己代码规范IDEA插件
- 分享一个Vue实现图片水平瀑布流的插件
- 手机里有个恶意广告插件怎样清除