Search in sources :

Example 1 with StudyStatus

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

the class PresentationDataUtils method setAttributes.

private static void setAttributes(@NotNull Project project, @NotNull PresentationData data, @NotNull StudyNode item) {
    String text = item.getName();
    item.setProject(project);
    StudyStatus status = item.getStatus();
    JBColor color = getColor(status);
    Icon icon = getIcon(item, status);
    setAttributes(data, text, color, icon, item.getWasDeleted());
}
Also used : StudyStatus(org.stepik.core.courseFormat.StudyStatus) JBColor(com.intellij.ui.JBColor) PresentationUtils.getIcon(org.stepik.core.utils.PresentationUtils.getIcon)

Example 2 with StudyStatus

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

the class DownloadSubmission method loadSubmission.

private void loadSubmission(@NotNull Project project, @NotNull StepNode stepNode, @NotNull Submission submission) {
    String fileName = stepNode.getCurrentLang().getMainFileName();
    VirtualFile src = getOrCreateSrcDirectory(project, stepNode, true);
    if (src == null) {
        Metrics.downloadAction(project, stepNode, TARGET_NOT_FOUND);
        return;
    }
    VirtualFile mainFile = src.findChild(fileName);
    if (mainFile == null) {
        Metrics.downloadAction(project, stepNode, TARGET_NOT_FOUND);
        return;
    }
    final String finalCode = submission.getReply().getCode();
    CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
        FileDocumentManager documentManager = FileDocumentManager.getInstance();
        Document document = documentManager.getDocument(mainFile);
        if (document != null) {
            SupportedLanguages language = langOfName(submission.getReply().getLanguage());
            if (containsDirectives(finalCode, language)) {
                String text = uncommentAmbientCode(finalCode, language);
                document.setText(text);
            } else {
                String code = replaceCode(document.getText(), finalCode, language);
                document.setText(code);
            }
            StudyStatus status = StudyStatus.of(submission.getStatus());
            stepNode.setStatus(status);
            FileEditorManager.getInstance(project).openFile(mainFile, true);
            ProjectView.getInstance(project).refresh();
            Metrics.downloadAction(project, stepNode, SUCCESSFUL);
        }
    }), "Download submission", "Download submission");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SupportedLanguages(org.stepik.core.SupportedLanguages) StudyStatus(org.stepik.core.courseFormat.StudyStatus) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Document(com.intellij.openapi.editor.Document)

Aggregations

StudyStatus (org.stepik.core.courseFormat.StudyStatus)2 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JBColor (com.intellij.ui.JBColor)1 SupportedLanguages (org.stepik.core.SupportedLanguages)1 PresentationUtils.getIcon (org.stepik.core.utils.PresentationUtils.getIcon)1