mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 17:57:53 +08:00
Change code samples reference to use intellij-sdk-code-samples repository
This commit is contained in:
parent
59669285b3
commit
4c8e7a5c9b
@ -85,7 +85,7 @@ See [Grouping Actions](#grouping-actions) for more information about the `compac
|
||||
> **NOTE** If an action is added to a toolbar, its `update()` can be called if there was any user activity or focus transfer.
|
||||
If the action's availability changes in the absence of these events, then call [`ActivityTracker.getInstance().inc()`](upsource:///platform/platform-api/src/com/intellij/ide/ActivityTracker.java) to notify the action subsystem to update all toolbar actions.
|
||||
|
||||
An example of enabling a menu action based on whether a project is open is demonstrated in [`PopupDialogAction.update()`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) method.
|
||||
An example of enabling a menu action based on whether a project is open is demonstrated in [`PopupDialogAction.update()`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) method.
|
||||
|
||||
### Overriding the AnAction.actionPerformed Method
|
||||
When the user selects an enabled action, be it from a menu or toolbar, the action's `AnAction.actionPerformed()` method is called.
|
||||
@ -98,7 +98,7 @@ The code that executes in the `AnAction.actionPerformed()` method should execute
|
||||
|
||||
<!-- TODO: does this all happen inside a transaction? Does that ensure the undo step? -->
|
||||
|
||||
An example of inspecting PSI elements is demonstrated in the SDK code sample `action_basics` [`PopupDialogAction.actionPerformed()`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) method.
|
||||
An example of inspecting PSI elements is demonstrated in the SDK code sample `action_basics` [`PopupDialogAction.actionPerformed()`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) method.
|
||||
|
||||
### Action IDs
|
||||
Every action and action group has a unique identifier.
|
||||
|
@ -65,4 +65,4 @@ PsiClass containingClass = containingMethod.getContainingClass();
|
||||
```
|
||||
|
||||
To see how the navigation works in practice, please refer to the
|
||||
[code sample](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java).
|
||||
[code sample](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java).
|
||||
|
@ -76,7 +76,7 @@ To create a library, perform the following steps:
|
||||
* For a module-level library, commit the modifiable model returned by `ModuleRootManager.getInstance(module).getModifiableModel()`.
|
||||
|
||||
For module-level libraries, you can also use simplified APIs in the [`ModuleRootModificationUtil`](upsource:///platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) class to add a library with a single API call.
|
||||
You can find an example of using these APIs in the [project_model](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java) code sample.
|
||||
You can find an example of using these APIs in the [project_model](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java) code sample.
|
||||
|
||||
### Adding Contents or Modifying a Library
|
||||
To add or change the roots of a library, you need to perform the following steps:
|
||||
@ -105,9 +105,9 @@ You can use the following methods:
|
||||
ProjectFileIndex.isInLibrarySource(virtualFileorDirectory)
|
||||
```
|
||||
|
||||
See the [project_model](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java) to see how the method mentioned above can be applied.
|
||||
See the [project_model](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java) to see how the method mentioned above can be applied.
|
||||
|
||||
More details on libraries can be found in the [plugin_model](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java) code sample.
|
||||
More details on libraries can be found in the [plugin_model](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java) code sample.
|
||||
|
||||
## Predefined Libraries
|
||||
EP: `com.intellij.additionalLibraryRootsProvider`
|
||||
|
@ -76,7 +76,7 @@ See [SDK](sdk.md) for more details.
|
||||
Utility classes used for modifying the project structure can be found in the package [`projectModel-impl.openapi`](upsource:///platform/projectModel-impl/src/com/intellij/openapi). Its [`roots`](upsource:///platform/projectModel-impl/src/com/intellij/openapi/roots/) subpackage contains instances and utilities intended for work with project and module source roots, including [`ModuleRootModificationUtil`](upsource:///platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) and [`ProjectRootUtil`](upsource:///platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java). Project structure
|
||||
changes need to be performed in a [write action](/basics/architectural_overview/general_threading_rules.md#readwrite-lock).
|
||||
|
||||
Refer to the [project_model](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java) code sample to learn how project structure modification can be implemented.
|
||||
Refer to the [project_model](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java) code sample to learn how project structure modification can be implemented.
|
||||
|
||||
## Receiving Notifications About Project Structure Changes
|
||||
To receive notifications about changes in project structure (modules or libraries being added or removed, module dependencies being changed, and so on), use the [message bus](/reference_guide/messaging_infrastructure.md) and the `ProjectTopics.PROJECT_ROOTS` topic:
|
||||
|
@ -35,7 +35,7 @@ See [Registering Actions in plugin.xml](/basics/action_system.md#registering-act
|
||||
### Binding Action Groups to UI Components
|
||||
The following sample shows how to use an `<add-to-group>` element to place a custom action group relative to an entry in the **Tools** menu.
|
||||
The attribute `relative-to-action` references the action `id` for `PopupDialogAction`, which is not a native IntelliJ menu entry.
|
||||
Rather `PopupDialogAction` is defined in the same [`plugin.xml`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
Rather `PopupDialogAction` is defined in the same [`plugin.xml`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
This group is placed after the single entry for the action `PopupDialogAction`, as defined in the tutorial [Creating Actions](working_with_custom_actions.md#registering-an-action-with-the-new-action-form).
|
||||
|
||||
```xml
|
||||
@ -94,7 +94,7 @@ to create the `CustomDefaultActionGroup` class in the `action_basics` code sampl
|
||||
```
|
||||
|
||||
### Registering the Custom Action Group
|
||||
As in the case with the static action group, the action `<group>` should be declared in the `<actions>` section of the `plugin.xml` file, for example, the [action_basics](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/resources/META-INF/plugin.xml) plugin.
|
||||
As in the case with the static action group, the action `<group>` should be declared in the `<actions>` section of the `plugin.xml` file, for example, the [action_basics](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/resources/META-INF/plugin.xml) plugin.
|
||||
The declaration below shows:
|
||||
* The presence of the `class` attribute in the `<group>` element, which tells the IntelliJ Platform framework to use `CustomDefaultActionGroup` rather than the default implementation.
|
||||
* Setting the group's `popup` attribute to allow submenus.
|
||||
@ -152,7 +152,7 @@ The set of actions in the `ActionGroup` is dynamically defined.
|
||||
|
||||
### Creating Variable Action Group
|
||||
To create a group of actions with a variable number of actions, extend `ActionGroup`.
|
||||
For example, as in the `action_basics` class [`DynamicActionGroup`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/java/org/intellij/sdk/action/DynamicActionGroup.java) code:
|
||||
For example, as in the `action_basics` class [`DynamicActionGroup`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/java/org/intellij/sdk/action/DynamicActionGroup.java) code:
|
||||
|
||||
```java
|
||||
public class DynamicActionGroup extends ActionGroup {
|
||||
@ -160,7 +160,7 @@ public class DynamicActionGroup extends ActionGroup {
|
||||
```
|
||||
|
||||
### Registering a Variable Action Group
|
||||
To register the dynamic menu group, a `<group>` attribute needs to be placed in the `<actions>` section of [`plugin`.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/resources/META-INF/plugin.xml).
|
||||
To register the dynamic menu group, a `<group>` attribute needs to be placed in the `<actions>` section of [`plugin`.xml](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/resources/META-INF/plugin.xml).
|
||||
When enabled, this group appears at the entry just below the [Static Grouped Actions](#binding-action-groups-to-ui-components) in the **Tools** menu:
|
||||
|
||||
```xml
|
||||
|
@ -19,7 +19,7 @@ Classes that extend it should override `AnAction.update()`, and must override `A
|
||||
* The `update()` method implements the code that enables or disables an action.
|
||||
* The `actionPerformed()` method implements the code that executes when an action is invoked by the user.
|
||||
|
||||
As an example, [`PopupDialogAction`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) overrides `AnAction` for the `action_basics` code sample.
|
||||
As an example, [`PopupDialogAction`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) overrides `AnAction` for the `action_basics` code sample.
|
||||
|
||||
```java
|
||||
public class PopupDialogAction extends AnAction {
|
||||
@ -99,7 +99,7 @@ An action declaration can be added manually to the `plugin.xml` file.
|
||||
An exhaustive list of declaration elements and attributes is presented in [Registering Actions in plugin.xml](/basics/action_system.md#registering-actions-in-pluginxml).
|
||||
Attributes are added by selecting them from the **New Action** form, or by editing the registration declaration directly in the plugin.xml file.
|
||||
|
||||
The `<action>` declaration for `PopupDialogAction` in the `action_basics` [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
The `<action>` declaration for `PopupDialogAction` in the `action_basics` [plugin.xml](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/action_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
It also contains an attribute for an [`Icon`](/reference_guide/work_with_icons_and_images.md) and encloses elements declaring text overrides, keyboard and mouse shortcuts, and to which menu group the action should be added.
|
||||
|
||||
The full declaration is:
|
||||
|
@ -21,7 +21,7 @@ The `SimpleLanguage` class is defined in the `org.intellij.sdk.language` package
|
||||
```
|
||||
|
||||
## 2.2. Define an Icon
|
||||
The [icon](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/simple_language_plugin/src/main/resources/icons/jar-gray.png) for the Simple Language is defined by the `SimpleIcons` class.
|
||||
The [icon](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/simple_language_plugin/src/main/resources/icons/jar-gray.png) for the Simple Language is defined by the `SimpleIcons` class.
|
||||
There is nothing uniquely Simple Language-specific about [defining the icon](/reference_guide/work_with_icons_and_images.md) itself.
|
||||
The definition follows a pattern similar to defining, e.g., `SdkIcons`.
|
||||
|
||||
|
@ -19,7 +19,7 @@ A keyboard shortcut can also initiate the action.
|
||||
|
||||
{:width="600px"}
|
||||
|
||||
The source code for the Java class behind the menu action is [EditorAreaIllustration](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java).
|
||||
The source code for the Java class behind the menu action is [EditorAreaIllustration](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java).
|
||||
The focus of discussion will be the `EditorAreaIllustration.actionPerformed()` method.
|
||||
For more information about creating action classes, see the [Actions Tutorial](/tutorials/action_system.md) which covers the topic in depth.
|
||||
|
||||
|
@ -22,10 +22,10 @@ The `editor_basics` code sample adds an **Editor Add Caret** menu item to the ed
|
||||
{:width="600px"}
|
||||
|
||||
### Creating the Menu Action Class
|
||||
The source code for the Java action class is [EditorHandlerIllustration](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java), a subclass of `AnAction`.
|
||||
The source code for the Java action class is [EditorHandlerIllustration](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java), a subclass of `AnAction`.
|
||||
For more information about creating action classes, see the [Actions Tutorial](/tutorials/action_system.md) which covers the topic in depth.
|
||||
|
||||
The `EditorHandlerIllustration` action is registered in the _editor_basic_ [`plugin.xml`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/editor_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
The `EditorHandlerIllustration` action is registered in the _editor_basic_ [`plugin.xml`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/editor_basics/src/main/resources/META-INF/plugin.xml) file.
|
||||
Note that this action class is registered to appear on the Editor context menu.
|
||||
|
||||
```xml
|
||||
|
@ -20,9 +20,9 @@ It may be helpful to open that project in an IntelliJ Platform-based IDE, build
|
||||
|
||||
## Creating a New Menu Action
|
||||
In this example, we access the `Editor` from an action.
|
||||
The source code for the Java class in this example is [EditorIllustrationAction](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java).
|
||||
The source code for the Java class in this example is [EditorIllustrationAction](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java).
|
||||
|
||||
To register the action, we must add the corresponding elements to the `<actions>` section of the plugin configuration file [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/editor_basics/src/main/resources/META-INF/plugin.xml).
|
||||
To register the action, we must add the corresponding elements to the `<actions>` section of the plugin configuration file [plugin.xml](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/editor_basics/src/main/resources/META-INF/plugin.xml).
|
||||
For more information, refer to the [Registering Actions](/tutorials/action_system/working_with_custom_actions.md#registering-a-custom-action) section of the Actions Tutorial.
|
||||
The `EditorIllustrationAction` action is registered in the group `EditorPopupMenu` so it will be available from the context menu when focus is on the editor:
|
||||
|
||||
|
@ -7,7 +7,7 @@ The following tutorial shows how to support a custom framework type for a projec
|
||||
The examples in this tutorial rely heavily on the [framework_basics](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/framework_basics) code sample.
|
||||
|
||||
## 1. Creating a New Framework
|
||||
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_basics/src/main/java/org/intellij/sdk/framework/DemoFramework.java) class.
|
||||
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-code-samples/tree/master/framework_basics/src/main/java/org/intellij/sdk/framework/DemoFramework.java) class.
|
||||
|
||||
```java
|
||||
public class DemoFramework extends FrameworkTypeEx {
|
||||
@ -16,7 +16,7 @@ public class DemoFramework extends FrameworkTypeEx {
|
||||
|
||||
## 2. Registering Framework
|
||||
The newly created framework class should be registered as an extension point by adding `com.intellij.framework.type` extension in
|
||||
[`plugin.xml`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework_basics/src/main/resources/META-INF/plugin.xml)
|
||||
[`plugin.xml`](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/framework_basics/src/main/resources/META-INF/plugin.xml)
|
||||
configuration file:
|
||||
|
||||
```xml
|
||||
|
@ -17,7 +17,7 @@ Create an empty plugin project as described in [Creating a Plugin Project](/basi
|
||||
## 1. Register a New ConfigurationType
|
||||
|
||||
Add new `configurationType` extension to the
|
||||
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/run_configuration/src/main/resources/META-INF/plugin.xml)
|
||||
[plugin.xml](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/run_configuration/src/main/resources/META-INF/plugin.xml)
|
||||
|
||||
```xml
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
@ -20,7 +20,7 @@ See
|
||||
## 1. Register Custom TreeStructure Provider
|
||||
|
||||
Add new *treeStructureProvider* extension to the
|
||||
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/tree_structure_provider/src/main/resources/META-INF/plugin.xml)
|
||||
[plugin.xml](https://github.com/JetBrains/intellij-sdk-code-samples/tree/master/tree_structure_provider/src/main/resources/META-INF/plugin.xml)
|
||||
|
||||
```java
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
Loading…
x
Reference in New Issue
Block a user