Skip to content

Commit 426cff2

Browse files
committed
add show content
1 parent e345c58 commit 426cff2

File tree

16 files changed

+309
-71
lines changed

16 files changed

+309
-71
lines changed

CustomCode.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#自定义代码生成介绍
2-
通过配置自定义代码生成模板可以自由生成代码格式,配合IDE可在本地调试代码。[示例工程](https://github.com/shuzijun/leetcode-question)
1+
#custom code generation
2+
The custom code generation template can be configured to generate the code format freely, the IDE can debug the code locally.[demo](https://github.com/shuzijun/leetcode-question)
33
- [English Document]()
4-
- [中文文档](https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode_ZH.md)
4+
- [中文文档](https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode_ZH.md)
5+
<p align="center">
6+
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/dev/doc/customConfig-100.gif" alt="demo"/>
7+
</p>

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/master/doc/leetcode-editor-3.0.gif" alt="demo"/>
1515
</p>
1616

17+
## Local debugging
18+
<p align="center">
19+
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/dev/doc/customConfig-100.gif" alt="demo"/>
20+
</p>
21+
1722
### Installation
1823
- **Install via plug-in library** https://plugins.jetbrains.com/plugin/12132-leetcode-editor
1924
- **Install by downloading the file** https://raw.githubusercontent.com/shuzijun/leetcode-editor/master/doc/leetcode-editor.zip
@@ -63,6 +68,7 @@
6368

6469
- **Menu (right-click on the questions)**:
6570
- **`open question`**:Open the question or double click on the question
71+
- **`open content`**:Show content(Rely on Markdown)
6672
- **`Submit`**:Submit the question
6773
- **`Submissions`**:View the submission record, select the record details in the pop-up window(`Show detail`)
6874
- **`Run Code`**:Run the code, the test case for the question is used by default

README_ZH.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/master/doc/leetcode-editor-3.0.gif" alt="demo"/>
1414
</p>
1515

16+
## 本地调试
17+
<p align="center">
18+
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/dev/doc/customConfig-100.gif" alt="demo"/>
19+
</p>
20+
1621
### 安装
1722
- **通过插件库安装** https://plugins.jetbrains.com/plugin/12132-leetcode-editor
1823
- **下载文件安装** https://raw.githubusercontent.com/shuzijun/leetcode-editor/master/doc/leetcode-editor.zip
@@ -62,6 +67,7 @@
6267

6368
- **菜单(在题目上右击出现)**:
6469
- **`open question`**:打开题目,在题目上双击也可以打开
70+
- **`open content`**:查看描述,包含图片(依赖 Markdown)
6571
- **`Submit`**:提交题目
6672
- **`Submissions`**:查看提交记录,在弹出的窗口上选择记录查看详情(`Show detail`)
6773
- **`Run Code`**:运行代码,默认使用题目的测试用例

resources/META-INF/plugin.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
</p>
2626
</div>
2727
<br>
28+
<div>
29+
<h2>Local debugging </h2>
30+
<br>
31+
<p >
32+
<img src="https://raw.githubusercontent.com/shuzijun/leetcode-editor/master/doc/customConfig-100.gif" alt="demo" />
33+
</p>
34+
</div>
2835
<br>
2936
<div>
3037
<h2>Configuration (configuration for first installation)</h2>
@@ -107,10 +114,12 @@
107114
<change-notes><![CDATA[
108115
<ul>
109116
<li>v5.0<br>
110-
1.增加代码自定义生成(<a href="https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode_ZH.md">详细介绍</a>)(<a href="https://github.com/shuzijun/leetcode-question">示例</a>)
117+
1.增加代码自定义生成(<a href="https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode_ZH.md">详细介绍</a>)(<a href="https://github.com/shuzijun/leetcode-question">示例</a>)<br>
118+
2.增加查看题目描述(依赖 Markdown)<br>
111119
</li>
112120
<li>v5.0<br>
113-
1.add code custom(<a href="https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode.md">details</a>)(<a href="https://github.com/shuzijun/leetcode-question">demo</a>)
121+
1.add code custom(<a href="https://github.com/shuzijun/leetcode-editor/blob/master/CustomCode.md">details</a>)(<a href="https://github.com/shuzijun/leetcode-question">demo</a>)<br>
122+
2.add show content(Rely on Markdown)
114123
</li>
115124
<li>v4.3<br>
116125
1.修复付费用户订阅题目展示<br>
@@ -249,6 +258,7 @@
249258

250259
<extensions defaultExtensionNs="com.intellij">
251260
<!-- <postStartupActivity implementation = "com.shuzijun.leetcode.plugin.listener.RegisterPluginInstallerStateListener"></postStartupActivity>-->
261+
<errorHandler implementation="com.shuzijun.leetcode.plugin.listener.ErrorReportHandler"/>
252262
<toolWindow id="leetcode" secondary="true" icon="/image/LeetCodeIcon.png" anchor="right"
253263
factoryClass="com.shuzijun.leetcode.plugin.window.WindowFactory"/>
254264
<applicationService serviceInterface="com.shuzijun.leetcode.plugin.setting.PersistentConfig"
@@ -288,6 +298,11 @@
288298
text="open question" description="open question" icon="AllIcons.Actions.Annotate">
289299
</action>
290300

301+
<action id="leetcode.OpenContentAction" class="com.shuzijun.leetcode.plugin.actions.OpenContentAction"
302+
text="open content" description="open content" icon="AllIcons.FileTypes.UiForm">
303+
</action>
304+
305+
291306
<action id="leetcode.OpenInWebAction" class="com.shuzijun.leetcode.plugin.actions.OpenInWebAction"
292307
text="open in web" description="open in web" icon="AllIcons.Actions.MoveTo2">
293308
</action>
@@ -329,6 +344,7 @@
329344

330345
<group id="leetcode.NavigatorActionsMenu">
331346
<reference id="leetcode.OpenAction"/>
347+
<reference id="leetcode.OpenContentAction"/>
332348
<reference id="leetcode.OpenInWebAction"/>
333349
<separator/>
334350
<reference id="leetcode.SubmitAction"/>

resources/i18n/info.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config.load=click {0} or {1} load question\nFirst installation, click {2} config
88
login.exist=already login
99
login.success=login success
1010
login.failed=login failed, examine e-mail or password
11+
login.unknown=Unable to determine the login status, please try to login the web and try again
1112
login.out=out success
1213
login.not=no login
1314
response.cache=request question failed,load cache
@@ -27,6 +28,8 @@ test.case=test case is empty
2728
response.type.failed=load {0} failed
2829
submission.empty=no submission
2930
submission.parse=parse error
31+
report=Report to plugin author
32+
donate.info=donate
3033
updata=leetcode editor new version {0} ,Please update
3134
user.email=YOU HAVE NOT VERIFIED YOUR ACCOUNT\nYou cannot submit your code to the judge system until you verify your email.\nYou may resend the verification email or change your email in your profile page.
3235
template.variable=${0}question.title{1}\tquestion title\tex:Two Sum\n${0}question.titleSlug{1}\tquestion title slug \tex:two-sum\n${0}question.frontendQuestionId{1}\tquestion serial number\n${0}question.content{1}\tquestion content\n${0}question.code{1}\tquestion code\n$!velocityTool.camelCaseName(str)\ttransform str camel case

resources/i18n/info_zh.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config.load=\u70B9\u51FB {0} \u6216\u8005 {1} \u52A0\u8F7D\u9898\u76EE\n\u9996\u
88
login.exist=\u5DF2\u7ECF\u767B\u5F55
99
login.success=\u767B\u5F55\u6210\u529F
1010
login.failed=\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7528\u6237\u540D\u5BC6\u7801
11+
login.unknown=\u65E0\u6CD5\u5224\u65AD\u767B\u9646\u72B6\u6001\uFF0C\u8BF7\u5C1D\u8BD5\u767B\u9646\u7F51\u9875\u7248\u540E\uFF0C\u518D\u6B21\u91CD\u8BD5
1112
login.out=\u9000\u51FA\u6210\u529F
1213
login.not=\u8BF7\u5148\u767B\u5F55
1314
response.cache=\u8BF7\u6C42\u9898\u76EE\u51FA\u9519,\u5C06\u52A0\u8F7D\u672C\u5730\u7F13\u5B58
@@ -27,6 +28,8 @@ test.case=\u6D4B\u8BD5\u7528\u4F8B\u4E3A\u7A7A
2728
response.type.failed=\u52A0\u8F7D{0}\u5931\u8D25
2829
submission.empty=\u65E0\u63D0\u4EA4\u8BB0\u5F55
2930
submission.parse=\u89E3\u6790\u5931\u8D25
31+
report=\u5411\u63D2\u4EF6\u4F5C\u8005\u62A5\u544A
32+
donate.info=\u6253\u8D4F
3033
updata=leetcode editor\u65B0\u7248\u672C {0} \u53D1\u5E03,\u8BF7\u53CA\u65F6\u66F4\u65B0
3134
user.email=\u60A8\u5C1A\u672A\u9A8C\u8BC1\u81EA\u5DF1\u7684\u5E10\u6237\n\u5728\u9A8C\u8BC1\u7535\u5B50\u90AE\u4EF6\u4E4B\u524D\uFF0C\u60A8\u65E0\u6CD5\u5C06\u4EE3\u7801\u63D0\u4EA4\u7ED9\u8BC4\u5224\u7CFB\u7EDF\u3002\n\u60A8\u53EF\u4EE5\u5728\u4E2A\u4EBA\u8D44\u6599\u9875\u9762\u4E2D\u91CD\u65B0\u53D1\u9001\u9A8C\u8BC1\u7535\u5B50\u90AE\u4EF6\u6216\u66F4\u6539\u7535\u5B50\u90AE\u4EF6\u3002
3235
template.variable=${0}question.title{1}\t\u9898\u76EE\u6807\u9898\t\u793A\u4F8B:\u4E24\u6570\u4E4B\u548C\n${0}question.titleSlug{1}\t\u9898\u76EE\u6807\u8BB0\t\u793A\u4F8B:two-sum\n${0}question.frontendQuestionId{1}\t\u9898\u76EE\u7F16\u53F7\n${0}question.content{1}\t\u9898\u76EE\u63CF\u8FF0\n${0}question.code{1}\t\u9898\u76EE\u4EE3\u7801\n$!velocityTool.camelCaseName(str)\t\u8F6C\u6362\u5B57\u7B26\u4E3A\u9A7C\u5CF0\u6837\u5F0F

src/com/shuzijun/leetcode/plugin/actions/LoginAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public void perform(AnActionEvent anActionEvent, Config config) {
7777
examineEmail();
7878
MessageUtils.showInfoMsg("info", PropertiesUtils.getInfo("login.success"));
7979
} else {
80-
MessageUtils.showInfoMsg("info", PropertiesUtils.getInfo("login.failed"));
80+
HttpClientUtils.resetHttpclient();
81+
MessageUtils.showInfoMsg("info", PropertiesUtils.getInfo("login.unknown"));
82+
SentryUtils.submitErrorReport(null,String.format("login.unknown:\nStatusCode:%s\nbody:%s",loginResponse.getStatusLine().getStatusCode(),body));
8183
return;
8284
}
8385
} catch (Exception e) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.shuzijun.leetcode.plugin.actions;
2+
3+
import com.intellij.openapi.actionSystem.AnActionEvent;
4+
import com.intellij.openapi.application.ApplicationManager;
5+
import com.intellij.openapi.project.Project;
6+
import com.shuzijun.leetcode.plugin.manager.CodeManager;
7+
import com.shuzijun.leetcode.plugin.model.Config;
8+
import com.shuzijun.leetcode.plugin.model.Question;
9+
import com.shuzijun.leetcode.plugin.utils.DataKeys;
10+
11+
import javax.swing.*;
12+
import javax.swing.tree.DefaultMutableTreeNode;
13+
14+
/**
15+
* @author shuzijun
16+
*/
17+
public class OpenContentAction extends AbstractAction {
18+
19+
@Override
20+
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
21+
JTree tree = anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE);
22+
DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
23+
Question question = (Question) note.getUserObject();
24+
25+
Project project = anActionEvent.getProject();
26+
ApplicationManager.getApplication().invokeLater(new Runnable() {
27+
@Override
28+
public void run() {
29+
CodeManager.openContent(question, project);
30+
}
31+
});
32+
}
33+
}

src/com/shuzijun/leetcode/plugin/listener/DonateListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.intellij.openapi.project.ProjectManager;
55
import com.intellij.openapi.ui.DialogWrapper;
66
import com.shuzijun.leetcode.plugin.utils.LogUtils;
7+
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;
78
import org.jetbrains.annotations.Nullable;
89

910
import javax.imageio.ImageIO;
@@ -28,7 +29,7 @@ public void actionPerformed(ActionEvent e) {
2829
if (jcb.isSelected()) {
2930
Project project = ProjectManager.getInstance().getDefaultProject();
3031
DonateListener.DonatePanel dialog = new DonateListener.DonatePanel(project);
31-
dialog.setTitle("Donate");
32+
dialog.setTitle(PropertiesUtils.getInfo("donate.info"));
3233
dialog.showAndGet();
3334
}
3435
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.shuzijun.leetcode.plugin.listener;
2+
3+
import com.intellij.diagnostic.AbstractMessage;
4+
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
5+
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
6+
import com.intellij.openapi.diagnostic.SubmittedReportInfo;
7+
import com.intellij.util.Consumer;
8+
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;
9+
import com.shuzijun.leetcode.plugin.utils.SentryUtils;
10+
import org.jetbrains.annotations.NotNull;
11+
import org.jetbrains.annotations.Nullable;
12+
13+
import java.awt.*;
14+
15+
/**
16+
* @author shuzijun
17+
*/
18+
public class ErrorReportHandler extends ErrorReportSubmitter {
19+
@NotNull
20+
@Override
21+
public String getReportActionText() {
22+
return PropertiesUtils.getInfo("report");
23+
}
24+
25+
@Override
26+
public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo, @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
27+
for (IdeaLoggingEvent event : events) {
28+
Throwable throwable = event.getThrowable();
29+
if (event.getData() instanceof AbstractMessage) {
30+
throwable = ((AbstractMessage) event.getData()).getThrowable();
31+
}
32+
33+
SentryUtils.submitErrorReport(throwable, additionalInfo);
34+
}
35+
36+
return true;
37+
}
38+
}

0 commit comments

Comments
 (0)