Search in sources :

Example 21 with StudyNode

use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.

the class StudyStepNavigationAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    Project project = e.getProject();
    if (!StepikProjectManager.isStepikProject(project)) {
        return;
    }
    StudyNode selected = StepikProjectManager.getSelected(project);
    StudyNode target = getTargetStep(selected);
    boolean enabled = selected == null || target != null;
    if (StepikProjectManager.isAdaptive(project)) {
        enabled = enabled && selected != null && target.getParent() == selected.getParent();
    }
    presentation.setEnabled(enabled);
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation) StudyNode(org.stepik.core.courseFormat.StudyNode)

Aggregations

StudyNode (org.stepik.core.courseFormat.StudyNode)21 Project (com.intellij.openapi.project.Project)6 StepNode (org.stepik.core.courseFormat.StepNode)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Nullable (org.jetbrains.annotations.Nullable)4 StepikApiClient (org.stepik.api.client.StepikApiClient)4 StepikAuthManager.authAndGetStepikApiClient (org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient)4 StepikProjectManager (org.stepik.core.StepikProjectManager)3 PsiDirectory (com.intellij.psi.PsiDirectory)2 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)2 NotNull (org.jetbrains.annotations.NotNull)2 StepikClientException (org.stepik.api.exceptions.StepikClientException)2 StudyObject (org.stepik.api.objects.StudyObject)2 SupportedLanguages (org.stepik.core.SupportedLanguages)2 PresentationData (com.intellij.ide.projectView.PresentationData)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Application (com.intellij.openapi.application.Application)1 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 FileEditorManagerAdapter (com.intellij.openapi.fileEditor.FileEditorManagerAdapter)1