public static ExternalSystemAction getOrRegisterAction( Project project, String group, TaskData taskData) { ExternalSystemTaskAction action = new ExternalSystemTaskAction(project, group, taskData); ActionManager manager = ActionManager.getInstance(); AnAction anAction = manager.getAction(action.getId()); if (anAction instanceof ExternalSystemTaskAction && action.equals(anAction)) { return (ExternalSystemAction) anAction; } manager.unregisterAction(action.getId()); manager.registerAction(action.getId(), action); return action; }
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); } } } }