mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
[site] "Supporting new module type" tutorial
This commit is contained in:
parent
337dba789b
commit
ebb69e3831
@ -131,7 +131,7 @@
|
||||
* [3. Handling Editor Events](tutorials/editor_basics/editor_events.html)
|
||||
* [Project Wizard](tutorials/project_wizard.html)
|
||||
* [Adding New Steps to Project Wizard](tutorials/project_wizard/adding_new_steps.html)
|
||||
* [Supporting Module Types](tutorials/project_wizard/module_types.md)
|
||||
* [Supporting Module Types](tutorials/project_wizard/module_types.html)
|
||||
* [Code Inspections](tutorials/code_inspections.html)
|
||||
* [Run Configurations](tutorials/run_configurations.html)
|
||||
* [Supporting Frameworks](tutorials/framework.html)
|
||||
|
@ -8,7 +8,7 @@ Configuring Project Wizard automatically allows you to do the following:
|
||||
|
||||
|
||||
1. [Adding New Steps to Project Wizard](tutorials/project_wizard/adding_new_steps.html)
|
||||
2. [Supporting Module Types](tutorials/project_wizard/module_types.md)
|
||||
2. [Supporting Module Types](tutorials/project_wizard/module_types.html)
|
||||
3. [Handling activities during project creation]()
|
||||
4. [Initial environment configuration]()
|
||||
|
||||
|
@ -2,3 +2,124 @@
|
||||
layout: editable
|
||||
title: Supporting Module Types
|
||||
---
|
||||
|
||||
*IntelliJ Platform* provides a set of standard module types which can be chosen, however, you might need to create a module of a type that haven't been supported yet.
|
||||
This tutorial shows how to register a new module and link it to the project creation procedure and the UI.
|
||||
|
||||
## Pre-requirements.
|
||||
|
||||
Create an empty plugin project.
|
||||
See
|
||||
[Creating a Plugin Project](basics/getting_started/creating_plugin_project.html)
|
||||
to know how to do it.
|
||||
|
||||
## 1. Register a New Module Type
|
||||
|
||||
Add a new *moduleType* extension into the
|
||||
[plugin.xml](TODO)
|
||||
configuration file.
|
||||
|
||||
```xml
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<moduleType id="DEMO_MODULE_TYPE" implementationClass="com.intellij.tutorials.module.DemoModuleType"/>
|
||||
</extensions>
|
||||
```
|
||||
|
||||
## 2. Implement ModuleType Interface
|
||||
|
||||
|
||||
```java
|
||||
public class DemoModuleType extends ModuleType<DemoModuleBuilder> {
|
||||
private static final String ID = "DEMO_MODULE_TYPE";
|
||||
|
||||
public DemoModuleType() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
public static DemoModuleType getInstance() {
|
||||
return (DemoModuleType) ModuleTypeManager.getInstance().findByID(ID);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DemoModuleBuilder createModuleBuilder() {
|
||||
return new DemoModuleBuilder();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Demo Module Type";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Demo Module Type";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBigIcon() {
|
||||
return AllIcons.General.Information;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getNodeIcon(@Deprecated boolean b) {
|
||||
return AllIcons.General.Information;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull DemoModuleBuilder moduleBuilder, @NotNull ModulesProvider modulesProvider) {
|
||||
return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Implement Custom Module Builder
|
||||
|
||||
```java
|
||||
public class DemoModuleBuilder extends ModuleBuilder {
|
||||
@Override
|
||||
public void setupRootModel(ModifiableRootModel model) throws ConfigurationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleType getModuleType() {
|
||||
return DemoModuleType.getInstance();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
|
||||
return new DemoModuleWizardStep();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Provide Custom Wizard Steps
|
||||
|
||||
Provide implementation of UI components for the project creating stage.
|
||||
|
||||
```java
|
||||
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
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5. Creating a Module of New Type
|
||||
|
||||
After compiling and running the plugin, create a new project with the instance of *IntelliJ IDEA* being run from sources.
|
||||
You will see a new module type and it's settings panel available in the Project Wizard.
|
||||
|
||||

|
||||
|
||||
|
BIN
tutorials/project_wizard/module_types/img/new_module_type.png
Normal file
BIN
tutorials/project_wizard/module_types/img/new_module_type.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 121 KiB |
Loading…
x
Reference in New Issue
Block a user