Search in sources :

Example 16 with AbstractExternalSystemSettings

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

the class ProjectRenameAware method beAware.

public static void beAware(@NotNull Project project) {
    final ExternalSystemFacadeManager facadeManager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
        AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project);
        //noinspection unchecked
        settings.subscribe(new ExternalSystemSettingsListenerAdapter() {

            @Override
            public void onProjectRenamed(@NotNull String oldName, @NotNull String newName) {
                facadeManager.onProjectRename(oldName, newName);
            }
        });
    }
}
Also used : ExternalSystemSettingsListenerAdapter(com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter) AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager)

Example 17 with AbstractExternalSystemSettings

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

the class ToggleAutoImportAction method getProjectSettings.

@Nullable
private ExternalProjectSettings getProjectSettings(AnActionEvent e) {
    final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
    if (projectNode == null || projectNode.getData() == null)
        return null;
    final AbstractExternalSystemSettings externalSystemSettings = ExternalSystemApiUtil.getSettings(getProject(e), getSystemId(e));
    return externalSystemSettings.getLinkedProjectSettings(projectNode.getData().getLinkedExternalProjectPath());
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with AbstractExternalSystemSettings

use of com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings in project kotlin by JetBrains.

the class ExternalSystemImportingTestCase method doImportProject.

private void doImportProject() {
    AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, getExternalSystemId());
    ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
    projectSettings.setExternalProjectPath(getProjectPath());
    @SuppressWarnings("unchecked") Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
    projects.remove(projectSettings);
    projects.add(projectSettings);
    //noinspection unchecked
    systemSettings.setLinkedProjectsSettings(projects);
    final Ref<Couple<String>> error = Ref.create();
    ExternalSystemUtil.refreshProjects(new ImportSpecBuilder(myProject, getExternalSystemId()).use(ProgressExecutionMode.MODAL_SYNC).callback(new ExternalProjectRefreshCallback() {

        @Override
        public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
            if (externalProject == null) {
                System.err.println("Got null External project after import");
                return;
            }
            ServiceManager.getService(ProjectDataManager.class).importData(externalProject, myProject, true);
            System.out.println("External project was successfully imported");
        }

        @Override
        public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
            error.set(Couple.of(errorMessage, errorDetails));
        }
    }).forceWhenUptodate());
    if (!error.isNull()) {
        String failureMsg = "Import failed: " + error.get().first;
        if (StringUtil.isNotEmpty(error.get().second)) {
            failureMsg += "\nError details: \n" + error.get().second;
        }
        fail(failureMsg);
    }
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) Couple(com.intellij.openapi.util.Couple) ExternalProjectRefreshCallback(com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) ImportSpecBuilder(com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)

Aggregations

AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)18 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)13 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 Collection (java.util.Collection)4 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)3 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)3 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)3 ExternalSystemSettingsListenerAdapter (com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter)3 Module (com.intellij.openapi.module.Module)2 ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)2 Couple (com.intellij.openapi.util.Couple)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 HashMap (java.util.HashMap)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 PersistentStateComponent (com.intellij.openapi.components.PersistentStateComponent)1 ImportSpec (com.intellij.openapi.externalSystem.importing.ImportSpec)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)1