use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class ExternalProjectsManager method init.
public void init() {
synchronized (isInitialized) {
if (isInitialized.getAndSet(true))
return;
myWatcher = new ExternalSystemProjectsWatcher(myProject);
myWatcher.start();
// load external projects data
ExternalProjectsDataStorage.getInstance(myProject).load();
myRunManagerListener.attach();
// init shortcuts manager
myShortcutsManager.init();
for (ExternalSystemManager<?, ?, ?, ?, ?> systemManager : ExternalSystemApiUtil.getAllManagers()) {
final Collection<ExternalProjectInfo> externalProjects = ExternalProjectsDataStorage.getInstance(myProject).list(systemManager.getSystemId());
for (ExternalProjectInfo externalProject : externalProjects) {
if (externalProject.getExternalProjectStructure() == null)
continue;
Collection<DataNode<TaskData>> taskData = ExternalSystemApiUtil.findAllRecursively(externalProject.getExternalProjectStructure(), TASK);
myShortcutsManager.scheduleKeymapUpdate(taskData);
}
if (!externalProjects.isEmpty()) {
myShortcutsManager.scheduleRunConfigurationKeymapUpdate(systemManager.getSystemId());
}
}
// init task activation info
myTaskActivator.init();
}
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class ConfigureTasksActivationDialog method createCenterPanel.
protected JComponent createCenterPanel() {
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
ProjectItem projectItem = (ProjectItem) projectCombobox.getSelectedItem();
if (projectItem == null)
return;
final ExternalProjectInfo projectData = ProjectDataManager.getInstance().getExternalProjectData(myProject, myProjectSystemId, projectItem.myProjectSettings.getExternalProjectPath());
if (projectData == null || projectData.getExternalProjectStructure() == null)
return;
final List<ProjectPopupItem> popupItems = ContainerUtil.newArrayList();
for (DataNode<ModuleData> moduleDataNode : ExternalSystemApiUtil.findAllRecursively(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
if (moduleDataNode.isIgnored())
continue;
final List<String> tasks = ContainerUtil.map(ExternalSystemApiUtil.findAll(moduleDataNode, ProjectKeys.TASK), node -> node.getData().getName());
if (!tasks.isEmpty()) {
popupItems.add(new ProjectPopupItem(moduleDataNode.getData(), tasks));
}
}
final ChooseProjectStep projectStep = new ChooseProjectStep(popupItems);
final List<ProjectPopupItem> projectItems = projectStep.getValues();
ListPopupStep step = projectItems.size() == 1 ? (ListPopupStep) projectStep.onChosen(projectItems.get(0), false) : projectStep;
assert step != null;
JBPopupFactory.getInstance().createListPopup(step).show(ObjectUtils.notNull(button.getPreferredPopupPoint(), RelativePoint.getSouthEastOf(projectCombobox)));
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
List<TaskActivationEntry> tasks = findSelectedTasks();
myTaskActivator.removeTasks(tasks);
updateTree(null);
}
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveAction(-1);
}
}).setMoveUpActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return isMoveActionEnabled(-1);
}
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveAction(+1);
}
}).setMoveDownActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return isMoveActionEnabled(+1);
}
}).setToolbarPosition(ActionToolbarPosition.RIGHT).setToolbarBorder(IdeBorderFactory.createEmptyBorder());
tasksPanel.add(decorator.createPanel());
return contentPane;
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class AbstractExternalSystemTaskConfigurationType method generateName.
@NotNull
public static String generateName(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @Nullable String externalProjectPath, @NotNull List<String> taskNames, @Nullable String executionName) {
String rootProjectPath = null;
if (externalProjectPath != null) {
final ExternalProjectInfo projectInfo = ExternalSystemUtil.getExternalProjectInfo(project, externalSystemId, externalProjectPath);
if (projectInfo != null) {
rootProjectPath = projectInfo.getExternalProjectPath();
}
}
StringBuilder buffer = new StringBuilder();
final String projectName;
if (rootProjectPath == null) {
projectName = null;
} else {
final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
projectName = uiAware.getProjectRepresentationName(project, externalProjectPath, rootProjectPath);
}
if (!StringUtil.isEmptyOrSpaces(projectName)) {
buffer.append(projectName);
buffer.append(' ');
} else {
buffer.append(externalProjectPath);
buffer.append(' ');
}
buffer.append('[');
if (!StringUtil.isEmpty(executionName)) {
buffer.append(executionName);
} else if (!taskNames.isEmpty()) {
for (String taskName : taskNames) {
buffer.append(taskName).append(' ');
}
buffer.setLength(buffer.length() - 1);
}
buffer.append(']');
return buffer.toString();
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class CachedModuleDataFinder method findModuleData.
@Nullable
public DataNode<ModuleData> findModuleData(@NotNull Module module) {
final String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
if (rootProjectPath == null)
return null;
final String projectId = ExternalSystemApiUtil.getExternalProjectId(module);
if (projectId == null)
return null;
final String externalProjectPath = ExternalSystemApiUtil.getExternalProjectPath(module);
if (externalProjectPath == null || StringUtil.endsWith(externalProjectPath, "buildSrc"))
return null;
ExternalProjectInfo projectData = ProjectDataManager.getInstance().getExternalProjectData(module.getProject(), GradleConstants.SYSTEM_ID, rootProjectPath);
if (projectData == null)
return null;
DataNode<ProjectData> projectStructure = projectData.getExternalProjectStructure();
if (projectStructure == null)
return null;
return findModuleData(projectStructure, externalProjectPath);
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class GradleParentProjectForm method findPotentialParentProject.
@Nullable
private ProjectData findPotentialParentProject(@Nullable Project project) {
if (project == null)
return null;
ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID).getLinkedProjectSettings(myContext.getProjectFileDirectory());
if (linkedProjectSettings == null)
return null;
final ExternalProjectInfo projectInfo = ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, linkedProjectSettings.getExternalProjectPath());
return projectInfo != null && projectInfo.getExternalProjectStructure() != null ? projectInfo.getExternalProjectStructure().getData() : null;
}
Aggregations