Search in sources :

Example 11 with KeymapManagerEx

use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-community by JetBrains.

the class StudyProjectComponent method projectClosed.

@Override
public void projectClosed() {
    final Course course = StudyTaskManager.getInstance(myProject).getCourse();
    if (course != null) {
        final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
        if (toolWindow != null) {
            toolWindow.getContentManager().removeAllContents(false);
        }
        KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
        for (Keymap keymap : keymapManager.getAllKeymaps()) {
            List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
            if (pairs != null && !pairs.isEmpty()) {
                for (Pair<String, String> actionShortcut : pairs) {
                    keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
                }
            }
        }
    }
    myListener = null;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) StudyProjectGenerator.flushCourse(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator.flushCourse) Keymap(com.intellij.openapi.keymap.Keymap) Pair(com.intellij.openapi.util.Pair)

Example 12 with KeymapManagerEx

use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-plugins by StepicOrg.

the class StudyProjectComponent method projectClosed.

@Override
public void projectClosed() {
    if (!StepikProjectManager.isStepikProject(project)) {
        return;
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (toolWindow != null) {
        toolWindow.getContentManager().removeAllContents(false);
    }
    KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
        List<Pair<String, String>> pairs = deletedShortcuts.get(keymap);
        if (pairs != null && !pairs.isEmpty()) {
            for (Pair<String, String> actionShortcut : pairs) {
                keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
            }
        }
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) Keymap(com.intellij.openapi.keymap.Keymap) Pair(com.intellij.openapi.util.Pair)

Aggregations

KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)12 Keymap (com.intellij.openapi.keymap.Keymap)9 Pair (com.intellij.openapi.util.Pair)4 NotNull (org.jetbrains.annotations.NotNull)3 KeyboardShortcut (com.intellij.openapi.actionSystem.KeyboardShortcut)2 ActionManagerEx (com.intellij.openapi.actionSystem.ex.ActionManagerEx)2 KeymapGroup (com.intellij.openapi.keymap.KeymapGroup)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 AntBuildTarget (com.intellij.lang.ant.config.AntBuildTarget)1 AntConfiguration (com.intellij.lang.ant.config.AntConfiguration)1 AntConfigurationBase (com.intellij.lang.ant.config.AntConfigurationBase)1 TargetActionStub (com.intellij.lang.ant.config.actions.TargetActionStub)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 Shortcut (com.intellij.openapi.actionSystem.Shortcut)1 EditorFactoryAdapter (com.intellij.openapi.editor.event.EditorFactoryAdapter)1 PluginId (com.intellij.openapi.extensions.PluginId)1 DefaultKeymap (com.intellij.openapi.keymap.impl.DefaultKeymap)1 KeymapImpl (com.intellij.openapi.keymap.impl.KeymapImpl)1 ProjectManagerAdapter (com.intellij.openapi.project.ProjectManagerAdapter)1