Wizard step to add jars to buildpath

Hi All!

I'm writing a plugin that defines a custom module type in the "New Project" wizard.
I need to add a step in which, when a folder path is given, all jars in that folder will be added to the build path of the project/module.

Some threads I've seen in this forum deal with adding libraries, but they seem to require the 'project' object, which is taken from the AnActionEvent argument of an Action's actionPerformed method. Since there is no Action in my wizard step, I am unable to retrieve the project object.

Also, i've seen the createLoadJarsStep() method in ProjectWizardStepFactory. But I am puzzled as to how to create or get the AddSupportContext required here.

I've been stuck on this for sometime now. Any help will be greatly appreciated.

Comment actions Permalink

To use AddSupportContext in your application component do this:

ProjectWizardStepFactory.getInstance().registerAddSupportProvider(ModuleType.WEB, new MyWizardStepsProvider());

You can attach it to any module type you want. MyWizardStepsProvider is just a class that implements AddSupportStepsProvider. The most important method you have to implement is createAddSupportSteps.

Here you'll return all the additional steps you want to include in the new module wizard. You can create brand new ones or you can also use the given LoadJarsStep. To use that just do:

ProjectWizardStepFactory.getInstance().createLoadJarsStep(addSupportContext, "My Libraries", "My Libraries", JavaeeIcons.WEB_WIZARD_ICON)

This will create the step instance and then you just have to return it.

Note: this is in IDEA 6.x. I don't know if this is still valid in 7.x.

Comment actions Permalink

Thanks a lot Hugo!

Your reply was really helpful. But one of my original questions remain.

ProjectWizardStepFactory.getInstance().createLoadJarsStep(addSupportContext, "My Libraries", "My Libraries", JavaeeIcons.WEB_WIZARD_ICON)

what do I pass as the AddSupportContext object to this method? Should I sub-class AddSupportContext and create a new instance of it? Or can I get the current AddSupportContext from somewhere?

The AddSupportContext constructor is
AddSupportContext(java.lang.String libraryName, Project project, boolean insideAddModuleWizard)

If i were to instantiate this, I would again need a reference to the project. ???

Thanks in advance for any help.

Comment actions Permalink

You will have to create a class that extends AddSupportContext.

Your createAddSupportSteps method in your AddSupportStepsProvider implementation receives a WizardContext parameter.
You can get the project like this:



Please sign in to leave a comment.