Search in sources :

Example 31 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.

the class GradleOpenProjectCompositeConfigurationAction method isVisible.

@Override
protected boolean isVisible(AnActionEvent e) {
    final Project project = getProject(e);
    if (project == null)
        return false;
    ProjectSystemId systemId = getSystemId(e);
    if (!GradleConstants.SYSTEM_ID.equals(systemId))
        return false;
    if (GradleSettings.getInstance(project).getLinkedProjectsSettings().size() > 1) {
        final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
        if (projectNode == null || projectNode.getData() == null)
            return false;
        GradleProjectSettings projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(projectNode.getData().getLinkedExternalProjectPath());
        GradleProjectSettings.CompositeBuild compositeBuild = null;
        if (projectSettings != null) {
            compositeBuild = projectSettings.getCompositeBuild();
        }
        if (compositeBuild == null || compositeBuild.getCompositeDefinitionSource() == CompositeDefinitionSource.IDE)
            return true;
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode)

Example 32 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.

the class ExternalProjectDataCache method getRootExternalProject.

@Nullable
public ExternalProject getRootExternalProject(@NotNull ProjectSystemId systemId, @NotNull File projectRootDir) {
    ExternalProject externalProject = myExternalRootProjects.get(Pair.create(systemId, projectRootDir));
    if (LOG.isDebugEnabled()) {
        LOG.debug("Can not find data for project at: " + projectRootDir);
        LOG.debug("Existing imported projects paths: " + ContainerUtil.map(myExternalRootProjects.entrySet(), (Function<Map.Entry<Pair<ProjectSystemId, File>, ExternalProject>, Object>) entry -> {
            if (!(entry.getValue() instanceof ExternalProject))
                return null;
            return Pair.create(entry.getKey(), entry.getValue().getProjectDir());
        }));
    }
    return externalProject;
}
Also used : ContainerUtil(com.intellij.util.containers.ContainerUtil) ExternalSourceSet(org.jetbrains.plugins.gradle.model.ExternalSourceSet) File(java.io.File) ExternalSystemUtil(com.intellij.openapi.externalSystem.util.ExternalSystemUtil) Nullable(org.jetbrains.annotations.Nullable) ExternalSystemApiUtil(com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil) ServiceManager(com.intellij.openapi.components.ServiceManager) DefaultExternalProject(org.jetbrains.plugins.gradle.model.DefaultExternalProject) ExternalProject(org.jetbrains.plugins.gradle.model.ExternalProject) Function(com.intellij.util.Function) Map(java.util.Map) Pair(com.intellij.openapi.util.Pair) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Project(com.intellij.openapi.project.Project) ConcurrentFactoryMap(com.intellij.util.containers.ConcurrentFactoryMap) Queue(java.util.Queue) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) DefaultExternalProject(org.jetbrains.plugins.gradle.model.DefaultExternalProject) ExternalProject(org.jetbrains.plugins.gradle.model.ExternalProject) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 33 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.

the class ToolWindowModuleService method processData.

@Override
protected void processData(@NotNull final Collection<DataNode<ModuleData>> nodes, @NotNull Project project) {
    if (nodes.isEmpty()) {
        return;
    }
    ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner();
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    final MultiMap<DataNode<ProjectData>, DataNode<ModuleData>> grouped = ExternalSystemApiUtil.groupBy(nodes, ProjectKeys.PROJECT);
    Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> data = ContainerUtilRt.newHashMap();
    for (Map.Entry<DataNode<ProjectData>, Collection<DataNode<ModuleData>>> entry : grouped.entrySet()) {
        data.put(ExternalProjectPojo.from(entry.getKey().getData()), ContainerUtilRt.map2List(entry.getValue(), MAPPER));
    }
    AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
    Set<String> pathsToForget = detectRenamedProjects(data, settings.getAvailableProjects());
    if (!pathsToForget.isEmpty()) {
        settings.forgetExternalProjects(pathsToForget);
    }
    Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> projects = ContainerUtilRt.newHashMap(settings.getAvailableProjects());
    projects.putAll(data);
    settings.setAvailableProjects(projects);
}
Also used : AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) MultiMap(com.intellij.util.containers.MultiMap)

Example 34 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.

the class MessageCounterTest method testIncrement.

@Test
public void testIncrement() throws Exception {
    MessageCounter counter = new MessageCounter();
    counter.increment(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM);
    assertEquals(counter.toString(), 1, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    counter.increment(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM);
    assertEquals(counter.toString(), 1, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 2, counter.getCount(null, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 2, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    counter.increment(GROUP2, NotificationSource.PROJECT_SYNC, NotificationCategory.WARNING, OTHER_BUILD_SYSTEM);
    assertEquals(counter.toString(), 1, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 0, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, NotificationCategory.WARNING, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 0, counter.getCount(GROUP2, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 0, counter.getCount(GROUP2, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(GROUP2, NotificationSource.PROJECT_SYNC, NotificationCategory.WARNING, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, NotificationCategory.INFO, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, NotificationCategory.ERROR, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(null, NotificationSource.PROJECT_SYNC, NotificationCategory.WARNING, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 3, counter.getCount(null, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    counter.increment(GROUP2, NotificationSource.PROJECT_SYNC, NotificationCategory.SIMPLE, new ProjectSystemId("anotherBuildSystem"));
    assertEquals(counter.toString(), 2, counter.getCount(GROUP1, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 1, counter.getCount(GROUP2, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    counter.remove(GROUP2, NotificationSource.PROJECT_SYNC, OTHER_BUILD_SYSTEM);
    assertEquals(counter.toString(), 0, counter.getCount(GROUP2, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    assertEquals(counter.toString(), 2, counter.getCount(null, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
    counter.remove(null, NotificationSource.PROJECT_SYNC, OTHER_BUILD_SYSTEM);
    assertEquals(counter.toString(), 0, counter.getCount(null, NotificationSource.PROJECT_SYNC, null, OTHER_BUILD_SYSTEM));
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Test(org.junit.Test)

Example 35 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.

the class ExternalSystemTaskActivator method runTasksQueue.

private boolean runTasksQueue(final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue) {
    final Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings> pair = tasksQueue.poll();
    if (pair == null)
        return true;
    final ProjectSystemId systemId = pair.first;
    final ExternalSystemTaskExecutionSettings executionSettings = pair.getSecond();
    final Semaphore targetDone = new Semaphore();
    targetDone.down();
    final Ref<Boolean> result = new Ref<>(false);
    ExternalSystemUtil.runTask(executionSettings, DefaultRunExecutor.EXECUTOR_ID, myProject, systemId, new TaskCallback() {

        @Override
        public void onSuccess() {
            result.set(runTasksQueue(tasksQueue));
            targetDone.up();
        }

        @Override
        public void onFailure() {
            targetDone.up();
        }
    }, ProgressExecutionMode.IN_BACKGROUND_ASYNC, false);
    targetDone.waitFor();
    return result.get();
}
Also used : Ref(com.intellij.openapi.util.Ref) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) TaskCallback(com.intellij.openapi.externalSystem.task.TaskCallback) Semaphore(com.intellij.util.concurrency.Semaphore) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Aggregations

ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)36 Project (com.intellij.openapi.project.Project)10 Map (java.util.Map)5 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 ExternalSystemManager (com.intellij.openapi.externalSystem.ExternalSystemManager)3 DataNode (com.intellij.openapi.externalSystem.model.DataNode)3 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)3 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)3 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)3 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)3 Collection (java.util.Collection)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Logger (com.intellij.openapi.diagnostic.Logger)2 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)2 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)2 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)2