IntelliJ Plugin Wizard Development

Joined
May 30, 2023
Messages
1
Reaction score
0
Hi,
I'm new to IntelliJ Plugin Development, and I apologize for my limited English skills.
I would like to have the default project wizard when selecting my plugin. However, I've encountered a problem. I'm currently using the "AbstractNewProjectWizardBuilder" class, which includes a method called "createStep." Unfortunately, I cannot return null in that method. As a workaround, I created a second class and implemented the "NewProjectWizardStep" class within it. However, I'm unsure how to utilize it, and I haven't been able to find any documentation on this topic.
Could someone assist me with this?
 
Joined
Mar 31, 2023
Messages
95
Reaction score
8
To create a custom project wizard in IntelliJ, you can indeed use the AbstractNewProjectWizardBuilder class. However, instead of returning null from the createStep method, you need to return an instance of a class that implements the NewProjectWizardStep interface.

Here's an example of how you can create a custom step class and utilize it in your project wizard:

  1. Create a class that implements the NewProjectWizardStep interface. This class will define the UI and behavior of your custom step in the project wizard. For example:
javaCopy code
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import javax.swing.*;

public class MyCustomProjectStep extends ModuleWizardStep implements NewProjectWizardStep {
private JPanel myPanel;

public MyCustomProjectStep() {
// Initialize your custom step UI here
myPanel = new JPanel();
myPanel.add(new JLabel("This is my custom step"));
}

@Override
public JComponent getComponent() {
return myPanel;
}

@Override
public void updateDataModel() {
// Perform any necessary actions when the user moves to the next step
}

@Override
public boolean validate() {
// Perform any necessary validation for the step
return true; // or return false if validation fails
}
}

  1. In your AbstractNewProjectWizardBuilder implementation, instead of returning null from the createStep method, return an instance of your custom step class. For example:
javaCopy code
import com.intellij.ide.util.projectWizard.AbstractNewProjectWizardBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.openapi.project.Project;

public class MyProjectWizardBuilder extends AbstractNewProjectWizardBuilder {
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
return new MyCustomProjectStep();
}

@Override
public boolean isAvailable() {
// Return true if your custom project wizard should be available, otherwise return false
return true;
}

@Override
public void setupProject(Project project, ProjectSetupContext context) {
// Perform any necessary setup for the project
}
}

  1. Register your MyProjectWizardBuilder class in your plugin.xml file. Add the following extension point declaration:
xmlCopy code
<extensions defaultExtensionNs="com.intellij">
<newProjectWizardBuilders>
<builder implementation="com.yourplugin.MyProjectWizardBuilder"/>
</newProjectWizardBuilders>
</extensions>

Make sure to replace com.yourplugin with the actual package name where your MyProjectWizardBuilder class is located.

With these steps, you should be able to create a custom step in your project wizard. The MyCustomProjectStep class will define the content and behavior of that step.

I hope this helps you in creating your IntelliJ plugin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,056
Messages
2,570,446
Members
47,097
Latest member
MarionMajo

Latest Threads

Top