diff --git a/code_samples/framework/resources/META-INF/plugin.xml b/code_samples/framework/resources/META-INF/plugin.xml index 4734dfb32..2ce41ec98 100644 --- a/code_samples/framework/resources/META-INF/plugin.xml +++ b/code_samples/framework/resources/META-INF/plugin.xml @@ -1,18 +1,43 @@ + + - com.intellij.demo.framework - Framework example - 1.0 - JetBrains - Demonstrates basic Framework support with custom Configurable + + org.intellij.sdk.framework + + SDK: Framework Sample Project + + + 2.0 + + com.intellij.modules.java - - + + + + + + +
  • 2.0.0 Convert to Gradle-based plugin, rename to framework_basics, change plugin ID
  • +
  • 1.0.0 Release 2018.3 and earlier.
  • + + ]]> +
    + + + IntelliJ Platform SDK + + + +
    \ No newline at end of file diff --git a/code_samples/framework/resources/META-INF/pluginIcon.svg b/code_samples/framework/resources/META-INF/pluginIcon.svg new file mode 100644 index 000000000..613290897 --- /dev/null +++ b/code_samples/framework/resources/META-INF/pluginIcon.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code_samples/framework/resources/icons/sdk_16.svg b/code_samples/framework/resources/icons/sdk_16.svg new file mode 100644 index 000000000..011462b8a --- /dev/null +++ b/code_samples/framework/resources/icons/sdk_16.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/code_samples/framework/src/icons/SdkIcons.java b/code_samples/framework/src/icons/SdkIcons.java new file mode 100644 index 000000000..1475ff91d --- /dev/null +++ b/code_samples/framework/src/icons/SdkIcons.java @@ -0,0 +1,11 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + +package icons; + +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; + +public class SdkIcons { + public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); +} diff --git a/code_samples/framework/src/com/intellij/tutorials/framework/DemoFramework.java b/code_samples/framework/src/org/intellij/sdk/framework/DemoFramework.java similarity index 73% rename from code_samples/framework/src/com/intellij/tutorials/framework/DemoFramework.java rename to code_samples/framework/src/org/intellij/sdk/framework/DemoFramework.java index 31f47f9ca..1f6218927 100644 --- a/code_samples/framework/src/com/intellij/tutorials/framework/DemoFramework.java +++ b/code_samples/framework/src/org/intellij/sdk/framework/DemoFramework.java @@ -1,4 +1,6 @@ -package com.intellij.tutorials.framework; +// Copyright 2000-2019 JetBrains s.r.o. 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.framework; import com.intellij.framework.FrameworkTypeEx; import com.intellij.framework.addSupport.*; @@ -6,15 +8,14 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel; import com.intellij.openapi.module.*; import com.intellij.openapi.roots.*; +import icons.SdkIcons; import org.jetbrains.annotations.*; import javax.swing.*; -/** - * @author Anna Bulenkova - */ public class DemoFramework extends FrameworkTypeEx { - public static final String FRAMEWORK_ID = "Demo"; + + public static final String FRAMEWORK_ID = "org.intellij.sdk.framework.DemoFramework"; protected DemoFramework() { super(FRAMEWORK_ID); @@ -37,14 +38,15 @@ public class DemoFramework extends FrameworkTypeEx { @Nullable @Override public JComponent createComponent() { - return new JCheckBox("Extra Option"); + return new JCheckBox("SDK Extra Option"); } @Override public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ModifiableModelsProvider provider) { - //do what you want here: setup a library, generate a specific file, etc + // This is the place to set up a library, generate a specific file, etc + // and actually add framework support to a module. } }; } @@ -59,12 +61,12 @@ public class DemoFramework extends FrameworkTypeEx { @NotNull @Override public String getPresentableName() { - return "Demo Framework"; + return "SDK Demo Framework"; } @NotNull @Override public Icon getIcon() { - return AllIcons.Providers.Apache; + return SdkIcons.Sdk_default_icon; } } diff --git a/tutorials/framework.md b/tutorials/framework.md index 34f866d52..e8c19b4a7 100644 --- a/tutorials/framework.md +++ b/tutorials/framework.md @@ -2,14 +2,10 @@ title: Supporting Frameworks --- -The following tutorial meant to show 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. ## 1. Creating a new framework - -In oder to make a custom framework available and configurable for a project -[FrameworkTypeEx](upsource:///java/idea-ui/src/com/intellij/framework/FrameworkTypeEx.java) -class needs to be extended: - +In oder to make a custom framework available and configurable for a project the [FrameworkTypeEx](upsource:///java/idea-ui/src/com/intellij/framework/FrameworkTypeEx.java) class needs to be extended, in this example to make the [DemoFramework](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework/src/com/intellij/tutorials/framework/DemoFramework.java) class. ```java public class DemoFramework extends FrameworkTypeEx { @@ -17,64 +13,51 @@ public class DemoFramework extends FrameworkTypeEx { ``` ## 2. Registering framework - -The newly created framework should be registered as an extension point by putting *framework.type* attribute into `` section of +The newly created framework class should be registered as an extension point by putting *framework.type* attribute into `` section of the [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework/resources/META-INF/plugin.xml) configuration file: - ```xml - + ``` ## 3. Setting up mandatory attributes - -The framework component should have a unique name passed as a string literal to the constructor: - +The framework component should have a unique name passed as a string literal to the constructor. +It is best if this is the FQN name of the class: ```java public class DemoFramework extends FrameworkTypeEx { - public static final String FRAMEWORK_ID = "Demo"; + public static final String FRAMEWORK_ID = "org.intellij.sdk.framework.DemoFramework"; protected DemoFramework() { super(FRAMEWORK_ID); } } ``` -*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: ```java public class DemoFramework extends FrameworkTypeEx { - public static final String FRAMEWORK_ID = "Demo"; - protected DemoFramework() { - super(FRAMEWORK_ID); - } + @NotNull + @Override + public String getPresentableName() { + return "SDK Demo Framework"; + } - @NotNull - @Override - public String getPresentableName() { - return "Demo Framework"; - } - - @NotNull - @Override - public Icon getIcon() { - return AllIcons.Providers.Apache; - } + @NotNull + @Override + public Icon getIcon() { + return SdkIcons.Sdk_default_icon; + } } ``` ## 4. Creating provider for enabling framework support - -To make framework set up available while executing project creating steps -`public FrameworkSupportInModuleProvider createProvider();` -of the -[DemoFramework](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework/src/com/intellij/tutorials/framework/DemoFramework.java) -must be implemented: - +To make the framework set up available while executing the steps to create a project, the +`DemoFramework.createProvider()` method must be implemented to return an object of type [FrameworkSupportInModuleConfigurable](upsource:///java/idea-ui/src/com/intellij/framework/addSupport/FrameworkSupportInModuleConfigurable.java), which adds the framework to a module. +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 @NotNull @@ -94,12 +77,13 @@ public FrameworkSupportInModuleProvider createProvider() { @Nullable @Override public JComponent createComponent() { - return new JCheckBox("Extra Option"); + return new JCheckBox("SDK Extra Option"); } @Override public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ModifiableModelsProvider provider) { - //do what you want here: setup a library, generate a specific file, etc + // This is the place to set up a library, generate a specific file, etc + // and actually add framework support to a module. } }; } @@ -112,7 +96,7 @@ public FrameworkSupportInModuleProvider createProvider() { } ``` -After compiling and running the code sample above an extra option for configuring the newly created custom framework should be available in the Project Wizard: +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: ![Custom Framework Support](framework/img/custom_framework.png) ---------- diff --git a/tutorials/framework/img/custom_framework.png b/tutorials/framework/img/custom_framework.png index f02a54045..223fa9d52 100644 Binary files a/tutorials/framework/img/custom_framework.png and b/tutorials/framework/img/custom_framework.png differ