EDU-595 Disable task navigation actions if no task to navigate to
[idea/community.git] / python / educational-core / student / src / com / jetbrains / edu / learning / actions / StudyNextStudyTaskAction.java
1 package com.jetbrains.edu.learning.actions;
2
3 import com.intellij.icons.AllIcons;
4 import com.intellij.openapi.actionSystem.KeyboardShortcut;
5 import com.intellij.openapi.keymap.KeymapUtil;
6 import com.jetbrains.edu.learning.courseFormat.Task;
7 import com.jetbrains.edu.learning.navigation.StudyNavigator;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
10
11 import javax.swing.*;
12
13 public class StudyNextStudyTaskAction extends StudyTaskNavigationAction {
14
15   public static final String ACTION_ID = "NextTaskAction";
16   public static final String SHORTCUT = "ctrl pressed PERIOD";
17
18   public StudyNextStudyTaskAction() {
19     super("Next Task (" + KeymapUtil.getShortcutText(new KeyboardShortcut(KeyStroke.getKeyStroke(SHORTCUT), null)) + ")", "Navigate to the next task", AllIcons.Actions.Forward);
20   }
21
22   @Override
23   protected Task getTargetTask(@NotNull final Task sourceTask) {
24     return StudyNavigator.nextTask(sourceTask);
25   }
26
27   @NotNull
28   @Override
29   public String getActionId() {
30     return ACTION_ID;
31   }
32
33   @Nullable
34   @Override
35   public String[] getShortcuts() {
36     return new String[]{SHORTCUT};
37   }
38 }