├── .gitignore
├── LICENSE.md
├── README.md
├── README_EN.md
├── mybatis-log-plugin-readme.iml
├── resources
└── META-INF
│ └── plugin.xml
├── snapshot
├── filter.png
├── format.png
├── plugin.jpg
└── sqltext.png
└── src
└── mybatis
└── log
├── Icons.java
├── action
├── ShowLogInConsoleAction.java
└── TailMyBatisLog.java
├── icon
├── disabledRun.png
├── filter.png
├── format.png
├── mybatis.png
└── text.png
├── tail
├── TailContentExecutor.java
└── TailRunExecutor.java
└── util
└── StringConst.java
/.gitignore:
--------------------------------------------------------------------------------
1 | /out
2 | *.class
3 |
4 | .idea
5 | .idea/workspace.xml
6 | /test
7 | mybatis.log
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | 插件源码开源截止到2.1.1版本(存在一些bug,以及与新版本IDE的api存在兼容问题)
2 | 新版本收费插件代码不再开源,敬请谅解!
3 |
4 | 开源代码采用GitHub的[默认协议](https://help.github.com/cn/github/creating-cloning-and-archiving-repositories/licensing-a-repository)
5 | 有些人可能没明白默认协议的内容:
6 | > 您没有选择许可的义务, 但如果没有许可,就会默认实施版权法,因此您会保留对您的源代码的所有权利,任何人都不能复制、分发您的工作或创建其派生作品。
7 |
8 | 也就是说,默认协议是最严格的协议,代码的任何使用都是不允许的。
9 | 因为前期的开源,以及对个人用户不想做限制,所以补充了下面的条款。
10 | **补充条款:**
11 | * 个人用户:源码对个人用户非常友好,你想怎么修改,怎么兼容版本,怎么编译安装在自己电脑上,都没有任何限制。
12 | * **绝对禁止:修改编译过的插件重新发布到仓库或共享出去。**
13 |
14 | 上面这些补充,都是出于私心,只要大家对源码的改造不进行二次发布,不影响插件的销售,原则上都是允许的。
15 | 希望有需要改造代码的用户,请使用clone到本地的方式,或者fork后改为私有仓库,请勿再公开改造后的代码,谢谢理解。
16 |
17 | **特别说明:**
18 | 最近看到有些github的用户,自己复制了本仓库代码改造后,开源代码打包发布,为了给自己增加一些star,以及不希望作者插件产生收益,又写了文章大肆宣传,甚至完全乱用许可协议。
19 | 对这种人的一些建议:
20 | * 损人不利己的事尽量不要做。
21 | * 你要用别人的代码,就最好遵守开源精神和别人的LICENSE协议。
22 | * 你这种断人财路,破坏开源协议的repo,再多的star也并不能为你加分。
23 | * 改造别人插件的时间尽量拿来创造自己的插件。
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin/versions)
3 | 
4 |
5 | ### [English](https://github.com/kookob/mybatis-log-plugin/blob/master/README_EN.md)
6 |
7 | # MyBatis Log Plugin
8 | ## 插件功能
9 | - 还原`MyBatis`输出的日志为完整的`SQL`语句。
10 | - 把`SQL`日志里面的`?`替换为真正的参数值。
11 | - 选中要还原的`MyBatis`日志,右键点击菜单`Restore Sql`,还原`SQL`语句.
12 | - `Java`接口方法与`Mapper xml`文件互相跳转。
13 |
14 | 
15 |
16 | ## 按钮作用
17 | - **Text**: 从文本内容还原`SQL`语句
18 | - **Settings**: 导航跳转开关,配置不想要输出的`SQL`语句
19 | - **Format**: 输出格式化过的`SQL`语句
20 | - **Rerun**: 重启插件
21 | - **Stop**: 停止插件
22 |
23 | ## 日志示例
24 | ```sql
25 | MyBatis Log Test: DEBUG sql1 - ==> Preparing: select * from t_table where name = ?
26 | MyBatis Log Test: DEBUG sql1 - ==> Parameters: hello(String)
27 | MyBatis Log Test: INFO sql2 - ==> Preparing: update t_table set name = ? where id = ?
28 | MyBatis Log Test: INFO sql2 - ==> Parameters: world(String), 123(Integer)
29 | MyBatis Log Test: WARN sql3 - ==> Preparing: delete from t_table where id = ?
30 | MyBatis Log Test: WARN sql3 - ==> Parameters: 123(Integer)
31 | MyBatis Log Test: ERROR sql4 - ==> Preparing: select * from t_table order by id asc
32 | MyBatis Log Test: ERROR sql4 - ==> Parameters:
33 | ```
34 | 插件输出的完整的可执行的`SQL`语句如下:
35 | ```sql
36 | -- 1 MyBatis Log Test: DEBUG sql1 - ==>
37 | select *
38 | FROM t_table
39 | WHERE name = 'hello';
40 | ------------------------------------------------------------
41 | -- 2 MyBatis Log Test: INFO sql2 - ==>
42 | update t_table set name = 'world'
43 | WHERE id = 123;
44 | ------------------------------------------------------------
45 | -- 3 MyBatis Log Test: WARN sql3 - ==>
46 | delete
47 | FROM t_table
48 | WHERE id = 123;
49 | ------------------------------------------------------------
50 | -- 4 MyBatis Log Test: ERROR sql4 - ==>
51 | select *
52 | FROM t_table order by id asc;
53 | ```
54 |
55 | ## 安装下载
56 | [mybatis-log-plugin.jar](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin/versions)
57 |
58 | ## 价格
59 | `$5/year`
60 |
61 | ## 插件文档
62 | https://www.yuque.com/kookob/plugin
63 | 文档里面包含插件介绍,使用手册,购买流程,激活失败等说明。
64 |
65 | ## 其他插件
66 | * [MyBatis Log Plugin](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin)
67 | * [Smart Jump](https://plugins.jetbrains.com/plugin/14053-smart-jump)
68 | * [Smart Search](https://plugins.jetbrains.com/plugin/14615-smart-search)
69 | * [Toolset](https://plugins.jetbrains.com/plugin/14384-toolset)
70 |
--------------------------------------------------------------------------------
/README_EN.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin/versions)
3 |
4 | ### [中文](https://github.com/kookob/mybatis-log-plugin/blob/master/README.md)
5 |
6 | # MyBatis Log Plugin
7 | ## Features
8 | - Restore mybatis sql log to original whole sql.
9 | - It will generate executable sql statements with replace ? to the really param value.
10 | - Select the console sql log and right-click "Restore Sql" menu to restore sql.
11 | - Navigate to each other between Java method and Mapper xml.
12 |
13 | 
14 |
15 | ## Button Features
16 | - **Text**: Restore sql from text
17 | - **Settings**: Setup filter rules and navigation switch
18 | - **Format**: Output beautiful formatted sql statements
19 | - **Rerun**: Rerun plugin
20 | - **Stop**: Stop plugin
21 |
22 | ## Example
23 | ```sql
24 | MyBatis Log Test: DEBUG sql1 - ==> Preparing: select * from t_table where name = ?
25 | MyBatis Log Test: DEBUG sql1 - ==> Parameters: hello(String)
26 | MyBatis Log Test: INFO sql2 - ==> Preparing: update t_table set name = ? where id = ?
27 | MyBatis Log Test: INFO sql2 - ==> Parameters: world(String), 123(Integer)
28 | MyBatis Log Test: WARN sql3 - ==> Preparing: delete from t_table where id = ?
29 | MyBatis Log Test: WARN sql3 - ==> Parameters: 123(Integer)
30 | MyBatis Log Test: ERROR sql4 - ==> Preparing: select * from t_table order by id asc
31 | MyBatis Log Test: ERROR sql4 - ==> Parameters:
32 | ```
33 | MyBatis Log Plugin output executable sql statements:
34 | ```sql
35 | -- 1 MyBatis Log Test: DEBUG sql1 - ==>
36 | select *
37 | FROM t_table
38 | WHERE name = 'hello';
39 | ------------------------------------------------------------
40 | -- 2 MyBatis Log Test: INFO sql2 - ==>
41 | update t_table set name = 'world'
42 | WHERE id = 123;
43 | ------------------------------------------------------------
44 | -- 3 MyBatis Log Test: WARN sql3 - ==>
45 | delete
46 | FROM t_table
47 | WHERE id = 123;
48 | ------------------------------------------------------------
49 | -- 4 MyBatis Log Test: ERROR sql4 - ==>
50 | select *
51 | FROM t_table order by id asc;
52 | ```
53 |
54 | ## Manual
55 | https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin/manual
56 |
57 | ## Download
58 | [mybatis-log-plugin.jar](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin/versions)
59 |
60 | ## Price
61 | `$5/year`
62 |
63 | ## Plugins
64 | * [MyBatis Log Plugin](https://plugins.jetbrains.com/plugin/13905-mybatis-log-plugin)
65 | * [Smart Jump](https://plugins.jetbrains.com/plugin/14053-smart-jump)
66 | * [Smart Search](https://plugins.jetbrains.com/plugin/14615-smart-search)
67 | * [Toolset](https://plugins.jetbrains.com/plugin/14384-toolset)
68 |
--------------------------------------------------------------------------------
/mybatis-log-plugin-readme.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | MyBatisLogPlugin
3 | MyBatis Log Plugin
4 | 2.1.1
5 | ob
6 |
7 |
8 |
11 |
12 |
13 |
14 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/snapshot/filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/snapshot/filter.png
--------------------------------------------------------------------------------
/snapshot/format.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/snapshot/format.png
--------------------------------------------------------------------------------
/snapshot/plugin.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/snapshot/plugin.jpg
--------------------------------------------------------------------------------
/snapshot/sqltext.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/snapshot/sqltext.png
--------------------------------------------------------------------------------
/src/mybatis/log/Icons.java:
--------------------------------------------------------------------------------
1 | package mybatis.log;
2 |
3 | import com.intellij.openapi.util.IconLoader;
4 |
5 | import javax.swing.*;
6 |
7 | /**
8 | * 图标文件
9 | * @author ob
10 | */
11 | public class Icons {
12 | public static final Icon MyBatisIcon = IconLoader.getIcon("/mybatis/log/icon/mybatis.png");
13 | public static final Icon FilterIcon = IconLoader.getIcon("/mybatis/log/icon/filter.png");
14 | public static final Icon FormatIcon = IconLoader.getIcon("/mybatis/log/icon/format.png");
15 | public static final Icon TextIcon = IconLoader.getIcon("/mybatis/log/icon/text.png");
16 | public static final Icon DisabledRunIcon = IconLoader.getIcon("/mybatis/log/icon/disabledRun.png");
17 | }
18 |
--------------------------------------------------------------------------------
/src/mybatis/log/action/ShowLogInConsoleAction.java:
--------------------------------------------------------------------------------
1 | package mybatis.log.action;
2 |
3 | import com.intellij.openapi.actionSystem.AnActionEvent;
4 | import com.intellij.openapi.project.DumbAwareAction;
5 | import com.intellij.openapi.project.Project;
6 | import com.intellij.openapi.util.Disposer;
7 | import mybatis.log.tail.TailContentExecutor;
8 | import mybatis.log.util.ConfigUtil;
9 |
10 |
11 | /**
12 | * 插件入口
13 | *
14 | * @author ob
15 | */
16 | public class ShowLogInConsoleAction extends DumbAwareAction {
17 |
18 | public ShowLogInConsoleAction(Project project) {
19 | super();
20 | ConfigUtil.active = true;
21 | ConfigUtil.init(project);
22 | }
23 |
24 | @Override
25 | public void actionPerformed(AnActionEvent e) {
26 | final Project project = e.getProject();
27 | if (project == null) return;
28 | }
29 |
30 | public void showLogInConsole(final Project project) {
31 | if (project == null) return;
32 | ConfigUtil.setRunning(project, true);
33 | final TailContentExecutor executor = new TailContentExecutor(project);
34 | Disposer.register(project, executor);
35 | executor.withRerun(() -> showLogInConsole(project));
36 | executor.withStop(() -> {
37 | ConfigUtil.setRunning(project, false);
38 | ConfigUtil.setIndexNum(project, 1);
39 | }, () -> ConfigUtil.getRunning(project));
40 | executor.withActivateToolWindow(true);
41 | executor.run();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/mybatis/log/action/TailMyBatisLog.java:
--------------------------------------------------------------------------------
1 | package mybatis.log.action;
2 |
3 | import com.intellij.openapi.actionSystem.AnActionEvent;
4 | import com.intellij.openapi.project.DumbAwareAction;
5 | import com.intellij.openapi.project.Project;
6 |
7 | /**
8 | * 初始化数据
9 | * @author ob
10 | */
11 | public class TailMyBatisLog extends DumbAwareAction {
12 | @Override
13 | public void actionPerformed(AnActionEvent e) {
14 | final Project project = e.getProject();
15 | if (project == null) return;
16 | new ShowLogInConsoleAction(project).showLogInConsole(project);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/mybatis/log/icon/disabledRun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/src/mybatis/log/icon/disabledRun.png
--------------------------------------------------------------------------------
/src/mybatis/log/icon/filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/src/mybatis/log/icon/filter.png
--------------------------------------------------------------------------------
/src/mybatis/log/icon/format.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/src/mybatis/log/icon/format.png
--------------------------------------------------------------------------------
/src/mybatis/log/icon/mybatis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/src/mybatis/log/icon/mybatis.png
--------------------------------------------------------------------------------
/src/mybatis/log/icon/text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kookob/mybatis-log-plugin/825d357df4a96823957caf6b0cc81e02c6cea4a0/src/mybatis/log/icon/text.png
--------------------------------------------------------------------------------
/src/mybatis/log/tail/TailContentExecutor.java:
--------------------------------------------------------------------------------
1 | package mybatis.log.tail;
2 |
3 | import com.intellij.execution.DefaultExecutionResult;
4 | import com.intellij.execution.ExecutionException;
5 | import com.intellij.execution.ExecutionManager;
6 | import com.intellij.execution.Executor;
7 | import com.intellij.execution.configurations.RunProfile;
8 | import com.intellij.execution.configurations.RunProfileState;
9 | import com.intellij.execution.filters.Filter;
10 | import com.intellij.execution.filters.TextConsoleBuilder;
11 | import com.intellij.execution.filters.TextConsoleBuilderFactory;
12 | import com.intellij.execution.runners.ExecutionEnvironment;
13 | import com.intellij.execution.ui.ConsoleView;
14 | import com.intellij.execution.ui.RunContentDescriptor;
15 | import com.intellij.execution.ui.RunnerLayoutUi;
16 | import com.intellij.execution.ui.actions.CloseAction;
17 | import com.intellij.icons.AllIcons;
18 | import com.intellij.openapi.Disposable;
19 | import com.intellij.openapi.actionSystem.ActionGroup;
20 | import com.intellij.openapi.actionSystem.ActionManager;
21 | import com.intellij.openapi.actionSystem.ActionPlaces;
22 | import com.intellij.openapi.actionSystem.ActionToolbar;
23 | import com.intellij.openapi.actionSystem.AnAction;
24 | import com.intellij.openapi.actionSystem.AnActionEvent;
25 | import com.intellij.openapi.actionSystem.CommonShortcuts;
26 | import com.intellij.openapi.actionSystem.DefaultActionGroup;
27 | import com.intellij.openapi.application.ApplicationManager;
28 | import com.intellij.openapi.fileEditor.FileDocumentManager;
29 | import com.intellij.openapi.project.DumbAware;
30 | import com.intellij.openapi.project.Project;
31 | import com.intellij.openapi.util.Computable;
32 | import com.intellij.openapi.util.Disposer;
33 | import com.intellij.openapi.wm.ToolWindowManager;
34 | import com.intellij.ui.content.Content;
35 | import mybatis.log.util.ConfigUtil;
36 | import org.jetbrains.annotations.NotNull;
37 | import org.jetbrains.annotations.Nullable;
38 |
39 | import javax.swing.*;
40 | import java.awt.*;
41 | import java.util.ArrayList;
42 | import java.util.List;
43 |
44 | /**
45 | * Copy of com.intellij.execution.RunContentExecutor Runs a process and prints the output in a content tab within the
46 | * Run toolwindow.
47 | *
48 | * @author ob
49 | */
50 | public class TailContentExecutor implements Disposable {
51 | private final Project myProject;
52 | private final List myFilterList = new ArrayList<>();
53 | private Runnable myRerunAction;
54 | private Runnable myStopAction;
55 | private Computable myStopEnabled;
56 | private String myTitle = "";//插件窗口标题
57 | private ConsoleView consoleView = null;
58 | private boolean myActivateToolWindow = true;
59 |
60 | public TailContentExecutor(@NotNull Project project) {
61 | myProject = project;
62 | consoleView = createConsole(project);
63 | ConfigUtil.consoleViewMap.put(project.getBasePath(), consoleView);
64 | }
65 |
66 | public TailContentExecutor withTitle(String title) {
67 | myTitle = title;
68 | return this;
69 | }
70 |
71 | public TailContentExecutor withRerun(Runnable rerun) {
72 | myRerunAction = rerun;
73 | return this;
74 | }
75 |
76 | public TailContentExecutor withStop(@NotNull Runnable stop, @NotNull Computable stopEnabled) {
77 | myStopAction = stop;
78 | myStopEnabled = stopEnabled;
79 | return this;
80 | }
81 |
82 | public TailContentExecutor withActivateToolWindow(boolean activateToolWindow) {
83 | myActivateToolWindow = activateToolWindow;
84 | return this;
85 | }
86 |
87 | private ConsoleView createConsole(@NotNull Project project) {
88 | TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
89 | consoleBuilder.filters(myFilterList);
90 | ConsoleView console = consoleBuilder.getConsole();
91 | return console;
92 | }
93 |
94 | public void run() {
95 | if (myProject.isDisposed()) {
96 | return;
97 | }
98 |
99 | FileDocumentManager.getInstance().saveAllDocuments();
100 | Executor executor = TailRunExecutor.getRunExecutorInstance();
101 | if(executor == null) {
102 | return;
103 | }
104 | DefaultActionGroup actions = new DefaultActionGroup();
105 | // Create runner UI layout
106 | final RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject);
107 | final RunnerLayoutUi layoutUi = factory.create("SQL", "SQL", "SQL", myProject);
108 | final JComponent consolePanel = createConsolePanel(consoleView, actions);
109 | RunContentDescriptor descriptor = new RunContentDescriptor(new RunProfile() {
110 | @Nullable
111 | @Override
112 | public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException {
113 | return null;
114 | }
115 |
116 | @Override
117 | public String getName() {
118 | //第一层名称显示
119 | return "Sql";
120 | }
121 |
122 | @Nullable
123 | @Override
124 | public Icon getIcon() {
125 | return null;
126 | }
127 | }, new DefaultExecutionResult(), layoutUi);
128 | descriptor.setExecutionId(System.nanoTime());
129 | //第二层名称显示
130 | final Content content = layoutUi.createContent("ConsoleContent", consolePanel, "executable sql statements", AllIcons.Debugger.Console, consolePanel);
131 | content.setCloseable(false);
132 | layoutUi.addContent(content);
133 | layoutUi.getOptions().setLeftToolbar(createActionToolbar(consolePanel, consoleView, layoutUi, descriptor, executor), "RunnerToolbar");
134 |
135 | Disposer.register(descriptor, this);
136 | Disposer.register(content, consoleView);
137 | if (myStopAction != null) {
138 | Disposer.register(consoleView, () -> myStopAction.run());
139 | }
140 |
141 | for (AnAction action : consoleView.createConsoleActions()) {
142 | actions.add(action);
143 | }
144 |
145 | ExecutionManager.getInstance(myProject).getContentManager().showRunContent(executor, descriptor);
146 | if (myActivateToolWindow) {
147 | activateToolWindow();
148 | }
149 | }
150 |
151 | @NotNull
152 | private ActionGroup createActionToolbar(JComponent consolePanel, ConsoleView consoleView, @NotNull final RunnerLayoutUi myUi, RunContentDescriptor contentDescriptor, Executor runExecutorInstance) {
153 | final DefaultActionGroup actionGroup = new DefaultActionGroup();
154 | actionGroup.add(new RerunAction(consolePanel, consoleView));
155 | actionGroup.add(new StopAction());
156 | actionGroup.add(consoleView.createConsoleActions()[2]);
157 | actionGroup.add(consoleView.createConsoleActions()[3]);
158 | actionGroup.add(consoleView.createConsoleActions()[5]);
159 | return actionGroup;
160 | }
161 |
162 | public void activateToolWindow() {
163 | ApplicationManager.getApplication().invokeLater(() -> ToolWindowManager.getInstance(myProject).getToolWindow(TailRunExecutor.TOOLWINDOWS_ID).activate(null));
164 | }
165 |
166 | private static JComponent createConsolePanel(ConsoleView view, ActionGroup actions) {
167 | JPanel panel = new JPanel();
168 | panel.setLayout(new BorderLayout());
169 | panel.add(view.getComponent(), BorderLayout.CENTER);
170 | // panel.add(createToolbar(actions), BorderLayout.WEST);
171 | return panel;
172 | }
173 |
174 | private static JComponent createToolbar(ActionGroup actions) {
175 | ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actions, false);
176 | return actionToolbar.getComponent();
177 | }
178 |
179 | @Override
180 | public void dispose() {
181 | Disposer.dispose(this);
182 | }
183 |
184 | private class RerunAction extends AnAction implements DumbAware {
185 | private final ConsoleView consoleView;
186 |
187 | public RerunAction(JComponent consolePanel, ConsoleView consoleView) {
188 | super("Rerun", "Rerun", AllIcons.Actions.Restart);
189 | this.consoleView = consoleView;
190 | registerCustomShortcutSet(CommonShortcuts.getRerun(), consolePanel);
191 | }
192 |
193 | @Override
194 | public void actionPerformed(AnActionEvent e) {
195 | Disposer.dispose(consoleView);
196 | myRerunAction.run();
197 | }
198 |
199 | @Override
200 | public void update(AnActionEvent e) {
201 | e.getPresentation().setVisible(myRerunAction != null);
202 | e.getPresentation().setIcon(AllIcons.Actions.Restart);
203 | }
204 | }
205 |
206 | private class StopAction extends AnAction implements DumbAware {
207 | public StopAction() {
208 | super("Stop", "Stop", AllIcons.Actions.Suspend);
209 | }
210 |
211 | @Override
212 | public void actionPerformed(AnActionEvent e) {
213 | myStopAction.run();
214 | }
215 |
216 | @Override
217 | public void update(AnActionEvent e) {
218 | e.getPresentation().setVisible(myStopAction != null);
219 | e.getPresentation().setEnabled(myStopEnabled != null && myStopEnabled.compute());
220 | }
221 | }
222 |
223 | private class MyCloseAction extends CloseAction implements DumbAware {
224 | public MyCloseAction(Executor executor, RunContentDescriptor contentDescriptor, Project project) {
225 | super(executor, contentDescriptor, project);
226 | }
227 |
228 | @Override
229 | public void actionPerformed(AnActionEvent e) {
230 | final Project project = e.getProject();
231 | if (project == null) return;
232 | ConfigUtil.active = false;
233 | ConfigUtil.setRunning(project, false);
234 | ConfigUtil.setIndexNum(project, 1);
235 | super.actionPerformed(e);
236 | }
237 | }
238 |
239 | }
240 |
--------------------------------------------------------------------------------
/src/mybatis/log/tail/TailRunExecutor.java:
--------------------------------------------------------------------------------
1 | package mybatis.log.tail;
2 |
3 | import com.intellij.execution.Executor;
4 | import com.intellij.execution.ExecutorRegistry;
5 | import mybatis.log.Icons;
6 | import mybatis.log.util.StringConst;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | import javax.swing.*;
10 |
11 | /**
12 | * Window Config
13 | *
14 | * @author ob
15 | */
16 | public class TailRunExecutor extends Executor {
17 | public static final String TOOLWINDOWS_ID = "MyBatis Log";
18 |
19 | @Override
20 | @NotNull
21 | public String getStartActionText() {
22 | return TOOLWINDOWS_ID;
23 | }
24 |
25 | @Override
26 | public String getToolWindowId() {
27 | return TOOLWINDOWS_ID;
28 | }
29 |
30 | @Override
31 | public Icon getToolWindowIcon() {
32 | return Icons.MyBatisIcon;
33 | }
34 |
35 | @Override
36 | @NotNull
37 | public Icon getIcon() {
38 | return Icons.MyBatisIcon;
39 | }
40 |
41 | @Override
42 | public Icon getDisabledIcon() {
43 | return Icons.DisabledRunIcon;
44 | }
45 |
46 | @Override
47 | public String getDescription() {
48 | return null;
49 | }
50 |
51 | @Override
52 | @NotNull
53 | public String getActionName() {
54 | return TOOLWINDOWS_ID;
55 | }
56 |
57 | @Override
58 | @NotNull
59 | public String getId() {
60 | return StringConst.PLUGIN_ID;
61 | }
62 |
63 | @Override
64 | public String getContextActionId() {
65 | return "MyBatisLogActionId";
66 | }
67 |
68 | @Override
69 | public String getHelpId() {
70 | return null;
71 | }
72 |
73 | public static Executor getRunExecutorInstance() {
74 | return ExecutorRegistry.getInstance().getExecutorById(StringConst.PLUGIN_ID);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/mybatis/log/util/StringConst.java:
--------------------------------------------------------------------------------
1 | package mybatis.log.util;
2 |
3 | /**
4 | * 字符串常量
5 | * @author ob
6 | */
7 | public class StringConst {
8 | public static final String PLUGIN_ID = "MyBatisLogPlugin";
9 | public static final String PREPARING = "Preparing:";
10 | public static final String PARAMETERS = "Parameters:";
11 | public static final String SPLIT_LINE = "-- ---------------------------------------------------------------------------------------------------------------------";
12 | public static final String FILTER_KEY = PLUGIN_ID + "MyBatisLog.Filters";
13 | public static final String PREPARING_KEY = PLUGIN_ID + "preparing";
14 | public static final String PARAMETERS_KEY = PLUGIN_ID + "parameters";
15 | public static final String runningKey = PLUGIN_ID + "running";
16 | public static final String indexNumKey = PLUGIN_ID + "indexNum";
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------