Search in sources :

Example 1 with ModuleNode

use of com.intellij.openapi.externalSystem.view.ModuleNode in project intellij-community by JetBrains.

the class AssignShortcutAction method perform.

@Override
protected void perform(@NotNull Project project, @NotNull ProjectSystemId projectSystemId, @NotNull TaskData taskData, @NotNull AnActionEvent e) {
    final ExternalSystemShortcutsManager shortcutsManager = ExternalProjectsManager.getInstance(project).getShortcutsManager();
    final String actionId = shortcutsManager.getActionId(taskData.getLinkedExternalProjectPath(), taskData.getName());
    if (actionId != null) {
        AnAction action = ActionManager.getInstance().getAction(actionId);
        if (action == null) {
            ExternalSystemNode<?> taskNode = ContainerUtil.getFirstItem(ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext()));
            assert taskNode != null;
            final String group;
            final ModuleNode moduleDataNode = taskNode.findParent(ModuleNode.class);
            if (moduleDataNode != null) {
                ModuleData moduleData = moduleDataNode.getData();
                group = moduleData != null ? moduleData.getInternalName() : null;
            } else {
                ProjectNode projectNode = taskNode.findParent(ProjectNode.class);
                ProjectData projectData = projectNode != null ? projectNode.getData() : null;
                group = projectData != null ? projectData.getInternalName() : null;
            }
            if (group != null) {
                ExternalSystemKeymapExtension.getOrRegisterAction(project, group, taskData);
            }
        }
        new EditKeymapsDialog(project, actionId).show();
    }
}
Also used : ExternalSystemShortcutsManager(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager) EditKeymapsDialog(com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) AnAction(com.intellij.openapi.actionSystem.AnAction) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) ModuleNode(com.intellij.openapi.externalSystem.view.ModuleNode)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 ExternalSystemShortcutsManager (com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager)1 ModuleNode (com.intellij.openapi.externalSystem.view.ModuleNode)1 ProjectNode (com.intellij.openapi.externalSystem.view.ProjectNode)1 EditKeymapsDialog (com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog)1