Search in sources :

Example 1 with StudyToolWindow

use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.

the class StudyProjectComponent method registerShortcuts.

private void registerShortcuts() {
    StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
    if (window != null) {
        List<AnAction> actionsOnToolbar = window.getActions(true);
        if (actionsOnToolbar != null) {
            actionsOnToolbar.stream().filter(action -> action instanceof StudyActionWithShortcut).map(action -> (StudyActionWithShortcut) action).forEach(action -> {
                String id = action.getActionId();
                String[] shortcuts = action.getShortcuts();
                if (shortcuts != null) {
                    addShortcut(id, shortcuts);
                }
            });
        } else {
            logger.warn("Actions on toolbar are nulls");
        }
    }
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ModuleManager(com.intellij.openapi.module.ModuleManager) KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) Keymap(com.intellij.openapi.keymap.Keymap) ArrayList(java.util.ArrayList) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) StudyActionWithShortcut(org.stepik.core.actions.StudyActionWithShortcut) Metrics(org.stepik.core.metrics.Metrics) Map(java.util.Map) StudyToolWindowFactory(org.stepik.core.ui.StudyToolWindowFactory) Project(com.intellij.openapi.project.Project) ProjectComponent(com.intellij.openapi.components.ProjectComponent) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) SUCCESSFUL(org.stepik.core.metrics.MetricsStatus.SUCCESSFUL) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) ExecutorService(java.util.concurrent.ExecutorService) HashMap(com.intellij.util.containers.hash.HashMap) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) ToolWindow(com.intellij.openapi.wm.ToolWindow) AnAction(com.intellij.openapi.actionSystem.AnAction) UISettings(com.intellij.ide.ui.UISettings) Executors(java.util.concurrent.Executors) Platform(javafx.application.Platform) List(java.util.List) Shortcut(com.intellij.openapi.actionSystem.Shortcut) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) javax.swing(javax.swing) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) StudyActionWithShortcut(org.stepik.core.actions.StudyActionWithShortcut) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 2 with StudyToolWindow

use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.

the class StepikProjectManager method setSelected.

public void setSelected(@Nullable StudyNode<?, ?> selected, boolean force) {
    this.selected = selected;
    if (project != null) {
        StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(project);
        if (toolWindow != null) {
            ApplicationManager.getApplication().invokeLater(() -> {
                toolWindow.setStepNode(selected, force);
                if (selected != null && !project.isDisposed()) {
                    ProjectView.getInstance(project).refresh();
                    VirtualFile file = project.getBaseDir().findFileByRelativePath(selected.getPath());
                    ProjectView.getInstance(project).select(null, file, true);
                }
            });
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StudyToolWindow(org.stepik.core.ui.StudyToolWindow)

Example 3 with StudyToolWindow

use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.

the class StudyProjectComponent method registerStudyToolWindow.

public void registerStudyToolWindow() {
    if (!StepikProjectManager.isStepikProject(project)) {
        return;
    }
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    registerToolWindows(toolWindowManager);
    final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (studyToolWindow != null) {
        studyToolWindow.show(null);
        StudyUtils.initToolWindows(project);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 4 with StudyToolWindow

use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.

the class StudyUtils method getStudyToolWindow.

@Nullable
static StudyToolWindow getStudyToolWindow(@NotNull final Project project) {
    if (project.isDisposed()) {
        return null;
    }
    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    if (toolWindowManager == null) {
        return null;
    }
    ToolWindow toolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (toolWindow != null) {
        Content[] contents = toolWindow.getContentManager().getContents();
        for (Content content : contents) {
            JComponent component = content.getComponent();
            if (component != null && component instanceof StudyToolWindow) {
                return (StudyToolWindow) component;
            }
        }
    }
    return null;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

StudyToolWindow (org.stepik.core.ui.StudyToolWindow)4 ToolWindow (com.intellij.openapi.wm.ToolWindow)3 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)3 UISettings (com.intellij.ide.ui.UISettings)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 KeyboardShortcut (com.intellij.openapi.actionSystem.KeyboardShortcut)1 Shortcut (com.intellij.openapi.actionSystem.Shortcut)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ProjectComponent (com.intellij.openapi.components.ProjectComponent)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Keymap (com.intellij.openapi.keymap.Keymap)1 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)1 Module (com.intellij.openapi.module.Module)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 Project (com.intellij.openapi.project.Project)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ToolWindowAnchor (com.intellij.openapi.wm.ToolWindowAnchor)1 Content (com.intellij.ui.content.Content)1