public static void updateRunConfigurationActions(Project project, ProjectSystemId systemId) { final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(systemId); if (configurationType == null) return; ActionManager actionManager = ActionManager.getInstance(); for (String eachAction : actionManager.getActionIds(getActionPrefix(project, null))) { AnAction action = actionManager.getAction(eachAction); if (action instanceof ExternalSystemRunConfigurationAction) { actionManager.unregisterAction(eachAction); } } Set<RunnerAndConfigurationSettings> settings = new THashSet<RunnerAndConfigurationSettings>( RunManager.getInstance(project).getConfigurationSettingsList(configurationType)); final ExternalSystemShortcutsManager shortcutsManager = ExternalProjectsManager.getInstance(project).getShortcutsManager(); for (RunnerAndConfigurationSettings configurationSettings : settings) { ExternalSystemRunConfigurationAction runConfigurationAction = new ExternalSystemRunConfigurationAction(project, configurationSettings); String id = runConfigurationAction.getId(); actionManager.unregisterAction(id); if (shortcutsManager.hasShortcuts(id)) { actionManager.registerAction(id, runConfigurationAction); } } }
private static void createActions(Project project, Collection<DataNode<TaskData>> taskNodes) { ActionManager actionManager = ActionManager.getInstance(); final ExternalSystemShortcutsManager shortcutsManager = ExternalProjectsManager.getInstance(project).getShortcutsManager(); if (actionManager != null) { for (DataNode<TaskData> each : taskNodes) { final DataNode<ModuleData> moduleData = ExternalSystemApiUtil.findParent(each, ProjectKeys.MODULE); if (moduleData == null || moduleData.isIgnored()) continue; TaskData taskData = each.getData(); ExternalSystemTaskAction eachAction = new ExternalSystemTaskAction(project, moduleData.getData().getInternalName(), taskData); actionManager.unregisterAction(eachAction.getId()); if (shortcutsManager.hasShortcuts( taskData.getLinkedExternalProjectPath(), taskData.getName())) { actionManager.registerAction(eachAction.getId(), eachAction); } } } }
public static String getActionPrefix(@NotNull Project project, @Nullable String path) { return ExternalProjectsManager.getInstance(project) .getShortcutsManager() .getActionId(path, null); }