diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:24:04 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:24:04 -0700 |
commit | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (patch) | |
tree | fc0dcd722b6d445468dbe7dad13b4c11781b1cbe /python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java | |
parent | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (diff) | |
download | idea-c3d3a90f6b4ead083d63e28e6b9fcea93d675678.tar.gz |
Snapshot idea/138.1980 from git://git.jetbrains.org/idea/community.git
Change-Id: Ib567c9c152d770212a7a3db20fbf591c210920bd
Diffstat (limited to 'python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java')
-rw-r--r-- | python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java b/python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java new file mode 100644 index 000000000000..1a7304123f0a --- /dev/null +++ b/python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/projectView/CCDirectoryNode.java @@ -0,0 +1,63 @@ +package org.jetbrains.plugins.coursecreator.projectView; + +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiDirectory; +import com.intellij.ui.SimpleTextAttributes; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.coursecreator.CCProjectService; +import org.jetbrains.plugins.coursecreator.format.Course; +import org.jetbrains.plugins.coursecreator.format.Lesson; +import org.jetbrains.plugins.coursecreator.format.Task; + +public class CCDirectoryNode extends PsiDirectoryNode { + private final PsiDirectory myValue; + private final Project myProject; + + public CCDirectoryNode(@NotNull final Project project, + PsiDirectory value, + ViewSettings viewSettings) { + super(project, value, viewSettings); + myValue = value; + myProject = project; + } + + @Override + protected void updateImpl(PresentationData data) { + String valueName = myValue.getName(); + final Course course = CCProjectService.getInstance(myProject).getCourse(); + if (course == null) return; + if (myProject.getBaseDir().equals(myValue.getVirtualFile())) { + data.clearText(); + data.addText(valueName, SimpleTextAttributes.REGULAR_ATTRIBUTES); + data.addText(" (" + course.getName() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES); + return; + } + final Lesson lesson = course.getLesson(valueName); + if (lesson != null) { + data.clearText(); + data.addText(valueName, SimpleTextAttributes.REGULAR_ATTRIBUTES); + data.addText(" (" + lesson.name + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES); + return; + } + else { + final PsiDirectory parentDir = myValue.getParentDirectory(); + if (parentDir != null) { + final Lesson parentLesson = course.getLesson(parentDir.getName()); + if (parentLesson != null) { + final Task task = parentLesson.getTask(valueName); + if (task != null) { + data.clearText(); + data.addText(valueName, SimpleTextAttributes.REGULAR_ATTRIBUTES); + data.addText(" (" + task.name + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES); + return; + } + } + } + } + data.setPresentableText(valueName); + } + +} |