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 / StudyPreviousStudyTaskAction.java
1 package com.jetbrains.edu.learning.actions;
2
3
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 icons.InteractiveLearningIcons;
9 import org.jetbrains.annotations.NotNull;
10 import org.jetbrains.annotations.Nullable;
11
12 import javax.swing.*;
13
14 public class StudyPreviousStudyTaskAction extends StudyTaskNavigationAction {
15   public StudyPreviousStudyTaskAction() {
16     super("Previous Task (" + KeymapUtil.getShortcutText(new KeyboardShortcut(KeyStroke.getKeyStroke(SHORTCUT), null)) + ")", "Navigate to the previous task", InteractiveLearningIcons.Prev);
17   }
18
19   public static final String ACTION_ID = "PreviousTaskAction";
20   public static final String SHORTCUT = "ctrl pressed COMMA";
21
22   @Override
23   protected Task getTargetTask(@NotNull final Task sourceTask) {
24     return StudyNavigator.previousTask(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 }