File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
src/main/kotlin/com/huayi/intellijplatform/gitstats/components Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.huayi.intellijplatform.gitstats.components
2
+
3
+ import java.awt.event.ActionEvent
4
+ import java.awt.event.ActionListener
5
+ import javax.swing.JButton
6
+ import javax.swing.SwingWorker
7
+
8
+
9
+ class RefreshButton (text : String? ) : JButton(text), ActionListener {
10
+ private var isLoading = false
11
+
12
+ init {
13
+ addActionListener(this )
14
+ }
15
+
16
+ override fun actionPerformed (e : ActionEvent ) {
17
+ isLoading = true
18
+ isEnabled = false
19
+ text = " Loading..."
20
+ BackgroundTask ().execute()
21
+ }
22
+
23
+ private inner class BackgroundTask : SwingWorker <String , String >() {
24
+ override fun doInBackground (): String {
25
+ return " null"
26
+ }
27
+
28
+ override fun done () {
29
+ isLoading = false
30
+ isEnabled = true
31
+ text = " Click me"
32
+ }
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ package com.huayi.intellijplatform.gitstats.components
2
+
3
+ import com.intellij.icons.AllIcons
4
+ import com.intellij.openapi.actionSystem.AnActionEvent
5
+ import com.intellij.openapi.project.DumbAwareAction
6
+ import org.jetbrains.annotations.Nls
7
+ import java.util.function.Supplier
8
+
9
+ class SettingAction (text : @Nls String , defaultMode : String , private val onSelectedModeChanged : (String ) -> Unit ) :
10
+ DumbAwareAction (Supplier { text }, AllIcons .General .Settings ) {
11
+ private var selectedMode: String = defaultMode
12
+ set(value) {
13
+ field = value
14
+ onSelectedModeChanged.invoke(value)
15
+ }
16
+
17
+ override fun actionPerformed (e : AnActionEvent ) {
18
+ val dialogWrapper = SettingDialogWrapper (selectedMode)
19
+ dialogWrapper.showAndGet()
20
+ if (dialogWrapper.isOK) {
21
+ selectedMode = dialogWrapper.selectedMode
22
+ }
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments