void (ActionEvent e) { final ComboBoxModel<DirectoryChooser.ItemWrapper> model = getComboBox().getModel(); VirtualFile root = CommonMoveClassesOrPackagesUtil.chooseSourceRoot( new PackageWrapper(PsiManager.getInstance(project), getTargetPackage()), mySourceRoots, targetDirectory ); if (root == null) return; List<DirectoryChooser.ItemWrapper> items = new ArrayList<>(model.getSize()); for (int i = 0; i < model.getSize(); i++) items.add(model.getElementAt(i)); record NonBlockingResult(@NotNull VirtualFile root, @Nullable DirectoryChooser.ItemWrapper item) { } ReadAction .nonBlocking(() -> new NonBlockingResult( root, ContainerUtil.find(items, item -> item != DirectoryChooser.ItemWrapper.NULL && Comparing.equal(fileIndex.getSourceRootForFile(item.getDirectory().getVirtualFile()), root) ) )) .expireWith(DestinationFolderComboBox.this) .finishOnUiThread(ModalityState.current(), result -> { if (result.item != null) { getComboBox().setSelectedItem(result.item); getComboBox().repaint(); } setComboboxModel(result.root, result.root, true); }) .submit(AppExecutorUtil.getAppExecutorService()); }