Search in sources :

Example 1 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ExternalSystemProjectsWatcher method scheduleUpdate.

private void scheduleUpdate(String projectPath) {
    Pair<ExternalSystemManager, ExternalProjectSettings> linkedProject = findLinkedProjectSettings(projectPath);
    if (linkedProject == null)
        return;
    ExternalSystemManager<?, ?, ?, ?, ?> manager = linkedProject.first;
    ProjectSystemId systemId = manager.getSystemId();
    boolean useAutoImport = linkedProject.second.isUseAutoImport();
    if (useAutoImport) {
        final ExternalSystemTask resolveTask = ServiceManager.getService(ExternalSystemProcessingManager.class).findTask(ExternalSystemTaskType.RESOLVE_PROJECT, systemId, projectPath);
        final ExternalSystemTaskState taskState = resolveTask == null ? null : resolveTask.getState();
        if (taskState == null || taskState.isStopped()) {
            scheduleRefresh(myProject, projectPath, systemId, false);
        } else if (taskState != ExternalSystemTaskState.NOT_STARTED) {
        // TODO re-schedule to wait for the project import task end
        }
    } else {
        myUpdatesQueue.queue(new Update(Pair.create(systemId, projectPath)) {

            public void run() {
                doUpdateNotifications(false, systemId, projectPath);
            }
        });
    }
}
Also used : ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) ExternalSystemProcessingManager(com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Update(com.intellij.util.ui.update.Update) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 2 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class RefreshExternalProjectAction method perform.

@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    assert externalSystemNode != null;
    final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
    assert externalConfigPathAware != null;
    // We save all documents because there is a possible case that there is an external system config file changed inside the ide.
    FileDocumentManager.getInstance().saveAllDocuments();
    final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
    final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
    ExternalSystemUtil.refreshProject(project, projectSystemId, externalProjectPath, false, ProgressExecutionMode.IN_BACKGROUND_ASYNC);
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 3 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ToggleAutoImportAction method setSelected.

@Override
public void setSelected(AnActionEvent e, boolean state) {
    final ExternalProjectSettings projectSettings = getProjectSettings(e);
    if (projectSettings != null) {
        if (state != projectSettings.isUseAutoImport()) {
            projectSettings.setUseAutoImport(state);
            ExternalSystemApiUtil.getSettings(getProject(e), getSystemId(e)).getPublisher().onUseAutoImportChange(state, projectSettings.getExternalProjectPath());
        }
    }
}
Also used : ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 4 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ExternalSystemApiUtil method isOneToOneMapping.

/**
   * Allows to answer if given ide project has 1-1 mapping with the given external project, i.e. the ide project has been
   * imported from external system and no other external projects have been added.
   * <p/>
   * This might be necessary in a situation when project-level setting is changed (e.g. project name). We don't want to rename
   * ide project if it doesn't completely corresponds to the given ide project then.
   *
   * @param ideProject       target ide project
   * @param projectData      target external project
   * @return                 <code>true</code> if given ide project has 1-1 mapping to the given external project;
   *                         <code>false</code> otherwise
   */
public static boolean isOneToOneMapping(@NotNull Project ideProject, @NotNull ProjectData projectData) {
    String linkedExternalProjectPath = null;
    for (ExternalSystemManager<?, ?, ?, ?, ?> manager : getAllManagers()) {
        ProjectSystemId externalSystemId = manager.getSystemId();
        AbstractExternalSystemSettings systemSettings = getSettings(ideProject, externalSystemId);
        Collection projectsSettings = systemSettings.getLinkedProjectsSettings();
        int linkedProjectsNumber = projectsSettings.size();
        if (linkedProjectsNumber > 1) {
            // More than one external project of the same external system type is linked to the given ide project.
            return false;
        } else if (linkedProjectsNumber == 1) {
            if (linkedExternalProjectPath == null) {
                // More than one external project of different external system types is linked to the current ide project.
                linkedExternalProjectPath = ((ExternalProjectSettings) projectsSettings.iterator().next()).getExternalProjectPath();
            } else {
                return false;
            }
        }
    }
    if (linkedExternalProjectPath != null && !linkedExternalProjectPath.equals(projectData.getLinkedExternalProjectPath())) {
        // New external project is being linked.
        return false;
    }
    for (Module module : ModuleManager.getInstance(ideProject).getModules()) {
        if (!isExternalSystemAwareModule(projectData.getOwner(), module)) {
            return false;
        }
    }
    return true;
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Module(com.intellij.openapi.module.Module) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 5 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class GradleRefreshProjectDependenciesAction method perform.

@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    assert externalSystemNode != null;
    final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
    assert externalConfigPathAware != null;
    // We save all documents because there is a possible case that there is an external system config file changed inside the ide.
    FileDocumentManager.getInstance().saveAllDocuments();
    final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
    final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
    ExternalSystemUtil.refreshProject(externalProjectPath, new ImportSpecBuilder(project, projectSystemId).useDefaultCallback().use(ProgressExecutionMode.IN_BACKGROUND_ASYNC).withArguments("--refresh-dependencies").build());
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) ImportSpecBuilder(com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)

Aggregations

ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)26 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)13 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)7 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)5 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)4 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)4 File (java.io.File)4 Collection (java.util.Collection)4 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)3 DataNode (com.intellij.openapi.externalSystem.model.DataNode)2 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)2 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)2 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)2 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)2 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)2 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)2