@@ -14,6 +14,7 @@ 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.Icon
17
18
import javax.swing.JButton
18
19
import javax.swing.JPanel
19
20
import javax.swing.event.HyperlinkEvent
@@ -187,45 +188,54 @@ class PlannerResultSummary(
187
188
val pathLabel = JBLabel (filePath).apply {
188
189
foreground = UIUtil .getLabelDisabledForeground()
189
190
toolTipText = filePath
191
+ isOpaque = false
192
+ componentStyle = UIUtil .ComponentStyle .SMALL
193
+ putClientProperty(" JComponent.truncateText" , true )
194
+ putClientProperty(" truncateAtWord" , false )
195
+ putClientProperty(" html.disable" , true )
196
+ maximumSize = JBUI .size(Int .MAX_VALUE , preferredSize.height)
197
+ }
198
+
199
+ val pathPanel = JPanel (BorderLayout ()).apply {
200
+ isOpaque = false
201
+ add(pathLabel, BorderLayout .CENTER )
190
202
}
191
203
192
204
val actionsPanel = JPanel (FlowLayout (FlowLayout .RIGHT , 2 , 0 )).apply {
193
205
isOpaque = false
194
206
195
- val viewButton = JButton ().apply {
196
- icon = AllIcons .Actions .Preview
197
- toolTipText = " View changes"
198
- isBorderPainted = false
199
- isContentAreaFilled = false
200
- isFocusPainted = false
201
- margin = JBUI .emptyInsets()
202
- preferredSize = JBUI .size(20 , 20 )
203
- addActionListener {
204
- changeActionListener?.onView(change)
205
- }
206
- }
207
+ val viewButton = createActionButton(
208
+ AllIcons .Actions .Preview ,
209
+ " View changes"
210
+ ) { changeActionListener.onView(change) }
207
211
208
- val discardButton = JButton ().apply {
209
- icon = AllIcons .Actions .Cancel
210
- toolTipText = " Discard changes"
211
- isBorderPainted = false
212
- isContentAreaFilled = false
213
- isFocusPainted = false
214
- margin = JBUI .emptyInsets()
215
- preferredSize = JBUI .size(20 , 20 )
216
- addActionListener {
217
- changeActionListener?.onDiscard(change)
218
- }
219
- }
212
+ val discardButton = createActionButton(
213
+ AllIcons .Actions .Cancel ,
214
+ " Discard changes"
215
+ ) { changeActionListener.onDiscard(change) }
220
216
221
217
add(viewButton)
222
218
add(discardButton)
223
219
}
224
220
225
221
add(infoPanel, BorderLayout .NORTH )
226
- add(pathLabel , BorderLayout .CENTER )
222
+ add(pathPanel , BorderLayout .CENTER )
227
223
add(actionsPanel, BorderLayout .EAST )
228
224
}
229
225
}
230
- }
231
226
227
+ private fun createActionButton (
228
+ icon : Icon ,
229
+ tooltip : String ,
230
+ action : () -> Unit
231
+ ): JButton = JButton ().apply {
232
+ this .icon = icon
233
+ toolTipText = tooltip
234
+ isBorderPainted = false
235
+ isContentAreaFilled = false
236
+ isFocusPainted = false
237
+ margin = JBUI .emptyInsets()
238
+ preferredSize = JBUI .size(20 , 20 )
239
+ addActionListener { action() }
240
+ }
241
+ }
0 commit comments