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