show error message (IDEA-144514)
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Fri, 28 Aug 2015 18:11:16 +0000 (21:11 +0300)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Fri, 28 Aug 2015 18:11:16 +0000 (21:11 +0300)
java/java-impl/src/com/intellij/codeInspection/MoveToPackageFix.java

index 3fd32c34212b1a6f0420e2d9dd296fa43002fdc2..a93f50361cf67f0f75661901c013e18912a0cca9 100644 (file)
@@ -78,12 +78,21 @@ public class MoveToPackageFix implements LocalQuickFix {
 
   private void chooseDirectoryAndMove(Project project, PsiFile myFile) {
     try {
-      PsiDirectory directory = MoveClassesOrPackagesUtil.chooseDestinationPackage(project, myTargetPackage, myFile.getContainingDirectory());
+      String error;
+      PsiDirectory directory = null;
+      try {
+        directory = MoveClassesOrPackagesUtil.chooseDestinationPackage(project, myTargetPackage, myFile.getContainingDirectory());
 
-      if (directory == null) {
-        return;
+        if (directory == null) {
+          return;
+        }
+
+        error = RefactoringMessageUtil.checkCanCreateFile(directory, myFile.getName());
       }
-      String error = RefactoringMessageUtil.checkCanCreateFile(directory, myFile.getName());
+      catch (IncorrectOperationException e) {
+        error = e.getLocalizedMessage();
+      }
+
       if (error != null) {
         Messages.showMessageDialog(project, error, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
         return;