Search in sources :

Example 1 with StepicAdaptiveReactionsPanel

use of com.jetbrains.edu.learning.stepic.StepicAdaptiveReactionsPanel in project intellij-community by JetBrains.

the class StudyToolWindow method init.

public void init(@NotNull final Project project, final boolean isToolwindow) {
    String taskText = StudyUtils.getTaskText(project);
    if (taskText == null)
        return;
    final DefaultActionGroup group = getActionGroup(project);
    setActionToolbar(group);
    final JPanel panel = new JPanel(new BorderLayout());
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (isToolwindow && course != null && course.isAdaptive()) {
        panel.add(new StepicAdaptiveReactionsPanel(project), BorderLayout.NORTH);
    }
    JComponent taskInfoPanel = createTaskInfoPanel(project);
    panel.add(taskInfoPanel, BorderLayout.CENTER);
    final JPanel courseProgress = createCourseProgress(project);
    if (isToolwindow && course != null && !course.isAdaptive() && EduNames.STUDY.equals(course.getCourseMode())) {
        panel.add(courseProgress, BorderLayout.SOUTH);
    }
    myContentPanel.add(TASK_INFO_ID, panel);
    mySplitPane.setFirstComponent(myContentPanel);
    addAdditionalPanels(project);
    myCardLayout.show(myContentPanel, TASK_INFO_ID);
    setContent(mySplitPane);
    if (isToolwindow) {
        StudyPluginConfigurator configurator = StudyUtils.getConfigurator(project);
        if (configurator != null) {
            final FileEditorManagerListener listener = configurator.getFileEditorManagerListener(project, this);
            project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
        }
        if (StudyTaskManager.getInstance(project).isTurnEditingMode() || StudyTaskManager.getInstance(project).getToolWindowMode() == StudyToolWindowMode.EDITING) {
            TaskFile file = StudyUtils.getSelectedTaskFile(project);
            if (file != null) {
                VirtualFile taskDir = file.getTask().getTaskDir(project);
                setTaskText(taskText, taskDir, project);
            }
        } else {
            setTaskText(taskText, null, project);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StepicAdaptiveReactionsPanel(com.jetbrains.edu.learning.stepic.StepicAdaptiveReactionsPanel) FileEditorManagerListener(com.intellij.openapi.fileEditor.FileEditorManagerListener)

Aggregations

FileEditorManagerListener (com.intellij.openapi.fileEditor.FileEditorManagerListener)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 StepicAdaptiveReactionsPanel (com.jetbrains.edu.learning.stepic.StepicAdaptiveReactionsPanel)1