|
32 | 32 | import org.openide.util.Exceptions; |
33 | 33 | import org.openide.util.NbPreferences; |
34 | 34 | import org.openide.util.Pair; |
| 35 | +import org.openide.util.RequestProcessor; |
35 | 36 |
|
36 | 37 | final class PythonLspServerConfigsPanel extends javax.swing.JPanel { |
37 | 38 |
|
38 | 39 | private static final long serialVersionUID = 1L; |
39 | 40 |
|
| 41 | + RequestProcessor RP = new RequestProcessor(this.getClass().getName(), 1); |
| 42 | + |
40 | 43 | public static String[] PACKAGES = { |
41 | 44 | "pylsp", |
42 | 45 | "pyls-isort", |
@@ -231,33 +234,36 @@ private void lspListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:eve |
231 | 234 | }//GEN-LAST:event_lspListMouseClicked |
232 | 235 |
|
233 | 236 | void load() { |
234 | | - if (errors != null && !errors.isEmpty()) { |
235 | | - return; |
236 | | - } |
237 | | - try { |
238 | | - lspServerCheckBox.setSelected(NbPreferences.root().getBoolean("autoUpdate", false)); |
239 | | - lspServerLabel.setText(String.format("%s%s", "Current Version: ", PythonUtility.getServerVersion())); |
240 | | - lspPythonVersionLabel.setText(String.format("%s%s", "Python Version: ", PythonUtility.getVersion(PythonUtility.getLspPythonExe()))); |
241 | | - String pipListOutput = PythonUtility.getPipList(PythonUtility.getLspPythonExe()); |
| 237 | + RP.post(() -> { |
| 238 | + if (errors != null && !errors.isEmpty()) { |
| 239 | + return; |
| 240 | + } |
| 241 | + try { |
| 242 | + lspServerCheckBox.setSelected(NbPreferences.root().getBoolean("autoUpdate", false)); |
| 243 | + lspServerLabel.setText(String.format("%s%s", "Current Version: ", PythonUtility.getServerVersion())); |
| 244 | + lspPythonVersionLabel.setText(String.format("%s%s", "Python Version: ", PythonUtility.getVersion(PythonUtility.getLspPythonExe()))); |
| 245 | + String pipListOutput = PythonUtility.getPipList(PythonUtility.getLspPythonExe()); |
| 246 | + |
| 247 | + DefaultListModel<Pair<String, Boolean>> model = new DefaultListModel<>(); |
242 | 248 |
|
243 | | - DefaultListModel<Pair<String, Boolean>> model = new DefaultListModel<>(); |
| 249 | + for (String pipPackage : PACKAGES) { |
| 250 | + if (pipListOutput.contains(pipPackage)) { |
| 251 | + model.addElement(Pair.of(pipPackage, true)); |
244 | 252 |
|
245 | | - for (String pipPackage : PACKAGES) { |
246 | | - if (pipListOutput.contains(pipPackage)) { |
247 | | - model.addElement(Pair.of(pipPackage, true)); |
| 253 | + } else { |
| 254 | + model.addElement(Pair.of(pipPackage, false)); |
248 | 255 |
|
249 | | - } else { |
250 | | - model.addElement(Pair.of(pipPackage, false)); |
| 256 | + } |
251 | 257 |
|
252 | 258 | } |
| 259 | + lspList.setModel(model); |
253 | 260 |
|
| 261 | + lspEditorPane.setText(Files.readString(PythonUtility.SETTINGS.toPath())); |
| 262 | + } catch (IOException ex) { |
| 263 | + Exceptions.printStackTrace(ex); |
254 | 264 | } |
255 | | - lspList.setModel(model); |
256 | 265 |
|
257 | | - lspEditorPane.setText(Files.readString(PythonUtility.SETTINGS.toPath())); |
258 | | - } catch (IOException ex) { |
259 | | - Exceptions.printStackTrace(ex); |
260 | | - } |
| 266 | + }); |
261 | 267 |
|
262 | 268 | } |
263 | 269 |
|
|
0 commit comments