Eclipse PDE creating a new project

蓝咒 提交于 2019-12-01 06:22:18

问题


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.


回答1:


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);



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/7345847/eclipse-pde-creating-a-new-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!