void (Project project, PsiElement targetContainer, final MoveCallback callback, final PsiDirectory[] directories) { if (targetContainer instanceof PsiDirectory) { String propertyName = "Drag.Drop.Confirmation"; PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); if (propertiesComponent.getBoolean(propertyName, true) && !MessageDialogBuilder.yesNo(JavaRefactoringBundle.message("dialog.title.confirm.move"), JavaRefactoringBundle.message("dialog.message.moving.directories.to", ((PsiDirectory)targetContainer).getName())) .yesText(RefactoringBundle.message("refactor.button")) .doNotAsk(new DoNotAskOption.Adapter() { @Override public void rememberChoice(boolean isSelected, int exitCode) { propertiesComponent.setValue(propertyName, !isSelected, true); } }).ask(project)) { return; } final JavaRefactoringSettings refactoringSettings = JavaRefactoringSettings.getInstance(); final MoveDirectoryWithClassesProcessor processor = new MoveDirectoryWithClassesProcessor(project, directories, (PsiDirectory)targetContainer, refactoringSettings.RENAME_SEARCH_IN_COMMENTS_FOR_PACKAGE, refactoringSettings.RENAME_SEARCH_IN_COMMENTS_FOR_PACKAGE, true, callback); processor.setPrepareSuccessfulSwingThreadCallback(() -> { }); processor.run(); } else { final boolean containsJava = hasJavaFiles(directories); if (!containsJava) { MoveFilesOrDirectoriesUtil.doMove(project, directories, new PsiElement[]{targetContainer}, callback); return; } final MoveClassesOrPackagesToNewDirectoryDialog dlg = new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], directories, false, callback) { @Override protected BaseRefactoringProcessor createRefactoringProcessor(Project project, final PsiDirectory targetDirectory, PsiPackage aPackage, boolean searchInComments, boolean searchForTextOccurences) { final MoveDestination destination = createDestination(aPackage, targetDirectory); if (destination == null) return null; try { for (PsiDirectory dir: directories) { MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(dir, WriteAction.compute(() -> destination.getTargetDirectory(dir))); } } catch (IncorrectOperationException e) { Messages.showErrorDialog(project, e.getMessage(), JavaRefactoringBundle.message("cannot.move")); return null; } return new MoveDirectoryWithClassesProcessor(project, directories, null, searchInComments, searchForTextOccurences, true, callback) { @NotNull @Override public TargetDirectoryWrapper getTargetDirectory(PsiDirectory dir) { final PsiDirectory targetDirectory = destination.getTargetDirectory(dir); return new TargetDirectoryWrapper(targetDirectory); } @Override protected String getTargetName() { return targetDirectory.getName(); } }; } }; dlg.show(); } }