diff --git a/tutorials/action_system.md b/tutorials/action_system.md index c013fc3cc..d35db368e 100644 --- a/tutorials/action_system.md +++ b/tutorials/action_system.md @@ -1,9 +1,54 @@ IntelliJ Action System ========== -The system of actions allows plugins to add their own items to IDEA menus and toolbars. -An action is a class, derived from the [AnAction] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java) class, -whose actionPerformed method is called when the menu item or toolbar button is selected. -For example, one of the action classes is responsible for the "File | Open File..." menu item and for the "Open File" toolbar button. -Actions may be organized into groups, which, in turn, can contain other groups. A group of actions can form a toolbar or a menu. -Subgroups of the group can form submenus of the menu. +Action system provides an option to handle certain events in a desired way. Action can either be simply a responce to some state, +or be bound to UI element and could be invoked on demand. These UI elements include main menu, context menus and toolbars. +An action is technically a class, derived from the [AnAction] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java) class. +To update the state of the action, the method AnAction.update() is periodically called by IDEA. +The object of type [AnActionEvent] (https://github.com/JetBrains/intellij-community/blob/ff16ce78a1e0ddb6e67fd1dbc6e6a597e20d483a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java) +passed to this method carries the information about the current context for the action, +and in particular, the specific presentation which needs to be updated. + +#How create a new menu item and bidn an action to it? +To register an action as a menu item, an attribute should be added to the section of the plugin configuration file +[plugin.xml] (https://github.com/JetBrains/intellij-sdk/blob/master/code_samples/plugin_sample/META-INF/plugin.xml) + + + + + + + + + + + + + + + + + + +[Link to source code] (https://github.com/JetBrains/intellij-sdk/blob/master/code_samples/plugin_sample/META-INF/plugin.xml)