5
5
package io.gitpod.jetbrains.remote.latest
6
6
7
7
import com.intellij.openapi.Disposable
8
- import com.intellij.openapi.client.ClientProjectSession
9
8
import com.intellij.openapi.components.service
10
9
import com.intellij.openapi.diagnostic.thisLogger
10
+ import com.intellij.openapi.project.Project
11
11
import com.intellij.openapi.util.Disposer
12
12
import com.intellij.remoteDev.util.onTerminationOrNow
13
+ import com.intellij.ui.RowIcon
13
14
import com.intellij.util.application
14
15
import com.jetbrains.rd.platform.codeWithMe.portForwarding.*
15
16
import com.jetbrains.rd.platform.util.lifetime
16
17
import com.jetbrains.rd.util.lifetime.LifetimeStatus
17
18
import io.gitpod.jetbrains.remote.GitpodIgnoredPortsForNotificationService
18
19
import io.gitpod.jetbrains.remote.GitpodManager
19
20
import io.gitpod.jetbrains.remote.GitpodPortsService
21
+ import io.gitpod.jetbrains.remote.icons.GitpodIcons
20
22
import io.gitpod.supervisor.api.Status
21
23
import io.gitpod.supervisor.api.StatusServiceGrpc
22
24
import io.grpc.stub.ClientCallStreamObserver
@@ -27,7 +29,7 @@ import java.util.concurrent.TimeUnit
27
29
import javax.swing.Icon
28
30
29
31
@Suppress(" UnstableApiUsage" )
30
- class GitpodPortForwardingService (private val session : ClientProjectSession ) {
32
+ class GitpodPortForwardingService (private val project : Project ) {
31
33
companion object {
32
34
const val FORWARDED_PORT_LABEL = " gitpod"
33
35
}
@@ -46,7 +48,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
46
48
}
47
49
48
50
private fun observePortsListWhileProjectIsOpen () = application.executeOnPooledThread {
49
- while (session. project.lifetime.status == LifetimeStatus .Alive ) {
51
+ while (project.lifetime.status == LifetimeStatus .Alive ) {
50
52
try {
51
53
observePortsList().get()
52
54
} catch (throwable: Throwable ) {
@@ -74,7 +76,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
74
76
val portsStatusResponseObserver = object :
75
77
ClientResponseObserver <Status .PortsStatusRequest , Status .PortsStatusResponse > {
76
78
override fun beforeStart (request : ClientCallStreamObserver <Status .PortsStatusRequest >) {
77
- session. project.lifetime.onTerminationOrNow { request.cancel(" gitpod: Project terminated." , null ) }
79
+ project.lifetime.onTerminationOrNow { request.cancel(" gitpod: Project terminated." , null ) }
78
80
}
79
81
override fun onNext (response : Status .PortsStatusResponse ) {
80
82
application.invokeLater { updateForwardedPortsList(response) }
@@ -104,14 +106,16 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
104
106
hostPort,
105
107
PortType .TCP ,
106
108
setOf (FORWARDED_PORT_LABEL ),
107
- hostPort,
108
- ClientPortPickingStrategy .REASSIGN_WHEN_BUSY
109
- ) {
110
- this .name = port.name
111
- this .description = port.description
112
- this .icon = null
113
- this .tooltip = " Forwarded Port"
114
- }
109
+ ClientPortAttributes (hostPort, ClientPortPickingStrategy .REASSIGN_WHEN_BUSY ),
110
+ )
111
+
112
+ forwardedPort.presentation.name = port.name
113
+ forwardedPort.presentation.description = port.description
114
+ val rowIcon = RowIcon (2 )
115
+ rowIcon.setIcon(GitpodIcons .Logo , 0 )
116
+ rowIcon.setIcon(GitpodIcons .Logo , 1 )
117
+ forwardedPort.presentation.icon = rowIcon
118
+ forwardedPort.presentation.tooltip = " Forwarded Port"
115
119
116
120
val portListenerDisposable = portToDisposableMap.getOrPut(hostPort, fun () = Disposer .newDisposable())
117
121
@@ -172,6 +176,25 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
172
176
portsService.removeForwardedPort(hostPort)
173
177
thisLogger().info(" gitpod: Stopped forwarding port $hostPort ." )
174
178
}
179
+
180
+ // if (!isServed && !isForwarded) {
181
+ // val exposedPort = perClientPortForwardingManager.exposePort(
182
+ // hostPort,
183
+ // port.exposed.url,
184
+ // setOf(FORWARDED_PORT_LABEL),
185
+ // )
186
+ //
187
+ // exposedPort.presentation.name = port.name
188
+ // exposedPort.presentation.description = port.description
189
+ // exposedPort.presentation.icon = GitpodIcons.Logo
190
+ // exposedPort.presentation.tooltip = "Exposed Port"
191
+ // }
192
+ //
193
+ // perClientPortForwardingManager.getPorts(hostPort).forEach {
194
+ // it.presentation.name = port.name
195
+ // it.presentation.description = port.description
196
+ // thisLogger().warn("gitpod: changing name and description of port $hostPort")
197
+ // }
175
198
}
176
199
}
177
200
}
0 commit comments