EDU-572 fix study and course creator move delegates so as not to block other move...
authorliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 24 Mar 2016 10:01:52 +0000 (13:01 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 24 Mar 2016 10:01:52 +0000 (13:01 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCLessonMoveHandlerDelegate.java
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCTaskMoveHandlerDelegate.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyMoveDelegate.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java

index 2a1cf8ca77332b243cb08a6dbee2f3d797229b90..685ac37417853ed9780e24f56e3565803e88a521 100644 (file)
@@ -18,12 +18,12 @@ import com.intellij.psi.PsiReference;
 import com.intellij.refactoring.move.MoveCallback;
 import com.intellij.refactoring.move.MoveHandlerDelegate;
 import com.intellij.util.Function;
+import com.jetbrains.edu.coursecreator.ui.CCMoveStudyItemDialog;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.core.EduUtils;
 import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.courseFormat.Lesson;
 import com.jetbrains.edu.learning.courseFormat.StudyItem;
-import com.jetbrains.edu.coursecreator.ui.CCMoveStudyItemDialog;
 import org.jetbrains.annotations.Nullable;
 
 import java.io.IOException;
@@ -129,6 +129,6 @@ public class CCLessonMoveHandlerDelegate extends MoveHandlerDelegate {
                            DataContext dataContext,
                            @Nullable PsiReference reference,
                            Editor editor) {
-    return true;
+    return CCProjectService.getInstance(project).getCourse() != null;
   }
 }
index 37cd620bc2e6dccf9e53786777d8a227cd027c67..380e0556112bf0f40fd00342151b8b04938721c0 100644 (file)
@@ -192,6 +192,6 @@ public class CCTaskMoveHandlerDelegate extends MoveHandlerDelegate {
                            DataContext dataContext,
                            @Nullable PsiReference reference,
                            Editor editor) {
-    return true;
+    return CCProjectService.getInstance(project).getCourse() != null;
   }
 }
index e21bb4007af4ac767888d1f5863d0f6f5438700b..7cd21a26b51083eb306631fe30d7145d107ef33f 100644 (file)
@@ -49,6 +49,6 @@ public class StudyMoveDelegate extends MoveHandlerDelegate{
                            DataContext dataContext,
                            @Nullable PsiReference reference,
                            Editor editor) {
-    return true;
+    return StudyUtils.isStudyProject(project);
   }
 }
index d783afb54c2ec78d35baf058b5b3c566011ed9b9..8ed23fb768d30df81e0a300c1e6164fdf618492f 100644 (file)
@@ -498,4 +498,8 @@ public class StudyUtils {
       studyToolWindow.setTaskText(taskText);
     }
   }
+
+  public static boolean isStudyProject(@NotNull Project project) {
+    return StudyTaskManager.getInstance(project).getCourse() != null;
+  }
 }