summaryrefslogtreecommitdiff
path: root/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyPrevWindowAction.java
blob: 347456189a005a92b3880bc3e5fe6cc85d71f5b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
  }
}