removed useless listener
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 24 Feb 2015 15:39:54 +0000 (18:39 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 24 Feb 2015 15:39:54 +0000 (18:39 +0300)
python/educational/interactive-learning/src/com/jetbrains/edu/learning/editor/StudyEditorFactoryListener.java
python/educational/src/com/jetbrains/edu/EduAnswerPlaceholderPainter.java

index 912269d3b446b443d0423b206ff52009208710ec..1a04083a612e2a85517105687ce738fe4fae279d 100644 (file)
@@ -4,59 +4,21 @@ package com.jetbrains.edu.learning.editor;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.LogicalPosition;
 import com.intellij.openapi.editor.event.EditorFactoryEvent;
 import com.intellij.openapi.editor.event.EditorFactoryListener;
-import com.intellij.openapi.editor.event.EditorMouseAdapter;
-import com.intellij.openapi.editor.event.EditorMouseEvent;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.problems.WolfTheProblemSolver;
-import com.intellij.ui.JBColor;
-import com.jetbrains.edu.EduAnswerPlaceholderPainter;
 import com.jetbrains.edu.EduDocumentListener;
-import com.jetbrains.edu.courseFormat.AnswerPlaceholder;
 import com.jetbrains.edu.courseFormat.TaskFile;
-import com.jetbrains.edu.learning.StudyTaskManager;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.navigation.StudyNavigator;
 import org.jetbrains.annotations.NotNull;
 
-import java.awt.*;
-
 
 public class StudyEditorFactoryListener implements EditorFactoryListener {
 
-  /**
-   * draws selected task window if there is one located in mouse position
-   */
-  private static class WindowSelectionListener extends EditorMouseAdapter {
-    private final TaskFile myTaskFile;
-
-    WindowSelectionListener(@NotNull final TaskFile taskFile) {
-      myTaskFile = taskFile;
-    }
-
-    @Override
-    public void mouseClicked(EditorMouseEvent e) {
-      final Editor editor = e.getEditor();
-      final Point point = e.getMouseEvent().getPoint();
-      final LogicalPosition pos = editor.xyToLogicalPosition(point);
-      final AnswerPlaceholder answerPlaceholder = myTaskFile.getAnswerPlaceholder(editor.getDocument(), pos);
-      if (answerPlaceholder != null) {
-        myTaskFile.setSelectedAnswerPlaceholder(answerPlaceholder);
-        final Project project = editor.getProject();
-        assert project != null;
-        final JBColor color = StudyTaskManager.getInstance(project).getColor(answerPlaceholder);
-        EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, true, color);
-      }
-      else {
-        StudyUtils.drawAllWindows(editor, myTaskFile);
-      }
-    }
-  }
-
   @Override
   public void editorCreated(@NotNull final EditorFactoryEvent event) {
     final Editor editor = event.getEditor();
@@ -78,7 +40,6 @@ public class StudyEditorFactoryListener implements EditorFactoryListener {
                 final TaskFile taskFile = StudyUtils.getTaskFile(project, openedFile);
                 if (taskFile != null) {
                   StudyNavigator.navigateToFirstAnswerPlaceholder(editor, taskFile);
-                  editor.addEditorMouseListener(new WindowSelectionListener(taskFile));
                   StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile));
                   WolfTheProblemSolver.getInstance(project).clearProblems(openedFile);
                   StudyUtils.drawAllWindows(editor, taskFile);
index 49921f2b37ebbb1988be9836fa194fa22b8f4cdc..25d1783f74ffa14fb4ac46c60543de6b3f8baa51 100644 (file)
@@ -49,7 +49,6 @@ public class EduAnswerPlaceholderPainter {
         g.drawRect(point.x, point.y - 2, (pointEnd.x - point.x), editor.getLineHeight() + 1);
       }
     });
-    editor.getCaretModel().moveToOffset(startOffset);
     highlighter.setGreedyToLeft(true);
     highlighter.setGreedyToRight(true);
   }