mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-230472 services: run dashboard: move content based on managed run configuration types
GitOrigin-RevId: edbfe227473da3468aa6a9e686000df240a78bd6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
16dfca46c2
commit
b9984e1dba
@@ -73,9 +73,6 @@ internal class FrontendRunDashboardManager(private val project: Project) : RunDa
|
||||
frontendDtos.value = updatesFromBackend
|
||||
|
||||
updateDashboard(true)
|
||||
withContext(Dispatchers.EDT) {
|
||||
RunDashboardUiManagerImpl.getInstance(project).syncContentsFromBackend()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +120,14 @@ internal class FrontendRunDashboardManager(private val project: Project) : RunDa
|
||||
|
||||
internal suspend fun subscribeToBackendConfigurationTypesUpdates() {
|
||||
RunDashboardServiceRpc.getInstance().getConfigurationTypes(project.projectId()).collect { updateFromBackend ->
|
||||
// Just update types set on the frontend,
|
||||
// do not filter frontend DTOs since they are synced via subscribeToBackendServicesUpdates().
|
||||
configurationTypes.value = types
|
||||
configurationTypes.value = updateFromBackend
|
||||
|
||||
updateDashboard(true)
|
||||
withContext(Dispatchers.EDT) {
|
||||
if (RunDashboardUiManagerImpl.getInstance(project).syncContentsFromBackend()) {
|
||||
updateDashboard(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.execution.dashboard.splitApi.frontend;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.RunContentDescriptorId;
|
||||
@@ -131,21 +130,49 @@ public final class RunDashboardUiManagerImpl implements RunDashboardUiManager {
|
||||
return Conditions.alwaysFalse();
|
||||
}
|
||||
|
||||
public void syncContentsFromBackend() {
|
||||
/**
|
||||
* Synchronizes content between the dashboard content manager and the run content manager
|
||||
* based on the current set of run configuration types that should be shown in services.
|
||||
* <p>
|
||||
* Content is moved out of the dashboard when its run configuration type is removed from services.
|
||||
* Content is moved into the dashboard when its run configuration type is added to services.
|
||||
*/
|
||||
public boolean syncContentsFromBackend() {
|
||||
FrontendRunDashboardManager frontendManager = FrontendRunDashboardManager.getInstance(myProject);
|
||||
List<@NotNull FrontendRunDashboardService> services = frontendManager.getServicePresentations();
|
||||
Set<Content> actualContents = new HashSet<>(
|
||||
ContainerUtil.mapNotNull(services,
|
||||
service -> {
|
||||
var descriptor = frontendManager.getServiceRunContentDescriptor(service);
|
||||
return descriptor != null ? descriptor.getAttachedContent() : null;
|
||||
}));
|
||||
var managedContents = Set.of(myContentManager.getContents());
|
||||
Set<String> types = frontendManager.getTypes();
|
||||
|
||||
var removed = Sets.difference(managedContents, actualContents);
|
||||
moveRemovedContent(removed);
|
||||
var added = Sets.difference(actualContents, managedContents);
|
||||
moveAddedContent(added);
|
||||
// Find content to remove from dashboard (type no longer in services)
|
||||
Set<Content> managedContents = Set.of(myContentManager.getContents());
|
||||
Set<Content> toRemove = new HashSet<>();
|
||||
for (Content content : managedContents) {
|
||||
RunContentDescriptor descriptor = RunContentManagerImpl.getRunContentDescriptorByContent(content);
|
||||
if (descriptor == null) continue;
|
||||
|
||||
String typeId = descriptor.getRunConfigurationTypeId();
|
||||
if (typeId != null && !types.contains(typeId)) {
|
||||
toRemove.add(content);
|
||||
}
|
||||
}
|
||||
moveRemovedContent(toRemove);
|
||||
|
||||
// Find content to add to dashboard (type now in services)
|
||||
RunContentManager runContentManager = RunContentManager.getInstance(myProject);
|
||||
Set<Content> toAdd = new HashSet<>();
|
||||
for (RunContentDescriptor descriptor : runContentManager.getRunContentDescriptors()) {
|
||||
String typeId = descriptor.getRunConfigurationTypeId();
|
||||
if (typeId == null || !types.contains(typeId)) continue;
|
||||
|
||||
Content content = descriptor.getAttachedContent();
|
||||
if (content == null || managedContents.contains(content)) continue;
|
||||
|
||||
// Only add content that is not already being managed by the dashboard
|
||||
if (content.getManager() != myContentManager) {
|
||||
toAdd.add(content);
|
||||
}
|
||||
}
|
||||
moveAddedContent(toAdd);
|
||||
|
||||
return !toRemove.isEmpty() || !toAdd.isEmpty();
|
||||
}
|
||||
|
||||
private void moveRemovedContent(Collection<Content> contents) {
|
||||
|
||||
Reference in New Issue
Block a user