mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
source: action group with one action and comments
This commit is contained in:
parent
5300e85b5c
commit
fe14eeeb09
@ -1,114 +1,137 @@
|
||||
<idea-plugin version="2" url="www.jetbrains.com" use-idea-classloader="true">
|
||||
<id>Tutorial</id>
|
||||
<name>Basic plugin example</name>
|
||||
<version>1.0</version>
|
||||
<vendor email="support@jetbrains.com" url="http://www.jetbrains.com">JetBrains</vendor>
|
||||
<category>Samples</category>
|
||||
<description><![CDATA[
|
||||
<id>Tutorial</id>
|
||||
<name>Basic plugin example</name>
|
||||
<version>1.0</version>
|
||||
<vendor email="support@jetbrains.com" url="http://www.jetbrains.com">JetBrains</vendor>
|
||||
<category>Samples</category>
|
||||
<description><![CDATA[
|
||||
Illustration of configuration options.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
]]></description>
|
||||
<change-notes><![CDATA[
|
||||
<change-notes><![CDATA[
|
||||
Initial release.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
]]>
|
||||
</change-notes>
|
||||
</change-notes>
|
||||
|
||||
<!-- http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products -->
|
||||
<!-- The unique identifiers of the plugins on which this plugin depends -->
|
||||
<!-- com.intellij.modules.lang is included in every IntelliJ-based IDE, plugin will be available as well -->
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<!-- Optional dependency on another plugin. If the plugin with the "MySecondPlugin" ID is installed, the contents of mysecondplugin.xml (the format of this file conforms to the format of plugin.xml) will be loaded. -->
|
||||
<!--<depends optional="true" config-file="custom-plugin.xml">CustomPlugin</depends>-->
|
||||
<!-- http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products -->
|
||||
<!-- The unique identifiers of the plugins on which this plugin depends -->
|
||||
<!-- com.intellij.modules.lang is included in every IntelliJ-based IDE, plugin will be available as well -->
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<!-- Optional dependency on another plugin. If the plugin with the "MySecondPlugin" ID is installed, the contents of mysecondplugin.xml (the format of this file conforms to the format of plugin.xml) will be loaded. -->
|
||||
<!--<depends optional="true" config-file="custom-plugin.xml">CustomPlugin</depends>-->
|
||||
|
||||
<!-- Allows a plugin to integrate its help system (in JavaHelp format) with the IDEA help system. The "file" attribute specifies the name of the JAR file
|
||||
in the "help" subdirectory of the plugin directory. The "path" attribute specifies the name of the helpset file within the JAR file.-->
|
||||
<helpset file="plugin-help.jar" path="/Help.hs" />
|
||||
<!-- Allows a plugin to integrate its help system (in JavaHelp format) with the IDEA help system. The "file" attribute specifies the name of the JAR file
|
||||
in the "help" subdirectory of the plugin directory. The "path" attribute specifies the name of the helpset file within the JAR file.-->
|
||||
<helpset file="plugin-help.jar" path="/Help.hs"/>
|
||||
|
||||
<!-- Minimum and maximum build of IDEA compatible with the plugin -->
|
||||
<idea-version since-build="139.000" until-build="999"/>
|
||||
<!-- Minimum and maximum build of IDEA compatible with the plugin -->
|
||||
<idea-version since-build="139.000" until-build="999"/>
|
||||
|
||||
<!-- Resource bundle from which the text of plugin descriptions, action names and etc. will be loaded -->
|
||||
<resource-bundle>org.jetbrains.plugins.sample.PluginSampleBundle</resource-bundle>
|
||||
<!-- Resource bundle from which the text of plugin descriptions, action names and etc. will be loaded -->
|
||||
<resource-bundle>org.jetbrains.plugins.sample.PluginSampleBundle</resource-bundle>
|
||||
|
||||
<!-- Plugin's application components -->
|
||||
<application-components>
|
||||
<component>
|
||||
<!-- Component's interface class -->
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyApplicationComponent</interface-class>
|
||||
<!-- Component's implementation class -->
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyApplicationComponentImpl</implementation-class>
|
||||
</component>
|
||||
</application-components>
|
||||
<!-- Plugin's application components -->
|
||||
<application-components>
|
||||
<component>
|
||||
<!-- Component's interface class -->
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyApplicationComponent</interface-class>
|
||||
<!-- Component's implementation class -->
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyApplicationComponentImpl</implementation-class>
|
||||
</component>
|
||||
</application-components>
|
||||
|
||||
<!-- Plugin's project components -->
|
||||
<project-components>
|
||||
<component>
|
||||
<!-- Interface and implementation classes are the same -->
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyProjectComponent</interface-class>
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyProjectComponentImpl</implementation-class>
|
||||
<!-- If the "workspace" option is set "true", the component saves its state to the .iws file
|
||||
instead of the .ipr file. Note that the <option> element is used only if the component implements the JDOMExternalizable interface. Otherwise, the use of the <option> element takes no effect.-->
|
||||
<!-- Plugin's project components -->
|
||||
<project-components>
|
||||
<component>
|
||||
<!-- Interface and implementation classes are the same -->
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyProjectComponent</interface-class>
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyProjectComponentImpl</implementation-class>
|
||||
<!-- If the "workspace" option is set "true", the component saves its state to the .iws file
|
||||
instead of the .ipr file. Note that the <option> element is used only if the component implements the JDOMExternalizable interface. Otherwise, the use of the <option> element takes no effect.-->
|
||||
|
||||
<option name="workspace" value="true" />
|
||||
<!-- If the "loadForDefaultProject" tag is present, the project component is instantiated also for the default project. -->
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
</project-components>
|
||||
<option name="workspace" value="true"/>
|
||||
<!-- If the "loadForDefaultProject" tag is present, the project component is instantiated also for the default project. -->
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<!-- Plugin's module components -->
|
||||
<module-components>
|
||||
<component>
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyModuleComponent</interface-class>
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyModuleComponentImpl</implementation-class>
|
||||
</component>
|
||||
</module-components>
|
||||
<!-- Plugin's module components -->
|
||||
<module-components>
|
||||
<component>
|
||||
<interface-class>org.jetbrains.plugins.sample.DummyModuleComponent</interface-class>
|
||||
<implementation-class>org.jetbrains.plugins.sample.DummyModuleComponentImpl</implementation-class>
|
||||
</component>
|
||||
</module-components>
|
||||
|
||||
<!-- Actions -->
|
||||
<actions>
|
||||
<!-- The <action> element defines an action to register.
|
||||
The mandatory "id" attribute specifies an unique identifier for the action.
|
||||
The mandatory "class" attribute specifies the full-qualified name of the class implementing the action.
|
||||
The mandatory "text" attribute specifies the text of the action (tooltip for toolbar button or text for menu item).
|
||||
The optional "use-shortcut-of" attribute specifies the ID of the action whose keyboard shortcut this action will use.
|
||||
The optional "description" attribute specifies the text which is displayed in the status bar when the action is focused.
|
||||
The optional "icon" attribute specifies the icon which is displayed on the toolbar button or next to the menu item. -->
|
||||
<action id="PluginSample.DummyAction" class="org.jetbrains.plugins.sample.SimpleAction" text="Dummy Action" description="Illustrates how to plug an action in">
|
||||
<!-- The <keyboard-shortcut> node specifies the keyboard shortcut for the action. An action can have several keyboard shortcuts.
|
||||
The mandatory "first-keystroke" attribute specifies the first keystroke of the action. The key strokes are specified according to the regular Swing rules.
|
||||
The optional "second-keystroke" attribute specifies the second keystroke of the action.
|
||||
The mandatory "keymap" attribute specifies the keymap for which the action is active. IDs of the standard keymaps are defined as
|
||||
constants in the com.intellij.openapi.keymap.KeymapManager class. -->
|
||||
<keyboard-shortcut first-keystroke="control alt A" second-keystroke="C" keymap="$default"/>
|
||||
<!-- The <mouse-shortcut> node specifies the mouse shortcut for the action. An action can have several mouse shortcuts.
|
||||
The mandatory "keystroke" attribute specifies the clicks and modifiers for the action. It is defined as a sequence of words separated by spaces:
|
||||
"button1", "button2", "button3" for the mouse buttons; "shift", "control", "meta", "alt", "altGraph" for the modifier keys;
|
||||
"doubleClick" if the action is activated by a double-click of the button.
|
||||
The mandatory "keymap" attribute specifies the keymap for which the action is active. IDs of the standard keymaps are defined as
|
||||
constants in the com.intellij.openapi.keymap.KeymapManager class. -->
|
||||
<mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/>
|
||||
<!-- The <add-to-group> node specifies that the action should be added to an existing group. An action can be added to several groups.
|
||||
The mandatory "group-id" attribute specifies the ID of the group to which the action is added.
|
||||
The group must be implemented by an instance of the DefaultActionGroup class.
|
||||
The mandatory "anchor" attribute specifies the position of the action in the group relative to other actions. It can have the values
|
||||
"first", "last", "before" and "after".
|
||||
The "relative-to-action" attribute is mandatory if the anchor is set to "before" and "after", and specifies the action before or after which
|
||||
the current action is inserted. -->
|
||||
<add-to-group group-id="ToolsMenu" anchor="after"/>
|
||||
</action>
|
||||
</actions>
|
||||
<!-- Actions -->
|
||||
<actions>
|
||||
<!-- The <action> element defines an action to register.
|
||||
The mandatory "id" attribute specifies an unique identifier for the action.
|
||||
The mandatory "class" attribute specifies the full-qualified name of the class implementing the action.
|
||||
The mandatory "text" attribute specifies the text of the action (tooltip for toolbar button or text for menu item).
|
||||
The optional "use-shortcut-of" attribute specifies the ID of the action whose keyboard shortcut this action will use.
|
||||
The optional "description" attribute specifies the text which is displayed in the status bar when the action is focused.
|
||||
The optional "icon" attribute specifies the icon which is displayed on the toolbar button or next to the menu item. -->
|
||||
<action id="PluginSample.DummyAction" class="org.jetbrains.plugins.sample.SimpleAction" text="Dummy Action"
|
||||
description="Illustrates how to plug an action in">
|
||||
<!-- The <keyboard-shortcut> node specifies the keyboard shortcut for the action. An action can have several keyboard shortcuts.
|
||||
The mandatory "first-keystroke" attribute specifies the first keystroke of the action. The key strokes are specified according to the regular Swing rules.
|
||||
The optional "second-keystroke" attribute specifies the second keystroke of the action.
|
||||
The mandatory "keymap" attribute specifies the keymap for which the action is active. IDs of the standard keymaps are defined as
|
||||
constants in the com.intellij.openapi.keymap.KeymapManager class. -->
|
||||
<keyboard-shortcut first-keystroke="control alt A" second-keystroke="C" keymap="$default"/>
|
||||
<!-- The <mouse-shortcut> node specifies the mouse shortcut for the action. An action can have several mouse shortcuts.
|
||||
The mandatory "keystroke" attribute specifies the clicks and modifiers for the action. It is defined as a sequence of words separated by spaces:
|
||||
"button1", "button2", "button3" for the mouse buttons; "shift", "control", "meta", "alt", "altGraph" for the modifier keys;
|
||||
"doubleClick" if the action is activated by a double-click of the button.
|
||||
The mandatory "keymap" attribute specifies the keymap for which the action is active. IDs of the standard keymaps are defined as
|
||||
constants in the com.intellij.openapi.keymap.KeymapManager class. -->
|
||||
<mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/>
|
||||
<!-- The <add-to-group> node specifies that the action should be added to an existing group. An action can be added to several groups.
|
||||
The mandatory "group-id" attribute specifies the ID of the group to which the action is added.
|
||||
The group must be implemented by an instance of the DefaultActionGroup class.
|
||||
The mandatory "anchor" attribute specifies the position of the action in the group relative to other actions. It can have the values
|
||||
"first", "last", "before" and "after".
|
||||
The "relative-to-action" attribute is mandatory if the anchor is set to "before" and "after", and specifies the action before or after which
|
||||
the current action is inserted. -->
|
||||
<add-to-group group-id="ToolsMenu" anchor="after"/>
|
||||
</action>
|
||||
<!-- The <group> element defines an action group. <action>, <group> and <separator> elements defined within it are automatically included in the group.
|
||||
The mandatory "id" attribute specifies an unique identifier for the action.
|
||||
The optional "class" attribute specifies the full-qualified name of the class implementing the group. If not specified,
|
||||
com.intellij.openapi.actionSystem.DefaultActionGroup is used.
|
||||
The optional "text" attribute specifies the text of the group (text for the menu item showing the submenu).
|
||||
The optional "description" attribute specifies the text which is displayed in the status bar when the group is focused.
|
||||
The optional "icon" attribute specifies the icon which is displayed on the toolbar button or next to the group.
|
||||
The optional "popup" attribute specifies how the group is presented in the menu. If a group has popup="true", actions in it
|
||||
are placed in a submenu; for popup="false", actions are displayed as a section of the same menu delimited by separators. -->
|
||||
<group class="org.jetbrains.plugins.sample.DummyActionGroup" id="DummyActionGroup" text="Action Group"
|
||||
description="Illustration of an action group"
|
||||
icon="icons/testgroup.png" popup="true">
|
||||
<action id="PluginSample.GroupedAction" class="org.jetbrains.plugins.sample.GroupedAction"
|
||||
text="Grouped Action" description="An action in the group"/>
|
||||
<!-- The <separator> element defines a separator between actions. It can also have an <add-to-group> child element. -->
|
||||
<separator/>
|
||||
<group id="ActionSubGroup"/>
|
||||
<!-- The <reference> element allows to add an existing action to the group. The mandatory "ref" attribute specifies the ID of the action to add. -->
|
||||
<reference ref="EditorCopy"/>
|
||||
<add-to-group group-id="MainMenu" relative-to-action="HelpMenu" anchor="before"/>
|
||||
</group>
|
||||
|
||||
<!-- Extension points defined by the plugin. Extension points are registered by a plugin so that other plugins can provide this plugin
|
||||
with certain data. The "beanClass" attribute specifies the class the implementations of which can be used for the extension point. -->
|
||||
<!--<extensionPoints>-->
|
||||
</actions>
|
||||
|
||||
<!-- Extension points defined by the plugin. Extension points are registered by a plugin so that other plugins can provide this plugin
|
||||
with certain data. The "beanClass" attribute specifies the class the implementations of which can be used for the extension point. -->
|
||||
<!--<extensionPoints>-->
|
||||
<!--<extensionPoint name="testExtensionPoint" beanClass="com.foo.impl.MyExtensionBean"/>-->
|
||||
<!--</extensionPoints>-->
|
||||
<!--</extensionPoints>-->
|
||||
|
||||
<!-- Extensions which the plugin adds to extension points defined by the IDEA core or by other plugins. The "defaultExtensionNs " attribute must be set to the ID of the plugin defining the extension point,
|
||||
or to "com.intellij" if the extension point is defined by the IDEA core. The name of the
|
||||
tag within the <extensions> tag matches the name of the extension point, and the "implementation" class specifies the name of the
|
||||
class added to the extension point. -->
|
||||
<extensions >
|
||||
<!--<testExtensionPoint implementation="com.foo.impl.MyExtensionImpl"/>-->
|
||||
</extensions>
|
||||
<!-- Extensions which the plugin adds to extension points defined by the IDEA core or by other plugins. The "defaultExtensionNs " attribute must be set to the ID of the plugin defining the extension point,
|
||||
or to "com.intellij" if the extension point is defined by the IDEA core. The name of the
|
||||
tag within the <extensions> tag matches the name of the extension point, and the "implementation" class specifies the name of the
|
||||
class added to the extension point. -->
|
||||
<extensions>
|
||||
<!--<testExtensionPoint implementation="com.foo.impl.MyExtensionImpl"/>-->
|
||||
</extensions>
|
||||
</idea-plugin>
|
@ -0,0 +1,17 @@
|
||||
package org.jetbrains.plugins.sample;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public class DummyActionGroup extends ActionGroup {
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(AnActionEvent anActionEvent) {
|
||||
return new GroupedAction[0];
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.jetbrains.plugins.sample;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public class GroupedAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user