[英]Eclipse PDE: How to load a new project in Package Explorer programmatically?
I have developed an Eclipse plugin that creates a new custom project via project creation wizard using INewWizard. 我已经开发了一个Eclipse插件,可以使用INewWizard通过项目创建向导创建一个新的自定义项目。
Once user inputs information and clicks 'Finish', project gets created within workspace successfully. 用户输入信息并单击“完成”后,将成功在工作区中创建项目。 Issue is that Package Explorer doesn't load this newly created project upon 'Finish' event. 问题是Package Explorer不会在“完成”事件后加载此新创建的项目。 What should be implemented under performFinish() of the final wizard page to load the project in Package Explorer automatically? 在最终向导页面的performFinish()下应执行什么以将项目自动加载到Package Explorer中?
How to load such newly created project in Package Explorer programmatically? 如何以编程方式在Package Explorer中加载此类新创建的项目?
Ideally a project should be created using the version of IProject.create
which takes a IProjectDescriptor
. 理想情况下,应使用带有IProjectDescriptor
的IProject.create
版本创建项目。 But if you are creating the project files some other way you still need to create the project using IProject
to tell Eclipse about it. 但是,如果您以其他方式创建项目文件,则仍然需要使用IProject
来创建项目以告知Eclipse。 You can use something like: 您可以使用类似:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
if (!project.exists()) {
project.create(monitor);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
// TODO add files
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.