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); } } }
public static ExternalSystemAction getOrRegisterAction( Project project, RunnerAndConfigurationSettings configurationSettings) { ActionManager manager = ActionManager.getInstance(); ExternalSystemRunConfigurationAction runConfigurationAction = new ExternalSystemRunConfigurationAction(project, configurationSettings); String id = runConfigurationAction.getId(); manager.unregisterAction(id); manager.registerAction(id, runConfigurationAction); return runConfigurationAction; }