简体   繁体   English

Eclipse PDE:如何以编程方式在Package Explorer中加载新项目?

[英]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 . 理想情况下,应使用带有IProjectDescriptorIProject.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.

相关问题 如何从Project Explorer和Package Explorer将文件获取到Eclipse上的新View? - How to get files from Project Explorer and Package Explorer to new View on Eclipse? 如何在Eclipse PDE中表达项目间依赖项 - How to express inter project dependencies in Eclipse PDE Web应用程序项目中的Eclipse包浏览器错误 - Eclipse package explorer error in a web application project Eclipse PDE:以编程方式读取目标平台的内容 - Eclipse PDE : Programmatically read the contents of the target platform 最近,我在 Eclipse 中创建的任何新 Maven 项目都将在 package 资源管理器视图中将“[workspace master]”作为标题的一部分 - Recently any new Maven project I create in Eclipse will have "[workspace master]" as part of the title in the package explorer view 在 Eclipse PDE 中打开编辑器以编程方式查看 - Open Editor in an Eclipse PDE View programmatically 将Eclipse PDE项目转换为Bndtools项目 - Transforming an eclipse pde project into a bndtools project Eclipse PDE项目中的Slf4j和登录? - Slf4j and logback in an eclipse PDE project? 将面板容器添加到Eclipse PDE项目中的PreferencePage - Adding a panel container to a PreferencePage in an Eclipse PDE project 如何清理和整理 Eclipse Package Explorer? - How to clean and organize Eclipse Package Explorer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM