IntelliJ Platform provides a set of standard module types. However, an application might need a module of a type that isn't supported yet. This tutorial shows how to register a new module type and link it to the project creation procedure and the UI.
The source code for the module and project_wizard code samples is used throughout this tutorial.
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.module;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.roots.ModifiableRootModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DemoModuleBuilder extends ModuleBuilder {
@Override
public void setupRootModel(@NotNull ModifiableRootModel model) {
}
@Override
public DemoModuleType getModuleType() {
return DemoModuleType.getInstance();
}
@Nullable
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
return new DemoModuleWizardStep();
}
}
Provide Custom Wizard Steps
Provide a straightforward implementation of UI components for the project creating stage. Create a generic DemoModuleWizardStep based on ModuleWizardStep
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.module;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import javax.swing.*;
public class DemoModuleWizardStep extends ModuleWizardStep {
@Override
public JComponent getComponent() {
return new JLabel("Provide some setting here");
}
@Override
public void updateDataModel() {
//todo update model according to UI
}
}
Creating a Module of New Type
After compiling and running the plugin in a development instance, create a new project. Select File | New | Module.... A new module type and its settings panel are available in the Project Wizard.