Eclipse PDE creating a new project
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 Ex开发者_JAVA百科plorer. 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.
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);
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.
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.
精彩评论