Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a new feature of browsing certain question on the website of leetcode #44

Merged
merged 5 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>leetcode-editor</id>
<name>leetcode editor</name>
<version>4.3</version>
<version>4.4</version>
<vendor email="[email protected]" url="https://github.com/shuzijun/idea-leetcode-plugin">shuzijun</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -102,6 +102,13 @@

<change-notes><![CDATA[
<ul>
<li>v4.4<br>
1.增加跳转到题目对应的leetcode官网地址的功能<br>
</li>
<li>v4.4<br>
1.add a new feature of browsing certain question on the website of leetcode<br>
</li>

<li>v4.3<br>
1.修复付费用户订阅题目展示<br>
2.修复leetcode-cn.com登陆问题<br>
Expand Down Expand Up @@ -274,6 +281,11 @@
<action id="leetcode.OpenAction" class="com.shuzijun.leetcode.plugin.actions.OpenAction"
text="open question" description="open question" icon="AllIcons.Actions.Annotate">
</action>

<action id="leetcode.OpenInLeetCodeAction" class="com.shuzijun.leetcode.plugin.actions.OpenInLeetCodeAction"
text="open in leetcode" description="open in leetcode" icon="AllIcons.Actions.Annotate">
</action>

<action id="leetcode.SubmitAction" class="com.shuzijun.leetcode.plugin.actions.SubmitAction"
text="Submit" description="Submit" icon="AllIcons.Actions.StepOut">
</action>
Expand Down Expand Up @@ -311,6 +323,7 @@

<group id="leetcode.NavigatorActionsMenu">
<reference id="leetcode.OpenAction"/>
<reference id="leetcode.OpenInLeetCodeAction"/>
<separator/>
<reference id="leetcode.SubmitAction"/>
<reference id="leetcode.SubmissionsAction"/>
Expand Down
26 changes: 26 additions & 0 deletions src/com/shuzijun/leetcode/plugin/actions/OpenInLeetCodeAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.shuzijun.leetcode.plugin.actions;

import com.alibaba.fastjson.JSON;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.shuzijun.leetcode.plugin.manager.CodeManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.utils.DataKeys;
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;
import com.shuzijun.leetcode.plugin.utils.URLUtils;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

public class OpenInLeetCodeAction extends AbstractAction {
@Override public void actionPerformed(AnActionEvent anActionEvent, Config config) {
JTree tree = anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE);
DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
Question question = (Question) note.getUserObject();
BrowserUtil.browse(URLUtils.getLeetcodeUrl()+"/problems/"+question.getTitleSlug());
}
}