Search in sources :

Example 1 with ExternalSystemManager

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

the class ExternalSystemFacadeManager method doGetFacade.

@SuppressWarnings("ConstantConditions")
@NotNull
private RemoteExternalSystemFacade doGetFacade(@NotNull IntegrationKey key, @NotNull Project project) throws Exception {
    final boolean currentInProcess = ExternalSystemApiUtil.isInProcessMode(key.getExternalSystemId());
    final ExternalSystemCommunicationManager myCommunicationManager = currentInProcess ? myInProcessCommunicationManager : myRemoteCommunicationManager;
    ExternalSystemManager manager = ExternalSystemApiUtil.getManager(key.getExternalSystemId());
    if (project.isDisposed() || manager == null) {
        return RemoteExternalSystemFacade.NULL_OBJECT;
    }
    Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings> pair = myRemoteFacades.get(key);
    if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
        return pair.first;
    }
    myLock.lock();
    try {
        pair = myRemoteFacades.get(key);
        if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
            return pair.first;
        }
        if (pair != null) {
            myFacadeWrappers.clear();
            myRemoteFacades.clear();
        }
        return doCreateFacade(key, project, myCommunicationManager);
    } finally {
        myLock.unlock();
    }
}
Also used : ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExternalSystemManager

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

the class ExternalSystemStartupActivity method runActivity.

@Override
public void runActivity(@NotNull final Project project) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    Runnable task = () -> {
        for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
            if (manager instanceof StartupActivity) {
                ((StartupActivity) manager).runActivity(project);
            }
        }
        if (project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) != Boolean.TRUE) {
            for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
                final boolean isNewProject = project.getUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT) == Boolean.TRUE;
                if (isNewProject) {
                    ExternalSystemUtil.refreshProjects(new ImportSpecBuilder(project, manager.getSystemId()).createDirectoriesForEmptyContentRoots());
                }
            }
        }
        ExternalToolWindowManager.handle(project);
        ExternalSystemVcsRegistrar.handle(project);
        ProjectRenameAware.beAware(project);
    };
    ExternalProjectsManager.getInstance(project).init();
    DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(task, project));
}
Also used : StartupActivity(com.intellij.openapi.startup.StartupActivity) ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) DisposeAwareRunnable(com.intellij.util.DisposeAwareRunnable) ImportSpecBuilder(com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)

Example 3 with ExternalSystemManager

use of com.intellij.openapi.externalSystem.ExternalSystemManager 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 4 with ExternalSystemManager

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

the class RefreshAllExternalProjectsAction method getSystemIds.

private static List<ProjectSystemId> getSystemIds(AnActionEvent e) {
    final List<ProjectSystemId> systemIds = ContainerUtil.newArrayList();
    final ProjectSystemId externalSystemId = ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.getData(e.getDataContext());
    if (externalSystemId != null) {
        systemIds.add(externalSystemId);
    } else {
        for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
            systemIds.add(manager.getSystemId());
        }
    }
    return systemIds;
}
Also used : ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 5 with ExternalSystemManager

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

the class ConfigurationErrorEvent method process.

@Override
public void process(@NotNull final TestEventXmlView xml) throws TestEventXmlView.XmlParserException {
    final String errorTitle = xml.getEventTitle();
    final String configurationErrorMsg = xml.getEventMessage();
    final boolean openSettings = xml.isEventOpenSettings();
    final Project project = getProject();
    assert project != null;
    final String message = openSettings ? String.format("<br>\n%s<br><br>\n\n<a href=\"Gradle settings\">Open gradle settings</a>", configurationErrorMsg) : String.format("<br>\n%s", configurationErrorMsg);
    GradleNotification.getInstance(project).showBalloon(errorTitle, message, NotificationType.WARNING, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            notification.expire();
            if ("Gradle settings".equals(event.getDescription())) {
                ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
                assert manager instanceof GradleManager;
                GradleManager gradleManager = (GradleManager) manager;
                Configurable configurable = gradleManager.getConfigurable(project);
                ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
            } else {
                BrowserUtil.browse(event.getDescription());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) GradleManager(org.jetbrains.plugins.gradle.GradleManager) Configurable(com.intellij.openapi.options.Configurable) GradleNotification(org.jetbrains.plugins.gradle.service.project.GradleNotification) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

ExternalSystemManager (com.intellij.openapi.externalSystem.ExternalSystemManager)5 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)1 ExternalSystemExecutionSettings (com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings)1 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)1 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)1 Configurable (com.intellij.openapi.options.Configurable)1 Project (com.intellij.openapi.project.Project)1 StartupActivity (com.intellij.openapi.startup.StartupActivity)1 DisposeAwareRunnable (com.intellij.util.DisposeAwareRunnable)1 Update (com.intellij.util.ui.update.Update)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1 GradleManager (org.jetbrains.plugins.gradle.GradleManager)1 GradleNotification (org.jetbrains.plugins.gradle.service.project.GradleNotification)1