diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java index 9d0567c0493..fca3d54ca2e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java @@ -196,6 +196,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog { @Override public void memberInfoChanged(MemberInfoChange event) { + updatePackageDirectiveCheckBox(); // Update file name field only if it user hasn't changed it to some non-default value if (shouldUpdateFileNameField(event.getChangedMembers())) { updateSuggestedFileName(); @@ -324,12 +325,16 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog { classPackageChooser.setEnabled(moveToPackage); updateFileNameInPackageField(); fileChooser.setEnabled(!moveToPackage); - cbUpdatePackageDirective.setEnabled(moveToPackage); + updatePackageDirectiveCheckBox(); UIUtil.setEnabled(targetPanel, moveToPackage && hasAnySourceRoots(), true); updateSuggestedFileName(); validateButtons(); } + private void updatePackageDirectiveCheckBox() { + cbUpdatePackageDirective.setEnabled(isMoveToPackage() && getSelectedElementsToMove().size() == sourceFile.getDeclarations().size()); + } + private boolean hasAnySourceRoots() { return !JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).isEmpty(); }