@@ -14,6 +14,8 @@ import com.intellij.util.ui.UIUtil
14
14
import java.awt.BorderLayout
15
15
import java.awt.FlowLayout
16
16
import java.awt.GridLayout
17
+ import javax.swing.Box
18
+ import javax.swing.BoxLayout
17
19
import javax.swing.Icon
18
20
import javax.swing.JButton
19
21
import javax.swing.JPanel
@@ -163,10 +165,11 @@ class PlannerResultSummary(
163
165
}
164
166
165
167
private fun createChangeItemPanel (change : Change , fileName : String , filePath : String ): JPanel {
166
- return JPanel (BorderLayout () ).apply {
168
+ return JPanel ().apply {
167
169
isOpaque = true
168
170
background = UIUtil .getListBackground()
169
171
border = JBUI .Borders .empty(5 , 8 )
172
+ layout = BoxLayout (this , BoxLayout .X_AXIS )
170
173
171
174
val changeIcon = when (change.type) {
172
175
Change .Type .NEW -> AllIcons .Actions .New
@@ -175,16 +178,21 @@ class PlannerResultSummary(
175
178
else -> AllIcons .Actions .Edit
176
179
}
177
180
178
- val infoPanel = JPanel (BorderLayout ()).apply {
179
- isOpaque = false
180
-
181
- val fileLabel = JBLabel (fileName, changeIcon, JBLabel .LEFT ).apply {
182
- toolTipText = filePath
183
- }
184
-
185
- add(fileLabel, BorderLayout .CENTER )
181
+ val fileLabel = HyperlinkLabel (fileName).apply {
182
+ icon = changeIcon
183
+ toolTipText = filePath
184
+ addHyperlinkListener(object : HyperlinkListener {
185
+ override fun hyperlinkUpdate (e : HyperlinkEvent ) {
186
+ if (e.eventType == HyperlinkEvent .EventType .ACTIVATED ) {
187
+ changeActionListener.onView(change)
188
+ }
189
+ }
190
+ })
186
191
}
187
-
192
+
193
+ add(fileLabel)
194
+ add(Box .createHorizontalStrut(5 ))
195
+
188
196
val pathLabel = JBLabel (filePath).apply {
189
197
foreground = UIUtil .getLabelDisabledForeground()
190
198
toolTipText = filePath
@@ -193,17 +201,19 @@ class PlannerResultSummary(
193
201
putClientProperty(" JComponent.truncateText" , true )
194
202
putClientProperty(" truncateAtWord" , false )
195
203
putClientProperty(" html.disable" , true )
204
+ minimumSize = JBUI .size(20 , preferredSize.height)
205
+ preferredSize = JBUI .size(100 , preferredSize.height)
196
206
maximumSize = JBUI .size(Int .MAX_VALUE , preferredSize.height)
197
207
}
198
-
199
- val pathPanel = JPanel (BorderLayout ()).apply {
200
- isOpaque = false
201
- add(pathLabel, BorderLayout .CENTER )
202
- }
203
-
204
- val actionsPanel = JPanel (FlowLayout (FlowLayout .RIGHT , 2 , 0 )).apply {
208
+
209
+ add(pathLabel)
210
+ add(Box .createHorizontalGlue()) // This pushes the action buttons to the right
211
+
212
+ // Action buttons
213
+ val actionsPanel = JPanel ().apply {
205
214
isOpaque = false
206
-
215
+ layout = BoxLayout (this , BoxLayout .X_AXIS )
216
+
207
217
val viewButton = createActionButton(
208
218
AllIcons .Actions .Preview ,
209
219
" View changes"
@@ -215,12 +225,11 @@ class PlannerResultSummary(
215
225
) { changeActionListener.onDiscard(change) }
216
226
217
227
add(viewButton)
228
+ add(Box .createHorizontalStrut(2 ))
218
229
add(discardButton)
219
230
}
220
-
221
- add(infoPanel, BorderLayout .NORTH )
222
- add(pathPanel, BorderLayout .CENTER )
223
- add(actionsPanel, BorderLayout .EAST )
231
+
232
+ add(actionsPanel)
224
233
}
225
234
}
226
235
0 commit comments