How to change WizardContext ProjectName in middle of Wizardstep
Hi,
In middle of wizard I made importing values from xml in zip that is chosen by user. I display them in textfields, can I somehow set project name to value from my textfield? I added listener and call for update after inserting value in textbox but it don't change project name in last step, however I can do requestWizardButtonsUpdate() in MyModuleWizardStep and change project name to value from textbox but when it's called textbox is empty. I don't know why my projectname is related to maven WizardContext. I have same project name from last step in maven project wizard in my last step.
public MyModuleWizardStep(MyModuleBuilder myBuilder, WizardContext wizardContext) {
this.myBuilder = myBuilder;
wizardContext.addContextListener(new WizardContext.Listener() {
@Override
public void buttonsUpdateRequested() {
wizardContext.setProjectName(myTextbox.getText());
}
@Override
public void nextStepRequested() {
}
});
this.wizardContext = wizardContext;
}
Please sign in to leave a comment.
Did you try to update WizardContext in your step's updateDataModel() method?
Hi, Was there ever a resolution to this issue?
I'm attempting to automatically change the project name in the final step, after entering into the initial New Project prompt, based on settings that I've selected there (using "new-proj-name" as an example below). However, the project name continues to display as that of the default module name ("untitled" in this case).
class MyCustomWizardStep(private val moduleBuilder: MyCustomModuleBuilder) : ModuleWizardStep() {...
override fun updateDataModel() {
moduleBuilder.wizardContext?.projectName = "new-proj-name"
}
}
I am only able to change the project name by overriding the wizard context project name property in:
However, I've confirmed by debugging that the 3 steps above fire immediately after selecting File -> New -> Project. After selecting some options and hitting the Next button, any other functions where I choose to override the wizard context's project name have no effect, when the final step is loaded.
Another related post:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000626140-Get-name-Text-field-from-last-step-of-new-project-wizard
After further debugging, this was resolved this by overriding the project name, module, and directory in MyCustomModuleBuilder::modifySettingsStep.
override fun modifySettingsStep(settingsStep: SettingsStep): ModuleWizardStep? {if (settingsStep is ProjectSettingsStep) {
settingsStep.setNameValue(...)
settingsStep.setModuleName(...)
settingsStep.setPath(...)
}
return super.modifySettingsStep(settingsStep)
}
It seems like a bug, that we are not able to override the wizard context's project name in MyCustomWizardStep::updateDataModel in the middle of the wizard step, when the base function's Java doc is:
Update: The above was not a viable fix, and doesn't support IntelliJ versions before 2019.2.1. `ProjectSettingsStep::setNameValue` and `ProjectSettingsStep::setPath` were recently added in the IntelliJ community source code with `@TestOnly` annotations, so we should not have been using them anyway. It looks like they really want to keep the`myNamePathComponent` variable private, as they do not provide public getters/ setters.