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());
}
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");
}
Aggregations