private void initModuleWizard(
      final Project project,
      final ModulesProvider modulesProvider,
      @Nullable final String defaultPath) {
    myWizardContext = new WizardContext(project);
    if (defaultPath != null) {
      myWizardContext.setProjectFileDirectory(defaultPath);
      myWizardContext.setProjectName(
          defaultPath.substring(
              FileUtil.toSystemIndependentName(defaultPath).lastIndexOf("/") + 1));
    }
    myWizardContext.addContextListener(
        new WizardContext.Listener() {
          public void buttonsUpdateRequested() {
            updateButtons();
          }

          public void nextStepRequested() {
            doNextAction();
          }
        });

    myRootStep =
        new ProjectCreateModeStep(defaultPath, myWizardContext) {
          protected void update() {
            updateButtons();
          }
        };
    addStep(myRootStep);
    for (WizardMode mode : myRootStep.getModes()) {
      appendSteps(mode.getSteps(myWizardContext, modulesProvider));
    }
    init();
  }
 private WizardMode getMode() {
   return myRootStep.getMode();
 }