[action_basics] add localization content IJSDK-886

update README for action_basics
This commit is contained in:
JohnHake 2020-08-21 13:58:42 -07:00
parent b1003b2b29
commit 8db59c9652
4 changed files with 46 additions and 18 deletions

View File

@ -1,16 +1,19 @@
# Action Sample Project [![JetBrains IntelliJ Platform SDK Docs](https://jb.gg/badges/docs.svg)][docs]
# Action Basics Sample Project [![JetBrains IntelliJ Platform SDK Docs](https://jb.gg/badges/docs.svg)][docs]
*Reference: [Action System in IntelliJ SDK Docs][docs:actions]*
## Quickstart
Action Sample Project demonstrates registering actions process in various configurations.
Each action is an extension of the [`AnAction`][sdk:AnAction] abstract class and brings the possibility of extending IDE with an event performed with the user interaction - i.e., clicking the button, using the keyboard or mouse shortcuts.
Plugin registers the [`PopupDialogAction`][file:PopupDialogAction] action, which provides a popup dialog as a feedback, in three different ways:
The Action Basics Sample Project demonstrates the process of registering actions in various configurations.
Each action is an extension of the [`AnAction`][sdk:AnAction] abstract class and brings the possibility of extending the IDE with an event performed with the user interaction - i.e., clicking the button, using the keyboard or mouse shortcuts.
This Plugin registers the [`PopupDialogAction`][file:PopupDialogAction] action, which provides a popup dialog as a feedback, in three different ways:
- by assigning the keyboard (<kbd>Ctrl/Cmd</kbd>+<kbd>Alt</kbd>+<kbd>A</kbd>, <kbd>C</kbd>) and mouse shortcuts (<kbd>Ctrl/Cmd</kbd> + <kbd>Mouse Button 3</kbd> + <kbd>Double Click</kbd>),
- by adding action item to the `ToolsMenu` group, available in Tools menu,
- by adding action item to the `EditorPopupMenu` group, available in Editor's context menu.
- by adding an action to the `ToolsMenu` directly, and as part of new groups added to the Tools menu,
- by adding an action to a new group in the `EditorPopupMenu`, which is the Editor's context menu.
Additional features of the plugin:
- [Using the `<override-text>`][docs:action-override] element in an `<action>` element is demonstrated in the `plugin.xml` declaration to add the `PopupDialogAction` action directly to the `ToolsMenu`.
- [Localization of action and group][docs:action-locale] `text` and `description` attributes using a `<resource-bundle>` is demonstrated in the declaration to add a new group to the `EditorPopupMenu`.
### Actions
@ -27,6 +30,8 @@ Plugin registers the [`PopupDialogAction`][file:PopupDialogAction] action, which
[docs]: https://www.jetbrains.org/intellij/sdk/docs
[docs:actions]: https://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html
[docs:action-override]: https://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html#setting-the-override-text-element-for-an-action
[docs:action-locale]: https://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html#localizing-actions-and-groups
[file:PopupDialogAction]: ./src/main/java/org/intellij/sdk/action/PopupDialogAction.java
[file:CustomDefaultActionGroup]: ./src/main/java/org/intellij/sdk/action/CustomDefaultActionGroup.java

View File

@ -26,7 +26,7 @@ public class CustomDefaultActionGroup extends DefaultActionGroup {
// Enable/disable depending on whether user is editing
Editor editor = event.getData(CommonDataKeys.EDITOR);
event.getPresentation().setEnabled(editor != null);
// Take this opportunity to set an icon for the menu entry.
// Take this opportunity to set an icon for the group.
event.getPresentation().setIcon(SdkIcons.Sdk_default_icon);
}

View File

@ -30,46 +30,61 @@
<!-- Text to display as company information on Preferences/Settings | Plugin page -->
<vendor url="https://plugins.jetbrains.com">IntelliJ Platform SDK</vendor>
<!-- Declare the default resource location for localizing menu strings -->
<resource-bundle>messages.BasicActionsBundle</resource-bundle>
<actions>
<!--
See https://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html#registering-actions-in-pluginxml
for information about the elements and attributes used for actions and groups.
The <action> element adds a static menu item in first position of the Tools menu that shows PopupDialogAction.
This <action> element adds a static menu item in first position of the Tools menu that shows PopupDialogAction.
Note this element has no text or description attributes because translations for them are given
by action-id in the resource-bundle.
An <override-text> element is also used for demonstration purposes to show alternate text and description strings
for this action's entries in the MainMenu. (Which includes the ToolsMenu. Try commenting out the override-text
element and see how the menu text changes.) The alternate text and description attributes do not
appear here because they are defined by action-id in the resource-bundle.
-->
<action id="org.intellij.sdk.action.PopupDialogAction" class="org.intellij.sdk.action.PopupDialogAction"
text="Action Basics Plugin: Pop Dialog Action" description="SDK action example"
icon="SdkIcons.Sdk_default_icon">
<add-to-group group-id="ToolsMenu" anchor="first"/>
<override-text place="MainMenu" text="Pop Dialog Action"/>
<keyboard-shortcut first-keystroke="control alt A" second-keystroke="C" keymap="$default"/>
<mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/>
<add-to-group group-id="ToolsMenu" anchor="first"/>
</action>
<!--
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.
GroupedActions demonstrates declaring an action group using the default ActionGroup implementation provided by the
IntelliJ Platform framework. (Note the lack of a group "class" attribute.) GroupedActions gets inserted after
PopupDialogAction in the Tools menu. Because the group's implementation is default, it cannot impose
enable/disable conditions. Instead it must rely on the conditions imposed by the parent menu where it is inserted.
It declares one action in the group.
-->
<group id="org.intellij.sdk.action.GroupedActions" text="Static Grouped Actions" popup="true"
icon="SdkIcons.Sdk_default_icon">
<group id="org.intellij.sdk.action.GroupedActions"
text="Static Grouped Actions" description="SDK statically grouped action example"
popup="true" icon="SdkIcons.Sdk_default_icon">
<add-to-group group-id="ToolsMenu" anchor="after" relative-to-action="org.intellij.sdk.action.PopupDialogAction"/>
<action class="org.intellij.sdk.action.PopupDialogAction" id="org.intellij.sdk.action.GroupPopDialogAction"
text="A Group Action" description="SDK static grouped action example" icon="SdkIcons.Sdk_default_icon">
<action id="org.intellij.sdk.action.GroupPopDialogAction" class="org.intellij.sdk.action.PopupDialogAction"
text="A Group Action" description="SDK static grouped action example"
icon="SdkIcons.Sdk_default_icon">
</action>
</group>
<!--
CustomDefaultActionGroup demonstrates declaring an action group based on a ActionGroup class supplied by this
plugin. This group is to be inserted atop the Editor Popup Menu. It declares one action in the group.
The group and action implementations are internationalized, so their declarations do not use the text or
description attributes. Instead, the information is defined in the BasicActionsBundle.
-->
<group id="org.intellij.sdk.action.CustomDefaultActionGroup"
class="org.intellij.sdk.action.CustomDefaultActionGroup" popup="true"
text="Popup Grouped Actions" description="Custom defaultActionGroup demo" icon="SdkIcons.Sdk_default_icon">
class="org.intellij.sdk.action.CustomDefaultActionGroup"
popup="true">
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
<action class="org.intellij.sdk.action.PopupDialogAction" id="org.intellij.sdk.action.CustomGroupedAction"
text="A Popup Action" description="SDK popup grouped action example" icon="SdkIcons.Sdk_default_icon"/>
<action id="org.intellij.sdk.action.CustomGroupedAction" class="org.intellij.sdk.action.PopupDialogAction"
icon="SdkIcons.Sdk_default_icon"/>
</group>
<!--
DynamicActionGroup demonstrates declaring an action group without a static action declaration.

View File

@ -0,0 +1,8 @@
# 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.
# Default plugin action and group texts and descriptions go here.
# All of these example "translated" strings have suffix "[en]" to symbolize they are translated.
# The suffix is meaningless to the localization process.
action.org.intellij.sdk.action.CustomGroupedAction.text=A Popup Action[en]
action.org.intellij.sdk.action.CustomGroupedAction.description=SDK popup grouped action example[en]
group.org.intellij.sdk.action.CustomDefaultActionGroup.text=Popup Grouped Actions[en]
group.org.intellij.sdk.action.CustomDefaultActionGroup.description=Custom defaultActionGroup demo[en]