New Project wizard

Answered

How can i create a dialog similar to new project wizard which has back ,next ,finish and cancel buttons?

6 comments
Comment actions Permalink

Hi Jakub

Thanks for the reply. I am new to plugin development and can you share any samples if you have for reference to start with.How to integrate the wizarddialog that you mentioned above with actionPerformed method

0
Comment actions Permalink

Since WizardDialog is an implementation of a regular DialogWrapper, you have to create a new instance of it and simply run .show() method.

What exact problem do you have?

Also please do not create a duplicated threads to keep this forum clean (ref. https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008406499-wizard-dialog)

1
Comment actions Permalink

Hi Jakub

Thanks for response. I am trying to create wizard where each step will have a form to get input from users and collect data from all steps when finish button is clicked at last step. I am calling below method in actionperformed event of menu item

Defined below action in plugins.xml

<actions>
<!-- Add your actions here -->
<group id="SampleWizard.SampleWizardAction " text="Sample Wizard Action " description="SampleWizardAction plugin">
<add-to-group group-id="MainMenu" anchor="last"/>
<action class="com.example.actions.SampleWizardAction" id="SpringBootManager.Actions.SampleWizardAction "
text="New Project Wizard"/>
</group>
</actions>

 

Action class :

public class SampleWizardAction extends AnAction {

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
if(new WizardDialog(true,new WizardModel("springbootmanager")).showAndGet()) {

}

 

I am getting below exception when the above action is performed

 

2020-06-05 15:06:06,849 [ 219088] ERROR - llij.ide.plugins.PluginManager - Not steps were added
java.lang.IllegalStateException: Not steps were added
at com.intellij.ui.wizard.WizardModel.checkModel(WizardModel.java:158)
at com.intellij.ui.wizard.WizardModel.getCurrentStep(WizardModel.java:119)
at com.intellij.ui.wizard.WizardDialog.initCurrentStep(WizardDialog.java:159)
at com.intellij.ui.wizard.WizardDialog.init(WizardDialog.java:118)
at com.intellij.ui.wizard.WizardDialog.<init>(WizardDialog.java:46)

please help me understand how to create steps for wizard and add form to each step

Based on wizard dialog class I understood that wizard dialog needs some steps to be defined in order to create an instance for it  but not getting clue how to achieve this.

 

Appreciate your help on this 

 

0
Comment actions Permalink

Hi Jakub 

I figured it out how to add wizard steps .In case if someone has ran into same issue below is what i did to add steps.

In the below example i was just returning a label. In place of label i will add GUI form.i am able to do that but how to do validation of form data like if every input field in the form has provided correct input then only next button should be enabled

WizardStep step1=new WizardStep() {
@Override
public JComponent prepare(WizardNavigationState state) {
return new JLabel("test label");
}
};
WizardStep step2=new WizardStep() {
@Override
public JComponent prepare(WizardNavigationState state) {
return new JLabel("test label 2");
}
};
WizardModel model=new WizardModel("samplewizard");
model.add(step1);
model.add(step2);
if(new WizardDialog(true,model).showAndGet()) {

}

0
Comment actions Permalink

Wizard has no validation provided out of the box. You can implement your own checks and i.e. make the next button enabled/disabled accessing it via:

getCurrentNavigationState().NEXT.setEnabled(false);

WizardStep has onNext method available, which can be used for the validation process.

0

Please sign in to leave a comment.