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