private void asyncUpdateSdkVersion(@NotNull String sdkPath) { ApplicationManager.getApplication().assertIsDispatchThread(); ((CardLayout)myVersionPanel.getLayout()).show(myVersionPanel, VERSION_GETTING); if (!myAlarm.isDisposed()) { myAlarm.cancelAllRequests(); myAlarm.addRequest(() -> { String version = GoSdkUtil.retrieveGoVersion(GoSdkUtil.adjustSdkPath(sdkPath)); ApplicationManager.getApplication().invokeLater(() -> { if (!Disposer.isDisposed(myDisposable)) { setVersion(version); } }, ModalityState.any()); }, 100); } }
handleKey(editor, keyStroke, new EditorDataContext(editor), false); }, ModalityState.stateForComponent(editor.getComponent())));
/** * Opens an error dialog with the specified title. Ensures that the error dialog is opened on the * UI thread. * * @param message The message to be displayed. * @param title The title of the error dialog to be displayed */ public static void showErrorDialog(final String message, @NotNull final String title) { if (ApplicationManager.getApplication().isDispatchThread()) { Messages.showErrorDialog(message, title); } else { ApplicationManager.getApplication() .invokeLater( () -> Messages.showErrorDialog(message, title), ModalityState.defaultModalityState()); } } }
console.debug("Saving files"); LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed(), "Should not be in a read action (risk of dead lock)"); ApplicationManager.getApplication().invokeAndWait(() -> SonarLintUtils.saveFiles(filesToAnalyze), ModalityState.defaultModalityState());
private void asyncUpdateSdkVersion(@NotNull String sdkPath) { ApplicationManager.getApplication().assertIsDispatchThread(); ((CardLayout) myVersionPanel.getLayout()).show(myVersionPanel, VERSION_GETTING); if (!myAlarm.isDisposed()) { myAlarm.cancelAllRequests(); myAlarm.addRequest(() -> { String version = BallerinaSdkUtil.retrieveBallerinaVersion(BallerinaSdkUtil.adjustSdkPath(sdkPath)); ApplicationManager.getApplication().invokeLater(() -> { if (!Disposer.isDisposed(myDisposable)) { setVersion(version); } }, ModalityState.any()); }, 100); } }
private void setStatusMessageAsync(final String message) { ApplicationManager.getApplication() .invokeLater( () -> setStatusMessage(message, true), ModalityState.stateForComponent( AppEngineApplicationCreateDialog.this.getContentPane())); }
private void handleError(Throwable e, ProgressIndicator indicator) { // if cancelled, ignore any errors since they were most likely caused by the interrupt if (!indicator.isCanceled()) { String msg = "Error running SonarLint analysis"; console.error(msg, e); LOGGER.warn(msg, e); if (indicator.isShowing()) { String dialogMsg = "SonarLint analysis failed: " + e.getMessage(); ApplicationManager.getApplication().invokeAndWait( () -> Messages.showErrorDialog(dialogMsg, "Error Running SonarLint Analysis"), ModalityState.defaultModalityState()); } AnalysisCallback callback = job.callback(); if (callback != null) { callback.onError(e); } } }
private void invokePanelValidationUpdate(Runnable runnable) { ApplicationManager.getApplication().invokeLater(runnable, ModalityState.any()); }
private void setMessage(Runnable messagePrinter, boolean isError) { ApplicationManager.getApplication() .invokeAndWait( () -> { errorIcon.setVisible(isError); // TODO(nkibler): Figure out what's causing the HyperlinkLabel to not refresh its view // if we re-use the label here. remove(messageText); messageText = new HyperlinkLabel(); messageText.setOpaque(false); add(messageText); messagePrinter.run(); }, ModalityState.stateForComponent(this)); }
ModalityState.defaultModalityState());
private static void addHighlightersFromEditor(final Set<RangeHighlighter> highlighters, final Editor editor) { ApplicationManager.getApplication().invokeAndWait(() -> { final RangeHighlighter[] highlightersFromCurrentEditor = editor.getMarkupModel().getAllHighlighters(); highlighters.addAll(Sets.newHashSet(highlightersFromCurrentEditor)); }, ModalityState.any()); }
private void refresh() { if (repositories == null) { repositories = new ProjectRepositoriesModelItem(); } setLoader(); loadRepositories( () -> ApplicationManager.getApplication() .invokeAndWait( () -> { treeModel.insertNodeInto(repositories, projectRootNode, 0); treeModel.reload(); repositoryTree.expandRow(0); }, ModalityState.stateForComponent(RepositorySelector.this))); }
/** * Updates all known projects belonging to a server configuration. * It assumes that the server binding is updated. */ private void updateProjects(ServerConfiguration serverConfiguration, TaskProgressMonitor monitor) { Set<String> failedProjects = new LinkedHashSet<>(); for (Map.Entry<String, List<Project>> entry : projectsPerProjectKey.entrySet()) { try { updateProject(serverConfiguration, entry.getKey(), entry.getValue(), monitor); } catch (Exception e) { // in case of error, save project key and keep updating other projects LOGGER.info(e.getMessage(), e); failedProjects.add(entry.getKey()); } } if (!projectsPerProjectKey.isEmpty() && !failedProjects.isEmpty()) { String errorMsg = "Failed to update the following projects. " + "Please check if the server bindings are updated and the module key is correct: " + failedProjects.toString(); log.log(errorMsg, LogOutput.Level.WARN); ApplicationManager.getApplication().invokeLater(new RunnableAdapter() { @Override public void doRun() { Messages.showWarningDialog((Project) null, errorMsg, "Projects Not Updated"); } }, ModalityState.any()); } }
ModalityState.stateForComponent( AppEngineApplicationCreateDialog.this.getContentPane())); });
.invokeAndWait(() -> imageConsumer.accept(finalImageIcon), ModalityState.any()); });
execution, ModalityState.any()); } else { execution.run();
versionOptional.get()), null), ModalityState.any());