mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 09:17:50 +08:00
Move some action content to plugin_configuration_file.md and reduce content duplication
This commit is contained in:
parent
90439bc9e8
commit
87f73f1ce6
@ -190,50 +190,11 @@ See the [](grouping_action.md) tutorial for examples of creating action groups.
|
|||||||
|
|
||||||
## Registering Actions
|
## Registering Actions
|
||||||
|
|
||||||
There are two main ways to register an action: either by listing it in the [`<actions>`](plugin_configuration_file.md#idea-plugin__actions) section of a plugin's <path>[plugin.xml](plugin_configuration_file.md)</path> file or through code.
|
There are two main ways to register an action: either by [registering it in the <path>plugin.xml</path> file](#registering-actions-in-pluginxml) or [through code](#registering-actions-from-code).
|
||||||
|
|
||||||
### Registering Actions in plugin.xml
|
### Registering Actions in plugin.xml
|
||||||
|
|
||||||
Registering actions in <path>plugin.xml</path> is demonstrated in the following reference examples, which document all elements and attributes used in the [`<actions>`](plugin_configuration_file.md#idea-plugin__actions) section and describe each element's meaning.
|
Registering actions in <path>[plugin.xml](plugin_configuration_file.md)</path> is demonstrated in the following reference examples, which document all elements and attributes used in the [`<actions>`](plugin_configuration_file.md#idea-plugin__actions) section and describe each element's meaning.
|
||||||
|
|
||||||
#### Setting the `override-text` Element
|
|
||||||
<primary-label ref="2020.1"/>
|
|
||||||
|
|
||||||
An alternate version of an action's menu text can be declared for use depending on where an action appears.
|
|
||||||
Using the [`<override-text>`](plugin_configuration_file.md#idea-plugin__actions__action__override-text) element, the menu text for an action can be different depending on context: menu location, toolbar, and other.
|
|
||||||
This is also available for groups in 2020.3 and later.
|
|
||||||
|
|
||||||
In the `<action>` element [reference example](#action-declaration-reference) with `id` attribute `VssIntegration.GarbageCollection`, the default is to use the menu text "Garbage Collector: Collect _Garbage."
|
|
||||||
The `<add-to-group>` element declares the action is added to the <ui-path>Tools</ui-path> menu.
|
|
||||||
|
|
||||||
However, the `<override-text>` element declares that text for `VssIntegration.GarbageCollection` displayed anywhere in the main menu system should be the alternate text "Collect _Garbage."
|
|
||||||
The <ui-path>Tools</ui-path> menu is part of the main menu, so the displayed menu text is "Collect _Garbage."
|
|
||||||
A different context, such as searching for the action using <ui-path>Help | Find Action</ui-path>, displays the default text "Garbage Collector: Collect _Garbage" to give the user additional information about the action.
|
|
||||||
|
|
||||||
A second `<override-text>` element uses `place` and `use-text-of-place` attributes to declare the same version of the text used in the main menu is also used in the editor popup menu.
|
|
||||||
Additional `<override-text>` elements could be used to specify other places where the main menu text should be used.
|
|
||||||
|
|
||||||
An example of using `<override-text>` is demonstrated in the [Creating Actions](working_with_custom_actions.md#using-override-text-for-an-action) tutorial.
|
|
||||||
|
|
||||||
#### Setting the `synonym` Element
|
|
||||||
|
|
||||||
_2020.3_<br/>
|
|
||||||
Users can locate actions via their name by invoking <ui-path>Help | Find Action</ui-path>.
|
|
||||||
|
|
||||||
To allow using alternative names in search, add one or more [`<synonym>`](plugin_configuration_file.md#idea-plugin__actions__action__synonym) elements inside [`<action>`](plugin_configuration_file.md#idea-plugin__actions__action) or [`<reference>`](plugin_configuration_file.md#idea-plugin__actions__group__reference):
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<action id="MyAction" text="My Action Name" class="...">
|
|
||||||
<synonym text="Another Search Term"/>
|
|
||||||
</action>
|
|
||||||
```
|
|
||||||
|
|
||||||
To provide a localized synonym, specify `key` instead of the `text` attribute.
|
|
||||||
|
|
||||||
#### Disabling Search for Group
|
|
||||||
<primary-label ref="2020.3"/>
|
|
||||||
|
|
||||||
To exclude a group from appearing in <ui-path>Help | Find Action</ui-path> results (for example, <control>New...</control> popup), specify `searchable="false"`.
|
|
||||||
|
|
||||||
#### Localizing Actions and Groups
|
#### Localizing Actions and Groups
|
||||||
|
|
||||||
@ -390,7 +351,9 @@ This and additional information can also be found by using the [Code Completion]
|
|||||||
It can also have an <add-to-group> child element. -->
|
It can also have an <add-to-group> child element. -->
|
||||||
<separator/>
|
<separator/>
|
||||||
|
|
||||||
<group id="TestActionSubGroup"/>
|
<!-- A group that is excluded from "Help | Find Action..."
|
||||||
|
and "Navigate | Search Everywhere" -->
|
||||||
|
<group id="TestActionSubGroup" searchable="false"/>
|
||||||
|
|
||||||
<!-- The <reference> element allows adding an existing action to
|
<!-- The <reference> element allows adding an existing action to
|
||||||
the group. The mandatory "ref" attribute specifies the ID of
|
the group. The mandatory "ref" attribute specifies the ID of
|
||||||
|
@ -977,7 +977,7 @@ Examples
|
|||||||
|
|
||||||
<primary-label ref="2020.1"/>
|
<primary-label ref="2020.1"/>
|
||||||
|
|
||||||
Defines an alternate version of the text for the menu action or group.
|
Defines an alternate menu action or group text depending on context: menu location, toolbar, and other.
|
||||||
|
|
||||||
{style="narrow"}
|
{style="narrow"}
|
||||||
Supported
|
Supported
|
||||||
@ -1004,9 +1004,22 @@ Examples
|
|||||||
:
|
:
|
||||||
- Explicitly overridden text:
|
- Explicitly overridden text:
|
||||||
```xml
|
```xml
|
||||||
<override-text
|
<!--
|
||||||
place="MainMenu"
|
Default action text:
|
||||||
text="Collect _Garbage"/>
|
"Garbage Collector: Collect _Garbage"
|
||||||
|
-->
|
||||||
|
<action
|
||||||
|
class="com.example.CollectGarbage"
|
||||||
|
text="Garbage Collector: Collect _Garbage"
|
||||||
|
...>
|
||||||
|
<!--
|
||||||
|
Alternate text displayed anywhere in the main menu:
|
||||||
|
"Collect _Garbage"
|
||||||
|
-->
|
||||||
|
<override-text
|
||||||
|
place="MainMenu"
|
||||||
|
text="Collect _Garbage"/>
|
||||||
|
</action>
|
||||||
```
|
```
|
||||||
- Overridden text reused from the `MainMenu` place:
|
- Overridden text reused from the `MainMenu` place:
|
||||||
```xml
|
```xml
|
||||||
@ -1032,7 +1045,7 @@ Required
|
|||||||
Attributes
|
Attributes
|
||||||
:
|
:
|
||||||
- `key` _(`key` or `text` is **required**)_<br/>
|
- `key` _(`key` or `text` is **required**)_<br/>
|
||||||
The key of the synonym text provided in a message bundle.
|
The key of the synonym text provided in a [message bundle](basic_action_system.md#localizing-actions-and-groups).
|
||||||
- `text` _(`key` or `text` is **required**)_<br/>
|
- `text` _(`key` or `text` is **required**)_<br/>
|
||||||
|
|
||||||
The synonym text.
|
The synonym text.
|
||||||
@ -1224,7 +1237,7 @@ Attributes
|
|||||||
Separator text is displayed only in specific contexts such as popup menus, toolbars, etc.
|
Separator text is displayed only in specific contexts such as popup menus, toolbars, etc.
|
||||||
- `key` _(optional)_<br/>
|
- `key` _(optional)_<br/>
|
||||||
|
|
||||||
The message key for the separator text.
|
The [message key]([message key](https://plugins.jetbrains.com/docs/intellij/basic-action-system.html#localizing-actions-and-groups)) for the separator text.
|
||||||
The message bundle for use should be registered via the `resource-bundle` attribute of
|
The message bundle for use should be registered via the `resource-bundle` attribute of
|
||||||
the [`<actions>`](#idea-plugin__actions) element.
|
the [`<actions>`](#idea-plugin__actions) element.
|
||||||
The attribute is ignored if the `text` attribute is specified.
|
The attribute is ignored if the `text` attribute is specified.
|
||||||
|
@ -139,10 +139,8 @@ The full declaration is:
|
|||||||
#### Using `override-text` for an Action
|
#### Using `override-text` for an Action
|
||||||
<primary-label ref="2020.1"/>
|
<primary-label ref="2020.1"/>
|
||||||
|
|
||||||
By using the `override-text` element, the action text can be different depending on the context of where the action appears: menu, toolbar, etc.
|
The example above uses the [`override-text`](plugin_configuration_file.md#idea-plugin__actions__action__override-text) element to ensure the shorter text "Popup Dialog Action" is shown anywhere the action appears in the main menu structure.
|
||||||
The example above uses this element to ensure the shorter text "Popup Dialog Action" is shown anywhere the action appears in the main menu structure.
|
|
||||||
Otherwise, the default, more explanatory text "Action Basics Plugin: Popup Dialog Action" is shown.
|
Otherwise, the default, more explanatory text "Action Basics Plugin: Popup Dialog Action" is shown.
|
||||||
For more information, see [](basic_action_system.md#setting-the-override-text-element).
|
|
||||||
|
|
||||||
> Use inspection <ui-path>Settings | Editor | Inspections | Plugin DevKit | Code | Component/Action not registered</ui-path> for reporting unregistered actions.
|
> Use inspection <ui-path>Settings | Editor | Inspections | Plugin DevKit | Code | Component/Action not registered</ui-path> for reporting unregistered actions.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user