我需要以编程方式从 eclipse 插件项目中调用 eclipse importwizard。 我按照 中的示例进行操作,似乎不起作用https://resheim.net/2010/07/invoking-eclipse-wizard.html
然后在我的代码中,它显示向导数组为空,我需要注册导入向导吗?
IWizardDescriptor[] wizards= PlatformUI.getWorkbench().getImportWizardRegistry().getPrimaryWizards();
导入对话框不使用"主要"向导。您需要知道要使用的向导的 id,并调用向导注册表findWizard
方法。
"导入项目"向导 ID org.eclipse.ui.wizards.import.ExternalProject
,因此代码如下所示:
String id = "org.eclipse.ui.wizards.import.ExternalProject"
IWizardDescriptor descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(id);
IWizard wizard = descriptor.createWizard();
WizardDialog wd = new WizardDialog(display.getActiveShell(), wizard);
wd.setTitle(wizard.getWindowTitle());
wd.open();
private void openProject(String projectfolder( 抛出 CoreException { 待办事项:检查项目是否已创建并打开,如果是,则不执行任何操作或只是刷新
IProjectDescription description = null;
IProject project = null;
description = ResourcesPlugin.getWorkspace().loadProjectDescription(
new Path(new File(projectfolder).getAbsolutePath()
+ "/.project"));
project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(description.getName());
project.create(description, null);
project.open(null);
}