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