use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepikStepNavigationAction method navigateStep.
@Override
public void navigateStep(@NotNull final Project project) {
StudyNode currentNode = StepikProjectManager.getSelected(project);
if (currentNode == null) {
currentNode = StepikProjectManager.getProjectRoot(project);
}
StudyNode targetNode;
targetNode = getTargetStep(currentNode);
if (targetNode == null) {
return;
}
NavigationUtils.navigate(project, targetNode);
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class Metrics method postMetrics.
private static void postMetrics(@NotNull Project project, @NotNull Metric metric, @NotNull MetricsStatus status) {
executor.schedule(() -> {
StepikApiClient stepikApiClient;
stepikApiClient = authAndGetStepikApiClient();
if (!isAuthenticated()) {
return;
}
final StepikMetricsPostQuery query = stepikApiClient.metrics().post().timestamp(System.currentTimeMillis() / 1000L).tags(metric.getTags()).data(metric.getData()).name("ide_plugin").tags("name", "S_Union").tags("ide_name", ApplicationInfo.getInstance().getVersionName()).data("ide_version", ApplicationInfo.getInstance().getBuild().toString()).data("plugin_version", PluginUtils.getVersion()).data("session", session).tags("status", status);
StepikProjectManager projectManager = StepikProjectManager.getInstance(project);
if (projectManager != null) {
query.data("project_id", projectManager.getUuid()).tags("project_programming_language", projectManager.getDefaultLang().getName()).data("project_manager_version", projectManager.getVersion());
StudyNode projectRoot = projectManager.getProjectRoot();
if (projectRoot != null) {
Class<? extends StudyNode> projectRootClass = projectRoot.getClass();
query.tags("project_root_class", projectRootClass.getSimpleName()).data("project_root_id", projectRoot.getId());
query.data("course_id", projectRoot.getCourseId(stepikApiClient));
}
}
query.executeAsync().exceptionally((e) -> {
String message = String.format("Failed post metric: %s", query.toString());
logger.warn(message, e);
return null;
});
}, 500, TimeUnit.MILLISECONDS);
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepHelper method getLink.
@NotNull
public String getLink() {
StepNode stepNode = getStepNode();
StudyNode parent = stepNode.getParent();
if (parent != null) {
return String.format("https://stepik.org/lesson/%d/step/%d", parent.getId(), stepNode.getPosition());
}
return "https://stepik.org/";
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepikPyProjectGenerator method createCourseFromGenerator.
private void createCourseFromGenerator(@NotNull Project project) {
generator.generateProject(project);
FileUtil.createDirectory(new File(project.getBasePath(), EduNames.SANDBOX_DIR));
StepikProjectManager projectManager = StepikProjectManager.getInstance(project);
if (projectManager == null) {
logger.warn("failed to generate builders: StepikProjectManager is null");
return;
}
projectManager.setDefaultLang(generator.getDefaultLang());
StudyNode root = projectManager.getProjectRoot();
if (root == null) {
logger.warn("failed to generate builders: Root is null");
return;
}
if (root instanceof StepNode) {
getOrCreateSrcDirectory(project, (StepNode) root, true);
} else {
createSubDirectories(project, generator.getDefaultLang(), root, null);
VirtualFileManager.getInstance().syncRefresh();
}
Application application = ApplicationManager.getApplication();
application.invokeLater(() -> DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> application.runWriteAction(() -> {
StudyProjectComponent.getInstance(project).registerStudyToolWindow();
StepikProjectManager.updateAdaptiveSelected(project);
})));
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepikTreeStructureProvider method isHidden.
private boolean isHidden(@NotNull Project project, @Nullable Object value) {
if (StepikProjectManager.isAdaptive(project)) {
if (!(value instanceof PsiFileSystemItem)) {
return false;
}
String relativePath = getRelativePath((PsiFileSystemItem) value);
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return false;
}
StudyNode node = StudyUtils.getStudyNode(root, relativePath);
if (node == null) {
return false;
}
StudyNode<?, ?> selected = StepikProjectManager.getSelected(project);
if (selected == null) {
return true;
}
String selectedPath = selected.getPath();
String nodePath = node.getPath();
if (!selectedPath.startsWith(nodePath) && selected.getParent() != node.getParent()) {
return true;
}
}
return false;
}
Aggregations