enable bg dumb mode after creating file from template (IDEA-144581)
authorpeter <peter@jetbrains.com>
Wed, 2 Sep 2015 18:54:25 +0000 (20:54 +0200)
committerpeter <peter@jetbrains.com>
Wed, 2 Sep 2015 20:09:15 +0000 (22:09 +0200)
platform/lang-impl/src/com/intellij/ide/actions/CreateFileFromTemplateAction.java

index 3cd0ed913eb1e02e84acf79c70cac9bbae5af808..edbd5bf0ed031054647d69c1ff4a38158f7a80db 100644 (file)
@@ -20,6 +20,8 @@ import com.intellij.ide.fileTemplates.FileTemplateManager;
 import com.intellij.ide.fileTemplates.FileTemplateUtil;
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.DumbModePermission;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -42,8 +44,15 @@ public abstract class CreateFileFromTemplateAction extends CreateFromTemplateAct
     super(text, description, icon);
   }
 
-  protected PsiFile createFileFromTemplate(String name, FileTemplate template, PsiDirectory dir) {
-    return createFileFromTemplate(name, template, dir, getDefaultTemplateProperty(), true);
+  protected PsiFile createFileFromTemplate(final String name, final FileTemplate template, final PsiDirectory dir) {
+    final PsiFile[] file = new PsiFile[1];
+    DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
+      @Override
+      public void run() {
+        file[0] = createFileFromTemplate(name, template, dir, getDefaultTemplateProperty(), true);
+      }
+    });
+    return file[0];
   }
 
   @SuppressWarnings("DialogTitleCapitalization")