mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
framework.md: update
This commit is contained in:
parent
be15f51668
commit
cdc54c7d51
@ -1,6 +1,6 @@
|
|||||||
[//]: # (title: Frameworks)
|
[//]: # (title: Frameworks)
|
||||||
|
|
||||||
<!-- Copyright 2000-2020 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. -->
|
<!-- Copyright 2000-2021 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. -->
|
||||||
|
|
||||||
The following tutorial shows how to support a custom framework type for a project and make this framework type embedded in a project wizard as a UI component.
|
The following tutorial shows how to support a custom framework type for a project and make this framework type embedded in a project wizard as a UI component.
|
||||||
The examples in this tutorial rely heavily on the [framework_basics](https://github.com/JetBrains/intellij-sdk-code-samples/tree/main/framework_basics) code sample.
|
The examples in this tutorial rely heavily on the [framework_basics](https://github.com/JetBrains/intellij-sdk-code-samples/tree/main/framework_basics) code sample.
|
||||||
@ -28,11 +28,12 @@ It is best if this is the FQN name of the class:
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
public class DemoFramework extends FrameworkTypeEx {
|
public class DemoFramework extends FrameworkTypeEx {
|
||||||
public static final String FRAMEWORK_ID = "org.intellij.sdk.framework.DemoFramework";
|
|
||||||
protected DemoFramework() {
|
public static final String FRAMEWORK_ID = "org.intellij.sdk.framework.DemoFramework";
|
||||||
super(FRAMEWORK_ID);
|
|
||||||
}
|
protected DemoFramework() {
|
||||||
}
|
super(FRAMEWORK_ID);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The *Presentable name* and *icon* define the appearance of visual components related to the framework:
|
The *Presentable name* and *icon* define the appearance of visual components related to the framework:
|
||||||
@ -59,42 +60,48 @@ To make the framework set up available while executing the steps to create a pro
|
|||||||
In this example the framework is added to any [`ModuleType`](upsource:///platform/lang-api/src/com/intellij/openapi/module/ModuleType.java) without checking, which is usually not the case.
|
In this example the framework is added to any [`ModuleType`](upsource:///platform/lang-api/src/com/intellij/openapi/module/ModuleType.java) without checking, which is usually not the case.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public FrameworkSupportInModuleProvider createProvider() {
|
public FrameworkSupportInModuleProvider createProvider() {
|
||||||
return new FrameworkSupportInModuleProvider() {
|
return new FrameworkSupportInModuleProvider() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public FrameworkTypeEx getFrameworkType() {
|
public FrameworkTypeEx getFrameworkType() {
|
||||||
return DemoFramework.this;
|
return DemoFramework.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public FrameworkSupportInModuleConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
|
public FrameworkSupportInModuleConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
|
||||||
return new FrameworkSupportInModuleConfigurable() {
|
return new FrameworkSupportInModuleConfigurable() {
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public JComponent createComponent() {
|
|
||||||
return new JCheckBox("SDK Extra Option");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ModifiableModelsProvider provider) {
|
public JComponent createComponent() {
|
||||||
// This is the place to set up a library, generate a specific file, etc
|
return new JCheckBox("SDK Extra Option");
|
||||||
// and actually add framework support to a module.
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabledForModuleType(@NotNull ModuleType type) {
|
public void addSupport(@NotNull Module module,
|
||||||
return true;
|
@NotNull ModifiableRootModel model,
|
||||||
}
|
@NotNull ModifiableModelsProvider provider) {
|
||||||
|
// This is the place to set up a library, generate a specific file, etc
|
||||||
|
// and actually add framework support to a module.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabledForModuleType(@NotNull ModuleType type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
After compiling and running the code sample above an extra option for configuring the newly created Demo custom framework should be available in the Project Wizard:
|
```
|
||||||
|
## Compile and Run the Plugin
|
||||||
|
|
||||||
|
See [Code Samples](code_samples.md) on how to set up and run the plugin.
|
||||||
|
|
||||||
|
Extra option for configuring the newly created Demo custom framework should be available in the Project Wizard:
|
||||||
|
|
||||||

|

|
||||||
|
Loading…
x
Reference in New Issue
Block a user