@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger
20
20
import com.intellij.openapi.ui.ComboBox
21
21
import com.intellij.openapi.ui.ComponentValidator
22
22
import com.intellij.openapi.ui.ValidationInfo
23
+ import com.intellij.openapi.ui.panel.ComponentPanelBuilder
23
24
import com.intellij.openapi.util.Disposer
24
25
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
25
26
import com.intellij.remote.AuthType
@@ -29,12 +30,9 @@ import com.intellij.ui.AnimatedIcon
29
30
import com.intellij.ui.ColoredListCellRenderer
30
31
import com.intellij.ui.DocumentAdapter
31
32
import com.intellij.ui.components.JBTextField
32
- import com.intellij.ui.dsl.builder.AlignX
33
- import com.intellij.ui.dsl.builder.BottomGap
34
- import com.intellij.ui.dsl.builder.RowLayout
35
- import com.intellij.ui.dsl.builder.TopGap
36
- import com.intellij.ui.dsl.builder.panel
33
+ import com.intellij.ui.dsl.builder.*
37
34
import com.intellij.util.ui.JBFont
35
+ import com.intellij.util.ui.JBUI
38
36
import com.intellij.util.ui.UIUtil
39
37
import com.intellij.util.ui.update.MergingUpdateQueue
40
38
import com.intellij.util.ui.update.Update
@@ -73,7 +71,7 @@ import javax.swing.ListCellRenderer
73
71
import javax.swing.SwingConstants
74
72
import javax.swing.event.DocumentEvent
75
73
76
- class CoderLocateRemoteProjectStepView (private val disableNextAction : () -> Unit ) : CoderWorkspacesWizardStep, Disposable {
74
+ class CoderLocateRemoteProjectStepView (private val setNextButtonEnabled : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
77
75
private val cs = CoroutineScope (Dispatchers .Main )
78
76
private val coderClient: CoderRestClientService = ApplicationManager .getApplication().getService(CoderRestClientService ::class .java)
79
77
@@ -82,44 +80,71 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
82
80
private lateinit var titleLabel: JLabel
83
81
private lateinit var wizard: CoderWorkspacesWizardModel
84
82
private lateinit var cbIDE: IDEComboBox
83
+ private lateinit var cbIDEComment: JLabel
85
84
private var tfProject = JBTextField ()
86
85
private lateinit var terminalLink: LazyBrowserLink
87
86
private lateinit var ideResolvingJob: Job
88
87
private val pathValidationJobs = MergingUpdateQueue (" remote-path-validation" , 1000 , true , tfProject)
89
88
90
89
override val component = panel {
91
- indent {
92
- row {
93
- titleLabel = label(" " ).applyToComponent {
94
- font = JBFont .h3().asBold()
95
- icon = CoderIcons .LOGO_16
96
- }.component
97
- }.bottomGap(BottomGap .MEDIUM )
90
+ row {
91
+ titleLabel = label(" " ).applyToComponent {
92
+ font = JBFont .h3().asBold()
93
+ icon = CoderIcons .LOGO_16
94
+ }.component
95
+ }.topGap(TopGap .SMALL )
96
+ row {
97
+ label(" IDE:" )
98
+ cbIDE = cell(IDEComboBox (ideComboBoxModel).apply {
99
+ renderer = IDECellRenderer ()
100
+ addActionListener {
101
+ setNextButtonEnabled(this .selectedItem != null )
102
+ ApplicationManager .getApplication().invokeLater {
103
+ logger.info(" Selected IDE: ${this .selectedItem} " )
104
+ when (this .selectedItem?.status) {
105
+ IdeStatus .ALREADY_INSTALLED ->
106
+ cbIDEComment.text =
107
+ CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.ide.installed.comment" )
98
108
99
- row {
100
- label(" IDE:" )
101
- cbIDE = cell(IDEComboBox (ideComboBoxModel).apply {
102
- renderer = IDECellRenderer ()
103
- }).resizableColumn().align(AlignX .FILL ).comment(" The IDE will be downloaded from jetbrains.com" ).component
104
- cell()
105
- }.topGap(TopGap .NONE ).layout(RowLayout .PARENT_GRID )
109
+ IdeStatus .DOWNLOAD ->
110
+ cbIDEComment.text =
111
+ CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.ide.download.comment" )
106
112
107
- row {
108
- label(" Project directory:" )
109
- cell(tfProject).resizableColumn().align(AlignX .FILL ).component
110
- cell()
111
- }.topGap(TopGap .NONE ).bottomGap(BottomGap .NONE ).layout(RowLayout .PARENT_GRID )
112
- row {
113
- cell()
114
- terminalLink = cell(
115
- LazyBrowserLink (
116
- CoderIcons .OPEN_TERMINAL ,
117
- " Open Terminal"
118
- )
119
- ).component
120
- }.topGap(TopGap .NONE ).layout(RowLayout .PARENT_GRID )
121
- }
122
- }.apply { background = WelcomeScreenUIManager .getMainAssociatedComponentBackground() }
113
+ else ->
114
+ cbIDEComment.text =
115
+ CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.ide.none.comment" )
116
+ }
117
+ }
118
+ }
119
+ }).resizableColumn().align(AlignX .FILL ).component
120
+ }.topGap(TopGap .NONE ).bottomGap(BottomGap .NONE ).layout(RowLayout .PARENT_GRID )
121
+ row {
122
+ cell() // Empty cell for alignment.
123
+ cbIDEComment = cell(
124
+ ComponentPanelBuilder .createCommentComponent(
125
+ CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.ide.none.comment" ),
126
+ false , - 1 , true
127
+ )
128
+ ).component
129
+ }.topGap(TopGap .NONE ).bottomGap(BottomGap .NONE ).layout(RowLayout .PARENT_GRID )
130
+ row {
131
+ label(" Project directory:" )
132
+ cell(tfProject).resizableColumn().align(AlignX .FILL ).component
133
+ }.topGap(TopGap .NONE ).bottomGap(BottomGap .NONE ).layout(RowLayout .PARENT_GRID )
134
+ row {
135
+ cell() // Empty cell for alignment.
136
+ terminalLink = cell(
137
+ LazyBrowserLink (
138
+ CoderIcons .OPEN_TERMINAL ,
139
+ " Open Terminal"
140
+ )
141
+ ).component
142
+ }.topGap(TopGap .NONE ).layout(RowLayout .PARENT_GRID )
143
+ gap(RightGap .SMALL )
144
+ }.apply {
145
+ background = WelcomeScreenUIManager .getMainAssociatedComponentBackground()
146
+ border = JBUI .Borders .empty(0 , 16 , 0 , 16 )
147
+ }
123
148
124
149
override val previousActionText = IdeBundle .message(" button.back" )
125
150
override val nextActionText = CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.next.text" )
@@ -153,7 +178,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
153
178
is SshException -> {
154
179
logger.error(" Can't connect to workspace ${selectedWorkspace.name} . Reason: $e " )
155
180
withContext(Dispatchers .Main ) {
156
- disableNextAction( )
181
+ setNextButtonEnabled( false )
157
182
cbIDE.renderer = object : ColoredListCellRenderer <IdeWithStatus >() {
158
183
override fun customizeCellRenderer (list : JList <out IdeWithStatus >, value : IdeWithStatus ? , index : Int , isSelected : Boolean , cellHasFocus : Boolean ) {
159
184
background = UIUtil .getListBackground(isSelected, cellHasFocus)
@@ -167,7 +192,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
167
192
else -> {
168
193
logger.error(" Could not resolve any IDE for workspace ${selectedWorkspace.name} . Reason: $e " )
169
194
withContext(Dispatchers .Main ) {
170
- disableNextAction( )
195
+ setNextButtonEnabled( false )
171
196
cbIDE.renderer = object : ColoredListCellRenderer <IdeWithStatus >() {
172
197
override fun customizeCellRenderer (list : JList <out IdeWithStatus >, value : IdeWithStatus ? , index : Int , isSelected : Boolean , cellHasFocus : Boolean ) {
173
198
background = UIUtil .getListBackground(isSelected, cellHasFocus)
0 commit comments