Skip to content

Commit c3618b0

Browse files
committed
fix #567
1 parent 7a24d6e commit c3618b0

File tree

8 files changed

+52
-19
lines changed

8 files changed

+52
-19
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static void RunCodeCode(String titleSlug, Project project) {
148148
} else if (response.getStatusCode() == 429) {
149149
MessageUtils.getInstance(project).showWarnMsg("", "Please wait for the result.");
150150
} else {
151-
LogUtils.LOG.error("RuncodeCode failure " + response == null ? "" : response.getBody());
151+
LogUtils.LOG.error("RuncodeCode failure " + response.getBody());
152152
MessageUtils.getInstance(project).showWarnMsg("", PropertiesUtils.getInfo("request.failed"));
153153
}
154154
} catch (Exception i) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static void loadAllServiceData(NavigatorAction navigatorAction, Project p
116116
}
117117
}
118118
if (status) {
119-
if ("TRIED".equalsIgnoreCase(filters.getStatus()) && !questionView.getStatusSign().equalsIgnoreCase("")) {
119+
if ("TRIED".equalsIgnoreCase(filters.getStatus()) && !questionView.getStatusSign().equalsIgnoreCase("?")) {
120120
continue;
121121
} else if ("AC".equalsIgnoreCase(filters.getStatus()) && !questionView.getStatusSign().equalsIgnoreCase("✔")) {
122122
continue;

src/main/java/com/shuzijun/leetcode/plugin/model/QuestionView.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public void setFrontendQuestionId(String frontendQuestionId) {
109109
}
110110

111111
public void setAcceptance(Double acceptance) {
112+
if (acceptance != null && acceptance.doubleValue() > 1) {
113+
acceptance = acceptance / 100;
114+
}
112115
this.acceptance = acceptance;
113116
}
114117

@@ -117,6 +120,9 @@ public Double getAcceptance() {
117120
}
118121

119122
public Double getFrequency() {
123+
if (frequency != null && frequency.doubleValue() > 1) {
124+
frequency = frequency / 100;
125+
}
120126
return frequency;
121127
}
122128

@@ -127,17 +133,17 @@ public void setFrequency(Double frequency) {
127133
public String getStatusSign() {
128134

129135
if ("notac".equalsIgnoreCase(status) || "TRIED".equalsIgnoreCase(status)) {
130-
return "";
136+
return "?";
131137
} else if ("ac".equalsIgnoreCase(status)) {
132138
return "✔";
133139
} else if ("lock".equalsIgnoreCase(status)) {
134140
return "$";
135141
} else if ("day".equalsIgnoreCase(status)) {
136142
return "D";
137143
} else if (level != null) {
138-
return " ";
144+
return " ";
139145
}
140-
return " ";
146+
return " ";
141147
}
142148

143149
public String getCategory() {

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.shuzijun.leetcode.plugin.utils;
22

3+
import com.shuzijun.leetcode.plugin.model.Config;
34
import com.shuzijun.leetcode.plugin.setting.PersistentConfig;
45
import org.apache.commons.lang.StringUtils;
56

@@ -29,7 +30,11 @@ public class URLUtils {
2930
private static String leetcodeRandomOneQuestion = "/problems/random-one-question/all";
3031

3132
public static String getLeetcodeHost() {
32-
String host = PersistentConfig.getInstance().getConfig().getUrl();
33+
Config config = PersistentConfig.getInstance().getInitConfig();
34+
if (config == null) {
35+
return leetcode;
36+
}
37+
String host = config.getUrl();
3338
if (StringUtils.isBlank(host)) {
3439
return leetcode;
3540
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static boolean ajaxLogin(Config config, NavigatorAction navigatorAction,
7878
} else {
7979
HttpRequestUtils.resetHttpclient();
8080
MessageUtils.getInstance(project).showInfoMsg("info", PropertiesUtils.getInfo("login.unknown"));
81-
SentryUtils.submitErrorReport(null, String.format("login.unknown:\nStatusCode:%s\nbody:%s", response.getStatusCode(), body));
81+
//SentryUtils.submitErrorReport(null, String.format("login.unknown:\nStatusCode:%s\nbody:%s", response.getStatusCode(), body));
8282
return Boolean.FALSE;
8383
}
8484
} else if (response.getStatusCode() == 400) {
@@ -93,7 +93,7 @@ public static boolean ajaxLogin(Config config, NavigatorAction navigatorAction,
9393
} else {
9494
HttpRequestUtils.resetHttpclient();
9595
MessageUtils.getInstance(project).showInfoMsg("info", PropertiesUtils.getInfo("login.unknown"));
96-
SentryUtils.submitErrorReport(null, String.format("login.unknown:\nStatusCode:%s\nbody:%s", response.getStatusCode(), body));
96+
//SentryUtils.submitErrorReport(null, String.format("login.unknown:\nStatusCode:%s\nbody:%s", response.getStatusCode(), body));
9797
return Boolean.FALSE;
9898
}
9999
} catch (Exception e) {

src/main/java/com/shuzijun/leetcode/plugin/window/navigator/AllNavigatorTable.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ protected MyJBTable<QuestionView> createMyTable(MyTableModel<QuestionView> myTab
8282
MyJBTable<QuestionView> myJBTable = new MyJBTable(myTableModel) {
8383
@Override
8484
protected void prepareRenderer(Component component, Object value, int row, int column) {
85+
if (component instanceof JLabel) {
86+
if (column == 0 || column == 2) {
87+
((JLabel) component).setHorizontalAlignment(SwingConstants.CENTER);
88+
} else {
89+
((JLabel) component).setHorizontalAlignment(SwingConstants.LEADING);
90+
}
91+
}
8592
if (column == 2) {
8693
if (value != null) {
8794
if (value.toString().equals("Easy")) {
@@ -147,8 +154,8 @@ public boolean compareSlug(QuestionView myData, String titleSlug) {
147154
}
148155

149156
protected void setColumnWidth(MyJBTable myJBTable) {
150-
myJBTable.getColumnModel().getColumn(0).setMaxWidth(20);
151-
myJBTable.getColumnModel().getColumn(2).setMaxWidth(60);
157+
myJBTable.getColumnModel().getColumn(0).setMaxWidth(30);
158+
myJBTable.getColumnModel().getColumn(2).setMaxWidth(70);
152159
}
153160

154161
}

src/main/java/com/shuzijun/leetcode/plugin/window/navigator/NavigatorTable.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.shuzijun.leetcode.plugin.model.PageInfo;
88
import com.shuzijun.leetcode.plugin.model.Question;
99
import com.shuzijun.leetcode.plugin.model.QuestionView;
10-
import com.shuzijun.leetcode.plugin.utils.URLUtils;
1110
import com.shuzijun.leetcode.plugin.window.NavigatorTableData;
1211
import icons.LeetCodeEditorIcons;
1312

@@ -103,6 +102,14 @@ protected MyJBTable<QuestionView> createMyTable(MyTableModel<QuestionView> myTab
103102
MyJBTable<QuestionView> myJBTable = new MyJBTable(myTableModel) {
104103
@Override
105104
protected void prepareRenderer(Component component, Object value, int row, int column) {
105+
106+
if (component instanceof JLabel) {
107+
if (column == 0 || column == 2 || column == 3 || column == 4) {
108+
((JLabel) component).setHorizontalAlignment(SwingConstants.CENTER);
109+
} else {
110+
((JLabel) component).setHorizontalAlignment(SwingConstants.LEADING);
111+
}
112+
}
106113
if (column == 3) {
107114
if (value != null) {
108115
if (value.toString().equals("Easy")) {
@@ -173,10 +180,10 @@ public boolean compareSlug(QuestionView myData, String titleSlug) {
173180
}
174181

175182
protected void setColumnWidth(MyJBTable myJBTable) {
176-
myJBTable.getColumnModel().getColumn(0).setMaxWidth(20);
177-
myJBTable.getColumnModel().getColumn(2).setMaxWidth(50);
178-
myJBTable.getColumnModel().getColumn(3).setMaxWidth(60);
179-
myJBTable.getColumnModel().getColumn(4).setMaxWidth(50);
183+
myJBTable.getColumnModel().getColumn(0).setMaxWidth(30);
184+
myJBTable.getColumnModel().getColumn(2).setMaxWidth(60);
185+
myJBTable.getColumnModel().getColumn(3).setMaxWidth(70);
186+
myJBTable.getColumnModel().getColumn(4).setMaxWidth(60);
180187
}
181188

182189
}

src/main/java/com/shuzijun/leetcode/plugin/window/navigator/TopNavigatorTable.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ protected MyJBTable<CodeTopQuestionView> createMyTable(MyTableModel<CodeTopQuest
100100
MyJBTable<CodeTopQuestionView> myJBTable = new MyJBTable(myTableModel) {
101101
@Override
102102
protected void prepareRenderer(Component component, Object value, int row, int column) {
103+
if (component instanceof JLabel) {
104+
if (column == 0 || column == 2 || column == 3 || column == 4) {
105+
((JLabel) component).setHorizontalAlignment(SwingConstants.CENTER);
106+
} else {
107+
((JLabel) component).setHorizontalAlignment(SwingConstants.LEADING);
108+
}
109+
}
103110
if (column == 2) {
104111
if (value != null) {
105112
if (value.toString().equals("Easy")) {
@@ -175,10 +182,11 @@ public boolean compareSlug(CodeTopQuestionView myData, String titleSlug) {
175182

176183
@Override
177184
protected void setColumnWidth(MyJBTable myJBTable) {
178-
myJBTable.getColumnModel().getColumn(0).setMaxWidth(20);
179-
myJBTable.getColumnModel().getColumn(2).setMaxWidth(60);
180-
myJBTable.getColumnModel().getColumn(3).setMaxWidth(80);
181-
myJBTable.getColumnModel().getColumn(4).setMaxWidth(50);
185+
myJBTable.getColumnModel().getColumn(0).setMaxWidth(30);
186+
myJBTable.getColumnModel().getColumn(2).setMaxWidth(70);
187+
myJBTable.getColumnModel().getColumn(3).setMinWidth(100);
188+
myJBTable.getColumnModel().getColumn(3).setMaxWidth(120);
189+
myJBTable.getColumnModel().getColumn(4).setMaxWidth(60);
182190
}
183191

184192

0 commit comments

Comments
 (0)