@Override public int getTypeSortWeight(boolean sortByType) { String name = myValue.getName(); String lessonDirName = "lesson"; String taskDirName = "task"; if (name.startsWith(lessonDirName) || name.startsWith(taskDirName)) { String logicalName = name.contains(lessonDirName) ? lessonDirName : taskDirName; int index = CCUtils.getIndex(name, logicalName) + 1; return index != -1 ? index : 0; } return 0; }
@Override public void update(@NotNull AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getProject(); presentation.setEnabledAndVisible(project != null && CCUtils.isCourseCreator(project)); if (project != null) { final Course course = StudyTaskManager.getInstance(project).getCourse(); if (course != null) { final int id = course.getId(); if (id > 0) { presentation.setText("Update Course on Stepik"); } } } }
@Override public void update(@NotNull AnActionEvent event) { final Project project = event.getProject(); final Presentation presentation = event.getPresentation(); if (project == null) { return; } presentation.setEnabledAndVisible(false); if (!CCUtils.isCourseCreator(project)) { return; } final IdeView view = event.getData(LangDataKeys.IDE_VIEW); if (view == null) { return; } final PsiDirectory[] directories = view.getDirectories(); if (directories.length == 0) { return; } presentation.setEnabledAndVisible(true); }