Eclipse插件开发-打开指定的向导

来源:互联网 发布:ubuntu server配置网络 编辑:程序博客网 时间:2024/05/26 09:54

我们在开发Eclipse RCP时,有时会想创建打开指定的向导的快捷方式,下面说一下利用Eclipse提供的API实现该功能。

创建向导的处理:

IWizardDescriptor wizardDesc = WorkbenchPlugin.getDefault().getNewWizardRegistry().findWizard(wizardId); //$NON-NLS-1$if (wizardDesc != null) {NewWizardShortcutAction shortcutAction = new NewWizardShortcutAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),wizardDesc);shortcutAction.run();}

导入向导的处理:

IWizardDescriptor wizardDesc = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard("org.eclipse.ui.wizards.import.ExternalProject");if (wizardDesc != null) {ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.IMPORT);wizard.init(PlatformUI.getWorkbench(),StructuredSelection.EMPTY);IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();IDialogSettings wizardSettings = workbenchSettings.getSection("ImportExportAction"); //$NON-NLS-1$if (wizardSettings == null) {wizardSettings = workbenchSettings.addNewSection("ImportExportAction"); //$NON-NLS-1$}wizard.setDialogSettings(wizardSettings);wizard.setForcePreviousAndNextButtons(true);final WizardDialog dialog = new WizardDialog(UIUtils.getActiveShell(), wizard);try {dialog.create();IWorkbenchWizard iwizard = wizardDesc.createWizard();iwizard.addPages();dialog.showPage(iwizard.getStartingPage());dialog.open();} catch (CoreException e) {e.printStackTrace();}}


原创粉丝点击