ModuleType, ModuleBuilder, and selection on "New Project"

As many developers of custom languages, I have a ModuleType and a ModuleBuilder. I have several ModuleBuilders that extend from a base and create different types of basic application, empty, etc. modules. For the different kinds of ModuleBuilders I have implemented a ProjectTemplatesFactory. There is one thing that bothers me: When I click on "New Project" it looked like this

As you can see there are Mathematica entries on the left side. "Mathematica" is provided by my ProjectTemplatesFactory and "Empty" (which is doubled since is also available on the right side) is coming from my ModuleType.createModuleBuilder() where I have to return something. I want to collect all my ModuleBuilders into one Mathematica group.

I debugged yesterday and one possible solution seems (!) to be to set ModuleBuilder.isAvailable() to false for my builders. That makes them still accessible through the ProjectTemplatesFactory, but the single "Empty" instance vanishes.

What is the correct way to expose several ModuleBuilders under one category? All of them create the same ModuleType but set-up different, project-specific stuff.

PS: I tried several settings of ModuleBuilder.getGroupName and ModuleBuilder.getParentGroup as well, but when you debug through it, you see that there seems no reasonable way to put them all in the same group. The fun happens in com.intellij.ide.projectWizard.ProjectTypeStep#fillTemplatesMap and the constructor TemplatesGroup(builder) works kind of unexpected.

0

Hello, you'll need to override isTemplateBased() in your builder and return "true" there. Please look at WebModuleBuilder for reference.

0
Avatar
Permanently deleted user

Thank you for your answer Dmitry. It was very helpful because you pointed me to look deeper into the implementation of the WebModuleBuilder. I had seen isTemplateBased() and isTemplate() and tried various combinations. Nothing helped.

The weird thing I had to fix is that a "TemplateGroup" is created from a ModuleBuilder but the name for the group is not the groupName you can provide in the ModuleBuilder, it is the "presentableName" of the builder. This is why I always had 2 groups: One coming from the ModuleBuilder I *had* to provide in my plugin.xml when I declare my module type, and one coming from my ProjectTemplateFactory.

I solved it like the WebModuleBuilder solved it. I return the groupName as "presentableName".

0

请先登录再写评论。