当前位置:网站首页>Develop plug-ins for idea
Develop plug-ins for idea
2022-07-03 12:06:00 【J_ D_ Chi】
Write it at the front
In the use of Android Studio When , In order to improve efficiency , We will use some plug-ins to expand IDE Use . Sometimes, because some function plug-ins are not provided , Or the author did not maintain it for a long time, resulting in failure , We can also try to develop a plug-in by ourselves , Such as Android Studio,PhpStorm Things like that belong to JetBrains, In other words, a plug-in we develop may be common in many different editors .
Development plugin The tools used are Intelij IDEA.
Besides, I also wrote right Android Of strings.xml Plug in for multilingual translation , To learn accordingly .GitHub Address
step
1. newly build InteliJ Platform Plugin engineering
After new creation , What we should pay attention to is plugin.xml And used to write code src There are two places in the folder .
2. Introduce
2.1 plugin.xml
This file is a registration file , If developed Android Words , Is similar to the Android Inside AndroidManifest.xml file , Contains some registration information . stay Android To develop an interface in, we say create a new Activity, That's in plugin This is called Action, It is used to develop the operations to be performed after clicking our plug-in .
We Activity After writing, it will be in AndroidManifest.xml Registered in the , So here Action We are going to plugin.xml Registered in the . So just look plugin.xml The content in is easy to understand .
<idea-plugin>
<id>com.your.company.unique.plugin.id</id>
<name>Plugin display name here</name>
<version>1.0</version>
<vendor email="[email protected]" url="http://www.yourcompany.com">YourCompany</vendor>
<description><![CDATA[ Enter short description for your plugin here.<br> <em>most HTML tags may be used</em> ]]></description>
<change-notes><![CDATA[ Add change notes here.<br> <em>most HTML tags may be used</em> ]]>
</change-notes>
<!-- Please check out http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html The introduction in -->
<idea-version since-build="173.0"/>
<!-- Please check out http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html About positioning different products -->
<!-- uncomment to enable plugin in all products <depends>com.intellij.modules.lang</depends> -->
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>
<actions>
<!-- Add your... Here Action -->
</actions>
</idea-plugin>
2. Action
I said before. , To develop a plugin The main thing is Action, This is our entrance , stay Action Write our code in , Achieve what we want .
2.1 newly build Action
Fill in some basic information here :
Name Indicates the title displayed in the menu at that time ;
Description Just write some introductions ;
Groups Where you want this plug-in to appear in the menu , Here we try to choose EditMenu, Then on the right is first, In other words, this plug-in will appear in Edit The first position under the menu ;
Keyboard Shortcuts Indicates that some shortcut keys can be defined ;
After new creation :
public class ClickAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
// Write your logic code here
Messages.showErrorDialog("Error message" , "Error Title");
}
}
Let's take a look at plugin.xml Change in :
<actions>
<!-- Add your actions here -->
<action id="Test.Test" class="ClickAction" text="MyIdeaPlugin" description="This is my first plugin test">
<add-to-group group-id="EditMenu" anchor="first"/>
</action>
</actions>
####2.2 function Action
We directly run, It will open a new plug-in IDE window , And then we can go in Edit The menu sees what we defined Action The entrance to . Click to pop up the window we just wrote .
notes : I have a question here , I'm in the process of developing , Click on this. action No response , Instead, it is the shortcut keys defined during initialization that are useful , I don't know what the problem is . And other options in the menu are , Need to use shortcut keys , And clicking is invalid . But looking at other people's articles, I didn't find such a situation .
3. Release plug-ins
After our development, we can package the plug-ins , Generate a jar package , Then we can install it into our Android Studio And so on. IDE Yes .
stay Build Choose Prepare Plugin Module ‘ name ’ For Deployment , IDE It will be automatically generated in the project directory jar It's packed .
This is the general process .
Other
Necessary knowledge
- Because here we will involve the operation of some interfaces , Then we have to learn swing, use Jpanel,JButton Do some simple interface implementation , This is related to development Android The process is similar ;
Problems encountered
1. Compatibility
After writing a plug-in and generating jar After package , I am here Android Studio There was an incompatible error when installing in , Cause unable to install , The main problem here is the version . Although these IDE All are JetBrains Of , But there are version differences between them .
What we need to revise is plugin.xml Inside
<idea-version since-build="173.0"/>
So how to modify the version number to match what we want IDE Well ? You can check it here :
http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html
So I'm here now Android Studio The latest version of is 1.3, Then we'll change it to 141:
<idea-version since-build="141"/>
Reference resources
AndroidStudio Plug-in development ( Advanced chapter of Action Mechanism )
边栏推荐
- VS2015的下载地址和安装教程
- Optimize interface performance
- (database authorization - redis) summary of unauthorized access vulnerabilities in redis
- Duplicate numbers in the array of sword finger offer 03
- rxjs Observable filter Operator 的实现原理介绍
- 简单工厂和工厂方法模式
- Laravel time zone timezone
- ArcGIS应用(二十一)Arcmap删除图层指定要素的方法
- Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
- XML (DTD, XML parsing, XML modeling)
猜你喜欢
QT OpenGL rotate, pan, zoom
Vulnhub's Tomato (tomato)
ArcGIS application (XXI) ArcMap method of deleting layer specified features
"Jianzhi offer 04" two-dimensional array search
MCDF Experiment 1
STL tutorial 10 container commonalities and usage scenarios
PHP导出word方法(一mht)
XML (DTD, XML parsing, XML modeling)
Extrapolated scatter data
[official MySQL document] deadlock
随机推荐
023(【模板】最小生成树)(最小生成树)
《剑指offer 03》数组中重复的数字
vulnhub之pyexp
(構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術
(构造笔记)GRASP学习心得
[official MySQL document] deadlock
Solution à la défaillance de l'installation d'Electron
解决msvcp120d.dll和msvcr120d.dll缺失
DEJA_VU3D - Cesium功能集 之 053-地下模式效果
牛牛的组队竞赛
Unicode encoding table download
Introduction to the implementation principle of rxjs observable filter operator
CGroup introduction
vulnhub之GeminiInc v2
vulnhub之GeminiInc
vulnhub之Ripper
Oracle advanced (I) realize DMP by expdp impdp command
During FTP login, the error "530 login incorrect.login failed" is reported
【mysql官方文档】死锁
Symlink(): solution to protocol error in PHP artisan storage:link on win10