EDU-407 Files created by user code are invisible
authorliana.bakradze <liana.bakradze@jetbrains.com>
Tue, 25 Aug 2015 16:44:43 +0000 (19:44 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Tue, 25 Aug 2015 16:44:43 +0000 (19:44 +0300)
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyTaskManager.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/actions/StudyRunAction.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/courseGeneration/StudyGenerator.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/projectView/StudyTreeStructureProvider.java

index 5ca158f09fe5d4838ca1e27b82f9e0d174573ad2..22130fe1a1f5f33456e159108faa763a49aa11bf 100644 (file)
@@ -36,6 +36,7 @@ public class StudyTaskManager implements PersistentStateComponent<StudyTaskManag
   public Map<AnswerPlaceholder, StudyStatus> myStudyStatusMap = new HashMap<AnswerPlaceholder, StudyStatus>();
   public Map<TaskFile, StudyStatus> myTaskStatusMap = new HashMap<TaskFile, StudyStatus>();
   public Map<Task, List<UserTest>> myUserTests = new HashMap<Task, List<UserTest>>();
+  public List<String> myInvisibleFiles = new ArrayList<String>();
 
   private StudyTaskManager() {
   }
@@ -184,4 +185,12 @@ public class StudyTaskManager implements PersistentStateComponent<StudyTaskManag
   public static StudyTaskManager getInstance(@NotNull final Project project) {
     return ServiceManager.getService(project, StudyTaskManager.class);
   }
+
+  public void addInvisibleFiles(String filePath) {
+    myInvisibleFiles.add(filePath);
+  }
+
+  public boolean isInvisibleFile(String path) {
+    return myInvisibleFiles.contains(path);
+  }
 }
index 79b07c1453edc38dd3c1b3f5f50e87ab46a15eb2..e466ada6c270d80d7c483328e99f6d0b0a903ed2 100644 (file)
@@ -80,6 +80,7 @@ public class StudyRunAction extends DumbAwareAction {
         Disposer.register(project, executor);
         executor.run();
       }
+      EduUtils.synchronize();
     }
   }
 
index 237ce394a182c7c9950c30591e848a2d0326afb7..e77229f40c23e87f9e6b7c5cd02bf1e3e356ce34 100644 (file)
@@ -9,6 +9,7 @@ import com.jetbrains.edu.courseFormat.Course;
 import com.jetbrains.edu.courseFormat.Lesson;
 import com.jetbrains.edu.courseFormat.Task;
 import com.jetbrains.edu.courseFormat.TaskFile;
+import com.jetbrains.edu.learning.StudyTaskManager;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -68,6 +69,7 @@ public class StudyGenerator {
           File resourceFile = new File(newResourceRoot, fileName);
           File fileInProject = new File(taskDir.getCanonicalPath(), fileName);
           FileUtil.copy(resourceFile, fileInProject);
+          StudyTaskManager.getInstance(project).addInvisibleFiles(fileInProject.getPath());
         }
       }
     }
index 955e29d5bf0e22f5e0807a7e5fc45a6a22bb0867..e07a349ac5de9a9620463e6c95b4578ff1e2b970 100644 (file)
@@ -54,6 +54,9 @@ public class StudyTreeStructureProvider implements TreeStructureProvider, DumbAw
               if (parentName.equals(EduNames.SANDBOX_DIR)) {
                 nodes.add(node);
               }
+              if (parentName.startsWith(EduNames.TASK)) {
+                addNonInvisibleFiles(nodes, node, project, virtualFile);
+              }
             }
           }
         }
@@ -62,6 +65,18 @@ public class StudyTreeStructureProvider implements TreeStructureProvider, DumbAw
     return nodes;
   }
 
+  private static void addNonInvisibleFiles(@NotNull final Collection<AbstractTreeNode> nodes,
+                                           @NotNull final AbstractTreeNode node,
+                                           @NotNull final Project project,
+                                           @NotNull final VirtualFile virtualFile) {
+    if (!StudyTaskManager.getInstance(project).isInvisibleFile(virtualFile.getPath())) {
+      String fileName = virtualFile.getName();
+      if (!fileName.contains(EduNames.WINDOW_POSTFIX) && !fileName.contains(EduNames.WINDOWS_POSTFIX)) {
+        nodes.add(node);
+      }
+    }
+  }
+
   protected boolean isCourseBasedProject(@NotNull final AbstractTreeNode parent) {
     final Project project = parent.getProject();
     if (project != null) {