Refactored for Gradle

This commit is contained in:
JohnHake 2019-08-23 16:45:17 -07:00
parent f7c6be6040
commit ce44d4822f
7 changed files with 144 additions and 57 deletions

View File

@ -1,18 +1,43 @@
<!-- 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. -->
<idea-plugin>
<id>com.intellij.demo.framework</id>
<name>Framework example</name>
<version>1.0</version>
<vendor>JetBrains</vendor>
<description>Demonstrates basic Framework support with custom Configurable</description>
<!-- Unique id for this plugin. Must stay constant for the life of the plugin. -->
<id>org.intellij.sdk.framework</id>
<!-- Text to display as name on Preferences/Settings | Plugin page -->
<name>SDK: Framework Sample Project</name>
<!-- The version of this plugin -->
<version>2.0</version>
<!-- Compatible with the following versions of IntelliJ Platform -->
<idea-version since-build="131"/>
<!-- Product and plugin compatibility requirements -->
<depends>com.intellij.modules.java</depends>
<!-- Text to display as description on Preferences/Settings | Plugin page -->
<description>
<![CDATA[
Demonstrates basic Framework support with custom Configurable...
]]>
</description>
<change-notes>
<![CDATA[
<ul>
<li><b>2.0.0</b> Convert to Gradle-based plugin, rename to framework_basics, change plugin ID</li>
<li><b>1.0.0</b> Release 2018.3 and earlier.</li>
</ul>
]]>
</change-notes>
<!-- Text to display as company information on Preferences/Settings | Plugin page -->
<vendor url="https://plugins.jetbrains.com">IntelliJ Platform SDK</vendor>
<extensions defaultExtensionNs="com.intellij">
<framework.type implementation="com.intellij.tutorials.framework.DemoFramework"/>
<framework.type implementation="org.intellij.sdk.framework.DemoFramework"/>
</extensions>
</idea-plugin>

View File

@ -0,0 +1,58 @@
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="80" viewBox="0 0 81 80">
<defs>
<linearGradient id="pluginsdk_80-a" x1="-.031%" x2="100.053%" y1="49.963%" y2="49.963%">
<stop offset="25.81%" stop-color="#F97A12"/>
<stop offset="45.91%" stop-color="#B07B58"/>
<stop offset="72.41%" stop-color="#577BAE"/>
<stop offset="91.05%" stop-color="#1E7CE5"/>
<stop offset="100%" stop-color="#087CFA"/>
</linearGradient>
<linearGradient id="pluginsdk_80-b" x1="27.55%" x2="82.223%" y1="34.514%" y2="77.605%">
<stop offset="0%" stop-color="#F97A12"/>
<stop offset="7.18%" stop-color="#CB7A3E"/>
<stop offset="15.41%" stop-color="#9E7B6A"/>
<stop offset="24.2%" stop-color="#757B91"/>
<stop offset="33.44%" stop-color="#537BB1"/>
<stop offset="43.24%" stop-color="#387CCC"/>
<stop offset="53.81%" stop-color="#237CE0"/>
<stop offset="65.52%" stop-color="#147CEF"/>
<stop offset="79.25%" stop-color="#0B7CF7"/>
<stop offset="100%" stop-color="#087CFA"/>
</linearGradient>
<linearGradient id="pluginsdk_80-c" x1="63.121%" x2="40.793%" y1="97.699%" y2="-6.587%">
<stop offset="0%" stop-color="#FE315D"/>
<stop offset="7.84%" stop-color="#CB417E"/>
<stop offset="16.01%" stop-color="#9E4E9B"/>
<stop offset="24.74%" stop-color="#755BB4"/>
<stop offset="33.92%" stop-color="#5365CA"/>
<stop offset="43.65%" stop-color="#386DDB"/>
<stop offset="54.14%" stop-color="#2374E9"/>
<stop offset="65.76%" stop-color="#1478F3"/>
<stop offset="79.4%" stop-color="#0B7BF8"/>
<stop offset="100%" stop-color="#087CFA"/>
</linearGradient>
<linearGradient id="pluginsdk_80-d" x1="25.331%" x2="93.854%" y1="24.119%" y2="132.621%">
<stop offset="0%" stop-color="#FE315D"/>
<stop offset="4.023%" stop-color="#F63462"/>
<stop offset="10.37%" stop-color="#DF3A71"/>
<stop offset="16.67%" stop-color="#C24383"/>
<stop offset="29.12%" stop-color="#AD4A91"/>
<stop offset="54.98%" stop-color="#755BB4"/>
<stop offset="91.75%" stop-color="#1D76ED"/>
<stop offset="100%" stop-color="#087CFA"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<g fill-rule="nonzero" transform="translate(8 8)">
<path fill="url(#pluginsdk_80-a)" d="M6.08754566,64 L2.66453526e-15,59.1000946 L0,26.7918961 L30,38.6703369 L10.1403967,64 L6.08754566,64 Z"/>
<path fill="url(#pluginsdk_80-b)" d="M20.9524706,64 L52.2740919,31.9159091 L37.6708832,0.460194805 L38.0580944,1.33226763e-15 L64,0 L64,64 L20.9524706,64 Z"/>
<path fill="url(#pluginsdk_80-c)" d="M34.4123783,0 L64,0 L64,28.0366227 L49.0078336,44 L34,0.44696173 L34.4123783,0 Z"/>
<path fill="url(#pluginsdk_80-d)" d="M30.3358775,64 L0,64 L0,49.9709549 L6.23437817,29.2830519 L0,27.1596093 L0,0 L39.4697238,0 L58,21.3844805 L30.5381317,63.9259091 L30.3358775,64 Z"/>
</g>
<g fill-rule="nonzero" transform="translate(12 12)">
<rect width="56" height="56" fill="#000"/>
<rect width="22" height="4" x="4" y="46" fill="#FFFEFE"/>
<path fill="#FFFEFE" d="M11.128,25.28 C8.584,25.28 6.016,24.392 4,22.592 L6.184,19.976 C7.696,21.224 9.28,22.016 11.2,22.016 C12.712,22.016 13.624,21.416 13.624,20.432 L13.624,20.384 C13.624,19.448 13.048,18.968 10.24,18.248 C6.856,17.384 4.672,16.448 4.672,13.112 L4.672,13.064 C4.672,10.016 7.12,8 10.552,8 C13,8 15.088,8.768 16.792,10.136 L14.872,12.92 C13.384,11.888 11.92,11.264 10.504,11.264 C9.088,11.264 8.344,11.912 8.344,12.728 L8.344,12.776 C8.344,13.88 9.064,14.24 11.968,14.984 C15.376,15.872 17.296,17.096 17.296,20.024 L17.296,20.072 C17.296,23.408 14.752,25.28 11.128,25.28 Z M19.512,25.04 L19.512,8.24 L26.064,8.24 C31.344,8.24 34.992,11.864 34.992,16.592 L34.992,16.64 C34.992,21.368 31.344,25.04 26.064,25.04 L19.512,25.04 Z M26.064,11.576 L23.208,11.576 L23.208,21.704 L26.064,21.704 C29.088,21.704 31.128,19.664 31.128,16.688 L31.128,16.64 C31.128,13.664 29.088,11.576 26.064,11.576 Z M37.28,25.04 L37.28,8.24 L40.976,8.24 L40.976,15.584 L47.744,8.24 L52.28,8.24 L45.416,15.368 L52.568,25.04 L48.128,25.04 L42.92,17.888 L40.976,19.904 L40.976,25.04 L37.28,25.04 Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" transform="translate(1 1)">
<rect width="14" height="14" fill="#000"/>
<rect width="5" height="1" x="1" y="11" fill="#FFFEFE"/>
<path fill="#FFFEFE" d="M1,5.96113281 L1.85546875,5.96113281 C1.89648438,6.30390625 2.2421875,6.52363281 2.74023438,6.52363281 C3.20019531,6.52363281 3.52539063,6.30097656 3.52539063,5.98164062 C3.52539063,5.71210937 3.31445313,5.55683594 2.79589844,5.44550781 L2.24511719,5.32832031 C1.47460938,5.1671875 1.09667969,4.76582031 1.09667969,4.12128906 C1.09667969,3.32441406 1.73828125,2.8 2.71386719,2.8 C3.64550781,2.8 4.3046875,3.32148437 4.33105469,4.07441406 L3.49902344,4.07441406 C3.45800781,3.74042969 3.14746094,3.51777344 2.71972656,3.51777344 C2.27734375,3.51777344 1.984375,3.72285156 1.984375,4.04511719 C1.984375,4.30585937 2.18652344,4.45527344 2.68164063,4.56074219 L3.19140625,4.66914062 C4.04101563,4.84785156 4.40722656,5.2140625 4.40722656,5.8703125 C4.40722656,6.72285156 3.75390625,7.24433594 2.69335938,7.24433594 C1.68554688,7.24433594 1.03222656,6.74921875 1,5.96113281 Z M5.19603365,2.90546875 L6.86009615,2.90546875 C8.11693209,2.90546875 8.84349459,3.6671875 8.84349459,4.99140625 C8.84349459,6.36542969 8.12572115,7.1359375 6.86009615,7.1359375 L5.19603365,7.1359375 L5.19603365,2.90546875 Z M6.08079927,3.66132812 L6.08079927,6.38007812 L6.71947115,6.38007812 C7.50169771,6.38007812 7.94115084,5.89960937 7.94115084,5.00605469 C7.94115084,4.15058594 7.48704927,3.66132812 6.71947115,3.66132812 L6.08079927,3.66132812 Z M10.5170673,7.1359375 L9.63230167,7.1359375 L9.63230167,2.90839844 L10.5170673,2.90839844 L10.5170673,4.7921875 L10.5698017,4.7921875 L12.1313251,2.90839844 L13.1157001,2.90839844 L11.5746845,4.76289062 L13.2240985,7.1359375 L12.1635517,7.1359375 L10.9360126,5.36640625 L10.5170673,5.86152344 L10.5170673,7.1359375 Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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");
}

View File

@ -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;
}
}

View File

@ -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 `<extensions>` section of
The newly created framework class should be registered as an extension point by putting *framework.type* attribute into `<extensions>` 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
<extensions defaultExtensionNs="com.intellij">
<framework.type implementation="com.intellij.tutorials.framework.DemoFramework"/>
<framework.type implementation="org.intellij.sdk.framework.DemoFramework"/>
</extensions>
```
## 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 "Demo Framework";
return "SDK Demo Framework";
}
@NotNull
@Override
public Icon getIcon() {
return AllIcons.Providers.Apache;
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)
----------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 153 KiB