add information about active subtask to project view node
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Thu, 22 Sep 2016 11:57:24 +0000 (14:57 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 17 Nov 2016 14:05:03 +0000 (17:05 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/projectView/StudyDirectoryNode.java

index 623d648e27ec26fc91344b36aa7cbc3daa168fcd..e0dad96eb9d016870a27a372f9f1838120721a39 100644 (file)
@@ -18,6 +18,7 @@ import com.jetbrains.edu.learning.core.EduUtils;
 import com.jetbrains.edu.learning.courseFormat.*;
 import icons.InteractiveLearningIcons;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
@@ -107,25 +108,33 @@ public class StudyDirectoryNode extends PsiDirectoryNode {
   }
 
   protected void setStudyAttributes(Task task, PresentationData data, String name) {
+    String additionalInfo = task.hasSubtasks() ? getSubtaskInfo(task) : null;
     StudyStatus taskStatus = task.getStatus();
     switch (taskStatus) {
       case Unchecked: {
-        updatePresentation(data, name, JBColor.BLACK, InteractiveLearningIcons.Task);
+        updatePresentation(data, name, JBColor.BLACK, InteractiveLearningIcons.Task, additionalInfo);
         break;
       }
       case Solved: {
-        updatePresentation(data, name, LIGHT_GREEN, InteractiveLearningIcons.TaskCompl);
+        updatePresentation(data, name, LIGHT_GREEN, InteractiveLearningIcons.TaskCompl, additionalInfo);
         break;
       }
       case Failed: {
-        updatePresentation(data, name, JBColor.RED, InteractiveLearningIcons.TaskProbl);
+        updatePresentation(data, name, JBColor.RED, InteractiveLearningIcons.TaskProbl, additionalInfo);
       }
     }
   }
 
   protected static void updatePresentation(PresentationData data, String name, JBColor color, Icon icon) {
+    updatePresentation(data, name, color, icon, null);
+  }
+
+  protected static void updatePresentation(PresentationData data, String name, JBColor color, Icon icon, @Nullable String additionalInfo) {
     data.clearText();
     data.addText(name, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color));
+    if (additionalInfo != null) {
+      data.addText(" (" + additionalInfo + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
+    }
     data.setIcon(icon);
   }
 
@@ -200,4 +209,9 @@ public class StudyDirectoryNode extends PsiDirectoryNode {
   public String getNavigateActionText(boolean focusEditor) {
     return null;
   }
+
+  private static String getSubtaskInfo(Task task) {
+    int index = task.getActiveSubtaskIndex() + 1;
+    return EduNames.SUBTASK + " " + index + "/" + task.getSubtaskNum();
+  }
 }