Skip to content

fix #613 #626

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

Merged
merged 1 commit into from
Mar 18, 2023
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
[![捐赠][badge:donate-zh]][shuzijun-donate]
[![内推][badge:referrals]][shuzijun-referrals]

## 8.7.0

### Added

### Changed

### Deprecated

### Fixed
- fix [#613](https://github.com/shuzijun/leetcode-editor/issues/613)
- fix [#625](https://github.com/shuzijun/leetcode-editor/issues/625)

### Removed

## 8.6.0

### Added
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![捐赠][badge:donate]][shuzijun-donate]
[![内推][badge:referrals]][shuzijun-referrals]

<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/10/leetcode-demo.gif" alt="demo" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/leetcode-demo.gif" alt="demo" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

---

Expand All @@ -27,6 +27,8 @@
- Useful Links
- [Login Help][gh:login-help]
- [Custom Code][gh:custom-code] ([demo][gh:leetcode-question])

- **More open functions**: [shuzijun/lc-sdk](https://github.com/shuzijun/lc-sdk)

## Getting Started
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/leetcode-editor@master/doc/leetcode-editor-3.0.gif" alt="start" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>
Expand Down
4 changes: 3 additions & 1 deletion README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![捐赠][badge:donate]][shuzijun-donate]
[![内推][badge:referrals]][shuzijun-referrals]

<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/10/leetcode-demo.gif" alt="demo" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/leetcode-demo.gif" alt="demo" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

---

Expand All @@ -27,6 +27,8 @@
- 有用的链接
- [登录帮助][gh:login-help]
- [自定义代码生成][gh:custom-code-zh] ([示例][gh:leetcode-question])

- **更开放的功能**: [shuzijun/lc-sdk](https://github.com/shuzijun/lc-sdk)


## 开始使用
Expand Down
10 changes: 5 additions & 5 deletions doc/description.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ <h2>Introduction</h2>
</div>
<br>
<h2 >Getting Started</h2>
<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/17/leetcode-editor-3.0.gif"
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/leetcode-editor-3.0.gif"
alt="start" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

<h2 >Local debugging</h2>
<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/17/customConfig-100.gif"
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/customConfig-100.gif"
alt="loacl" style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

<h3 >Configuration (configuration for first installation)</h3>
<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/17/config-3.0.jpg" alt="config"
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/config-3.0.jpg" alt="config"
style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

<ul>
Expand All @@ -52,7 +52,7 @@ <h3 >Configuration (configuration for first installation)</h3>
</li>
</ul>
<h3 >Window</h3>
<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/17/window-3.0.jpg" alt="window"
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/window-3.0.jpg" alt="window"
style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>

<ul>
Expand Down Expand Up @@ -87,7 +87,7 @@ <h3 >Window</h3>
</li>
</ul>
<h3 >Menu</h3>
<p align="center"><img src="https://s1.imagehub.cc/images/2022/07/17/menu-3.0.jpg" alt="menu"
<p align="center"><img src="https://cdn.jsdelivr.net/gh/shuzijun/[email protected]/doc/menu-3.0.jpg" alt="menu"
style="width: auto;height: auto;max-width: 90%; max-height: 90%;"></p>


Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginGroup = com.shuzijun.leetcode
pluginName = leetcode-editor
pluginVersion = 8.6
pluginVersion = 8.7

pluginSinceBuild = 203.0
pluginUntilBuild =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public void update(@NotNull AnActionEvent anActionEvent) {
anActionEvent.getPresentation().setEnabled(false);
return;
}
Question question = QuestionManager.getQuestionByTitleSlug(leetcodeEditor.getTitleSlug(), anActionEvent.getProject());
Question question = QuestionManager.getQuestionByTitleSlug(leetcodeEditor.getTitleSlug(), anActionEvent.getProject(), true);
if (question != null) {
anActionEvent.getPresentation().setEnabled(!Constant.ARTICLE_LIVE_NONE.equals(question.getArticleLive()));
} else {
anActionEvent.getPresentation().setEnabled(false);
anActionEvent.getPresentation().setEnabled(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean isSelected(AnActionEvent anActionEvent) {
if (questionView == null) {
return false;
}
Question cacheQuestion = QuestionManager.getQuestionByTitleSlug(questionView.getTitleSlug(), anActionEvent.getProject());
Question cacheQuestion = QuestionManager.getQuestionByTitleSlug(questionView.getTitleSlug(), anActionEvent.getProject(),true);
if (cacheQuestion == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class FavoriteActionGroup extends ActionGroup implements DumbAware {
@Override
public AnAction[] getChildren(AnActionEvent anActionEvent) {
NavigatorAction navigatorAction = WindowFactory.getDataContext(anActionEvent.getProject()).getData(DataKeys.LEETCODE_PROJECTS_NAVIGATORACTION);
if (navigatorAction == null){
return new AnAction[0];
}
List<AnAction> anActionList = Lists.newArrayList();
List<Tag> tags = navigatorAction.getFind().getFilter(Constant.FIND_TYPE_LISTS);
if (tags != null && !tags.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void update(@NotNull AnActionEvent anActionEvent) {
anActionEvent.getPresentation().setEnabled(false);
return;
}
Question question = QuestionManager.getQuestionByTitleSlug(questionView.getTitleSlug(), anActionEvent.getProject());
Question question = QuestionManager.getQuestionByTitleSlug(questionView.getTitleSlug(), anActionEvent.getProject(), true);
if (question == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -317,6 +318,11 @@ public static User getUser() {
}

public static Question getQuestionByTitleSlug(String titleSlug, Project project) {
return getQuestionByTitleSlug(titleSlug,project, false);
}

public static Question getQuestionByTitleSlug(String titleSlug, Project project, boolean readOnlyCache) {

if (StringUtils.isBlank(titleSlug)) {
return null;
}
Expand All @@ -327,9 +333,13 @@ public static Question getQuestionByTitleSlug(String titleSlug, Project project)
try {
Question question = new Question();
question.setTitleSlug(titleSlug);
if (ApplicationManager.getApplication().executeOnPooledThread(() -> {
Future<Boolean> questionFuture = ApplicationManager.getApplication().executeOnPooledThread(() -> {
return getQuestion(question, project);
}).get()) {
});
if (readOnlyCache) {
return null;
}
if (questionFuture.get()) {
questionCache.put(key, question);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ public static void loadAllServiceData(NavigatorAction navigatorAction, Project p
PageInfo.Filters filters = pageInfo.getFilters();
if (StringUtils.isNotBlank(filters.getListId())) {
List<Tag> tagList = navigatorAction.getFind().getFilter(Constant.FIND_TYPE_LISTS);
Tag tag = tagList.stream().filter(t -> t.getSlug().equalsIgnoreCase(filters.getListId())).findAny().get();
conformSet.retainAll(tag.getQuestions());
Optional<Tag> optional = tagList.stream().filter(t -> t.getSlug().equalsIgnoreCase(filters.getListId())).findAny();
if (optional.isPresent()){
Tag tag = optional.get();
conformSet.retainAll(tag.getQuestions());
}
}
if (CollectionUtils.isNotEmpty(filters.getTags())) {
List<Tag> tagList = navigatorAction.getFind().getFilter(Constant.FIND_TYPE_TAGS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shuzijun.leetcode.plugin.window;

import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
Expand All @@ -16,9 +16,9 @@
import icons.LeetCodeEditorIcons;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.concurrent.atomic.AtomicReference;

/**
* @author shuzijun
Expand Down Expand Up @@ -48,16 +48,17 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo

@NotNull
public static DataContext getDataContext(@NotNull Project project) {
AtomicReference<DataContext> dataContext = new AtomicReference<>();
ApplicationManager.getApplication().invokeAndWait(() -> {
ToolWindow leetcodeToolWindows = ToolWindowManager.getInstance(project).getToolWindow(ID);
if (leetcodeToolWindows == null) {
dataContext.set(DataContext.EMPTY_CONTEXT);
} else {
dataContext.set(DataManager.getInstance().getDataContext(leetcodeToolWindows.getContentManager().getContent(0).getComponent()));
}
});
return dataContext.get();
ToolWindow leetcodeToolWindows = ToolWindowManager.getInstance(project).getToolWindow(ID);
if (leetcodeToolWindows == null) {
return DataContext.EMPTY_CONTEXT;
}

JComponent navigatorPanel = leetcodeToolWindows.getContentManager().getContent(0).getComponent();
if (navigatorPanel instanceof DataProvider){
return new MyDataContext((DataProvider) navigatorPanel);
}

return DataContext.EMPTY_CONTEXT;
}

public static void updateTitle(@NotNull Project project, String userName) {
Expand All @@ -77,4 +78,17 @@ public static void activateToolWindow(@NotNull Project project) {
leetcodeToolWindows.activate(null);
}

public static class MyDataContext implements DataContext{
private final DataProvider dataProvider;

public MyDataContext(DataProvider dataProvider) {
this.dataProvider = dataProvider;
}

@Override
public @Nullable Object getData(@NotNull String dataId) {
return dataProvider.getData(dataId);
}
}

}