EDU-228 Remove reload course action
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 07:31:27 +0000 (11:31 +0400)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Oct 2014 07:31:27 +0000 (11:31 +0400)
python/edu/learn-python/resources/META-INF/plugin.xml
python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyReloadCourseAction.java [deleted file]
python/edu/learn-python/src/com/jetbrains/python/edu/ui/StudyToolWindowFactory.java

index 264dfba2049b15ad39b4cb0e2bb7f996b797b5b5..388da68ae6658b488640d75f6f5918cd213e4879 100644 (file)
@@ -64,8 +64,6 @@
       <add-to-group group-id="WelcomeScreen.QuickStart" anchor="first"/>
     </action>
 
-    <action id="ReloadCourseAction" class="com.jetbrains.python.edu.actions.StudyReloadCourseAction"/>
-
   </actions>
 
   <extensions defaultExtensionNs="com.intellij">
diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyReloadCourseAction.java b/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyReloadCourseAction.java
deleted file mode 100644 (file)
index 62f087c..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.jetbrains.python.edu.actions;
-
-import com.intellij.ide.projectView.ProjectView;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.fileEditor.FileEditorManager;
-import com.intellij.openapi.project.DumbAwareAction;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.wm.ToolWindow;
-import com.intellij.openapi.wm.ToolWindowId;
-import com.intellij.openapi.wm.ToolWindowManager;
-import com.intellij.util.ui.tree.TreeUtil;
-import com.jetbrains.python.edu.StudyTaskManager;
-import com.jetbrains.python.edu.StudyUtils;
-import com.jetbrains.python.edu.course.Course;
-import com.jetbrains.python.edu.course.Lesson;
-import com.jetbrains.python.edu.course.Task;
-import com.jetbrains.python.edu.course.TaskFile;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-import javax.swing.tree.TreePath;
-import java.util.List;
-import java.util.Map;
-
-public class StudyReloadCourseAction extends DumbAwareAction {
-
-  public StudyReloadCourseAction() {
-    super("Reload Course", "Reload Course", null);
-  }
-
-  @Override
-  public void update(@NotNull AnActionEvent e) {
-    Presentation presentation = e.getPresentation();
-    Project project = e.getProject();
-    if (project != null) {
-      Course course = StudyTaskManager.getInstance(project).getCourse();
-      if (course != null) {
-        presentation.setVisible(true);
-        presentation.setEnabled(true);
-      }
-    }
-    presentation.setVisible(false);
-    presentation.setEnabled(false);
-  }
-
-  @Override
-  public void actionPerformed(@NotNull AnActionEvent e) {
-    Project project = e.getProject();
-    if (project == null) {
-      return;
-    }
-    reloadCourse(project);
-  }
-
-  public static void reloadCourse(@NotNull final Project project) {
-    ApplicationManager.getApplication().invokeLater(new Runnable() {
-      @Override
-      public void run() {
-        ApplicationManager.getApplication().runWriteAction(new Runnable() {
-          @Override
-          public void run() {
-            Course course = StudyTaskManager.getInstance(project).getCourse();
-            if (course == null) {
-              return;
-            }
-            for (VirtualFile file : FileEditorManager.getInstance(project).getOpenFiles()) {
-              FileEditorManager.getInstance(project).closeFile(file);
-            }
-            JTree tree = ProjectView.getInstance(project).getCurrentProjectViewPane().getTree();
-            TreePath path = TreeUtil.getFirstNodePath(tree);
-            tree.collapsePath(path);
-            List<Lesson> lessons = course.getLessons();
-            for (Lesson lesson : lessons) {
-              List<Task> tasks = lesson.getTaskList();
-              VirtualFile lessonDir = project.getBaseDir().findChild(Lesson.LESSON_DIR + (lesson.getIndex() + 1));
-              if (lessonDir == null) {
-                continue;
-              }
-              for (Task task : tasks) {
-                VirtualFile taskDir = lessonDir.findChild(Task.TASK_DIR + (task.getIndex() + 1));
-                if (taskDir == null) {
-                  continue;
-                }
-                Map<String, TaskFile> taskFiles = task.getTaskFiles();
-                for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
-                  String name = entry.getKey();
-                  TaskFile taskFile = entry.getValue();
-                  VirtualFile file = taskDir.findChild(name);
-                  if (file == null) {
-                    continue;
-                  }
-                  Document document = FileDocumentManager.getInstance().getDocument(file);
-                  if (document == null) {
-                    continue;
-                  }
-                  StudyRefreshTaskFileAction.resetTaskFile(document, project, course, taskFile, name, task);
-                }
-              }
-            }
-            ToolWindow runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.RUN);
-            if (runToolWindow != null) {
-              runToolWindow.hide(null);
-            }
-            Lesson firstLesson = StudyUtils.getFirst(lessons);
-            if (firstLesson == null) {
-              return;
-            }
-            Task firstTask = StudyUtils.getFirst(firstLesson.getTaskList());
-            VirtualFile lessonDir = project.getBaseDir().findChild(Lesson.LESSON_DIR + (firstLesson.getIndex() + 1));
-            if (lessonDir != null) {
-              VirtualFile taskDir = lessonDir.findChild(Task.TASK_DIR + (firstTask.getIndex() + 1));
-              if (taskDir != null) {
-                ProjectView.getInstance(project).select(taskDir, taskDir, true);
-              }
-            }
-          }
-        });
-      }
-    });
-  }
-}
index 5e5508872257eeae397c2c99ea5d22a665b7b5c6..1c312af6e5d9f18e6057cc771a49549a63422ba2 100644 (file)
@@ -9,7 +9,6 @@ import com.intellij.ui.content.Content;
 import com.intellij.ui.content.ContentFactory;
 import com.intellij.util.ui.UIUtil;
 import com.jetbrains.python.edu.StudyTaskManager;
-import com.jetbrains.python.edu.actions.StudyReloadCourseAction;
 import com.jetbrains.python.edu.course.Course;
 import com.jetbrains.python.edu.course.Lesson;
 import com.jetbrains.python.edu.course.LessonInfo;
@@ -18,8 +17,6 @@ import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.util.List;
 
 public class StudyToolWindowFactory implements ToolWindowFactory, DumbAware {
@@ -45,14 +42,6 @@ public class StudyToolWindowFactory implements ToolWindowFactory, DumbAware {
       contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
       contentPanel.add(new JLabel(description));
       contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
-      JButton reloadCourseButton = new JButton("Reload course");
-      reloadCourseButton.addActionListener(new ActionListener() {
-        public void actionPerformed(ActionEvent e) {
-          StudyReloadCourseAction.reloadCourse(project);
-        }
-      });
-
-      contentPanel.add(reloadCourseButton);
       int taskNum = 0;
       int taskSolved = 0;
       int lessonsCompleted = 0;