void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) return; final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true); FileChooser.chooseFiles(descriptor, project, null, files -> { //gatherPatchFiles final ProgressManager pm = ProgressManager.getInstance(); final ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(project); final List<VirtualFile> patchTypeFiles = new ArrayList<>(); final boolean filesFound = pm.runProcessWithProgressSynchronously( () -> patchTypeFiles.addAll(shelveChangesManager.gatherPatchFiles(files)), VcsBundle.message("looking.for.patch.files"), true, project); if (!filesFound || patchTypeFiles.isEmpty()) return; if (!patchTypeFiles.equals(files)) { final String message = patchTypeFiles.size() == 1 ? VcsBundle.message("shelve.import.one.patch.file.prompt", patchTypeFiles.get(0).getPath()) : VcsBundle.message("shelve.import.patches.prompt", patchTypeFiles.size()); final int toImport = Messages.showYesNoDialog(project, message, VcsBundle.message("import.patches"), Messages.getQuestionIcon()); if (Messages.NO == toImport) return; } pm.runProcessWithProgressSynchronously(() -> { final List<VcsException> exceptions = new ArrayList<>(); final List<ShelvedChangeList> lists = shelveChangesManager.importChangeLists(patchTypeFiles, e1 -> exceptions.add(e1)); if (!lists.isEmpty()) { ShelvedChangesViewManager.getInstance(project).activateView(lists.get(lists.size() - 1)); } if (!exceptions.isEmpty()) { AbstractVcsHelper.getInstance(project).showErrors(exceptions, VcsBundle.message("patch.import.to.shelf.tab")); } if (lists.isEmpty() && exceptions.isEmpty()) { VcsBalloonProblemNotifier.showOverChangesView(project, VcsBundle.message("patch.import.no.patches.found.warning"), MessageType.WARNING); } }, VcsBundle.message("import.patches.into.shelf"), true, project); }); }