mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
replace NBSP with plain space
This commit is contained in:
parent
6883d46487
commit
6c57d648a6
@ -22,7 +22,7 @@ Most of the existing functionality of IntelliJ IDEA is covered by functional tes
|
||||
We're generally pretty lax about code formatting, but at least the following conventions must be observed:
|
||||
|
||||
- 2 space indents in source files
|
||||
- **my** prefix for instance variables and **our** prefix for class variables
|
||||
- **my** prefix for instance variables and **our** prefix for class variables
|
||||
- new source code files must include a copyright statement with the Apache 2 license and the name of the contributor.
|
||||
|
||||
The easiest way to follow our code formatting guidelines is to reformat your code submissions using the shared code style, which is included in the IntelliJ IDEA Community Edition project directory.
|
||||
|
@ -8,7 +8,7 @@ Please make sure to read the [Code of Conduct](/CODE_OF_CONDUCT.md).
|
||||
## Participate in the Community
|
||||
|
||||
### Participate in Newsgroups and Forums
|
||||
There are several community [forums and newsgroups](https://intellij-support.jetbrains.com/hc/en-us/community/topics) you can join to discuss the IntelliJ Platform. The forums are an excellent source for users and contributors interested in having technical discussions, answering questions, or resolving potential issues for newcomers.
|
||||
There are several community [forums and newsgroups](https://intellij-support.jetbrains.com/hc/en-us/community/topics) you can join to discuss the IntelliJ Platform. The forums are an excellent source for users and contributors interested in having technical discussions, answering questions, or resolving potential issues for newcomers.
|
||||
|
||||
### Link to jetbrains.org
|
||||
The success of any open source project depends on the number of people who use the product and contribute back to the project. By linking to jetbrains.org, you can increase the chances of a new user or contributor finding out about the project and joining the community.
|
||||
@ -29,20 +29,20 @@ Screencasts have recently become very popular as a way to show other developers
|
||||
## Contribute Code
|
||||
|
||||
### File a Bug Report
|
||||
Bug reports take little time to file and are very helpful to developers. This is one of the easiest contributions you can make. When you discover a problem with the IDE or the platform, please report it. Make sure you provide information about your environment (OS, JDK version), steps to reproduce the issue, as well as a written description of the problem. You can file a bug in our [YouTrack issue tracker](https://youtrack.jetbrains.com/issues/IDEA).
|
||||
Bug reports take little time to file and are very helpful to developers. This is one of the easiest contributions you can make. When you discover a problem with the IDE or the platform, please report it. Make sure you provide information about your environment (OS, JDK version), steps to reproduce the issue, as well as a written description of the problem. You can file a bug in our [YouTrack issue tracker](https://youtrack.jetbrains.com/issues/IDEA).
|
||||
Before submitting an issue, please search for already submitted ones describing the same problem - and if you find one, feel free to vote for it.
|
||||
|
||||
### Help Triage Existing Bug Reports
|
||||
Over the years, users have submitted thousands of issues to the IntelliJ issue tracker. Many of the unresolved issues are no longer applicable to the latest version of IntelliJ IDEA, are duplicates, or require additional information to be resolved. Leaving comments notifying about the status of such issues helps the team keep the issue tracker clean and useful for everyone.
|
||||
|
||||
### Write a Plugin
|
||||
One of the best ways to contribute a larger piece of code, adding extra functionality to IntelliJ IDEA or any of the other IntelliJ Platform based IDEs, is by writing a plug-in. You can submit a plug-in to the [JetBrains Plugins Repository](https://plugins.jetbrains.com/), making it available for all users. When writing a plug-in, you have control over the code and don't need to sign the contribution agreement.
|
||||
One of the best ways to contribute a larger piece of code, adding extra functionality to IntelliJ IDEA or any of the other IntelliJ Platform based IDEs, is by writing a plug-in. You can submit a plug-in to the [JetBrains Plugins Repository](https://plugins.jetbrains.com/), making it available for all users. When writing a plug-in, you have control over the code and don't need to sign the contribution agreement.
|
||||
|
||||
### Submit a Patch
|
||||
If you would like to improve the code in the IntelliJ Platform or the core functionality of IntelliJ IDEA, you can submit a patch in the [YouTrack bug database](https://youtrack.jetbrains.com/issues/IDEA). You can either file a new issue with the patch attached, or attach a patch to an issue submitted by another user. When writing a patch, please make sure to follow the [IntelliJ Platform Coding Guidelines](intellij_coding_guidelines.md).
|
||||
If you would like to improve the code in the IntelliJ Platform or the core functionality of IntelliJ IDEA, you can submit a patch in the [YouTrack bug database](https://youtrack.jetbrains.com/issues/IDEA). You can either file a new issue with the patch attached, or attach a patch to an issue submitted by another user. When writing a patch, please make sure to follow the [IntelliJ Platform Coding Guidelines](intellij_coding_guidelines.md).
|
||||
|
||||
Alternatively, you can fork the [IntelliJ IDEA Community Edition repository on GitHub](https://github.com/JetBrains/intellij-community), make the changes in your fork and send us a pull request.
|
||||
A developer will review your patch and, if it meets the [quality criteria](intellij_coding_guidelines.md) and fits well with the rest of the code, you'll be notified about the acceptance of the patch. You will also need to sign the [JetBrains Contributor License Agreement (CLA)](https://www.jetbrains.com/agreements/cla/) to complete your contribution.
|
||||
Alternatively, you can fork the [IntelliJ IDEA Community Edition repository on GitHub](https://github.com/JetBrains/intellij-community), make the changes in your fork and send us a pull request.
|
||||
A developer will review your patch and, if it meets the [quality criteria](intellij_coding_guidelines.md) and fits well with the rest of the code, you'll be notified about the acceptance of the patch. You will also need to sign the [JetBrains Contributor License Agreement (CLA)](https://www.jetbrains.com/agreements/cla/) to complete your contribution.
|
||||
|
||||
### Become a Committer
|
||||
Developers with a long history of submitting high-quality patches can gain direct commit rights.
|
||||
|
@ -3,17 +3,17 @@ title: Code Inspections
|
||||
---
|
||||
<!-- 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. -->
|
||||
|
||||
The IntelliJ Platform provides tools designed for static code analysis called _code inspections_, which help the user maintain and clean up code without actually executing it.
|
||||
The IntelliJ Platform provides tools designed for static code analysis called _code inspections_, which help the user maintain and clean up code without actually executing it.
|
||||
Custom code inspections can be implemented as IntelliJ Platform plugins.
|
||||
Examples of the plugin approach are the IntelliJ Platform SDK code samples [inspection_basics](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/inspection_basics) and [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection).
|
||||
In addition, the comparing_references_inspection code sample demonstrates implementing a unit test.
|
||||
|
||||
You can also create custom inspections through the IntelliJ IDEA user interface.
|
||||
See [Code Inspection](https://www.jetbrains.com/idea/webhelp/code-inspection.html) and [Creating Custom Inspections](https://www.jetbrains.com/idea/help/creating-custom-inspections.html) for more information.
|
||||
You can also create custom inspections through the IntelliJ IDEA user interface.
|
||||
See [Code Inspection](https://www.jetbrains.com/idea/webhelp/code-inspection.html) and [Creating Custom Inspections](https://www.jetbrains.com/idea/help/creating-custom-inspections.html) for more information.
|
||||
|
||||
## Creating an Inspection Plugin
|
||||
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample adds a new inspection to the **Java | Probable Bugs** group in the [Inspections list](https://www.jetbrains.com/help/idea/inspections-settings.html).
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample adds a new inspection to the **Java | Probable Bugs** group in the [Inspections list](https://www.jetbrains.com/help/idea/inspections-settings.html).
|
||||
The inspection reports when the `==` or `!=` operator is used between Java expressions of reference types.
|
||||
It illustrates the components for a custom inspection plugin:
|
||||
* Describing an [inspection](#plugin-configuration-file) in the plugin configuration file.
|
||||
@ -23,7 +23,7 @@ It illustrates the components for a custom inspection plugin:
|
||||
Quick fixes are displayed to the user like [intentions](code_intentions.md).
|
||||
* Implementing an [inspection preferences panel](#inspection-preferences-panel) to display information about the inspection.
|
||||
* Writing an HTML [description](#inspection-description) of the inspection for display in the inspection preferences panel.
|
||||
* Optionally, create a [unit test](#inspection-unit-test) for the plugin.
|
||||
* Optionally, create a [unit test](#inspection-unit-test) for the plugin.
|
||||
|
||||
Although the IntelliJ Platform SDK code samples illustrate implementations of these components, it is often useful to see examples of inspections implemented in the _intellij_community_ code base.
|
||||
This process can help find inspection descriptions and implementations based on what is visible in the IDE UI.
|
||||
@ -41,7 +41,7 @@ The overall approach works for inspections aimed at other languages as well.
|
||||
* Use the `implementationClass` text as the [target of a class search](https://www.jetbrains.com/help/idea/searching-everywhere.html#Searching_Everywhere.xml) in the _intellij_community_ codebase to find the Java implementation file.
|
||||
|
||||
## Creating an Inspection
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample reports when the `==` or `!=` operators are used between Java expressions of reference types.
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample reports when the `==` or `!=` operators are used between Java expressions of reference types.
|
||||
The user can apply a quick fix to change `a==b` to `a.equals(b)`, or `a!=b` to `!a.equals(b)`.
|
||||
|
||||
The details of the `comparing_references_inspection` implementation illustrate the components of an inspection plugin.
|
||||
@ -143,39 +143,39 @@ The `comparing_references_inspection` tests run the inspection on the `*.java` f
|
||||
|
||||
|
||||
## Running the Comparing References Inspection Code Sample
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample adds a new inspection to the **Java | Probable Bugs** group in the [Inspections list](https://www.jetbrains.com/help/idea/inspections-settings.html).
|
||||
The [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) code sample adds a new inspection to the **Java | Probable Bugs** group in the [Inspections list](https://www.jetbrains.com/help/idea/inspections-settings.html).
|
||||
The inspection reports when the `==` or `!=` operator is used between Java expressions of reference types.
|
||||
|
||||
To run the sample plugin:
|
||||
* Start **IntelliJ IDEA**, open the `intellij-sdk-docs` project, and highlight the [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) module.
|
||||
* Open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog and ensure that the project settings are valid for your environment.
|
||||
* If necessary, modify the [Run/Debug Configurations](https://www.jetbrains.com/idea/webhelp/run-debug-configuration-plugin.html) for the `comparing_references_inspection` module.
|
||||
* Run the plugin by choosing **Run** on the main menu.
|
||||
* Start **IntelliJ IDEA**, open the `intellij-sdk-docs` project, and highlight the [comparing_references_inspection](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection) module.
|
||||
* Open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog and ensure that the project settings are valid for your environment.
|
||||
* If necessary, modify the [Run/Debug Configurations](https://www.jetbrains.com/idea/webhelp/run-debug-configuration-plugin.html) for the `comparing_references_inspection` module.
|
||||
* Run the plugin by choosing **Run** on the main menu.
|
||||
|
||||
### Configuring the Plugin
|
||||
|
||||
Once the plugin is launched, you can set the plugin options.
|
||||
You can specify the Java classes to participate in the code inspection and the severity level of the found probable bugs.
|
||||
|
||||
On the IDEA main menu, open the **Preferences | Editor | Inspections** dialog.
|
||||
In the list of the IntelliJ IDEA _Java_ inspections, expand the _Probable bugs_ node, and then click _SDK: '==' or '!=' instead of 'equals()'_.
|
||||
On the IDEA main menu, open the **Preferences | Editor | Inspections** dialog.
|
||||
In the list of the IntelliJ IDEA _Java_ inspections, expand the _Probable bugs_ node, and then click _SDK: '==' or '!=' instead of 'equals()'_.
|
||||
|
||||

|
||||
|
||||
Under **Options**, you can specify the following plugin settings:
|
||||
* From the **Severity** list, select the severity level of probable bugs the plugin finds such as Warning, Info, etc.
|
||||
* In the text box under **Severity**, specify the semicolon separated list of Java classes to participate in this code inspection.
|
||||
* When finished, click **OK**.
|
||||
Under **Options**, you can specify the following plugin settings:
|
||||
* From the **Severity** list, select the severity level of probable bugs the plugin finds such as Warning, Info, etc.
|
||||
* In the text box under **Severity**, specify the semicolon separated list of Java classes to participate in this code inspection.
|
||||
* When finished, click **OK**.
|
||||
|
||||
### How does it work?
|
||||
|
||||
The plugin inspects your code opened in the IntelliJ IDEA editor or the code you are typing.
|
||||
The plugin highlights the code fragments where two variables of the reference type are separated by `==` or `!=` and proposes to replace this code fragment with `.equals()`:
|
||||
The plugin inspects your code opened in the IntelliJ IDEA editor or the code you are typing.
|
||||
The plugin highlights the code fragments where two variables of the reference type are separated by `==` or `!=` and proposes to replace this code fragment with `.equals()`:
|
||||
|
||||

|
||||
|
||||
In this example, the `str1` and `str2` are variables of the String type.
|
||||
Clicking _SDK: Use equals()_ replaces:
|
||||
In this example, the `str1` and `str2` are variables of the String type.
|
||||
Clicking _SDK: Use equals()_ replaces:
|
||||
|
||||
```java
|
||||
return (str1==str2);
|
||||
|
@ -3,37 +3,37 @@ title: Code Intentions
|
||||
---
|
||||
<!-- 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. -->
|
||||
|
||||
This topic describes the [conditional_operator_intention](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/conditional_operator_intention), a sample plugin that adds a new [intention action](https://www.jetbrains.com/help/idea/intention-actions.html) to the IntelliJ Platform Intentions list.
|
||||
This topic describes the [conditional_operator_intention](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/conditional_operator_intention), a sample plugin that adds a new [intention action](https://www.jetbrains.com/help/idea/intention-actions.html) to the IntelliJ Platform Intentions list.
|
||||
In addition, the sample plugin contains a JUnit-based test.
|
||||
|
||||
## About Intention Actions
|
||||
|
||||
The **IntelliJ Platform** analyzes your code and helps handle situations that may result in errors.
|
||||
When a possible problem is suspected, the IDE suggests an appropriate intention action, denoted with special icons.
|
||||
For more information, refer to [Intention Actions](https://www.jetbrains.com/help/idea/intention-actions.html) in the **IntelliJ IDEA** Web Help.
|
||||
The **IntelliJ Platform** analyzes your code and helps handle situations that may result in errors.
|
||||
When a possible problem is suspected, the IDE suggests an appropriate intention action, denoted with special icons.
|
||||
For more information, refer to [Intention Actions](https://www.jetbrains.com/help/idea/intention-actions.html) in the **IntelliJ IDEA** Web Help.
|
||||
|
||||
You can view a list of all available intention actions using the [Intention List](https://www.jetbrains.com/help/idea/intention-actions.html#intention-settings) provided by the IDE.
|
||||
You can view a list of all available intention actions using the [Intention List](https://www.jetbrains.com/help/idea/intention-actions.html#intention-settings) provided by the IDE.
|
||||
|
||||
**To display Intention List**
|
||||
|
||||
1. Open the **Settings** dialog box.
|
||||
2. Under **IDE Settings**, click **Intentions**. This displays the list of all intention actions currently available in **IntelliJ IDEA**.
|
||||
1. Open the **Settings** dialog box.
|
||||
2. Under **IDE Settings**, click **Intentions**. This displays the list of all intention actions currently available in **IntelliJ IDEA**.
|
||||
- The intention actions are grouped according to the areas of their use.
|
||||
- To enable/disable an intention action, select/deselect the check box to its left.
|
||||
|
||||
## Techniques Used
|
||||
|
||||
The [conditional_operator_intention](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/conditional_operator_intention) sample plugin illustrates the use of the following techniques:
|
||||
The [conditional_operator_intention](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/conditional_operator_intention) sample plugin illustrates the use of the following techniques:
|
||||
|
||||
- How to analyze a [PSI tree](/basics/architectural_overview/psi_files.md).
|
||||
- How to analyze a [PSI tree](/basics/architectural_overview/psi_files.md).
|
||||
- How to find a Java token of interest in the PSI tree.
|
||||
- How to invoke a quick fix action for a token element under cursor using the [`PsiElementBaseIntentionAction`](upsource:///platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java) class.
|
||||
- How to create a JUnit test for this plugin using the [`IdeaTestFixtureFactory`](upsource:///platform/testFramework/src/com/intellij/testFramework/fixtures/IdeaTestFixtureFactory.java) class.
|
||||
- How to invoke a quick fix action for a token element under cursor using the [`PsiElementBaseIntentionAction`](upsource:///platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java) class.
|
||||
- How to create a JUnit test for this plugin using the [`IdeaTestFixtureFactory`](upsource:///platform/testFramework/src/com/intellij/testFramework/fixtures/IdeaTestFixtureFactory.java) class.
|
||||
|
||||
## Sample Plugin
|
||||
|
||||
The **ConditionalOperatorConverter** sample plugin is available in the `<%IntelliJ SDK Docs project%>/code_samples/conditional_operator_intention` directory.
|
||||
When launched, this plugin adds the **Convert ternary operator if statement** item to the **Conditional Operator** node in the IDEA Intentions list:
|
||||
The **ConditionalOperatorConverter** sample plugin is available in the `<%IntelliJ SDK Docs project%>/code_samples/conditional_operator_intention` directory.
|
||||
When launched, this plugin adds the **Convert ternary operator if statement** item to the **Conditional Operator** node in the IDEA Intentions list:
|
||||
|
||||

|
||||
|
||||
@ -41,14 +41,14 @@ When launched, this plugin adds the **Convert ternary operator if statement**
|
||||
|
||||
**To run the sample plugin**
|
||||
|
||||
1. Start **IntelliJ IDEA** and open the **conditionalOperatorConvertor** plugin project saved into the `<%IntelliJ SDK Docs project%>/code_samples/conditional_operator_intention` directory.
|
||||
2. Open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog and ensure that the project settings are valid for your environment.
|
||||
3. If necessary, modify the [Run/Debug Configurations](https://www.jetbrains.com/idea/webhelp/run-debug-configuration-plugin.html) and Run the plugin by choosing the **Run** on the main menu.
|
||||
1. Start **IntelliJ IDEA** and open the **conditionalOperatorConvertor** plugin project saved into the `<%IntelliJ SDK Docs project%>/code_samples/conditional_operator_intention` directory.
|
||||
2. Open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog and ensure that the project settings are valid for your environment.
|
||||
3. If necessary, modify the [Run/Debug Configurations](https://www.jetbrains.com/idea/webhelp/run-debug-configuration-plugin.html) and Run the plugin by choosing the **Run** on the main menu.
|
||||
|
||||
#### How does it work?
|
||||
|
||||
The plugin analyzes symbols under the cursor in your code opened in the IDEA editor.
|
||||
If the cursor is positioned on the "?" conditional operator, **IntelliJ IDEA** proposes to replace this conditional (ternary) operator with the "if-then-else" statement:
|
||||
If the cursor is positioned on the "?" conditional operator, **IntelliJ IDEA** proposes to replace this conditional (ternary) operator with the "if-then-else" statement:
|
||||
|
||||

|
||||
|
||||
@ -70,7 +70,7 @@ if ((n>=0)) {
|
||||
|
||||
##### Testing the Plugin
|
||||
|
||||
The sample plugin contains the `YourTest` Java class in the `testSource/testPlugin/` package and the test data in the `testData/` directory.
|
||||
To perform the plugin test, run the `YourTest.test()` method.
|
||||
The sample plugin contains the `YourTest` Java class in the `testSource/testPlugin/` package and the test data in the `testData/` directory.
|
||||
To perform the plugin test, run the `YourTest.test()` method.
|
||||
|
||||
For detailed information about testing and all related procedures, refer to [Testing](https://www.jetbrains.com/help/idea/performing-tests.html) in the **IntelliJ IDEA** Web Help.
|
||||
For detailed information about testing and all related procedures, refer to [Testing](https://www.jetbrains.com/help/idea/performing-tests.html) in the **IntelliJ IDEA** Web Help.
|
||||
|
@ -5,7 +5,7 @@ title: Tool Windows
|
||||
|
||||
## Tool Windows
|
||||
|
||||
_Tool windows_ are child windows of the IDE used to display information. These windows generally have their own toolbars (referred to as _tool window bars_) along the outer edges of the main window containing one or more _tool window buttons_, which activate panels displayed on the left, bottom and right sides of the main IDE window. For detailed information about tool windows, please see [IntelliJ IDEA Web Help ](https://www.jetbrains.com/idea/help/tool-windows.html).
|
||||
_Tool windows_ are child windows of the IDE used to display information. These windows generally have their own toolbars (referred to as _tool window bars_) along the outer edges of the main window containing one or more _tool window buttons_, which activate panels displayed on the left, bottom and right sides of the main IDE window. For detailed information about tool windows, please see [IntelliJ IDEA Web Help ](https://www.jetbrains.com/idea/help/tool-windows.html).
|
||||
|
||||
Each side contains two tool window groups, the primary and the secondary one, and only one tool window from each group can be active at a time.
|
||||
|
||||
@ -66,22 +66,22 @@ If closing tabs is enabled in general, a plugin can disable closing of specific
|
||||
|
||||
## How to Create a Tool Window?
|
||||
|
||||
The IntelliJ Platform provides the `com.intellij.toolWindow` [extension point](/basics/plugin_structure/plugin_extensions.md) to create and configure custom tool windows. This extension point is declared using the [`ToolWindowEP`](upsource:///platform/platform-api/src/com/intellij/openapi/wm/ToolWindowEP.java) bean class.
|
||||
The IntelliJ Platform provides the `com.intellij.toolWindow` [extension point](/basics/plugin_structure/plugin_extensions.md) to create and configure custom tool windows. This extension point is declared using the [`ToolWindowEP`](upsource:///platform/platform-api/src/com/intellij/openapi/wm/ToolWindowEP.java) bean class.
|
||||
|
||||
### Creation of Plugin
|
||||
|
||||
To create a plugin that displays a custom tool window, perform the following steps:
|
||||
|
||||
1. In a plugin project, create a class implementing [`ToolWindowFactory`](upsource:///platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java).
|
||||
2. In this class, override the `createToolWindowContent` method. This method specifies the content for the tool window.
|
||||
3. In the plugin configuration file `plugin.xml`, create the `<extensions defaultExtensionNs="com.intellij">...</extensions>` section.
|
||||
4. To this section, add the `<toolWindow>` element, and for this element, set the following attributes declared in the `ToolWindowEP` bean class:
|
||||
- `id` (required): specifies the tool window caption.
|
||||
- `anchor` (required): specifies the tool window bar where the tool window button will be displayed. Possible values: "left", "right", or "bottom."
|
||||
- `secondary` (optional): when `true`, the tool window button will be shown on the lower part of the tool window bar. Default value is `false`.
|
||||
- `factoryClass` (required): specifies the class implementing the `ToolWindowFactory` interface (see Step 1).
|
||||
- `icon` (optional): specifies path to the icon that identifies the tool window, if any.
|
||||
- `conditionClass` (optional): specifies a class that implements [`Condition<Project>`](upsource:///platform/util-rt/src/com/intellij/openapi/util/Condition.java). Using this class, define conditions to be met to display tool window button. When returning `false`, the tool window button is not displayed on tool window bar.
|
||||
2. In this class, override the `createToolWindowContent` method. This method specifies the content for the tool window.
|
||||
3. In the plugin configuration file `plugin.xml`, create the `<extensions defaultExtensionNs="com.intellij">...</extensions>` section.
|
||||
4. To this section, add the `<toolWindow>` element, and for this element, set the following attributes declared in the `ToolWindowEP` bean class:
|
||||
- `id` (required): specifies the tool window caption.
|
||||
- `anchor` (required): specifies the tool window bar where the tool window button will be displayed. Possible values: "left", "right", or "bottom."
|
||||
- `secondary` (optional): when `true`, the tool window button will be shown on the lower part of the tool window bar. Default value is `false`.
|
||||
- `factoryClass` (required): specifies the class implementing the `ToolWindowFactory` interface (see Step 1).
|
||||
- `icon` (optional): specifies path to the icon that identifies the tool window, if any.
|
||||
- `conditionClass` (optional): specifies a class that implements [`Condition<Project>`](upsource:///platform/util-rt/src/com/intellij/openapi/util/Condition.java). Using this class, define conditions to be met to display tool window button. When returning `false`, the tool window button is not displayed on tool window bar.
|
||||
|
||||
To clarify the above procedure, consider the following fragment of the `plugin.xml` file:
|
||||
|
||||
@ -96,16 +96,16 @@ To clarify the above procedure, consider the following fragment of the `plugin.x
|
||||
|
||||
### Sample Plugin
|
||||
|
||||
To clarify how to develop plugins that create tool windows, consider the **toolWindow** sample plugin available in the [code_samples](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/) directory of the SDK documentation. This plugin creates the **Sample Calendar** tool window that displays the system date, time and time zone.
|
||||
To clarify how to develop plugins that create tool windows, consider the **toolWindow** sample plugin available in the [code_samples](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/) directory of the SDK documentation. This plugin creates the **Sample Calendar** tool window that displays the system date, time and time zone.
|
||||
|
||||
**To run the toolWindow plugin**
|
||||
|
||||
1. Start **IntelliJ IDEA** and open the **tool_window** project saved into the [code_samples/tool_window](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/tool_window) directory.
|
||||
1. Start **IntelliJ IDEA** and open the **tool_window** project saved into the [code_samples/tool_window](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/tool_window) directory.
|
||||
2. Ensure that the project settings are valid for the environment. If necessary, modify the project settings.
|
||||
To view or modify the project settings, open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog.
|
||||
3. Run the plugin by choosing the **Run | Run** on the main menu.
|
||||
If necessary, change the [Run/Debug Configurations](https://www.jetbrains.com/help/idea/run-debug-configuration-plugin.html).
|
||||
To view or modify the project settings, open the [Project Structure](https://www.jetbrains.com/help/idea/project-structure-dialog.html) dialog.
|
||||
3. Run the plugin by choosing the **Run | Run** on the main menu.
|
||||
If necessary, change the [Run/Debug Configurations](https://www.jetbrains.com/help/idea/run-debug-configuration-plugin.html).
|
||||
|
||||
The plugin creates the **Sample Calendar** tool window. When opened, this tool window is similar to the following screen:
|
||||
The plugin creates the **Sample Calendar** tool window. When opened, this tool window is similar to the following screen:
|
||||
|
||||

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