EDU-659 Hide Course Creator action group for educational projects
authorliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 28 Jul 2016 11:12:14 +0000 (14:12 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 28 Jul 2016 11:14:50 +0000 (14:14 +0300)
python/educational-core/course-creator/resources/META-INF/plugin.xml
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCFileActionGroup.java [new file with mode: 0644]
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCProjectViewActionGroup.java [new file with mode: 0644]

index 2708d4d9a78563476ec232ebe4b34341f03847b2..106a1e21acd70f9cc3a5c74d7598a004b0fe9b49 100644 (file)
@@ -54,7 +54,7 @@
 
     <action id="ChangeCourseInfo" class="com.jetbrains.edu.coursecreator.PyCCChangeCourseInfo"/>
 
 
     <action id="ChangeCourseInfo" class="com.jetbrains.edu.coursecreator.PyCCChangeCourseInfo"/>
 
-    <group id="CCProjectViewGroup" popup="true" text="Course Creator">
+    <group id="CCProjectViewGroup" popup="true" text="Course Creator" class="com.jetbrains.edu.coursecreator.actions.CCProjectViewActionGroup">
       <action id="AddTaskFile" class="com.jetbrains.edu.coursecreator.actions.CCAddAsTaskFile" text="Make Visible to Student"/>
       <action id="HideTaskFile" class="com.jetbrains.edu.coursecreator.actions.CCHideFromStudent" text="Hide from Student"/>
       <action id="ShowPreview" class="com.jetbrains.edu.coursecreator.actions.CCShowPreview">
       <action id="AddTaskFile" class="com.jetbrains.edu.coursecreator.actions.CCAddAsTaskFile" text="Make Visible to Student"/>
       <action id="HideTaskFile" class="com.jetbrains.edu.coursecreator.actions.CCHideFromStudent" text="Hide from Student"/>
       <action id="ShowPreview" class="com.jetbrains.edu.coursecreator.actions.CCShowPreview">
@@ -68,7 +68,7 @@
       <add-to-group group-id="ProjectViewPopupMenu" anchor="before" relative-to-action="CutCopyPasteGroup"/>
     </group>
     
       <add-to-group group-id="ProjectViewPopupMenu" anchor="before" relative-to-action="CutCopyPasteGroup"/>
     </group>
     
-    <group id="CCFileGroup" popup="true" text="Course Creator">
+    <group id="CCFileGroup" popup="true" text="Course Creator" class="com.jetbrains.edu.coursecreator.actions.CCFileActionGroup">
       <reference id="ChangeCourseInfo"/>
       <reference id="PackCourse"/>
       <reference id="PushLesson"/>
       <reference id="ChangeCourseInfo"/>
       <reference id="PackCourse"/>
       <reference id="PushLesson"/>
index cc30ce5e77e16141ecb586a51cef412b1e29fccd..ba987b2b0b5871cf26d707000909204283eb1296 100644 (file)
@@ -4,6 +4,8 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.intellij.ide.projectView.actions.MarkRootActionBase;
 import com.intellij.lang.Language;
 import com.google.common.collect.Collections2;
 import com.intellij.ide.projectView.actions.MarkRootActionBase;
 import com.intellij.lang.Language;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
@@ -245,4 +247,10 @@ public class CCUtils {
       });
     }
   }
       });
     }
   }
+
+  public static void updateActionGroup(AnActionEvent e) {
+    Presentation presentation = e.getPresentation();
+    Project project = e.getProject();
+    presentation.setEnabledAndVisible(project != null && isCourseCreator(project));
+  }
 }
 }
diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCFileActionGroup.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCFileActionGroup.java
new file mode 100644 (file)
index 0000000..41b7358
--- /dev/null
@@ -0,0 +1,12 @@
+package com.jetbrains.edu.coursecreator.actions;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.jetbrains.edu.coursecreator.CCUtils;
+
+public class CCFileActionGroup extends DefaultActionGroup {
+  @Override
+  public void update(AnActionEvent e) {
+    CCUtils.updateActionGroup(e);
+  }
+}
diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCProjectViewActionGroup.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCProjectViewActionGroup.java
new file mode 100644 (file)
index 0000000..a052330
--- /dev/null
@@ -0,0 +1,12 @@
+package com.jetbrains.edu.coursecreator.actions;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.jetbrains.edu.coursecreator.CCUtils;
+
+public class CCProjectViewActionGroup extends DefaultActionGroup {
+  @Override
+  public void update(AnActionEvent e) {
+    CCUtils.updateActionGroup(e);
+  }
+}