remove placeholders if file was hidden from student
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 5 Aug 2016 15:13:37 +0000 (18:13 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 5 Aug 2016 15:15:10 +0000 (18:15 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCHideFromStudent.java

index 07cd46cfdf200e8249564d2b0518d2c4007b9ee6..f794e69d0ea21bd2c45e182c206ca19e5cf37f98 100644 (file)
@@ -2,6 +2,10 @@ package com.jetbrains.edu.coursecreator.actions;
 
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.jetbrains.edu.learning.StudyUtils;
@@ -23,6 +27,14 @@ public class CCHideFromStudent extends CCTaskFileActionBase {
     if (taskFile == null) {
       return;
     }
     if (taskFile == null) {
       return;
     }
+    if (!taskFile.getAnswerPlaceholders().isEmpty() && FileEditorManager.getInstance(project).isFileOpen(file)) {
+      for (FileEditor fileEditor : FileEditorManager.getInstance(project).getEditors(file)) {
+        if (fileEditor instanceof PsiAwareTextEditorImpl) {
+          Editor editor = ((PsiAwareTextEditorImpl)fileEditor).getEditor();
+          editor.getMarkupModel().removeAllHighlighters();
+        }
+      }
+    }
     String name = file.getName();
     VirtualFile patternFile = StudyUtils.getPatternFile(taskFile, name);
     ApplicationManager.getApplication().runWriteAction(() -> {
     String name = file.getName();
     VirtualFile patternFile = StudyUtils.getPatternFile(taskFile, name);
     ApplicationManager.getApplication().runWriteAction(() -> {