mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 09:17:50 +08:00
Add override-text
This commit is contained in:
parent
60c415a176
commit
81e111ab84
@ -150,19 +150,17 @@ Registering actions in `plugin.xml` is demonstrated in the following reference e
|
|||||||
|
|
||||||
> **Tip** Beginning in 2020.1, an alternate version of an action's menu text can be declared for use depending on where an action appears.
|
> **Tip** Beginning in 2020.1, an alternate version of an action's menu text can be declared for use depending on where an action appears.
|
||||||
|
|
||||||
By using the `override-text` element introduced in v2020.1 of the IntelliJ Platform, the menu text for an action can be different depending on context: menu location, toolbar, etc.
|
By using the `<override-text>` element introduced in 2020.1 of the IntelliJ Platform, the menu text for an action can be different depending on context: menu location, toolbar, etc.
|
||||||
In the `action` element reference example (below) with `id` attribute `VssIntegration.GarbageCollection`, the default is to use the verbose text "Garbage Collector: Collect _Garbage."
|
|
||||||
The `add-to-group` element declares the action is to be added to the Tools Menu.
|
|
||||||
|
|
||||||
However, the `override-text` element declares that text for `VssIntegration.GarbageCollection` displayed anywhere in the Main Menu system should be the compact text version "Collect _Garbage."
|
In the `action` element reference example (below) 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 Tools 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 Tools Menu is part of the Main Menu, so the displayed menu text is "Collect _Garbage."
|
The Tools 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 **Help \| Find Action...**, displays the verbose text "Garbage Collector: Collect _Garbage" to give the user additional information about the action.
|
A different context, such as searching for the action using **Help \| Find Action...**, displays the default text "Garbage Collector: Collect _Garbage" to give the user additional information about the action.
|
||||||
|
|
||||||
The example uses `MainMenu` for the `place` attribute in the `override-text` element, which is broad in scope.
|
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.
|
||||||
The `place` attribute could be finer granularity if the action is to be added to more than one location in the main menu.
|
Additional `override-text` elements could be used to specify additional places where the Main Menu text should be used.
|
||||||
For example, the `override-text` element for `VssIntegration.GarbageCollection` might only specify a `place` element of `ToolsMenu`.
|
|
||||||
Then additional `add-to-group` elements could specify other `group-id` attributes, such as `HelpMenu`.
|
|
||||||
For each `add-to-group` unique `group-id` attribute, an additional `override-text` element could be added with a matching `place` attribute.
|
|
||||||
|
|
||||||
#### Action Declaration Reference
|
#### Action Declaration Reference
|
||||||
The places where actions can appear are defined by constants in [`ActionPlaces`](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java).
|
The places where actions can appear are defined by constants in [`ActionPlaces`](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java).
|
||||||
@ -189,11 +187,15 @@ This, and additional information can also be found by using the [Code Completion
|
|||||||
<action id="VssIntegration.GarbageCollection" class="com.foo.impl.CollectGarbage" text="Garbage Collector: Collect _Garbage"
|
<action id="VssIntegration.GarbageCollection" class="com.foo.impl.CollectGarbage" text="Garbage Collector: Collect _Garbage"
|
||||||
description="Run garbage collector" icon="icons/garbage.png">
|
description="Run garbage collector" icon="icons/garbage.png">
|
||||||
<!-- The <override-text> element defines an alternate version of the text for the menu action.
|
<!-- The <override-text> element defines an alternate version of the text for the menu action.
|
||||||
The mandatory "text" attribute defines the brief-version text to be displayed for the action.
|
The mandatory "text" attribute defines the text to be displayed for the action.
|
||||||
The mandatory "place" attribute declares where the alternate text should be used. In this example,
|
The mandatory "place" attribute declares where the alternate text should be used. In this example,
|
||||||
any time the action is displayed in the IDE Main Menu (and submenus) the override-text
|
any time the action is displayed in the IDE Main Menu (and submenus) the override-text
|
||||||
version should be used. -->
|
version should be used.
|
||||||
|
The second <override-text> element uses the alternate attribute "use-text-of-place" to define
|
||||||
|
a location (EditorPopup) to use the same text as is used in MainMenu. It is a way to specify
|
||||||
|
use of alternate menu text in multiple discrete menu groups. -->
|
||||||
<override-text place="MainMenu" text="Collect _Garbage"/>
|
<override-text place="MainMenu" text="Collect _Garbage"/>
|
||||||
|
<override-text place="EditorPopup" use-text-of-place="MainMenu"/>
|
||||||
<!-- The <add-to-group> node specifies that the action should be added
|
<!-- The <add-to-group> node specifies that the action should be added
|
||||||
to an existing group. An action can be added to several groups.
|
to an existing group. An action can be added to several groups.
|
||||||
The mandatory "group-id" attribute specifies the ID of the group
|
The mandatory "group-id" attribute specifies the ID of the group
|
||||||
|
@ -16,8 +16,7 @@ repositories {
|
|||||||
|
|
||||||
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
||||||
intellij {
|
intellij {
|
||||||
// Uncomment the version line below when the product releases
|
version '201-EAP-SNAPSHOT'
|
||||||
// version '2020.1'
|
|
||||||
sameSinceUntilBuild = true
|
sameSinceUntilBuild = true
|
||||||
}
|
}
|
||||||
patchPluginXml {
|
patchPluginXml {
|
||||||
|
@ -7,13 +7,6 @@
|
|||||||
<!-- Text to display as name on Preferences/Settings | Plugin page -->
|
<!-- Text to display as name on Preferences/Settings | Plugin page -->
|
||||||
<name>SDK: Action Sample Project</name>
|
<name>SDK: Action Sample Project</name>
|
||||||
|
|
||||||
<!-- The version of this plugin -->
|
|
||||||
<version>2.0.0</version>
|
|
||||||
|
|
||||||
<!-- Compatible with the following versions of IntelliJ Platform:
|
|
||||||
version 2018.3 (build #183) and newer. -->
|
|
||||||
<idea-version since-build="191"/>
|
|
||||||
|
|
||||||
<!-- Indicate this plugin can be loaded in all IntelliJ Platform-based products. -->
|
<!-- Indicate this plugin can be loaded in all IntelliJ Platform-based products. -->
|
||||||
<depends>com.intellij.modules.platform</depends>
|
<depends>com.intellij.modules.platform</depends>
|
||||||
|
|
||||||
@ -45,7 +38,6 @@
|
|||||||
<override-text place="MainMenu" text="Pop Dialog Action"/>
|
<override-text place="MainMenu" text="Pop Dialog Action"/>
|
||||||
<keyboard-shortcut first-keystroke="control alt A" second-keystroke="C" keymap="$default"/>
|
<keyboard-shortcut first-keystroke="control alt A" second-keystroke="C" keymap="$default"/>
|
||||||
<mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/>
|
<mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/>
|
||||||
<add-to-group group-id="ToolsMenu" anchor="first"/>
|
|
||||||
</action>
|
</action>
|
||||||
<!-- All of the following menu groups add the action PopupDialogAction to menus in different ways.
|
<!-- All of the following menu groups add the action PopupDialogAction to menus in different ways.
|
||||||
Note that even though these groups reuse the same action class, in each use the action ids are unique. -->
|
Note that even though these groups reuse the same action class, in each use the action ids are unique. -->
|
||||||
@ -75,4 +67,4 @@
|
|||||||
</group>
|
</group>
|
||||||
</actions>
|
</actions>
|
||||||
|
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
@ -26,8 +26,8 @@ Refactoring dialog: builtin "Open in editor" option
|
|||||||
Configurable status bar widgets
|
Configurable status bar widgets
|
||||||
: Use extension point `com.intellij.statusBarWidgetFactory` to provide widgets that can be disabled or reordered.
|
: Use extension point `com.intellij.statusBarWidgetFactory` to provide widgets that can be disabled or reordered.
|
||||||
|
|
||||||
Override text presentation for actions depending on context.
|
Override text presentation for actions depending on menu context.
|
||||||
: Set the [`override-text`](/basics/action_system.md#setting-the-override-text-element-for-an-action) element within the `action` declaration in `plugin.xml`.
|
: Set the `<override-text>` element within the `<action>` declaration in `plugin.xml`.
|
||||||
|
|
||||||
## Notable Changes in IntelliJ IDEA
|
## Notable Changes in IntelliJ IDEA
|
||||||
|
|
||||||
|
@ -112,9 +112,9 @@ The full declaration is:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Using Override-Text for an Action
|
#### Using Override-Text for an Action
|
||||||
By using the `override-text` element introduced in v2020.1 of the IntelliJ Platform, the action text can be different depending on the context of where the action appears: menu, toolbar, etc.
|
By using the `override-text` element introduced in 2020.1 of the IntelliJ Platform, the action text can be different depending on the context of where the action appears: menu, toolbar, etc.
|
||||||
The example above uses this element to ensure the more terse text "Pop Dialog Action" is shown anywhere the action appears in the Main Menu structure.
|
The example above uses this element to ensure the shorter text "Pop Dialog Action" is shown anywhere the action appears in the Main Menu structure.
|
||||||
Otherwise, the default verbose text "Action Basics Plugin: Pop Dialog Action" is shown.
|
Otherwise, the default, more explanatory text "Action Basics Plugin: Pop Dialog Action" is shown.
|
||||||
For more information, see [Setting the Override-Text Element for an Action](/basics/action_system.md#setting-the-override-text-element-for-an-action)
|
For more information, see [Setting the Override-Text Element for an Action](/basics/action_system.md#setting-the-override-text-element-for-an-action)
|
||||||
|
|
||||||
## Testing the Minimal Custom Action Implementation
|
## Testing the Minimal Custom Action Implementation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user