use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCRenameHandler method isAvailableOnDataContext.
@Override
public boolean isAvailableOnDataContext(DataContext dataContext) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (element == null || !(element instanceof PsiDirectory)) {
return false;
}
if (!CCUtils.isCourseCreator(element.getProject())) {
return false;
}
VirtualFile directory = ((PsiDirectory) element).getVirtualFile();
return isAvailable(directory);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCTaskMoveHandlerDelegate method canMove.
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
return isTaskDir(sourceDirectory);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCTaskRenameHandler method rename.
@Override
protected void rename(@NotNull Project project, @NotNull Course course, @NotNull PsiDirectory directory) {
if (directory.getName().equals(EduNames.SRC)) {
directory = directory.getParent();
if (directory == null) {
return;
}
}
PsiDirectory lessonDir = directory.getParent();
if (lessonDir == null || !lessonDir.getName().contains(EduNames.LESSON)) {
return;
}
Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson == null) {
return;
}
String directoryName = directory.getName();
Task task = lesson.getTask(directoryName);
if (task != null) {
processRename(task, EduNames.TASK, project);
}
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCPushLesson method update.
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE))
return;
PsiDirectory lessonDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && course.getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
if (lesson.getId() <= 0) {
e.getPresentation().setText("Upload Lesson to Stepik");
}
}
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCPushTask method update.
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE))
return;
PsiDirectory taskDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (taskDir == null || !taskDir.getName().contains(EduNames.TASK)) {
return;
}
final PsiDirectory lessonDir = taskDir.getParentDirectory();
if (lessonDir == null)
return;
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && lesson.getId() > 0 && course.getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
final com.jetbrains.edu.learning.courseFormat.Task task = lesson.getTask(taskDir.getName());
if (task.getStepId() <= 0) {
e.getPresentation().setText("Upload Task to Stepik");
}
}
}
Aggregations