@@ -2,7 +2,7 @@ package cc.unitmesh.devti.gui.planner
2
2
3
3
import com.intellij.ide.ui.LafManagerListener
4
4
import com.intellij.openapi.project.Project
5
- import com.intellij.util.ui.StartupUiUtil.isDarkTheme
5
+ import com.intellij.util.ui.JBUI
6
6
import java.awt.*
7
7
import java.awt.event.ActionEvent
8
8
import java.awt.event.ActionListener
@@ -52,6 +52,8 @@ class LoadingPanel(val project: Project) : JPanel() {
52
52
private val darkProgressBackground = Color (55 , 65 , 81 )
53
53
54
54
init {
55
+ val isDarkTheme = UIManager .getLookAndFeelDefaults().getBoolean(" ui.theme.is.dark" )
56
+
55
57
isDarkMode = isDarkTheme
56
58
project.messageBus.connect().subscribe(
57
59
LafManagerListener .TOPIC ,
@@ -63,7 +65,7 @@ class LoadingPanel(val project: Project) : JPanel() {
63
65
)
64
66
65
67
setLayout(BorderLayout ())
66
- setBorder(EmptyBorder ( 20 , 20 , 20 , 20 ))
68
+ setBorder(JBUI . Borders .empty( 20 ))
67
69
setOpaque(false )
68
70
69
71
glassPanel = object : JPanel (BorderLayout ()) {
@@ -75,33 +77,29 @@ class LoadingPanel(val project: Project) : JPanel() {
75
77
val width = getWidth()
76
78
val height = getHeight()
77
79
78
-
79
- // Create rounded rectangle for the panel
80
80
val roundedRect: RoundRectangle2D =
81
81
RoundRectangle2D .Float (0f , 0f , width.toFloat(), height.toFloat(), 15f , 15f )
82
- g2d.setClip( roundedRect)
82
+ g2d.clip = roundedRect
83
83
84
84
val color1 = if (isDarkMode) Color (30 , 40 , 70 , 200 ) else Color (240 , 245 , 255 , 200 )
85
85
val color2 = if (isDarkMode) Color (40 , 30 , 70 , 200 ) else Color (245 , 240 , 255 , 200 )
86
- val color3 = if (isDarkMode) Color (35 , 35 , 60 , 200 ) else Color (250 , 245 , 255 , 200 )
87
86
88
87
val pos1 = (gradientPosition) % 1.0f
89
88
val pos2 = (gradientPosition + 0.33f ) % 1.0f
90
- val pos3 = (gradientPosition + 0.66f ) % 1.0f
91
89
92
90
val gradient = GradientPaint (
93
91
width * pos1, 0f , color1,
94
92
width * pos2, height.toFloat(), color2
95
93
)
96
94
97
- g2d.setPaint( gradient)
95
+ g2d.paint = gradient
98
96
g2d.fill(roundedRect)
99
97
100
- g2d.setComposite( AlphaComposite .getInstance(AlphaComposite .SRC_OVER , 0.1f ) )
101
- g2d.setColor( Color .WHITE )
98
+ g2d.composite = AlphaComposite .getInstance(AlphaComposite .SRC_OVER , 0.1f )
99
+ g2d.color = Color .WHITE
102
100
g2d.fillRect(0 , 0 , width, height / 2 )
103
101
104
- g2d.setComposite( AlphaComposite .getInstance(AlphaComposite .SRC_OVER , opacity) )
102
+ g2d.composite = AlphaComposite .getInstance(AlphaComposite .SRC_OVER , opacity)
105
103
g2d.dispose()
106
104
}
107
105
}
@@ -111,15 +109,15 @@ class LoadingPanel(val project: Project) : JPanel() {
111
109
112
110
contentPanel = JPanel (BorderLayout (10 , 10 ))
113
111
contentPanel.setOpaque(false )
114
- contentPanel.setBorder(EmptyBorder ( 15 , 15 , 15 , 15 ))
112
+ contentPanel.setBorder(JBUI . Borders .empty( 12 ))
115
113
116
114
emojiLabel = JLabel ()
117
115
emojiLabel.setFont(Font (" Segoe UI Emoji" , Font .PLAIN , 24 ))
118
116
emojiLabel.setHorizontalAlignment(SwingConstants .CENTER )
119
- emojiLabel.setPreferredSize( Dimension (40 , 40 ) )
117
+ emojiLabel.preferredSize = Dimension (40 , 40 )
120
118
121
119
messagePane = JTextPane ()
122
- messagePane.setEditable( false )
120
+ messagePane.isEditable = false
123
121
messagePane.setOpaque(false )
124
122
messagePane.setFont(Font (" Monospaced" , Font .PLAIN , 14 ))
125
123
messagePane.setBorder(null )
@@ -128,7 +126,7 @@ class LoadingPanel(val project: Project) : JPanel() {
128
126
progressBar.setStringPainted(false )
129
127
progressBar.setBorderPainted(false )
130
128
progressBar.setOpaque(false )
131
- progressBar.setPreferredSize( Dimension (0 , 5 ) )
129
+ progressBar.preferredSize = Dimension (0 , 5 )
132
130
progressBar.setUI(object : BasicProgressBarUI () {
133
131
override fun paintDeterminate (g : Graphics , c : JComponent ) {
134
132
val g2d = g.create() as Graphics2D
@@ -215,7 +213,7 @@ class LoadingPanel(val project: Project) : JPanel() {
215
213
}
216
214
217
215
private fun updateTypingAnimation () {
218
- val message = loadingMessages.get( messageIndex)
216
+ val message = loadingMessages[ messageIndex]
219
217
val textPart = message.substring(message.indexOf(' ' ) + 1 )
220
218
221
219
if (charIndex < textPart.length) {
@@ -238,25 +236,25 @@ class LoadingPanel(val project: Project) : JPanel() {
238
236
}
239
237
240
238
private fun updateMessageText () {
241
- val doc = messagePane.getStyledDocument()
239
+ val doc = messagePane.styledDocument
242
240
val style = messagePane.addStyle(" MessageStyle" , null )
243
241
StyleConstants .setForeground(style, if (isDarkMode) darkForeground else lightForeground)
244
242
StyleConstants .setFontFamily(style, " Monospaced" )
245
243
StyleConstants .setFontSize(style, 14 )
246
244
247
245
try {
248
- doc.remove(0 , doc.getLength() )
246
+ doc.remove(0 , doc.length )
249
247
doc.insertString(0 , currentText, style)
250
248
251
249
StyleConstants .setForeground(style, progressColor)
252
- doc.insertString(doc.getLength() , " |" , style)
250
+ doc.insertString(doc.length , " |" , style)
253
251
} catch (e: BadLocationException ) {
254
252
e.printStackTrace()
255
253
}
256
254
}
257
255
258
256
private fun updateEmojiLabel () {
259
- val message = loadingMessages.get( messageIndex)
257
+ val message = loadingMessages[ messageIndex]
260
258
val emoji = message.substring(0 , message.indexOf(' ' ))
261
259
emojiLabel.setText(emoji)
262
260
}
0 commit comments