void () { if (myShowNewNameField) { String newName = getNewName(); if (newName.length() == 0) { Messages.showErrorDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title")); return; } if (myFileCopy && !PathUtilRt.isValidFileName(newName, false)) { Messages.showErrorDialog(myNewNameField, RefactoringBundle.message("name.is.not.a.valid.file.name")); return; } if (myFileCopy && myTargetDirectory != null && isOpenInEditor()) { if (FileTypeChooser.getKnownFileTypeOrAssociate(myTargetDirectory.getVirtualFile(), newName, myProject) == null) { myUnknownFileType = true; } } } if (myShowDirectoryField) { final String targetDirectoryName = getTargetDirectoryComponent().getText(); if (targetDirectoryName.length() == 0) { Messages.showErrorDialog(myProject, RefactoringBundle.message("no.target.directory.specified"), RefactoringBundle.message("error.title")); return; } RecentsManager.getInstance(myProject).registerRecentEntry(RECENT_KEYS, targetDirectoryName); CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> { try { String path = FileUtil.toSystemIndependentName(targetDirectoryName); myTargetDirectory = DirectoryUtil.mkdirs(PsiManager.getInstance(myProject), path); } catch (IncorrectOperationException ignored) { } }), RefactoringBundle.message("create.directory"), null); if (myTargetDirectory == null) { Messages.showErrorDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title")); return; } FileChooserUtil.setLastOpenedFile(myProject, myTargetDirectory.getVirtualFile().toNioPath()); try { for (PsiElement element : myElements) { MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(element, myTargetDirectory); } } catch (IncorrectOperationException e) { Messages.showErrorDialog(myProject, e.getMessage(), RefactoringBundle.message("error.title")); return; } } closeOKAction(); }