EDU-234 Generated python file becomes visible after .answer file was deleted idea/140.275
authorliana.bakradze <liana.bakradze@jetbrains.com>
Sat, 25 Oct 2014 18:35:14 +0000 (22:35 +0400)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Sat, 25 Oct 2014 18:35:14 +0000 (22:35 +0400)
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/CCProjectComponent.java

index 8b524dbffd4b4006b160db257ce1547a2615b5d5..88a2424925812b713f8bec7a56105ed5fba1c8c9 100644 (file)
@@ -17,6 +17,7 @@ import com.intellij.openapi.vfs.VirtualFileAdapter;
 import com.intellij.openapi.vfs.VirtualFileEvent;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.coursecreator.actions.CCRunTestsAction;
 import org.jetbrains.plugins.coursecreator.format.Course;
 import org.jetbrains.plugins.coursecreator.format.Lesson;
 import org.jetbrains.plugins.coursecreator.format.Task;
@@ -158,7 +159,8 @@ public class CCProjectComponent implements ProjectComponent {
     }
 
     private void deleteTaskFile(Course course, VirtualFile removedFile) {
-      VirtualFile taskDir = removedFile.getParent();
+
+      final VirtualFile taskDir = removedFile.getParent();
       if (taskDir == null || !taskDir.getName().contains("task")) {
         return;
       }
@@ -182,6 +184,12 @@ public class CCProjectComponent implements ProjectComponent {
       if (taskFile == null) {
         return;
       }
+      ApplicationManager.getApplication().runWriteAction(new Runnable() {
+        @Override
+        public void run() {
+          CCRunTestsAction.clearTestEnvironment(taskDir, myProject);
+        }
+      });
       String name = CCProjectService.getRealTaskFileName(removedFile.getName());
       task.getTaskFiles().remove(name);
     }