Custom ModuleBuilder only for new projects, not modules
Hello,
I would like to create a custom project generator that shows up in the “New Project” dialog window. However, I do not want this generator in the “New Module” window.
To achieve this, I have created a custom ModuleType and a corresponding ModuleBuilder, and then added the ModuleType to plugin.xml. Unsurprisingly, the custom project generator shows up in both “New Project” and “New Module” windows. What should I do to make the project generator hidden from the “New Module” window?
I am aware of the `ModuleBuilder.isAvailable` method, and I can return false to hide the generator. However, I don't know how to distinguish between creating a project vs. a module in the context of `isAvailable`.
@Override
public boolean isAvailable() {
return false; // This would hide the generator from both "New Project" and "New Module" dialog windows. I want to hide it solely from the "New Module" window.
}
If relevant, here's the current implementation:
- ModuleType: https://github.com/Aalto-LeTech/aplus-courses/blob/71114b98885d24c55b4635ae7b7397e9f2a403ca/src/main/java/fi/aalto/cs/apluscourses/intellij/generator/APlusModuleType.java
- ModuleBuilder: https://github.com/Aalto-LeTech/aplus-courses/blob/71114b98885d24c55b4635ae7b7397e9f2a403ca/src/main/java/fi/aalto/cs/apluscourses/intellij/generator/APlusModuleBuilder.java
Thanks in advance
Please sign in to leave a comment.
Did you manage to figure it out? I've got similar case but using `GeneratorNewProjectWizardBuilderAdapter`. There is also `canCreateModule` but it does not seem to affect New Module menu visibility.
I fixed it by checking that the action that opened the dialog is the NewProject action
For me those actions are:
So indeed, if contains “Module” do not make it available, thanks