void (ActionEvent e) { Object selectedItem = getComboBox().getSelectedItem(); record NonBlockingResult(@Nullable String error, @NlsSafe @Nullable String relativeSrcPath) { } ReadAction .nonBlocking(() -> { if (selectedItem instanceof DirectoryChooser.ItemWrapper && selectedItem != DirectoryChooser.ItemWrapper.NULL) { PsiDirectory directory = ((DirectoryChooser.ItemWrapper)selectedItem).getDirectory(); if (directory != null) { selection.set(fileIndex.getSourceRootForFile(directory.getVirtualFile())); } } String relativeSrcPath = null; if (sourceRoot != null) { relativeSrcPath = ProjectUtil.calcRelativeToProjectPath(sourceRoot, myProject, true, false, true); } return new NonBlockingResult(getUpdateErrorMessage(fileIndex, selectedItem), relativeSrcPath); }) .expireWith(DestinationFolderComboBox.this) .finishOnUiThread(ModalityState.stateForComponent(getComboBox()), (result) -> { myUpdateErrorMessage.accept(result.error); updateTooltipText(result.relativeSrcPath); }).submit(AppExecutorUtil.getAppExecutorService()); }