Minor Fix according to review IDEA-CR-11509
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Thu, 16 Jun 2016 13:03:43 +0000 (16:03 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Fri, 17 Jun 2016 12:56:42 +0000 (15:56 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/StudyBasePluginConfigurator.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/StepicAdaptiveReactionsPanel.java

index 9fbfb736a5e494bed98140782dbaef49d3431ab2..99163eea7916c499fe212a5ad777c01e877f57d4 100644 (file)
@@ -81,7 +81,7 @@ public abstract class StudyBasePluginConfigurator implements StudyPluginConfigur
       }
 
       private void setTaskText(@Nullable final Task task, @Nullable final VirtualFile taskDirectory) {
-        String text = StudyUtils.getTaskTextFromTask(task, taskDirectory);
+        String text = StudyUtils.getTaskTextFromTask(taskDirectory, task);
         if (text == null) {
           toolWindow.setEmptyText(project);
           return;
index ea45745a363b548c3f4b2538ad388326296921bf..8cedfc1dadfa302bcc4cdb79764104103933fd4e 100644 (file)
@@ -442,7 +442,7 @@ public class StudyUtils {
   }
 
   @Nullable
-  public static String getTaskTextFromTask(@Nullable final Task task, @Nullable final VirtualFile taskDirectory) {
+  public static String getTaskTextFromTask(@Nullable final VirtualFile taskDirectory, @Nullable final Task task) {
     if (task == null) {
       return null;
     }
@@ -451,17 +451,17 @@ public class StudyUtils {
       return text;
     }
     if (taskDirectory != null) {
-      final String taskTextFileHtml = getTaskTextFrom(taskDirectory, EduNames.TASK_HTML);
+      final String taskTextFileHtml = getTaskTextFromTaskName(taskDirectory, EduNames.TASK_HTML);
       if (taskTextFileHtml != null) return taskTextFileHtml;
       
-      final String taskTextFileMd = getTaskTextFrom(taskDirectory, EduNames.TASK_MD);
+      final String taskTextFileMd = getTaskTextFromTaskName(taskDirectory, EduNames.TASK_MD);
       if (taskTextFileMd != null) return convertToHtml(taskTextFileMd);      
     }
     return null;
   }
 
   @Nullable
-  private static String getTaskTextFrom(@NotNull VirtualFile taskDirectory, @NotNull String taskTextFilename) {
+  private static String getTaskTextFromTaskName(@NotNull VirtualFile taskDirectory, @NotNull String taskTextFilename) {
     VirtualFile taskTextFile = taskDirectory.findChild(taskTextFilename);
     if (taskTextFile == null) {
       VirtualFile srcDir = taskDirectory.findChild(EduNames.SRC);
@@ -510,7 +510,7 @@ public class StudyUtils {
     }
     final Task task = taskFile.getTask();
     if (task != null) {
-      return getTaskTextFromTask(task, task.getTaskDir(project));
+      return getTaskTextFromTask(task.getTaskDir(project), task);
     }
     return null;
   }
@@ -529,18 +529,8 @@ public class StudyUtils {
   
   @Nullable
   public static Task getCurrentTask(@NotNull final Project project) {
-    VirtualFile[] files = FileEditorManager.getInstance(project).getSelectedFiles();
-    TaskFile taskFile = null;
-    for (VirtualFile file : files) {
-      taskFile = getTaskFile(project, file);
-      if (taskFile != null) {
-        break;
-      }
-    }
-    if (taskFile != null) {
-      return taskFile.getTask();
-    }
-    return null;
+    final TaskFile taskFile = getSelectedTaskFile(project);
+    return taskFile != null ? taskFile.getTask() : null;
   }
 
   public static void updateStudyToolWindow(Project project) {
index 97521b1919c7d2b025e57bfd59d2e1c4a75a60a6..04a52dec8e7dda123bcf7cb80eeb246aaa76b929 100644 (file)
@@ -76,9 +76,6 @@ public class StepicAdaptiveReactionsPanel extends JPanel {
     final FileEditorManagerListener editorManagerListener = new FileEditorManagerListener() {
       @Override
       public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
-        final com.jetbrains.edu.learning.courseFormat.Task task = StudyUtils.getTaskFromSelectedEditor(myProject);
-        final boolean isEnabled = task != null && task.getStatus() != StudyStatus.Solved;
-        StepicAdaptiveReactionsPanel.this.setEnabledRecursive(isEnabled);
       }
 
       @Override