Skip to content

Commit 89cdf93

Browse files
committed
Login WebView; gradle build
1 parent 922bc89 commit 89cdf93

File tree

87 files changed

+367
-155
lines changed

Some content is hidden

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

87 files changed

+367
-155
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@
2323
hs_err_pid*
2424
/*.iml
2525
.idea/
26+
.gradle/
27+
/gradle
28+
/gradlew
29+
/gradlew.bat
30+
/build/
31+
/out/

build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id 'java'
3+
id 'org.jetbrains.intellij' version '0.4.14'
4+
}
5+
6+
group 'com.shuzijun.leetcode'
7+
version 'V5.4'
8+
9+
sourceCompatibility = 1.8
10+
targetCompatibility = 1.8
11+
12+
repositories {
13+
mavenCentral()
14+
maven {
15+
url "https://repo.panda-lang.org/"
16+
}
17+
}
18+
19+
dependencies {
20+
compile 'com.alibaba:fastjson:1.2.47'
21+
compile 'org.jsoup:jsoup:1.11.3'
22+
compile 'io.sentry:sentry:1.7.9'
23+
compile 'org.panda-lang:pandomium:67.0.6'
24+
}
25+
26+
// See https://github.com/JetBrains/gradle-intellij-plugin/
27+
intellij {
28+
pluginName 'leetcode-editor'
29+
//version 'IU-193.5233.102'
30+
//type 'IU'
31+
downloadSources false
32+
updateSinceUntilBuild false
33+
buildSearchableOptions.enabled(false)
34+
localPath 'use idea path'
35+
alternativeIdePath 'use idea path'
36+
37+
prepareSandbox {
38+
from('src/main/natives') { into(getPluginName()+'/natives') }
39+
}
40+
41+
}
42+
43+
tasks.withType(JavaCompile) {
44+
options.encoding = "UTF-8"
45+
}
46+
47+

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Dfile.encoding=utf-8

resources/lib/fastjson-1.2.47.jar

-534 KB
Binary file not shown.

resources/lib/jackson-core-2.9.9.jar

-318 KB
Binary file not shown.

resources/lib/jsoup-1.11.3.jar

-386 KB
Binary file not shown.

resources/lib/sentry-1.7.9.jar

-152 KB
Binary file not shown.

settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rootProject.name = 'leetcode-editor'
2+
3+

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

Lines changed: 0 additions & 155 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.shuzijun.leetcode.plugin.actions;
2+
3+
import com.intellij.openapi.actionSystem.AnActionEvent;
4+
import com.intellij.openapi.application.ApplicationManager;
5+
import com.shuzijun.leetcode.plugin.manager.ViewManager;
6+
import com.shuzijun.leetcode.plugin.model.Config;
7+
import com.shuzijun.leetcode.plugin.setting.PersistentConfig;
8+
import com.shuzijun.leetcode.plugin.utils.*;
9+
import com.shuzijun.leetcode.plugin.window.LoginPanel;
10+
import org.apache.commons.lang.StringUtils;
11+
import org.apache.http.client.methods.CloseableHttpResponse;
12+
import org.apache.http.client.methods.HttpGet;
13+
14+
import javax.swing.*;
15+
16+
/**
17+
* @author shuzijun
18+
*/
19+
public class LoginAction extends AbstractAsynAction {
20+
@Override
21+
public void perform(AnActionEvent anActionEvent, Config config) {
22+
23+
if (StringUtils.isBlank(HttpClientUtils.getToken())) {
24+
HttpGet httpget = new HttpGet(URLUtils.getLeetcodeVerify());
25+
CloseableHttpResponse response = HttpClientUtils.executeGet(httpget);
26+
httpget.abort();
27+
if (response == null) {
28+
MessageUtils.showWarnMsg("warning", PropertiesUtils.getInfo("request.failed"));
29+
return;
30+
}
31+
if (response.getStatusLine().getStatusCode() != 200) {
32+
JTree tree = anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE);
33+
ViewManager.loadServiceData(tree);
34+
MessageUtils.showWarnMsg("warning", PropertiesUtils.getInfo("request.failed"));
35+
return;
36+
}
37+
} else {
38+
if (HttpClientUtils.isLogin()) {
39+
MessageUtils.showWarnMsg("info", PropertiesUtils.getInfo("login.exist"));
40+
return;
41+
}
42+
}
43+
44+
if (StringUtils.isBlank(config.getLoginName()) || StringUtils.isBlank(PersistentConfig.getInstance().getPassword())) {
45+
MessageUtils.showWarnMsg("info", PropertiesUtils.getInfo("config.user"));
46+
return;
47+
}
48+
49+
ApplicationManager.getApplication().invokeLater(new Runnable() {
50+
@Override
51+
public void run() {
52+
LoginPanel dialog = new LoginPanel(anActionEvent.getProject(),anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE));
53+
dialog.setTitle("login");
54+
dialog.show();
55+
}
56+
});
57+
58+
}
59+
60+
}

src/com/shuzijun/leetcode/plugin/utils/HttpClientUtils.java renamed to src/main/java/com/shuzijun/leetcode/plugin/utils/HttpClientUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ private static void createHttpClient() {
8888
}
8989
}
9090

91+
public static void setCookie(List<Cookie> cookieList) {
92+
if (httpclient == null) {
93+
createHttpClient();
94+
}
95+
for (Cookie cookie : cookieList) {
96+
context.getCookieStore().addCookie(cookie);
97+
}
98+
}
99+
91100
public static CloseableHttpResponse executeGet(HttpGet httpGet) {
92101
if (httpclient == null) {
93102
createHttpClient();

0 commit comments

Comments
 (0)