<!-- url="..." URL ( Welcome Screen "Plugins") --> <idea-plugin url="http://www.jetbrains.com/idea"> <!-- --> <name>VssIntegration</name> <!-- . . , - <name> --> <id>VssIntegration</id> <!-- --> <description>Vss integration plugin</description> <!-- . Web- --> <change-notes>Initial release of the plugin.</change-notes> <!-- --> <version>1.0</version> <!-- . "url" . "email" . "logo" 1616, JAR --> <vendor url="http://www.jetbrains.com" email="support@jetbrains.com" logo="icons/plugin.png">Foo Inc.</vendor> <!-- --> <depends>MyFirstPlugin</depends> <!-- --> <depends optional="true" config-file="mysecondplugin.xml">MySecondPlugin</depends> <!-- ( JavaHelp ) IDEA. "file" JAR "help". "path" helpset. --> <helpset file="myhelp.jar" path="/Help.hs" /> <!-- , --> <idea-version since-build="3000" until-build="3999"/> <!-- --> <resource-bundle>messages.MyPluginBundle</resource-bundle> <!-- --> <application-components> <component> <!-- --> <interface-class>com.foo.Component1Interface</interface-class> <!-- --> <implementation-class>com.foo.impl.Component1Impl</implementation-class> </component> </application-components> <!-- --> <project-components> <component> <!-- --> <interface-class>com.foo.Component2</interface-class> <!-- "workspace" "true", *.iws *.ipr ( JDOMExternalizable). --> <option name="workspace" value="true" /> <!-- "loadForDefaultProject", - --> <loadForDefaultProject> </component> </project-components> <!-- --> <module-components> <component> <interface-class>com.foo.Component3</interface-class> </component> </module-components> <!-- --> <actions> <action id="VssIntegration.GarbageCollection" class="com.foo.impl.CollectGarbage" text="Collect _Garbage" description="Run garbage collector"> <keyboard-shortcut first-keystroke="control alt G" second-keystroke="C" keymap="$default"/> </action> </actions> <!-- , . . "beanClass" , . --> <extensionPoints> <extensionPoint name="testExtensionPoint" beanClass="com.foo.impl.MyExtensionBean"/> </extensionPoints> <!-- , , IDEA . "defaultExtensionNs" ID "com.intellij" IDEA Core. <extensions> --> <extensions xmlns="VssIntegration"> <testExtensionPoint implementation="com.foo.impl.MyExtensionImpl"/> </extensions> </idea-plugin>
<actions> <!-- <action> , . "id" . "class" , . "text" . "use-shortcut-of" , . "description" . "icon" . --> <action id="VssIntegration.GarbageCollection" class="com.foo.impl.CollectGarbage" text="Collect _Garbage" description="Run garbage collector" icon="icons/garbage.png"> <!-- <add-to-group> , ( ). "group-id" . DefaultActionGroup. "anchor" ("first", "last", "before" "after"). "relative-to-action" , anchor "before" "after". --> <add-to-group group-id="ToolsMenu" relative-to-action="GenerateJavadoc" anchor="after"/> <!-- <keyboard-shortcut> . "first-keystroke" . Swing-. "second-keystroke" . "keymap" . com.intellij.openapi.keymap.KeymapManager. --> <keyboard-shortcut first-keystroke="control alt G" second-keystroke="C" keymap="$default"/> <!-- <mouse-shortcut> . , : "button1", "button2", "button3" ; "shift", "control", "meta", "alt", "altGraph" ; "doubleClick" – . --> <mouse-shortcut keystroke="control button3 doubleClick" keymap="$default"/> </action> <!-- <group> . <action>, <group> <separator> . "popup" , . popup="true", ; popup="false", . --> <group class="com.foo.impl.MyActionGroup" id="TestActionGroup" text="Test Group" description="Group with test actions" icon="icons/testgroup.png" popup="true"> <action id="VssIntegration.TestAction" class="com.foo.impl.TestAction" text="My Test Action" description="My test action"/> <!-- <separator> . <add-to-group>. --> <separator/> <group id="TestActionGroup"/> <!-- <reference> . "ref" . --> <reference ref="EditorCopy"/> <add-to-group group-id="MainMenu" relative-to-action="HelpMenu" anchor="before"/> </group> </actions>
<application-components>
section of the plugin.xml file. public class MyPluginRegistration implements ApplicationComponent { // @NotNull public String getComponentName() { return "MyPlugin"; } // MyPluginRegistration <application-components> // IDEA. public void initComponent() { ActionManager am = ActionManager.getInstance(); TextBoxes action = new TextBoxes(); // . am.registerAction("MyPluginAction", action); // , . DefaultActionGroup windowM = (DefaultActionGroup) am.getAction("WindowMenu"); // . windowM.addSeparator(); windowM.add(action); } // . public void disposeComponent() { } }
@State
annotation. class MyService implements PersistentStateComponent<MyService.State> { class State { public String value; } State myState; public State getState() { return myState; } public void loadState(State state) { myState = state; } }
class MyService implements PersistentStateComponent<MyService> { public String stateValue; public MyService getState() { return this; } public void loadState(MyService state) { XmlSerializerUtil.copyBean(state, this); } }
@Transient
annotation.@State
annotation to the component class, in which you must specify the following fields:@Storage
(required) - defines the storage location for * .ipr files;@Storage
annotation:@Storage(id="other", file = StoragePathMacros.APP_CONFIG + "/other.xml")
- for application-level values;@Storage(id="other", file = StoragePathMacros.PROJECT_FILE)
- for values stored in the project file (.ipr);@Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/other.xml", scheme = StorageScheme.DIRECTORY_BASED)})
- for values stored in the project directory;@Storage(id="other", file = StoragePathMacros.WORKSPACE_FILE)
- for values stored in the workspace file.@Storage
annotation can be used to exclude fields when serialized to a specific format. If you do not need to exclude anything, you can assign an arbitrary string value to the parameter.@Storage
annotation with the “scheme” parameter set to StorageScheme.DIRECTORY_BASED
, for example: @State( name = "AntConfiguration", storages = { @Storage(id = "default", file = StoragePathMacros.PROJECT_FILE), @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/ant.xml", scheme = StorageScheme.DIRECTORY_BASED) } )
@Tag, @Attribute, @Property, @MapAnnotation, @AbstractCollection
.Source: https://habr.com/ru/post/187142/
All Articles