private AnAction registerChameleon(String actionId, AnAction action, PluginId pluginId, String projectType) { ProjectType type = projectType == null ? null : new ProjectType(projectType); // make sure id+projectType is unique AnAction o = myId2Action.get(actionId); ChameleonAction chameleonAction; if (o == null) { chameleonAction = new ChameleonAction(action, type); myId2Action.put(actionId, chameleonAction); return chameleonAction; } if (o instanceof ChameleonAction) { chameleonAction = (ChameleonAction)o; } else { chameleonAction = new ChameleonAction(o, type); myId2Action.put(actionId, chameleonAction); } AnAction old = chameleonAction.addAction(action, type); if (old != null) { reportActionError(pluginId, "action with the ID \"" + actionId + "\" was already registered. Action being registered is " + action + "; Registered action is " + myId2Action.get(actionId) + getPluginInfo(pluginId)); return null; } return chameleonAction; }
public AnAction addAction(AnAction action, ProjectType projectType) { if (action instanceof ActionStub) { String type = ((ActionStub)action).getProjectType(); action = ActionManagerImpl.convertStub((ActionStub)action); projectType = type == null ? null : new ProjectType(type); } return myActions.put(projectType, action); }
@Nullable private AnAction getAction(AnActionEvent e) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); ProjectType projectType = ProjectTypeService.getProjectType(project); AnAction action = myActions.get(projectType); if (action == null) action = myActions.get(null); return action; }
private static boolean shouldBeBuiltByExternalSystem(@NotNull Project project) { // skip resource compilation by IDE for Android projects // TODO [vlad] this check should be replaced when an option to make any gradle project with gradle be introduced. ProjectType projectType = ProjectTypeService.getProjectType(project); if (projectType != null && "Android".equals(projectType.getId())) return true; return false; }
public ChameleonAction(@NotNull AnAction first, ProjectType projectType) { addAction(first, projectType); copyFrom(myActions.values().iterator().next()); }
@TestOnly public Map<ProjectType, AnAction> getActions() { return myActions; }
protected ProjectType getProjectType() { return null; }
protected void setProjectType(Module module) { ProjectType projectType = getProjectType(); if (projectType != null && ProjectTypeService.getProjectType(module.getProject()) == null) { ProjectTypeService.setProjectType(module.getProject(), projectType); } }
@Override protected ProjectType getProjectType() { return ANDROID_PROJECT_TYPE; }
@Override protected ProjectType getProjectType() { return AndroidModuleBuilder.ANDROID_PROJECT_TYPE; }
/** * Project Type * @return */ @Override protected ProjectType getProjectType() { return PI_PROJECT_TYPE; }
/** * Project Type * @return */ @Override protected ProjectType getProjectType() { return BBB_PROJECT_TYPE; }