use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalModuleStructureExtension method getLinkedProjects.
private static Map<String, Pair<ProjectSystemId, ExternalProjectSettings>> getLinkedProjects(Project project) {
Map<String, Pair<ProjectSystemId, ExternalProjectSettings>> result = new HashMap<>();
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
ProjectSystemId systemId = manager.getSystemId();
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, systemId);
Collection projectsSettings = systemSettings.getLinkedProjectsSettings();
for (Object settings : projectsSettings) {
if (settings instanceof ExternalProjectSettings) {
ExternalProjectSettings projectSettings = (ExternalProjectSettings) settings;
result.put((projectSettings).getExternalProjectPath(), Pair.create(systemId, projectSettings));
}
}
}
return result;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemKeymapExtension method createGroup.
public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) {
KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(ExternalSystemBundle.message("external.system.keymap.group"), ExternalSystemIcons.TaskGroup);
AnAction[] externalSystemActions = ActionsTreeUtil.getActions("ExternalSystem.Actions");
for (AnAction action : externalSystemActions) {
ActionsTreeUtil.addAction(result, action, condition);
}
if (project == null)
return result;
MultiMap<ProjectSystemId, String> projectToActionsMapping = MultiMap.create();
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
projectToActionsMapping.putValues(manager.getSystemId(), ContainerUtil.<String>emptyList());
}
ActionManager actionManager = ActionManager.getInstance();
if (actionManager != null) {
for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) {
AnAction eachAction = actionManager.getAction(eachId);
if (!(eachAction instanceof MyExternalSystemAction))
continue;
if (condition != null && !condition.value(actionManager.getActionOrStub(eachId)))
continue;
MyExternalSystemAction taskAction = (MyExternalSystemAction) eachAction;
projectToActionsMapping.putValue(taskAction.getSystemId(), eachId);
}
}
Map<ProjectSystemId, KeymapGroup> keymapGroupMap = ContainerUtil.newHashMap();
for (ProjectSystemId systemId : projectToActionsMapping.keySet()) {
if (!keymapGroupMap.containsKey(systemId)) {
final Icon projectIcon = ExternalSystemUiUtil.getUiAware(systemId).getProjectIcon();
KeymapGroup group = KeymapGroupFactory.getInstance().createGroup(systemId.getReadableName(), projectIcon);
keymapGroupMap.put(systemId, group);
}
}
for (Map.Entry<ProjectSystemId, Collection<String>> each : projectToActionsMapping.entrySet()) {
Collection<String> tasks = each.getValue();
final ProjectSystemId systemId = each.getKey();
final KeymapGroup systemGroup = keymapGroupMap.get(systemId);
if (systemGroup == null)
continue;
for (String actionId : tasks) {
systemGroup.addActionId(actionId);
}
if (systemGroup instanceof Group) {
Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add;
((Group) systemGroup).addHyperlink(new Hyperlink(icon, "Choose a task to assign a shortcut") {
@Override
public void onClick(MouseEvent e) {
SelectExternalTaskDialog dialog = new SelectExternalTaskDialog(systemId, project);
if (dialog.showAndGet() && dialog.getResult() != null) {
TaskData taskData = dialog.getResult().second;
String ownerModuleName = dialog.getResult().first;
ExternalSystemTaskAction externalSystemAction = (ExternalSystemTaskAction) getOrRegisterAction(project, ownerModuleName, taskData);
ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged();
Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent()));
KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null;
if (keymapPanel != null) {
// clear actions filter
keymapPanel.showOption("");
keymapPanel.selectAction(externalSystemAction.myId);
}
}
}
});
}
}
for (KeymapGroup keymapGroup : keymapGroupMap.values()) {
if (isGroupFiltered(condition, keymapGroup)) {
result.addGroup(keymapGroup);
}
}
for (ActionsProvider extension : ActionsProvider.EP_NAME.getExtensions()) {
KeymapGroup keymapGroup = extension.createGroup(condition, project);
if (isGroupFiltered(condition, keymapGroup)) {
result.addGroup(keymapGroup);
}
}
return result;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method runTasks.
public boolean runTasks(@NotNull Collection<String> modules, @NotNull Phase... phases) {
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue = new LinkedList<>();
//noinspection MismatchedQueryAndUpdateOfCollection
Map<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>> lazyConfigurationsMap = new FactoryMap<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>>() {
@Nullable
@Override
protected Map<String, RunnerAndConfigurationSettings> create(ProjectSystemId key) {
final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(key);
if (configurationType == null)
return null;
return ContainerUtil.map2Map(RunManager.getInstance(myProject).getConfigurationSettingsList(configurationType), configurationSettings -> Pair.create(configurationSettings.getName(), configurationSettings));
}
};
for (final ExternalProjectsStateProvider.TasksActivation activation : stateProvider.getAllTasksActivation()) {
final boolean hashPath = modules.contains(activation.projectPath);
final Set<String> tasks = ContainerUtil.newLinkedHashSet();
for (Phase phase : phases) {
List<String> activationTasks = activation.state.getTasks(phase);
if (hashPath || (phase.isSyncPhase() && !activationTasks.isEmpty() && isShareSameRootPath(modules, activation))) {
ContainerUtil.addAll(tasks, activationTasks);
}
}
if (tasks.isEmpty())
continue;
for (Iterator<String> iterator = tasks.iterator(); iterator.hasNext(); ) {
String task = iterator.next();
if (task.length() > RUN_CONFIGURATION_TASK_PREFIX.length() && task.startsWith(RUN_CONFIGURATION_TASK_PREFIX)) {
iterator.remove();
final String configurationName = task.substring(RUN_CONFIGURATION_TASK_PREFIX.length());
Map<String, RunnerAndConfigurationSettings> settings = lazyConfigurationsMap.get(activation.systemId);
if (settings == null)
continue;
RunnerAndConfigurationSettings configurationSettings = settings.get(configurationName);
if (configurationSettings == null)
continue;
final RunConfiguration runConfiguration = configurationSettings.getConfiguration();
if (configurationName.equals(configurationSettings.getName()) && runConfiguration instanceof ExternalSystemRunConfiguration) {
tasksQueue.add(Pair.create(activation.systemId, ((ExternalSystemRunConfiguration) runConfiguration).getSettings()));
}
}
}
if (tasks.isEmpty())
continue;
if (ExternalProjectsManager.getInstance(myProject).isIgnored(activation.systemId, activation.projectPath))
continue;
ExternalSystemTaskExecutionSettings executionSettings = new ExternalSystemTaskExecutionSettings();
executionSettings.setExternalSystemIdString(activation.systemId.toString());
executionSettings.setExternalProjectPath(activation.projectPath);
executionSettings.getTaskNames().addAll(tasks);
tasksQueue.add(Pair.create(activation.systemId, executionSettings));
}
return runTasksQueue(tasksQueue);
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemNodeAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = getProject(e);
if (project == null)
return;
ProjectSystemId projectSystemId = getSystemId(e);
if (projectSystemId == null)
return;
final T data = getExternalData(e, myExternalDataClazz);
if (data == null)
return;
perform(project, projectSystemId, data, e);
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class OpenExternalConfigAction method isEnabled.
@Override
protected boolean isEnabled(AnActionEvent e) {
if (!super.isEnabled(e))
return false;
final ExternalEntityData externalData = getExternalData(e, ExternalEntityData.class);
if (!(externalData instanceof ExternalConfigPathAware))
return false;
VirtualFile config = getExternalConfig((ExternalConfigPathAware) externalData, externalData.getOwner());
if (config == null)
return false;
ProjectSystemId externalSystemId = getSystemId(e);
e.getPresentation().setText(ExternalSystemBundle.message("action.open.config.text", externalSystemId.getReadableName()));
e.getPresentation().setDescription(ExternalSystemBundle.message("action.open.config.description", externalSystemId.getReadableName()));
final ExternalSystemUiAware uiAware = getExternalSystemUiAware(e);
if (uiAware != null) {
e.getPresentation().setIcon(uiAware.getProjectIcon());
}
return true;
}
Aggregations