Skip to content

Commit 4f21cdd

Browse files
authored
Merge pull request #267 from flagist0/fix-jcef-always-disabled
Fix permanently disabled JCEF checkbox in plugin settings
2 parents aebf75a + 93cf935 commit 4f21cdd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void actionPerformed(AnActionEvent anActionEvent, Config config) {
6565
@Override
6666
public void run() {
6767
LoginFrame loginFrame;
68-
if (HttpLogin.isSupportedJcef()) {
68+
if (HttpLogin.isEnabledJcef()) {
6969
loginFrame = new JcefLogin(anActionEvent.getProject(), tree);
7070
} else {
7171
loginFrame = new CookieLogin(anActionEvent.getProject(), tree);

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.jetbrains.annotations.NotNull;
1818

1919
import javax.swing.*;
20+
import java.lang.reflect.InvocationTargetException;
2021
import java.lang.reflect.Method;
2122
import java.net.HttpCookie;
2223
import java.util.List;
@@ -142,15 +143,17 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
142143
});
143144
}
144145

146+
public static boolean isEnabledJcef() {
147+
Config config = PersistentConfig.getInstance().getInitConfig();
148+
return config != null && config.getJcef() && isSupportedJcef();
149+
}
150+
145151
public static boolean isSupportedJcef() {
146152
try {
147153
Class<?> JBCefAppClass = Class.forName("com.intellij.ui.jcef.JBCefApp");
148154
Method method = JBCefAppClass.getMethod("isSupported");
149-
boolean supported = (boolean) method.invoke(null);
150-
151-
Config config = PersistentConfig.getInstance().getInitConfig();
152-
return config.getJcef() && supported;
153-
} catch (Throwable e) {
155+
return (boolean) method.invoke(null);
156+
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
154157
return Boolean.FALSE;
155158
}
156159
}

0 commit comments

Comments
 (0)