Search in sources :

Example 6 with StudyNode

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

the class CourseModuleBuilder method createCourseFromGenerator.

private void createCourseFromGenerator(@NotNull ModifiableModuleModel moduleModel, @NotNull Project project) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    generator.generateProject(project);
    String moduleDir = getModuleFileDirectory();
    if (moduleDir == null) {
        return;
    }
    logger.info("Module dir = " + moduleDir);
    new SandboxModuleBuilder(moduleDir).createModule(moduleModel);
    StudyNode root = StepikProjectManager.getProjectRoot(project);
    if (root == null) {
        logger.info("Failed to generate builders: project root is null");
        return;
    }
    if (root instanceof StepNode) {
        getOrCreateSrcDirectory(project, (StepNode) root, true, moduleModel);
    } else {
        createSubDirectories(project, generator.getDefaultLang(), root, moduleModel);
        VirtualFileManager.getInstance().syncRefresh();
    }
}
Also used : StepNode(org.stepik.core.courseFormat.StepNode) StudyNode(org.stepik.core.courseFormat.StudyNode)

Example 7 with StudyNode

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

the class NavBarModelExtensionUtils method getPresentableText.

@Nullable
public static String getPresentableText(@Nullable final Object object) {
    if (object instanceof Project) {
        Project project = (Project) object;
        StudyNode root = StepikProjectManager.getProjectRoot(project);
        if (root == null) {
            return null;
        }
        return root.getName();
    }
    if (object instanceof PsiDirectory) {
        PsiDirectory psiDirectory = (PsiDirectory) object;
        PresentationData data = new PresentationData();
        updatePresentationData(data, psiDirectory);
        String text = data.getPresentableText();
        if (text != null)
            return text;
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) PresentationData(com.intellij.ide.projectView.PresentationData) PresentationDataUtils.updatePresentationData(org.stepik.plugin.utils.PresentationDataUtils.updatePresentationData) PsiDirectory(com.intellij.psi.PsiDirectory) StudyNode(org.stepik.core.courseFormat.StudyNode) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with StudyNode

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

the class PresentationDataUtils method updatePresentationData.

public static void updatePresentationData(@NotNull PresentationData data, @NotNull PsiDirectory psiDirectory) {
    Project project = psiDirectory.getProject();
    String valueName = psiDirectory.getName();
    StudyNode root = StepikProjectManager.getProjectRoot(project);
    if (root == null) {
        return;
    }
    String path = getRelativePath(psiDirectory);
    if (isSandbox(path)) {
        setAttributes(data, EduNames.SANDBOX_DIR, JBColor.BLACK, AllStepikIcons.ProjectTree.sandbox, false);
        return;
    }
    path = ".".equals(path) ? "" : path;
    StudyNode node = StudyUtils.getStudyNode(project, psiDirectory.getVirtualFile());
    if (node != null && path.equals(node.getPath())) {
        setAttributes(project, data, node);
    } else {
        data.setPresentableText(valueName);
    }
}
Also used : Project(com.intellij.openapi.project.Project) StudyNode(org.stepik.core.courseFormat.StudyNode)

Example 9 with StudyNode

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

the class NavBarModelExtensionUtils method adjustElement.

@Nullable
public static PsiElement adjustElement(final PsiElement psiElement) {
    Project project = psiElement.getProject();
    StudyNode root = StepikProjectManager.getProjectRoot(project);
    if (root == null) {
        return psiElement;
    }
    if (psiElement instanceof PsiDirectory) {
        if (!isVisibleDirectory((PsiDirectory) psiElement))
            return null;
    } else if (psiElement instanceof PsiFile) {
        if (!isVisibleFile((PsiFile) psiElement))
            return null;
    }
    return psiElement;
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) StudyNode(org.stepik.core.courseFormat.StudyNode) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with StudyNode

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

the class StepikDirectoryNode method navigate.

@Override
public void navigate(boolean requestFocus) {
    VirtualFile virtualFile = getVirtualFile();
    StudyNode studyNode;
    if (virtualFile != null) {
        studyNode = StudyUtils.getStudyNode(myProject, virtualFile);
        StepikProjectManager.setSelected(myProject, studyNode);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) 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