new editing mode for task description panel
[idea/community.git] / python / educational-core / student / src / com / jetbrains / edu / learning / actions / StudyPrevWindowAction.java
1 package com.jetbrains.edu.learning.actions;
2
3 import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
4 import com.jetbrains.edu.learning.StudyUtils;
5 import icons.InteractiveLearningIcons;
6 import org.jetbrains.annotations.NotNull;
7 import org.jetbrains.annotations.Nullable;
8
9 import java.util.List;
10
11 /**
12  * author: liana
13  * data: 6/30/14.
14  */
15 public class StudyPrevWindowAction extends StudyWindowNavigationAction {
16   public static final String ACTION_ID = "PrevWindowAction";
17   public static final String SHORTCUT = "ctrl shift pressed COMMA";
18
19   public StudyPrevWindowAction() {
20     super("Navigate to the Previous Answer Placeholder", "Navigate to the previous answer placeholder", InteractiveLearningIcons.Prev);
21   }
22
23
24   @Nullable
25   @Override
26   protected AnswerPlaceholder getNextAnswerPlaceholder(@NotNull final AnswerPlaceholder window) {
27     int prevIndex = window.getIndex() - 1;
28     List<AnswerPlaceholder> windows = window.getTaskFile().getAnswerPlaceholders();
29     if (StudyUtils.indexIsValid(prevIndex, windows)) {
30       return windows.get(prevIndex);
31     }
32     return null;
33   }
34
35   @NotNull
36   @Override
37   public String getActionId() {
38     return ACTION_ID;
39   }
40
41   @Nullable
42   @Override
43   public String[] getShortcuts() {
44     return new String[]{SHORTCUT};
45   }
46 }