Search in sources :

Example 1 with StudyActionWithShortcut

use of org.stepik.core.actions.StudyActionWithShortcut 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)

Aggregations

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 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 ToolWindowAnchor (com.intellij.openapi.wm.ToolWindowAnchor)1 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)1 HashMap (com.intellij.util.containers.hash.HashMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1