Skip to content

Commit 14a47a5

Browse files
authored
Merge pull request #374 from shuzijun/gradle
fix bug
2 parents e7450a9 + 2345d85 commit 14a47a5

File tree

9 files changed

+44
-12
lines changed

9 files changed

+44
-12
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public void update(AnActionEvent e) {
4040
}
4141
}
4242
e.getPresentation().setIcon(null);
43-
findToolbar.getComponent().updateUI();
43+
if (findToolbar != null && findToolbar.getComponent() != null) {
44+
findToolbar.getComponent().updateUI();
45+
}
4446
}
4547

4648

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public void update(@NotNull AnActionEvent e) {
3939
} else {
4040
e.getPresentation().setIcon(null);
4141
}
42-
sortToolbar.getComponent().updateUI();
42+
if (sortToolbar != null && sortToolbar.getComponent() != null) {
43+
sortToolbar.getComponent().updateUI();
44+
}
4345
super.update(e);
4446

4547
}

src/main/java/com/shuzijun/leetcode/plugin/editor/LCVPreview.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public LCVPreview(@NotNull Project project, @NotNull VirtualFile file) {
6868
tempPanel = new LCVPanel(url, project);
6969
tempPanel.loadHTML(createHtml(isPresentableUrl), url);
7070
myHtmlPanelWrapper.add(tempPanel.getComponent(), BorderLayout.CENTER);
71-
} catch (IllegalStateException e) {
72-
myHtmlPanelWrapper.add(new JBLabel(e.getMessage()), BorderLayout.CENTER);
71+
} catch (Throwable e) {
72+
myHtmlPanelWrapper.add(new JBLabel("<html><body>Your environment does not support JCEF.<br>Check the Registry 'ide.browser.jcef.enabled'.<br>"+e.getMessage()+"<body></html>"), BorderLayout.CENTER);
7373
}
7474
myPanel = tempPanel;
7575
myHtmlPanelWrapper.repaint();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.shuzijun.leetcode.plugin.listener;
2+
3+
import com.intellij.notification.Notification;
4+
import com.intellij.notification.NotificationType;
5+
import com.intellij.notification.Notifications;
6+
import com.intellij.openapi.application.ApplicationManager;
7+
import com.intellij.openapi.project.DumbAware;
8+
import com.intellij.openapi.project.Project;
9+
import com.intellij.openapi.startup.StartupActivity;
10+
import com.intellij.ui.jcef.JBCefApp;
11+
import com.shuzijun.leetcode.plugin.model.PluginConstant;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
/**
15+
* @author shuzijun
16+
*/
17+
public class SupportCheck implements StartupActivity, DumbAware {
18+
19+
public static boolean isFirstProject = true;
20+
21+
@Override
22+
public void runActivity(@NotNull Project project) {
23+
if (ApplicationManager.getApplication().isUnitTestMode() || !isFirstProject ) {
24+
return;
25+
}
26+
if(!JBCefApp.isSupported()){
27+
Notifications.Bus.notify(new Notification(PluginConstant.NOTIFICATION_GROUP, "Not Support JCEF", "Your environment does not support JCEF, cannot use LeetCode Editor.Check the Registry 'ide.browser.jcef.enabled'.", NotificationType.ERROR));
28+
}
29+
}
30+
}

src/main/java/com/shuzijun/leetcode/plugin/manager/CodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void openCode(Question question, Project project) {
4646
if (file.exists()) {
4747
FileUtils.openFileEditorAndSaveState(file,project,question,fillPath,true);
4848
} else {
49-
if (config.getQuestionEditor() || getQuestion(question, codeTypeEnum, project)) {
49+
if (getQuestion(question, codeTypeEnum, project)) {
5050
question.setContent(CommentUtils.createComment(question.getContent(), codeTypeEnum,config));
5151
FileUtils.saveFile(file, VelocityUtils.convert(config.getCustomTemplate(), question));
5252
FileUtils.openFileEditorAndSaveState(file,project,question,fillPath,true);

src/main/java/com/shuzijun/leetcode/plugin/utils/FileUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public static void saveFile(String path, String body) {
3434

3535
public static void saveFile(File file, String body) {
3636
try {
37+
if (body == null) {
38+
return;
39+
}
3740
if (!file.getParentFile().exists()) {
3841
file.getParentFile().mkdirs();
3942
}

src/main/java/com/shuzijun/leetcode/plugin/window/HttpLogin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static boolean ajaxLogin(Config config, JTree tree, Project project) {
8282
return Boolean.FALSE;
8383
}
8484
} else if (response.getStatusCode() == 400) {
85+
LogUtils.LOG.error("login 400:" + body);
8586
JSONObject jsonObject = JSONObject.parseObject(body);
8687
MessageUtils.getInstance(project).showInfoMsg("info", StringUtils.join(jsonObject.getJSONObject("form").getJSONArray("errors"), ","));
8788
return Boolean.FALSE;

src/main/java/com/shuzijun/leetcode/plugin/window/JcefLogin.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ public JCEFPanel(Project project) {
6868
loginJCEFPanel.loadURL(URLUtils.getLeetcodeLogin());
6969
}
7070

71-
@NotNull
72-
@Override
73-
protected Action getOKAction() {
74-
75-
return null;
76-
}
77-
7871
@NotNull
7972
@Override
8073
protected Action[] createActions() {

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
implementationClass="com.shuzijun.leetcode.plugin.editor.LCVFileType" fieldName="INSTANCE"/>
172172
<fileEditorProvider implementation="com.shuzijun.leetcode.plugin.editor.LCVProvider"/>
173173
<httpRequestHandler implementation="com.shuzijun.leetcode.plugin.editor.PreviewStaticServer"/>
174+
<postStartupActivity implementation="com.shuzijun.leetcode.plugin.listener.SupportCheck"/>
174175
</extensions>
175176

176177
<actions>

0 commit comments

Comments
 (0)