Skip to content

Commit db3b681

Browse files
authored
Merge pull request #415 from shuzijun/gradle
Synchronize the website API and modify the display style.
2 parents 7e1ac86 + 7edd6d6 commit db3b681

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1258
-1237
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plugin_version = 7.4
1+
plugin_version = 8.0
22
idea_local_path =
33
# '' | windows | mac | linux
44
build_env =

src/main/java/com/shuzijun/leetcode/plugin/actions/AbstractAsynAction.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/java/com/shuzijun/leetcode/plugin/actions/editor/AbstractEditAction.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
1313
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
1414
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;
15+
import com.shuzijun.leetcode.plugin.utils.URLUtils;
16+
import org.apache.commons.lang3.StringUtils;
1517

1618
/**
1719
* @author shuzijun
@@ -21,21 +23,30 @@ abstract class AbstractEditAction extends AbstractAction {
2123
@Override
2224
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
2325
VirtualFile vf = ArrayUtil.getFirstElement(FileEditorManager.getInstance(anActionEvent.getProject()).getSelectedFiles());
24-
if(vf == null){
26+
if (vf == null) {
2527
return;
2628
}
2729
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
2830
if (leetcodeEditor == null) {
2931
return;
3032
}
31-
Question question = ViewManager.getQuestionById(leetcodeEditor.getFrontendQuestionId(), anActionEvent.getProject());
33+
if (StringUtils.isBlank(leetcodeEditor.getTitleSlug())) {
34+
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
35+
return;
36+
}
37+
if(!URLUtils.getLeetcodeHost().equals(leetcodeEditor.getHost())){
38+
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.host"));
39+
return;
40+
}
41+
Question question = ViewManager.getQuestionByTitleSlug(leetcodeEditor.getTitleSlug(), null, anActionEvent.getProject());
3242
if (question == null) {
3343
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
3444
return;
3545
}
3646

3747
actionPerformed(anActionEvent, config, question);
3848

49+
3950
}
4051

4152
public abstract void actionPerformed(AnActionEvent anActionEvent, Config config, Question question);

src/main/java/com/shuzijun/leetcode/plugin/actions/editor/AbstractEditAsynAction.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/com/shuzijun/leetcode/plugin/actions/editor/OpenSolutionAction.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import com.intellij.openapi.actionSystem.AnActionEvent;
44
import com.intellij.openapi.actionSystem.PlatformDataKeys;
55
import com.intellij.openapi.application.ApplicationManager;
6+
import com.intellij.openapi.progress.ProgressIndicator;
7+
import com.intellij.openapi.progress.ProgressManager;
8+
import com.intellij.openapi.progress.Task;
69
import com.intellij.openapi.project.Project;
710
import com.intellij.openapi.vfs.VirtualFile;
811
import com.shuzijun.leetcode.plugin.manager.ArticleManager;
912
import com.shuzijun.leetcode.plugin.manager.ViewManager;
1013
import com.shuzijun.leetcode.plugin.model.*;
1114
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
15+
import com.shuzijun.leetcode.plugin.utils.URLUtils;
1216
import com.shuzijun.leetcode.plugin.window.SolutionPanel;
17+
import org.apache.commons.lang3.StringUtils;
1318
import org.jetbrains.annotations.NotNull;
1419

1520
import java.util.List;
@@ -27,15 +32,26 @@ public void update(@NotNull AnActionEvent anActionEvent) {
2732
return;
2833
}
2934
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
30-
if (leetcodeEditor == null) {
31-
return;
32-
}
33-
Question question = ViewManager.getDumbQuestionById(leetcodeEditor.getFrontendQuestionId(), anActionEvent.getProject());
34-
if (question == null) {
35+
if (leetcodeEditor == null || StringUtils.isBlank(leetcodeEditor.getTitleSlug()) || !URLUtils.getLeetcodeHost().equals(leetcodeEditor.getHost())) {
3536
anActionEvent.getPresentation().setEnabled(false);
3637
return;
3738
}
38-
anActionEvent.getPresentation().setEnabled(!Constant.ARTICLE_LIVE_NONE.equals(question.getArticleLive()));
39+
Question question = ViewManager.getCaCheQuestionByTitleSlug(leetcodeEditor.getTitleSlug(), null, anActionEvent.getProject());
40+
if (question != null) {
41+
anActionEvent.getPresentation().setEnabled(!Constant.ARTICLE_LIVE_NONE.equals(question.getArticleLive()));
42+
} else {
43+
ProgressManager.getInstance().run(new Task.Backgroundable(anActionEvent.getProject(), "Get Question", false) {
44+
@Override
45+
public void run(@NotNull ProgressIndicator progressIndicator) {
46+
Question question = ViewManager.getQuestionByTitleSlug(leetcodeEditor.getTitleSlug(), null, anActionEvent.getProject());
47+
if (question == null) {
48+
anActionEvent.getPresentation().setEnabled(false);
49+
return;
50+
}
51+
anActionEvent.getPresentation().setEnabled(!Constant.ARTICLE_LIVE_NONE.equals(question.getArticleLive()));
52+
}
53+
});
54+
}
3955
}
4056

4157
@Override
@@ -58,7 +74,7 @@ public void actionPerformed(AnActionEvent anActionEvent, Config config, Question
5874
solution.set(solutionList.get(dialog.getSelectedRow()));
5975
}
6076
});
61-
if(solution.get() !=null){
77+
if (solution.get() != null) {
6278
question.setArticleSlug(solution.get().getSlug());
6379
ArticleManager.openArticle(question, project);
6480
}

src/main/java/com/shuzijun/leetcode/plugin/actions/editor/PositionAction.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/main/java/com/shuzijun/leetcode/plugin/actions/toolbar/CollapseAction.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/java/com/shuzijun/leetcode/plugin/actions/toolbar/FindActionGroup.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void update(AnActionEvent e) {
3232

3333
if (tags != null && !tags.isEmpty()) {
3434
for (Tag tag : tags) {
35-
if(tag.isSelect()){
35+
if (tag.isSelect()) {
3636
e.getPresentation().setIcon(LeetCodeEditorIcons.FILTER);
3737
findToolbar.getComponent().updateUI();
3838
return;
@@ -57,11 +57,7 @@ public AnAction[] getChildren(AnActionEvent anActionEvent) {
5757

5858
if (tags != null && !tags.isEmpty()) {
5959
for (Tag tag : tags) {
60-
if (PluginConstant.LEETCODE_FIND_CATEGORY.equals(id)) {
61-
anActionList.add(new FindTagAction(tag.getName(), tag, true));
62-
}else {
63-
anActionList.add(new FindTagAction(tag.getName(), tag));
64-
}
60+
anActionList.add(new FindTagAction(tag.getName(), tag, tags, onlyOne(id), getFilterKey(id)));
6561
}
6662
}
6763
AnAction[] anActions = new AnAction[anActionList.size()];
@@ -86,4 +82,26 @@ private List<Tag> getTags(String id) {
8682
return tags;
8783
}
8884

85+
private boolean onlyOne(String id) {
86+
if (PluginConstant.LEETCODE_FIND_TAGS.equals(id)) {
87+
return false;
88+
}
89+
90+
return true;
91+
}
92+
93+
private String getFilterKey(String id) {
94+
if (PluginConstant.LEETCODE_FIND_DIFFICULTY.equals(id)) {
95+
return "difficulty";
96+
} else if (PluginConstant.LEETCODE_FIND_STATUS.equals(id)) {
97+
return "status";
98+
} else if (PluginConstant.LEETCODE_FIND_LISTS.equals(id)) {
99+
return "listId";
100+
} else if (PluginConstant.LEETCODE_FIND_TAGS.equals(id)) {
101+
return "tags";
102+
} else if (PluginConstant.LEETCODE_FIND_CATEGORY.equals(id)) {
103+
return "categorySlug";
104+
}
105+
return "";
106+
}
89107
}

src/main/java/com/shuzijun/leetcode/plugin/actions/toolbar/FindClearAction.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import com.shuzijun.leetcode.plugin.manager.ViewManager;
77
import com.shuzijun.leetcode.plugin.model.Config;
88
import com.shuzijun.leetcode.plugin.utils.DataKeys;
9+
import com.shuzijun.leetcode.plugin.window.NavigatorTable;
910
import com.shuzijun.leetcode.plugin.window.WindowFactory;
1011

11-
import javax.swing.*;
12-
1312
/**
1413
* @author shuzijun
1514
*/
@@ -18,15 +17,12 @@ public class FindClearAction extends AbstractAction {
1817
@Override
1918
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
2019

21-
JTree tree = WindowFactory.getDataContext(anActionEvent.getProject()).getData(DataKeys.LEETCODE_PROJECTS_TREE);
22-
if (tree == null) {
20+
NavigatorTable navigatorTable = WindowFactory.getDataContext(anActionEvent.getProject()).getData(DataKeys.LEETCODE_PROJECTS_TREE);
21+
if (navigatorTable == null) {
2322
return;
24-
}
25-
boolean isLoad = ViewManager.clearFilter();
26-
if (isLoad) {
27-
ViewManager.loadServiceData(tree,anActionEvent.getProject());
2823
} else {
29-
ViewManager.update(tree);
24+
navigatorTable.getPageInfo().clearFilter();
3025
}
26+
ViewManager.loadServiceData(navigatorTable,anActionEvent.getProject());
3127
}
3228
}

src/main/java/com/shuzijun/leetcode/plugin/actions/toolbar/FindConfigAction.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)