summaryrefslogtreecommitdiff
path: root/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java')
-rw-r--r--python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java b/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java
new file mode 100644
index 000000000000..347456189a00
--- /dev/null
+++ b/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java
@@ -0,0 +1,34 @@
+package com.jetbrains.python.edu.actions;
+
+import com.jetbrains.python.edu.StudyUtils;
+import com.jetbrains.python.edu.course.TaskWindow;
+import icons.StudyIcons;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+/**
+ * author: liana
+ * data: 6/30/14.
+ */
+public class StudyPrevWindowAction extends StudyWindowNavigationAction {
+ public static final String ACTION_ID = "PrevWindowAction";
+ public static final String SHORTCUT = "ctrl pressed COMMA";
+
+ public StudyPrevWindowAction() {
+ super("PrevWindowAction", "Select previous window", StudyIcons.Prev);
+ }
+
+
+ @Nullable
+ @Override
+ protected TaskWindow getNextTaskWindow(@NotNull final TaskWindow window) {
+ int prevIndex = window.getIndex() - 1;
+ List<TaskWindow> windows = window.getTaskFile().getTaskWindows();
+ if (StudyUtils.indexIsValid(prevIndex, windows)) {
+ return windows.get(prevIndex);
+ }
+ return null;
+ }
+}