Search in sources :

Example 1 with ExternalProjectInfo

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();
    }
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ExternalSystemProjectsWatcher(com.intellij.openapi.externalSystem.service.project.autoimport.ExternalSystemProjectsWatcher) DataNode(com.intellij.openapi.externalSystem.model.DataNode)

Example 2 with ExternalProjectInfo

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;
}
Also used : BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ListPopupStep(com.intellij.openapi.ui.popup.ListPopupStep) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData)

Example 3 with ExternalProjectInfo

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();
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) DefaultExternalSystemUiAware(com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ExternalProjectInfo

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);
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with ExternalProjectInfo

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;
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)13 DataNode (com.intellij.openapi.externalSystem.model.DataNode)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 Nullable (org.jetbrains.annotations.Nullable)4 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)3 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)2 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Editor (com.intellij.openapi.editor.Editor)1 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)1