Eclipse PDE 创建新项目

发布于 2024-12-03 16:07:19 字数 152 浏览 1 评论 0原文

我正在使用向导扩展从用户那里获取一些设置。在我的插件修改 Eclipse 项目之后,它应该包含在 Package Explorer 中。整个事情与“新项目→现有项目”非常相似。

但我找不到任何解决方案或教程等如何通过向导扩展将 Eclipse 项目包含到我的包资源管理器中。

I'm using the Wizard Extension to get some settings from the user. After on my plugin modifies an Eclipse project and then it should be included into the Package Explorer. The whole thing is then quite similar to "New Project → Existing Project".

But I can't find any solution or tutorial etc. how to include an Eclipse project to my package explorer via the wizard extension.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北城孤痞 2024-12-10 16:07:19

对于任何感兴趣的人来说,这对我来说非常完美:

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(ProjectPath + "/.project")); 
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
project.create(description, null);
project.open(null);

描述将从构建路径加载并导入到工作区中。之后该项目将存在但已关闭,因此 project.open();
就是这样...

编辑:这将是确保项目尚未导入的代码。

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(BuildPath + "/.project")); 
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
IProject[] array = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for(int count = 0; count <= array.length - 1; count ++){
  if(project.equals(array[count])){
    array[count].close(null);
    array[count].delete(true, null);
  }
}
project.create(description, null);
project.open(null);

For anyone who´s interested this one works for me just perfect:

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(ProjectPath + "/.project")); 
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
project.create(description, null);
project.open(null);

The Description will be loaded from the build Path and import into the workspace. After that the project would exist but is closed so project.open();
That´s it...

Edit: This would be the code to make sure that the project isn´t already imported.

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(BuildPath + "/.project")); 
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
IProject[] array = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for(int count = 0; count <= array.length - 1; count ++){
  if(project.equals(array[count])){
    array[count].close(null);
    array[count].delete(true, null);
  }
}
project.create(description, null);
project.open(null);
雪若未夕 2024-12-10 16:07:19

当您使用 eclipse PDE 创建项目时,该项目将位于本地工作空间下,其中类似于“${workspace_loc}/../runtime-...”。该工作空间已经是您默认的 Eclipse 工作空间,但是当您构建 PDE 时,它将打开一个特殊目录(您可以从插件项目的运行配置中定义该目录)。然后,您可以从该目录将创建的新项目打开到 eclipse 包资源管理器中。

When you create a project with eclipse PDE, the project would be under workspace in your local where something like that "${workspace_loc}/../runtime-...". The workspace is already your default eclipse workspace, but when you build your PDE, it would be opened a special directory (you can define the directory from run configurations of your plugin project). So then, you can open the created new project into your eclipse package explorer from that directory.

嘿哥们儿 2024-12-10 16:07:19

创建插件

旅程的第一站是创建一个新的插件项目(文件>新建>项目>插件项目)。请使用模板。确保项目和org.eclipse.pde.ui之间存在依赖关系。完成此操作后,您可以转到 Extensions 插件编辑器选项卡,然后开始创建模板。

Create a plug-in

The first leg of the journey is to create a new plug-in project (File> New> Project> Plug-in Project). Please use the template. Ensure that dependencies between projects and org.eclipse.pde.ui. Once this is done, you can go to the Extensions plug-in editor tab, and then began to create a template.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文