archit jain
archit jain

Reputation: 83

eclipse plugin development --add predefined sub folders in a Project when selecting a wizard

I am a beginner to eclipse plugin development.Actually i was trying to make a wizard in NEW->OTHERS. Say NEW->OTHERS->XYZenterprise (category)and a wizard in it XYZproject.I have done this.

What i am struggling with is ,that when i click XYZproject a page opens and it ask project name and when u click finish it adds that project with the specified name in the workspace.i achieved this by creating a class and extending it with BasicNewProjectResourceWizard.

like this:- import org.eclipse.ui.wizards.newresource.*; "public class NewWizard1 extends BasicNewProjectResourceWizard {"

Upto this point i am able to achieve what is required. What i want is when i click finish ,it add project with the name specified in the workspace but also with some folders with predefined names as sub folders in project.

Upvotes: 2

Views: 179

Answers (1)

greg-449
greg-449

Reputation: 111142

A problem with using BasicNewProjectResourceWizard is that the performFinish creates the project and immediately shows it before you have a chance to add the extra folders. Unfortunately this is not easy to change so many of the new wizards don't use it.

If you do use this wizard, you could override performFinish and add the folder creates there:

@Override
public boolean performFinish()
{
  if (!super.performFinish())
    return false;

  IProject newProject = getNewProject();

  IFolder newFolder = newProject.getFolder(new Path("relative path for folder"));

  newFolder.create(false, true, progress monitor);

  return true;
}

If you are creating a lot of folders you may want to use an WorkspaceModifyOperation or WorkspaceJob to show progress during the create.

Upvotes: 1

Related Questions