EDU-230 Move show hint action to editor
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 13:34:33 +0000 (17:34 +0400)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 13:34:33 +0000 (17:34 +0400)
python/edu/learn-python/gen/icons/StudyIcons.java
python/edu/learn-python/resources/META-INF/plugin.xml
python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint.png
python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint@2x.png [new file with mode: 0644]
python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyShowHintAction.java
python/edu/learn-python/src/com/jetbrains/python/edu/editor/StudyEditor.java

index d5a48ba4adfb7edbda9940940514f365f7109bf8..477e5ed54364fca089c6b8ff854e8b1eb217e6cc 100644 (file)
@@ -19,7 +19,7 @@ public class StudyIcons {
   public static final Icon Prev = load("/icons/com/jetbrains/python/edu/prev.png"); // 16x16
   public static final Icon Resolve = load("/icons/com/jetbrains/python/edu/resolve.png"); // 16x16
   public static final Icon Sandbox = load("/icons/com/jetbrains/python/edu/Sandbox.png"); // 16x16
-  public static final Icon ShowHint = load("/icons/com/jetbrains/python/edu/showHint.png"); // 24x24
+  public static final Icon ShowHint = load("/icons/com/jetbrains/python/edu/showHint.png"); // 16x16
   public static final Icon Task = load("/icons/com/jetbrains/python/edu/Task.png"); // 16x16
   public static final Icon TaskCompl = load("/icons/com/jetbrains/python/edu/TaskCompl.png"); // 16x16
   public static final Icon TaskProbl = load("/icons/com/jetbrains/python/edu/TaskProbl.png"); // 16x16
index 388da68ae6658b488640d75f6f5918cd213e4879..59457f3a1a9592de4306d95bbba3b9ffb39b0248 100644 (file)
     <action id="WatchInputAction" class="com.jetbrains.python.edu.actions.StudyEditInputAction" text="WatchInputAction"
             description="watch input"/>
     <action id="StudyRunAction" class="com.jetbrains.python.edu.actions.StudyRunAction" text="StudyRunAction" description="run your code"/>
-    <action id="ShowHintAction" class="com.jetbrains.python.edu.actions.StudyShowHintAction" text="Show hint"
-            description="show hint">
-      <add-to-group group-id="MainToolBar" anchor="last"/>
-    </action>
-
     <action id="WelcomeScreen.PythonIntro" class="com.jetbrains.python.edu.actions.StudyIntroductionCourseAction" icon="StudyIcons.EducationalProjectType">
       <add-to-group group-id="WelcomeScreen.QuickStart" anchor="first"/>
     </action>
index f10fd560464a494e76fac3b239a6d597d5264933..e3d4abf91fe9cd0d2a5851ae9461e7f4952b143a 100644 (file)
Binary files a/python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint.png and b/python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint.png differ
diff --git a/python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint@2x.png b/python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint@2x.png
new file mode 100644 (file)
index 0000000..1d79e73
Binary files /dev/null and b/python/edu/learn-python/resources/icons/com/jetbrains/python/edu/showHint@2x.png differ
index 0568a406759b7cd202cad8dc86539349957e10ba..a464996d877a0b924465eb06d7cffc60407f1a35 100644 (file)
@@ -32,11 +32,15 @@ public class StudyShowHintAction extends DumbAwareAction {
     super("Show hint", "Show hint", StudyIcons.ShowHint);
   }
 
-  public void actionPerformed(AnActionEvent e) {
+  public void actionPerformed(@NotNull AnActionEvent e) {
     final Project project = e.getProject();
     if (project == null) {
       return;
     }
+    showHint(project);
+  }
+
+  public static void showHint(Project project) {
     Course course = StudyTaskManager.getInstance(project).getCourse();
     if (course == null) {
       return;
index 1a06e7ade6ab398110901b11668668553138850b..a85df6c4cf14cfd30ead2de9267147993bfec38d 100644 (file)
@@ -66,6 +66,7 @@ public class StudyEditor implements TextEditor {
   private JButton myRefreshButton;
   private static final Map<Document, StudyDocumentListener> myDocumentListeners = new HashMap<Document, StudyDocumentListener>();
   private final Project myProject;
+  private JButton myShowHintButton;
 
   public JButton getCheckButton() {
     return myCheckButton;
@@ -196,6 +197,7 @@ public class StudyEditor implements TextEditor {
     myPrevTaskButton = addButton(taskActionsPanel, "Prev Task", StudyIcons.Prev);
     myNextTaskButton = addButton(taskActionsPanel, "Next Task", AllIcons.Actions.Forward);
     myRefreshButton = addButton(taskActionsPanel, "Start task again", AllIcons.Actions.Refresh);
+    myShowHintButton = addButton(taskActionsPanel, "Show hint", StudyIcons.ShowHint);
     if (!taskFile.getTask().getUserTests().isEmpty()) {
       JButton runButton = addButton(taskActionsPanel, "Run", AllIcons.General.Run);
       runButton.addActionListener(new ActionListener() {
@@ -242,9 +244,14 @@ public class StudyEditor implements TextEditor {
     myRefreshButton.addActionListener(new ActionListener() {
       @Override
       public void actionPerformed(ActionEvent e) {
-        StudyRefreshTaskFileAction studyRefreshTaskAction =
-          (StudyRefreshTaskFileAction)ActionManager.getInstance().getAction("RefreshTaskAction");
-        studyRefreshTaskAction.refresh(myProject);
+        StudyRefreshTaskFileAction.refresh(myProject);
+      }
+    });
+
+    myShowHintButton.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent e) {
+        StudyShowHintAction.showHint(myProject);
       }
     });
   }