@@ -57,6 +57,7 @@ class DevSpacesWorkspacesStepView(
5757 // 'true' when there are DevWorkspaces come from multiple namespaces
5858 private var multipleNamespaces = false
5959
60+ private lateinit var startDevWorkspaceButton: JButton
6061 private lateinit var stopDevWorkspaceButton: JButton
6162
6263 override val component = panel {
@@ -71,6 +72,10 @@ class DevSpacesWorkspacesStepView(
7172 row {
7273 label(" " ).resizableColumn().align(AlignX .FILL )
7374
75+ startDevWorkspaceButton =
76+ button(DevSpacesBundle .message(" connector.wizard_step.remote_server_connection.button.start" )) {
77+ startDevWorkspace()
78+ }.gap(RightGap .SMALL ).align(AlignX .RIGHT ).component
7479 stopDevWorkspaceButton =
7580 button(DevSpacesBundle .message(" connector.wizard_step.remote_server_connection.button.stop" )) {
7681 stopDevWorkspace()
@@ -160,6 +165,34 @@ class DevSpacesWorkspacesStepView(
160165 listDevWorkspaces.selectedIndex = selectedIndex
161166 }
162167
168+ private fun startDevWorkspace () {
169+ if (! listDevWorkspaces.isSelectionEmpty) {
170+ listDWDataModel
171+ .get(listDevWorkspaces.selectedIndex)
172+ .also {
173+ DevWorkspaces (devSpacesContext.client)
174+ .start(
175+ it.namespace,
176+ it.name
177+ )
178+ ProgressManager .getInstance().runProcessWithProgressSynchronously(
179+ {
180+ if (waitDevWorkspaceNotStopped(it)) {
181+ refreshDevWorkspace(
182+ it.namespace,
183+ it.name
184+ )
185+ enableButtons()
186+ }
187+ },
188+ " Refreshing Workspace" ,
189+ true ,
190+ null
191+ )
192+ }
193+ }
194+ }
195+
163196 private fun stopDevWorkspace () {
164197 if (! listDevWorkspaces.isSelectionEmpty) {
165198 listDWDataModel
@@ -235,6 +268,16 @@ class DevSpacesWorkspacesStepView(
235268 )
236269 }
237270
271+ private fun waitDevWorkspaceNotStopped (devWorkspace : DevWorkspace ): Boolean {
272+ return DevWorkspaces (devSpacesContext.client)
273+ .waitPhaseChanges(
274+ devWorkspace.namespace,
275+ devWorkspace.name,
276+ listOf (DevWorkspaces .STOPPED , DevWorkspaces .FAILED ),
277+ 30
278+ )
279+ }
280+
238281 private fun waitDevWorkspaceStopped (devWorkspace : DevWorkspace ): Boolean {
239282 return DevWorkspaces (devSpacesContext.client)
240283 .waitPhase(
@@ -249,9 +292,11 @@ class DevSpacesWorkspacesStepView(
249292 runInEdt {
250293 val workspace = getSelectedWorkspace()
251294 val running = isRunning(workspace)
295+ val stopped = isStopped(workspace)
252296 val alreadyConnected = isAlreadyConnected(workspace)
253297
254298 // stop button enabled only if workspace is running
299+ startDevWorkspaceButton.isEnabled = stopped
255300 stopDevWorkspaceButton.isEnabled = running
256301
257302 // Enable/disable "Next" (connect) button dynamically
@@ -279,6 +324,10 @@ class DevSpacesWorkspacesStepView(
279324 return isRunning(workspace) && ! isAlreadyConnected(workspace)
280325 }
281326
327+ private fun isStopped (workspace : DevWorkspace ? ): Boolean {
328+ return workspace?.started == false
329+ }
330+
282331 private fun isRunning (workspace : DevWorkspace ? ): Boolean {
283332 return workspace?.running ? : false
284333 }
0 commit comments