EDU-217 Close files from previous task when creating a new one - course creator mode
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 15:37:44 +0000 (19:37 +0400)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 15:37:44 +0000 (19:37 +0400)
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/actions/CCCreateTask.java

index c194b8ba01b667612df3dce6f6ea567b009c8a69..fed406ec8df0d594b7a15dc2a8a7b0237fb31d26 100644 (file)
@@ -12,9 +12,11 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.LangDataKeys;
 import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.PlatformIcons;
@@ -68,6 +70,10 @@ public class CCCreateTask extends DumbAwareAction {
             ApplicationManager.getApplication().invokeLater(new Runnable() {
               @Override
               public void run() {
+                FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
+                for (VirtualFile virtualFile : fileEditorManager.getOpenFiles()) {
+                  fileEditorManager.closeFile(virtualFile);
+                }
                 EditorHelper.openInEditor(testsFile, false);
                 EditorHelper.openInEditor(taskPyFile, false);
                 view.selectElement(taskFile);