Search in sources :

Example 16 with StepNode

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

the class ProjectWizardUtils method createSubDirectories.

public static void createSubDirectories(@NotNull Project project, @NotNull SupportedLanguages defaultLanguage, @NotNull StudyNode<?, ?> root, @Nullable ModifiableModuleModel model) {
    root.getChildren().forEach(child -> {
        FileUtil.createDirectory(new File(project.getBasePath(), child.getPath()));
        if (child instanceof StepNode) {
            StepNode stepNode = (StepNode) child;
            stepNode.setCurrentLang(defaultLanguage);
            getOrCreateSrcDirectory(project, stepNode, false, model);
        } else {
            createSubDirectories(project, defaultLanguage, child, model);
        }
    });
}
Also used : StepNode(org.stepik.core.courseFormat.StepNode) File(java.io.File)

Example 17 with StepNode

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

the class NavigationUtils method navigate.

public static void navigate(@NotNull Project project, @NotNull StudyNode targetNode) {
    for (VirtualFile file : FileEditorManager.getInstance(project).getOpenFiles()) {
        FileEditorManager.getInstance(project).closeFile(file);
    }
    VirtualFile projectDir = project.getBaseDir();
    if (projectDir == null) {
        return;
    }
    VirtualFile mainFile;
    if (targetNode instanceof StepNode) {
        VirtualFile srcDir = getOrCreateSrcDirectory(project, (StepNode) targetNode, true);
        if (srcDir == null) {
            return;
        }
        StepNode stepNode = (StepNode) targetNode;
        mainFile = srcDir.findChild(stepNode.getCurrentLang().getMainFileName());
        if (mainFile == null) {
            mainFile = srcDir.getChildren().length > 0 ? srcDir : srcDir.getParent();
        }
    } else {
        mainFile = projectDir.findFileByRelativePath(targetNode.getPath());
    }
    if (mainFile != null) {
        updateProjectView(project, mainFile);
    }
    Metrics.navigateAction(project, targetNode, SUCCESSFUL);
    StepikProjectManager.setSelected(project, targetNode);
    ToolWindow runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.RUN);
    if (runToolWindow != null) {
        runToolWindow.hide(null);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindow(com.intellij.openapi.wm.ToolWindow) StepNode(org.stepik.core.courseFormat.StepNode)

Aggregations

StepNode (org.stepik.core.courseFormat.StepNode)17 StudyNode (org.stepik.core.courseFormat.StudyNode)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 StepikApiClient (org.stepik.api.client.StepikApiClient)4 SupportedLanguages (org.stepik.core.SupportedLanguages)4 StepikAuthManager.authAndGetStepikApiClient (org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient)4 Document (com.intellij.openapi.editor.Document)3 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)3 Project (com.intellij.openapi.project.Project)3 File (java.io.File)3 NotNull (org.jetbrains.annotations.NotNull)3 Submission (org.stepik.api.objects.submissions.Submission)3 StepikProjectManager (org.stepik.core.StepikProjectManager)3 Application (com.intellij.openapi.application.Application)2 Logger (com.intellij.openapi.diagnostic.Logger)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 IOException (java.io.IOException)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2