use of org.stepik.core.courseFormat.StepNode in project intellij-plugins by StepicOrg.
the class StepikSendAction method check.
private void check(@NotNull Project project) {
logger.info("Start checking step");
StudyNode<?, ?> selected = StepikProjectManager.getSelected(project);
if (!(selected instanceof StepNode)) {
logger.info("Stop checking step: step is null or is not StepNode ");
return;
}
StepNode stepNode = (StepNode) selected;
String title = "Checking Step: " + stepNode.getName();
ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
StepikApiClient stepikApiClient = authAndGetStepikApiClient(true);
if (!isAuthenticated()) {
return;
}
Long submissionId = sendStep(stepikApiClient, project, stepNode);
if (submissionId == null) {
return;
}
Metrics.sendAction(project, stepNode, SUCCESSFUL);
SendAction.checkStepStatus(project, stepikApiClient, stepNode, submissionId, indicator);
logger.info(String.format("Finish checking step: id=%s", stepNode.getId()));
}
});
}
use of org.stepik.core.courseFormat.StepNode in project intellij-plugins by StepicOrg.
the class StudyToolWindow method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (stepNode == null) {
return;
}
SupportedLanguages language = (SupportedLanguages) languageBox.getSelectedItem();
if (language == null) {
return;
}
final StepNode targetNode = stepNode;
executor.execute(() -> {
final SupportedLanguages[] selectedLang = new SupportedLanguages[1];
ApplicationManager.getApplication().invokeAndWait(() -> selectedLang[0] = (SupportedLanguages) languageBox.getSelectedItem());
if (selectedLang[0] != null) {
ProgrammingLanguageUtils.switchProgrammingLanguage(project, targetNode, selectedLang[0]);
if (selectedLang[0] != targetNode.getCurrentLang()) {
ApplicationManager.getApplication().invokeLater(() -> languageBox.setSelectedItem(targetNode.getCurrentLang()));
}
}
});
}
use of org.stepik.core.courseFormat.StepNode in project intellij-plugins by StepicOrg.
the class AbstractStepAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
StepNode stepNode = getCurrentStep(e.getProject());
e.getPresentation().setEnabled(stepNode != null && !stepNode.getWasDeleted());
}
use of org.stepik.core.courseFormat.StepNode in project intellij-plugins by StepicOrg.
the class OpenInBrowserAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
Project project = e.getProject();
StepNode stepNode = getCurrentStep(project);
if (stepNode == null) {
presentation.setDescription(DESCRIPTION);
return;
}
String link = getLink(project, stepNode);
presentation.setDescription(link);
}
use of org.stepik.core.courseFormat.StepNode in project intellij-plugins by StepicOrg.
the class StepikResetStepAction method resetFile.
private static void resetFile(@Nullable final Project project) {
StepNode stepNode = getCurrentCodeStepNode(project);
if (stepNode == null) {
return;
}
VirtualFile src = getOrCreateSrcDirectory(project, stepNode, true);
if (src == null) {
return;
}
String mainFileName = stepNode.getCurrentLang().getMainFileName();
VirtualFile mainFile = src.findChild(mainFileName);
if (mainFile != null) {
FileDocumentManager documentManager = FileDocumentManager.getInstance();
Document document = documentManager.getDocument(mainFile);
if (document != null) {
resetDocument(project, document, stepNode);
if (!project.isDisposed()) {
ProjectView.getInstance(project).refresh();
WolfTheProblemSolver.getInstance(project).clearProblems(mainFile);
}
StepikProjectManager.updateSelection(project);
}
}
}
Aggregations