Search in sources :

Example 21 with ProjectSystemId

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

the class ExternalSystemNotificationManager method prepareMessagesView.

@NotNull
public NewErrorTreeViewPanel prepareMessagesView(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationSource notificationSource, boolean activateView) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final NewErrorTreeViewPanel errorTreeView;
    final String contentDisplayName = getContentDisplayName(notificationSource, externalSystemId);
    final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
    Content targetContent = findContent(contentIdPair, contentDisplayName);
    final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
    if (targetContent == null || !contentIdPair.equals(targetContent.getUserData(CONTENT_ID_KEY))) {
        errorTreeView = new NewEditableErrorTreeViewPanel(myProject, null, true, true, null);
        targetContent = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, contentDisplayName, true);
        targetContent.putUserData(CONTENT_ID_KEY, contentIdPair);
        messageView.getContentManager().addContent(targetContent);
        Disposer.register(targetContent, errorTreeView);
    } else {
        assert targetContent.getComponent() instanceof NewEditableErrorTreeViewPanel;
        errorTreeView = (NewEditableErrorTreeViewPanel) targetContent.getComponent();
    }
    messageView.getContentManager().setSelectedContent(targetContent);
    final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
    if (activateView && tw != null && !tw.isActive()) {
        tw.activate(null, false);
    }
    return errorTreeView;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with ProjectSystemId

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

the class ExternalModuleStructureExtension method moduleRemoved.

@Override
public void moduleRemoved(Module module) {
    String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
    if (StringUtil.isEmpty(systemIdString))
        return;
    String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
    if (StringUtil.isEmpty(rootProjectPath))
        return;
    Project project = module.getProject();
    ModulesConfigurator modulesConfigurator = getModulesConfigurator(project);
    if (modulesConfigurator == null)
        return;
    for (Module m : modulesConfigurator.getModules()) {
        if (m != module && rootProjectPath.equals(ExternalSystemApiUtil.getExternalRootProjectPath(m))) {
            return;
        }
    }
    ProjectSystemId systemId = new ProjectSystemId(systemIdString);
    ExternalSystemApiUtil.getSettings(project, systemId).unlinkExternalProject(rootProjectPath);
    assert myOrphanProjectsCandidates != null;
    myOrphanProjectsCandidates.put(rootProjectPath, systemId);
    isExternalSystemsInvolved = true;
}
Also used : Project(com.intellij.openapi.project.Project) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Module(com.intellij.openapi.module.Module)

Example 23 with ProjectSystemId

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

the class ExternalModuleStructureExtension method disposeUIResources.

@Override
public void disposeUIResources() {
    try {
        if (isExternalSystemsInvolved) {
            assert myOrphanProjectsCandidates != null;
            assert myProject != null;
            if (myExternalProjectsToRestore != null) {
                for (Pair<ProjectSystemId, ExternalProjectSettings> settingsPair : myExternalProjectsToRestore.values()) {
                    AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(myProject, settingsPair.first);
                    String rootProjectPath = settingsPair.second.getExternalProjectPath();
                    if (settings.getLinkedProjectSettings(rootProjectPath) == null) {
                        //noinspection unchecked
                        settings.linkProject(settingsPair.second);
                    }
                    myOrphanProjectsCandidates.remove(rootProjectPath);
                }
            }
            ModulesConfigurator modulesConfigurator = getModulesConfigurator(myProject);
            if (modulesConfigurator != null) {
                for (Map.Entry<String, ProjectSystemId> entry : myOrphanProjectsCandidates.entrySet()) {
                    String rootProjectPath = entry.getKey();
                    if (StringUtil.isNotEmpty(rootProjectPath)) {
                        unlinkProject(myProject, entry.getValue(), rootProjectPath);
                    }
                }
            }
        }
    } catch (Throwable e) {
        LOG.warn(e);
    } finally {
        myProject = null;
        myExternalProjectsToRestore = null;
        myOrphanProjectsCandidates = null;
    }
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) HashMap(java.util.HashMap) Map(java.util.Map) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 24 with ProjectSystemId

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

the class ExternalModuleStructureExtension method addModuleNodeChildren.

@Override
public boolean addModuleNodeChildren(Module module, MasterDetailsComponent.MyNode moduleNode, Runnable treeNodeNameUpdater) {
    String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
    if (StringUtil.isNotEmpty(systemIdString)) {
        isExternalSystemsInvolved = true;
        String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
        if (myOrphanProjectsCandidates != null && StringUtil.isNotEmpty(rootProjectPath)) {
            myOrphanProjectsCandidates.put(rootProjectPath, new ProjectSystemId(systemIdString));
        }
    }
    return false;
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 25 with ProjectSystemId

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

the class ExternalProjectsManager method getStateProvider.

@NotNull
public ExternalProjectsStateProvider getStateProvider() {
    return new ExternalProjectsStateProvider() {

        @Override
        public List<TasksActivation> getAllTasksActivation() {
            List<TasksActivation> result = new SmartList<>();
            Map<String, ProjectSystemId> systemIds = ExternalSystemApiUtil.getAllManagers().stream().collect(Collectors.toMap(o -> o.getSystemId().getId(), o -> o.getSystemId()));
            for (Map.Entry<String, ExternalProjectsState.State> systemState : myState.getExternalSystemsState().entrySet()) {
                ProjectSystemId systemId = systemIds.get(systemState.getKey());
                if (systemId == null)
                    continue;
                for (Map.Entry<String, TaskActivationState> activationStateEntry : systemState.getValue().getExternalSystemsTaskActivation().entrySet()) {
                    result.add(new TasksActivation(systemId, activationStateEntry.getKey(), activationStateEntry.getValue()));
                }
            }
            return result;
        }

        @Override
        public List<TasksActivation> getTasksActivation(@NotNull final ProjectSystemId systemId) {
            final Set<Map.Entry<String, TaskActivationState>> entries = myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation().entrySet();
            return ContainerUtil.map(entries, entry -> new TasksActivation(systemId, entry.getKey(), entry.getValue()));
        }

        @Override
        public TaskActivationState getTasksActivation(@NotNull ProjectSystemId systemId, @NotNull String projectPath) {
            return myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation().get(projectPath);
        }

        @Override
        public Map<String, TaskActivationState> getProjectsTasksActivationMap(@NotNull final ProjectSystemId systemId) {
            return myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation();
        }
    };
}
Also used : com.intellij.openapi.components(com.intellij.openapi.components) ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ContainerUtil(com.intellij.util.containers.ContainerUtil) ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ExternalSystemApiUtil(com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil) DataNode(com.intellij.openapi.externalSystem.model.DataNode) SmartList(com.intellij.util.SmartList) MODULE(com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE) Map(java.util.Map) ExternalSystemProjectsWatcher(com.intellij.openapi.externalSystem.service.project.autoimport.ExternalSystemProjectsWatcher) ExternalProjectsViewState(com.intellij.openapi.externalSystem.view.ExternalProjectsViewState) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) Logger(com.intellij.openapi.diagnostic.Logger) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) Disposable(com.intellij.openapi.Disposable) ExternalProjectsViewImpl(com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl) ExternalSystemUtil(com.intellij.openapi.externalSystem.util.ExternalSystemUtil) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ExternalProjectsView(com.intellij.openapi.externalSystem.view.ExternalProjectsView) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData) NotNull(org.jetbrains.annotations.NotNull) TASK(com.intellij.openapi.externalSystem.model.ProjectKeys.TASK) NotNull(org.jetbrains.annotations.NotNull) ExternalProjectsViewState(com.intellij.openapi.externalSystem.view.ExternalProjectsViewState) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) SmartList(com.intellij.util.SmartList) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

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