use correct placeholder length
authorliana.bakradze <liana.bakradze@jetbrains.com>
Wed, 6 Apr 2016 14:53:52 +0000 (17:53 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Wed, 6 Apr 2016 14:53:52 +0000 (17:53 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCAddAnswerPlaceholder.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/editor/StudyEditorFactoryListener.java

index aab278175e0b62e83f3cde8e30fac1d023286266..d7835cb5db042ca523d8cc6fc90f0e8bc6954fe4 100644 (file)
@@ -98,7 +98,7 @@ public class CCAddAnswerPlaceholder extends CCAnswerPlaceholderAction {
       answerPlaceholders.remove(answerPlaceholder);
       final Editor editor = state.getEditor();
       editor.getMarkupModel().removeAllHighlighters();
-      StudyUtils.drawAllWindows(editor, taskFile);
+      StudyUtils.drawAllWindows(editor, taskFile, false);
       EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, false);
     }
   }
index 3db531be22d221a6c78d0e685d1479a6fc4a8ae4..80fbb6a339b4f6213a8de795ef3a43985be5427f 100644 (file)
@@ -300,20 +300,23 @@ public class StudyUtils {
     return null;
   }
 
-
   public static void drawAllWindows(Editor editor, TaskFile taskFile) {
+    drawAllWindows(editor, taskFile, true);
+  }
+
+  public static void drawAllWindows(Editor editor, TaskFile taskFile, boolean useLength) {
     editor.getMarkupModel().removeAllHighlighters();
     final Project project = editor.getProject();
     if (project == null) return;
     final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
     for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
       final JBColor color = taskManager.getColor(answerPlaceholder);
-      EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, true, color);
+      EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, useLength, color);
     }
     final Document document = editor.getDocument();
     EditorActionManager.getInstance()
       .setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
-    EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, true);
+    EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, useLength);
     editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
   }
 
index 9a1eb88859f280c2131e6028573090513d03dde6..55a784a534cb46541d74d78a78c3435b6a050071 100644 (file)
@@ -15,8 +15,11 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.problems.WolfTheProblemSolver;
+import com.jetbrains.edu.learning.StudyTaskManager;
 import com.jetbrains.edu.learning.core.EduDocumentListener;
+import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
+import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.courseFormat.TaskFile;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.navigation.StudyNavigator;
@@ -76,11 +79,20 @@ public class StudyEditorFactoryListener implements EditorFactoryListener {
                     StudyUtils.updateToolWindows(project);
                     studyToolWindow.show(null);
                   }
+                  Course course = StudyTaskManager.getInstance(project).getCourse();
+                  if (course == null) {
+                    return;
+                  }
+
                   if (!taskFile.getAnswerPlaceholders().isEmpty()) {
                     StudyNavigator.navigateToFirstAnswerPlaceholder(editor, taskFile);
-                    StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile));
-                    StudyUtils.drawAllWindows(editor, taskFile);
-                    editor.addEditorMouseListener(new WindowSelectionListener(taskFile));
+                    boolean isStudyProject = EduNames.STUDY.equals(course.getCourseType());
+                    StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile, true,
+                                                                                      !isStudyProject));
+                    StudyUtils.drawAllWindows(editor, taskFile, isStudyProject);
+                    if (isStudyProject) {
+                      editor.addEditorMouseListener(new WindowSelectionListener(taskFile));
+                    }
                   }
                 }
               }