|
1 | 1 | package com.shuzijun.leetcode.plugin.window; |
2 | 2 |
|
| 3 | +import com.intellij.openapi.application.ApplicationManager; |
3 | 4 | import com.intellij.openapi.progress.ProgressIndicator; |
4 | 5 | import com.intellij.openapi.progress.ProgressManager; |
5 | 6 | import com.intellij.openapi.progress.Task; |
@@ -132,7 +133,7 @@ public Component prepareRenderer(TableCellRenderer renderer, int row, int column |
132 | 133 | public void updateTable(Question question) { |
133 | 134 | if (questionList != null) { |
134 | 135 | for (Question q : questionList) { |
135 | | - if(q.getTitleSlug().equals(question.getTitleSlug())){ |
| 136 | + if (q.getTitleSlug().equals(question.getTitleSlug())) { |
136 | 137 | q.setStatus(question.getStatus()); |
137 | 138 | refreshData(); |
138 | 139 | break; |
@@ -247,19 +248,23 @@ public PageInfo<Question> getPageInfo() { |
247 | 248 | } |
248 | 249 |
|
249 | 250 | public void refreshData() { |
250 | | - this.tableModel.updateData(questionList); |
251 | | - setColumnWidth(); |
| 251 | + ApplicationManager.getApplication().invokeLater(() -> { |
| 252 | + this.tableModel.updateData(questionList); |
| 253 | + setColumnWidth(); |
| 254 | + }); |
252 | 255 | } |
253 | 256 |
|
254 | 257 | public void loadData(PageInfo<Question> pageInfo) { |
255 | | - if (this.first) { |
256 | | - this.tableModel.setRowCount(0); |
257 | | - this.tableModel.setColumnCount(5); |
258 | | - this.first = false; |
259 | | - } |
260 | | - this.questionList = pageInfo.getRows(); |
261 | | - this.tableModel.updateData(questionList); |
262 | | - setColumnWidth(); |
| 258 | + ApplicationManager.getApplication().invokeLater(() -> { |
| 259 | + if (this.first) { |
| 260 | + this.tableModel.setRowCount(0); |
| 261 | + this.tableModel.setColumnCount(5); |
| 262 | + this.first = false; |
| 263 | + } |
| 264 | + this.questionList = pageInfo.getRows(); |
| 265 | + this.tableModel.updateData(questionList); |
| 266 | + setColumnWidth(); |
| 267 | + }); |
263 | 268 | if (pageInfo.getPageTotal() != this.page.getItemCount()) { |
264 | 269 | this.page.removeAllItems(); |
265 | 270 | for (int i = 1; i <= pageInfo.getPageTotal(); i++) { |
@@ -365,7 +370,7 @@ public void updateData(List<Question> questionList) { |
365 | 370 | } |
366 | 371 | dataVector[i] = line; |
367 | 372 | } |
368 | | - setDataVector(dataVector, MyTableModel.columnNameShort.clone()); |
| 373 | + setDataVector(dataVector, MyTableModel.columnNameShort); |
369 | 374 | } |
370 | 375 | } |
371 | 376 | } |
0 commit comments