Skip to content

Commit

Permalink
Add service focusing and expanding
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelldi committed May 14, 2024
1 parent d7f0282 commit 5f13e46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import com.intellij.openapi.application.EDT
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.rd.util.lifetime
import com.intellij.openapi.rd.util.startOnUiAsync
import com.intellij.openapi.wm.ToolWindowId
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.util.application
import com.jetbrains.rd.framework.*
import com.jetbrains.rd.util.lifetime.Lifetime
Expand All @@ -28,11 +26,7 @@ import me.rafaelldi.aspire.generated.aspireSessionHostModel
import me.rafaelldi.aspire.services.AspireServiceManager
import me.rafaelldi.aspire.sessionHost.SessionHostManager
import me.rafaelldi.aspire.settings.AspireSettings
import me.rafaelldi.aspire.util.DEBUG_SESSION_PORT
import me.rafaelldi.aspire.util.DEBUG_SESSION_TOKEN
import me.rafaelldi.aspire.util.DOTNET_DASHBOARD_OTLP_ENDPOINT_URL
import me.rafaelldi.aspire.util.DOTNET_DASHBOARD_RESOURCESERVICE_APIKEY
import me.rafaelldi.aspire.util.DOTNET_RESOURCE_SERVICE_ENDPOINT_URL
import me.rafaelldi.aspire.util.*
import org.jetbrains.concurrency.Promise
import org.jetbrains.concurrency.asPromise
import kotlin.io.path.Path
Expand Down Expand Up @@ -95,10 +89,6 @@ class AspireHostProgramRunner : DotNetProgramRunner() {
LOG.trace("Aspire session host config: $config")

val sessionHostPromise = aspireHostLifetime.startOnUiAsync {
val serviceToolWindow =
ToolWindowManager.getInstance(environment.project).getToolWindow(ToolWindowId.SERVICES)
serviceToolWindow?.activate {}

val protocol = startProtocol(aspireHostLifetime)
val sessionHostModel = protocol.aspireSessionHostModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import com.intellij.execution.ExecutionResult
import com.intellij.execution.RunManagerListener
import com.intellij.execution.RunnerAndConfigurationSettings
import com.intellij.execution.services.ServiceEventListener
import com.intellij.execution.services.ServiceViewManager
import com.intellij.openapi.application.EDT
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.util.application
import com.jetbrains.rd.util.addUnique
import com.jetbrains.rd.util.lifetime.Lifetime
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -110,6 +112,12 @@ class AspireServiceManager(private val project: Project) {
val aspireHostServiceLifetime = aspireHostConfig.aspireHostLifetime.createNested()

val hostService = hostServices[hostPathString] ?: return

val serviceViewManager = ServiceViewManager.getInstance(project)
withContext(Dispatchers.EDT) {
serviceViewManager.select(hostService, AspireServiceContributor::class.java, true, true)
}

aspireHostServiceLifetime.bracketIfAlive({
hostService.startHost(
aspireHostConfig.aspireHostProjectUrl,
Expand Down Expand Up @@ -150,6 +158,12 @@ class AspireServiceManager(private val project: Project) {

val resourceService = AspireResourceService(resource, resourceLifetime, hostService, project)
resourcesByHost.addUnique(resourceLifetime, resourceId, resourceService)

val serviceViewManager = ServiceViewManager.getInstance(project)
application.invokeLater {
serviceViewManager.expand(hostService, AspireServiceContributor::class.java)
}

resource.isInitialized.set(true)

resourceLifetime.bracketIfAlive({
Expand Down

0 comments on commit 5f13e46

Please sign in to comment.