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
13
import com.intellij.util.application
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit
27
27
import javax.swing.Icon
28
28
29
29
@Suppress(" UnstableApiUsage" )
30
- class GitpodPortForwardingService (private val session : ClientProjectSession ) {
30
+ class GitpodPortForwardingService (private val project : Project ) {
31
31
companion object {
32
32
const val FORWARDED_PORT_LABEL = " gitpod"
33
33
}
@@ -46,7 +46,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
46
46
}
47
47
48
48
private fun observePortsListWhileProjectIsOpen () = application.executeOnPooledThread {
49
- while (session. project.lifetime.status == LifetimeStatus .Alive ) {
49
+ while (project.lifetime.status == LifetimeStatus .Alive ) {
50
50
try {
51
51
observePortsList().get()
52
52
} catch (throwable: Throwable ) {
@@ -74,7 +74,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
74
74
val portsStatusResponseObserver = object :
75
75
ClientResponseObserver <Status .PortsStatusRequest , Status .PortsStatusResponse > {
76
76
override fun beforeStart (request : ClientCallStreamObserver <Status .PortsStatusRequest >) {
77
- session. project.lifetime.onTerminationOrNow { request.cancel(" gitpod: Project terminated." , null ) }
77
+ project.lifetime.onTerminationOrNow { request.cancel(" gitpod: Project terminated." , null ) }
78
78
}
79
79
override fun onNext (response : Status .PortsStatusResponse ) {
80
80
application.invokeLater { updateForwardedPortsList(response) }
@@ -104,38 +104,15 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
104
104
hostPort,
105
105
PortType .TCP ,
106
106
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
- }
107
+ ClientPortAttributes (hostPort, ClientPortPickingStrategy .REASSIGN_WHEN_BUSY ),
108
+ )
109
+
110
+ forwardedPort.presentation.name = port.name
111
+ forwardedPort.presentation.description = port.description
115
112
116
113
val portListenerDisposable = portToDisposableMap.getOrPut(hostPort, fun () = Disposer .newDisposable())
117
114
118
115
forwardedPort.addPortListener(portListenerDisposable, object : ForwardedPortListener {
119
- override fun becameReadOnly (port : ForwardedPort , reason : String? ) {
120
- thisLogger().warn(" gitpod: becameReadOnly($port , $reason )" )
121
- }
122
-
123
- override fun descriptionChanged (port : ForwardedPort , oldDescription : String? , newDescription : String? ) {
124
- thisLogger().warn(" gitpod: descriptionChanged($port , $oldDescription , $newDescription )" )
125
- }
126
-
127
- override fun exposedUrlChanged (port : ForwardedPort , newUrl : String ) {
128
- thisLogger().warn(" gitpod: exposedUrlChanged($port , $newUrl )" )
129
- }
130
-
131
- override fun iconChanged (port : ForwardedPort , oldIcon : Icon ? , newIcon : Icon ? ) {
132
- thisLogger().warn(" gitpod: iconChanged($port , $oldIcon , $newIcon )" )
133
- }
134
-
135
- override fun nameChanged (port : ForwardedPort , oldName : String? , newName : String? ) {
136
- thisLogger().warn(" gitpod: nameChanged($port , $oldName , $newName )" )
137
- }
138
-
139
116
override fun stateChanged (port : ForwardedPort , newState : ClientPortState ) {
140
117
when (newState) {
141
118
is ClientPortState .Assigned -> {
@@ -150,10 +127,6 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
150
127
}
151
128
}
152
129
}
153
-
154
- override fun tooltipChanged (port : ForwardedPort , oldTooltip : String? , newTooltip : String? ) {
155
- thisLogger().warn(" gitpod: tooltipChanged($port , $oldTooltip , $newTooltip )" )
156
- }
157
130
})
158
131
} catch (error: Error ) {
159
132
thisLogger().warn(" gitpod: ${error.message} " )
0 commit comments