Xplora
Xplora

Reputation: 905

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.

enter image description here

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. What should be implemented under performFinish() of the final wizard page to load the project in Package Explorer automatically?

How to load such newly created project in Package Explorer programmatically?

Upvotes: 0

Views: 180

Answers (1)

greg-449
greg-449

Reputation: 111142

Ideally a project should be created using the version of IProject.create which takes a IProjectDescriptor. 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. 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);

Upvotes: 1

Related Questions