Mrli
别装作很努力,
因为结局不会陪你演戏。
Contacts:
QQ博客园

IDEA插件开发

2021/09/22 Java
Word count: 783 | Reading time: 4min

目的是想将类方法和成员方法区分开来, 想设计这么一个插件

新建IDEA 插件工程

File -> new -> Project -> Plugin即可

初始会生成一个项目xml配置文件, 以下是我进行修改后的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<idea-plugin>
<id>top.nymrli.privatesee</id>
<name>privateSee</name>
<version>1.0</version>
<vendor email="nymrli99@163.com" url="http://nymrli.top">Mrli</vendor>

<description><![CDATA[
Highlight when private methods are called.
]]></description>

<change-notes><![CDATA[
<br>
<em>First created. This time will be tried</em>
<br>
]]>
</change-notes>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>

<actions>
<!-- Add your actions here -->
<action id="FirstPluginActionId" class="top.nymrli.privatesee.FirstPluginAction" text="测试" description="测试描述">
<add-to-group group-id="ToolsMenu" anchor="first"/>
<keyboard-shortcut keymap="$default" first-keystroke="ctrl I"/>
</action>
</actions>

</idea-plugin>

新建action

1
2
3
4
5
6
7
8
9
10
11
12

public class FirstPluginAction extends AnAction {

@Override
public void actionPerformed(AnActionEvent e) {
// TODO: insert action logic here
NotificationGroup notificationgroup = new NotificationGroup("flugin_id", NotificationDisplayType.BALLOON, true);
Notification notification = notificationgroup.createNotification("点击测试", MessageType.INFO);
Notifications.Bus.notify(notification);

}
}

运行测试: edit configuration选择plugin, 然后选择运行

启动初始化

新建一个类

1
2
3
4
5
6
7
8
9
public class MyApplicationComponent implements ApplicationComponent {

@Override
public void initComponent() {
System.out.println("插件初始化");
TanChuanDialog dialog = new TanChuanDialog();
dialog.show();
}
}

在xml配置指定

1
2
3
4
5
6
7
<application-components>
<component>
<implementation-class>
top.nymrli.privatesee.MyApplicationComponent
</implementation-class>
</component>
</application-components>

弹窗效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class TanChuanDialog extends DialogWrapper {
JPanel jPanel;
JLabel label;
JButton btn;

public TanChuanDialog() {
super(true);
// 设置弹窗的标题
setTitle("启动弹窗");
init();
}

// 设置弹窗中间展示内容
@Nullable
@Override
protected JComponent createCenterPanel() {
jPanel = new JPanel();
label = new JLabel("显示内容");
jPanel.add(label);
return jPanel;
}


// 自定义设置底部的按钮
@Override
protected JComponent createSouthPanel() {
jPanel = new JPanel();
btn = new JButton("再干一杯");
btn.addActionListener(e->{
label.setText("被点击了哦");
});
jPanel.add(btn);
return jPanel;
}
}

教程:

插件推荐

插件名 功能
Codegalance 提供侧栏的代码缩览图
translation IDE内提供划线翻译功能
grep-console 显示多颜色调试日志
restfultoolkit 一套 RESTful 服务开发辅助工具集
1. 可根据URL查找对应controller
2. 提供一个service tree窗口
3. 一个简单的http请求工具
4. 提供将类生成json数据
gsonformaterPlus json对象生成器
jsonparser 内置json美化工具
mybatis log plugin (现收费) 根据log4j的打印的sql日志一键生成执行的sql语句
free mybatis plugin 1.提供xml和dao层的互相跳转功能,箭头形状。
2,
mapper生成xml文件: alt+enter快捷键
3.mybatis自动补全及语法错误提示
4.集成mybatis generator gui界面
Alibaba Java Coding Guidelines 阿里巴巴JAVA开发规范检测插件
codata 人工智能代码检测补全插件
easycode 自动生成mybatis mapper相关
lombok lombok识别插件,2020IDEA已内置
JUnitGenerate 单元测试生成器
MyBatisCodeHelperPro 全能mybatis插件
alibaba cloud toolkit 快速部署到服务器
idea zookeeper 图形化zookeeper
sequencediagram 时序图生成插件

https://www.zhihu.com/zvideo/1319971719340761088

Author: Mrli

Link: https://nymrli.top/2020/07/11/IDEA插件开发/

Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.

< PreviousPost
SQL练习
NextPost >
getBargains的record和Solution
CATALOG
  1. 1. 新建IDEA 插件工程
  2. 2. 新建action
  3. 3. 启动初始化
  4. 4. 弹窗效果
  • 教程:
  • 插件推荐