mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
[site] Project wizard api overview
This commit is contained in:
parent
aaeacf904c
commit
543cb0b3f4
@ -55,6 +55,7 @@
|
||||
* [SDK](reference_guide/project_model/sdk.html)
|
||||
* [Library](reference_guide/project_model/library.html)
|
||||
* [Facet](reference_guide/project_model/facet.html)
|
||||
* [Project Wizard](reference_guide/project_wizard.html)
|
||||
* [Custom Language Support](reference_guide/custom_language_support.html)
|
||||
* [Registering File Type](reference_guide/custom_language_support/registering_file_type.html)
|
||||
* [Implementing Lexer](reference_guide/custom_language_support/implementing_lexer.html)
|
||||
|
@ -9,6 +9,7 @@ If you are not familiar with *IntelliJ Platform* API please refer to
|
||||
section.
|
||||
|
||||
* [Project Model](reference_guide/project_model.html)
|
||||
* [Project Wizard](reference_guide/project_wizard.html)
|
||||
* [Custom Language Support](reference_guide/custom_language_support.html)
|
||||
* [Frameworks and External APIs](reference_guide/frameworks_and_external_apis.html)
|
||||
* [VCS Integration Plugins](reference_guide/vcs_integration_for_plugins.html)
|
||||
|
141
reference_guide/project_wizard.md
Normal file
141
reference_guide/project_wizard.md
Normal file
@ -0,0 +1,141 @@
|
||||
---
|
||||
title: Project Wizard. Adding Support for Creating New Project Types.
|
||||
layout: editable
|
||||
---
|
||||
|
||||
## Project Wizard
|
||||
|
||||
Working with the project wizard can be illustrated with the
|
||||
[RedLine SmallTalk plugin](https://github.com/bulenkov/RedlineSmalltalk.git)
|
||||
|
||||
## Implementing New Module Type
|
||||
|
||||
Additional support for specific tools and technologies is usually done via implementing some certain module type which is attached to the project.
|
||||
New module type should be derived from the class
|
||||
[ModuleType](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java).
|
||||
|
||||
|
||||
## Project Wizard
|
||||
|
||||
Main utilities to configure a custom project wizard can be found in the package
|
||||
[lang-api.ide.util.projectWizard](https://github.com/JetBrains/intellij-community/tree/master/platform/lang-api/src/com/intellij/ide/util/projectWizard).
|
||||
These classes and interfaces serve the following purposes:
|
||||
|
||||
* Modification of the configuration wizard view
|
||||
* Adding new steps to the wizard
|
||||
* Providing additional setting for project creation
|
||||
* Handling activities during project creation
|
||||
* Initial environment configuration
|
||||
|
||||
### Module Type
|
||||
|
||||
To create a new module type and an extension
|
||||
|
||||
```xml
|
||||
<moduleType id="MY_MODULE" implementationClass="st.redline.smalltalk.module.MyModuleType"/>
|
||||
```
|
||||
to the
|
||||
[plugin.xml](https://github.com/bulenkov/RedlineSmalltalk/blob/master/resources/META-INF/plugin.xml).
|
||||
A custom module type should extend the
|
||||
[ModuleType](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java)
|
||||
generic from
|
||||
[ModuleBuilder](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java).
|
||||
The following
|
||||
[module type implementation](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleType.java)
|
||||
of a custom module type show how this instance can be registered and implemented.
|
||||
|
||||
### Implementing Module Builder
|
||||
|
||||
To set up a new module environment
|
||||
[ModuleBuilder](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java)
|
||||
class should be extended and registered as an extension point like the following snippet shows:
|
||||
|
||||
```xml
|
||||
<extensions>
|
||||
<!--Place your extensions here-->
|
||||
<moduleBuilder builderClass="org.jetbrains.plugins.ruby.rails.facet.versions.MyModuleBuilder"/>
|
||||
</extensions>
|
||||
```
|
||||
|
||||
Functionality which is mandatory to implement consists of:
|
||||
|
||||
* Setting up a root model for the new module by overriding
|
||||
|
||||
```java
|
||||
public abstract void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException;
|
||||
```
|
||||
|
||||
* Getting a module type
|
||||
|
||||
```java
|
||||
public abstract ModuleType getModuleType();
|
||||
```
|
||||
|
||||
See
|
||||
[JavaModuleBuilder](https://github.com/JetBrains/intellij-community/blob/master/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java)
|
||||
to understand better how to implement a module builder.
|
||||
|
||||
If your module type is based on the java module and meant to support Java as well, extending
|
||||
[JavaModuleBuilder](https://github.com/JetBrains/intellij-community/blob/master/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java)
|
||||
is enough.
|
||||
No extension point needs no be registered.
|
||||
Refer to
|
||||
[SmallTalk module type](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleType.java)
|
||||
to see how
|
||||
[JavaModuleBuilder](https://github.com/JetBrains/intellij-community/blob/master/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java)
|
||||
can be derived.
|
||||
|
||||
### Implementing Module Builder Listener
|
||||
|
||||
Module builder listener reacts on a new module creation, which could be done either as a part of the project creation process,
|
||||
or as adding a new module to the already existing project.
|
||||
To provide a certain behavior right after a module has been created, module builder should implement
|
||||
[ModuleBuilderListener](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilderListener.java)
|
||||
Method
|
||||
|
||||
```java
|
||||
public void moduleCreated(@NotNull final Module module);
|
||||
```
|
||||
executed tasks right after a module has been created,
|
||||
these may include configuring roots looking up for an SDK and setting it up, adding a specific facet if required and others.
|
||||
For more details please see the following
|
||||
[SmallTalk custom module type](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleType.java)
|
||||
implementation.
|
||||
|
||||
### Adding New Wizard Steps
|
||||
|
||||
Adding new steps to the module wizard can be done by overriding the
|
||||
|
||||
```java
|
||||
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider);
|
||||
```
|
||||
method in a custom
|
||||
[module builder](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleBuilder.java).
|
||||
If this method returns a non-empty array of ModuleWizardStep objects, new steps will be shown in their indexing oder while creating a new module.
|
||||
The following
|
||||
[implementation](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleWizardStep.java)
|
||||
for the SmallTalk project type illustrates how a custom wizard step can be created.
|
||||
The
|
||||
[RsModuleWizardStep](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleWizardStep.java)
|
||||
class is derived from
|
||||
[ModuleWizardStep](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java),
|
||||
which has two methods to be overridden:
|
||||
|
||||
* ```java
|
||||
public JComponent getComponent();
|
||||
```
|
||||
defines how the step will look like
|
||||
* ```java
|
||||
public void updateDataModel();
|
||||
```
|
||||
commits data from UI into ModuleBuilder and WizardContext
|
||||
|
||||
## Facet
|
||||
|
||||
Facets in IntelliJ are the way to store multiple kinds of module-specific settings, for instance to make a language support or framework available in some given module.
|
||||
To understand facets better from the point of view of an end-user, please see
|
||||
[Facet](/reference_guide/project_model/facet.html)
|
||||
documentation section.
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user