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