use of com.jetbrains.edu.learning.ui.StudyToolWindow in project intellij-community by JetBrains.
the class StudyProjectComponent method registerShortcuts.
private void registerShortcuts() {
StudyToolWindow window = StudyUtils.getStudyToolWindow(myProject);
if (window != null) {
List<AnAction> actionsOnToolbar = window.getActions(true);
for (AnAction action : actionsOnToolbar) {
if (action instanceof StudyActionWithShortcut) {
String id = ((StudyActionWithShortcut) action).getActionId();
String[] shortcuts = ((StudyActionWithShortcut) action).getShortcuts();
if (shortcuts != null) {
addShortcut(id, shortcuts);
}
}
}
addShortcut(StudyNextWindowAction.ACTION_ID, new String[] { StudyNextWindowAction.SHORTCUT, StudyNextWindowAction.SHORTCUT2 });
addShortcut(StudyPrevWindowAction.ACTION_ID, new String[] { StudyPrevWindowAction.SHORTCUT });
}
}
use of com.jetbrains.edu.learning.ui.StudyToolWindow in project intellij-community by JetBrains.
the class StudySubtaskUtils method updateUI.
public static void updateUI(@NotNull Project project, @NotNull Task task, VirtualFile taskDir, boolean navigateToTask) {
StudyCheckUtils.drawAllPlaceholders(project, task);
ProjectView.getInstance(project).refresh();
StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(project);
if (toolWindow != null) {
String text = StudyUtils.getTaskTextFromTask(taskDir, task);
if (text == null) {
toolWindow.setEmptyText(project);
return;
}
toolWindow.setTaskText(text, taskDir, project);
}
if (navigateToTask) {
StudyNavigator.navigateToTask(project, task);
}
}
use of com.jetbrains.edu.learning.ui.StudyToolWindow in project intellij-community by JetBrains.
the class CCEditTaskTextAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
Project project = e.getProject();
if (project == null) {
return;
}
StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
if (window == null) {
return;
}
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor == null) {
return;
}
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
if (virtualFile == null) {
StudyTaskManager.getInstance(project).setTurnEditingMode(true);
return;
}
Task task = StudyUtils.getTaskForFile(project, virtualFile);
if (task == null) {
StudyTaskManager.getInstance(project).setTurnEditingMode(true);
return;
}
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
StudyTaskManager.getInstance(project).setTurnEditingMode(true);
return;
}
VirtualFile taskTextFile = StudyUtils.findTaskDescriptionVirtualFile(project, taskDir);
if (taskTextFile == null) {
LOG.info("Failed to find task.html");
StudyTaskManager.getInstance(project).setTurnEditingMode(true);
return;
}
Document document = FileDocumentManager.getInstance().getDocument(taskTextFile);
if (!state) {
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
}
window.leaveEditingMode(project);
return;
}
window.enterEditingMode(taskTextFile, project);
}
use of com.jetbrains.edu.learning.ui.StudyToolWindow in project intellij-community by JetBrains.
the class StudyRefreshTaskFileAction method refreshFile.
private static void refreshFile(@NotNull final StudyState studyState, @NotNull final Project project) {
final Editor editor = studyState.getEditor();
final TaskFile taskFile = studyState.getTaskFile();
final Task task = taskFile.getTask();
if (task.hasSubtasks()) {
for (AnswerPlaceholder placeholder : taskFile.getActivePlaceholders()) {
StudySubtaskUtils.refreshPlaceholder(editor, placeholder);
}
} else {
if (!resetTaskFile(editor.getDocument(), project, taskFile, studyState.getVirtualFile().getName())) {
Messages.showInfoMessage("The initial text of task file is unavailable", "Failed to Refresh Task File");
return;
}
if (task.isChoiceTask()) {
final StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
if (window != null) {
window.setBottomComponent(new StudyChoiceVariantsPanel(task));
}
}
}
WolfTheProblemSolver.getInstance(project).clearProblems(studyState.getVirtualFile());
taskFile.setHighlightErrors(false);
StudyUtils.drawAllAnswerPlaceholders(editor, taskFile);
EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.getInstance(project).requestFocus(editor.getContentComponent(), true));
StudyNavigator.navigateToFirstAnswerPlaceholder(editor, taskFile);
showBalloon(project, "You can start again now", MessageType.INFO);
}
use of com.jetbrains.edu.learning.ui.StudyToolWindow in project intellij-community by JetBrains.
the class StudyUtils method registerStudyToolWindow.
public static void registerStudyToolWindow(@Nullable final Course course, Project project) {
if (course != null && "PyCharm".equals(course.getCourseType())) {
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
registerToolWindows(toolWindowManager, project);
final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
if (studyToolWindow != null) {
studyToolWindow.show(null);
initToolWindows(project);
}
}
}
Aggregations