From 495a38aac2a0b28a4b1b84f7fc06c611b31c1f7a Mon Sep 17 00:00:00 2001 From: Tsonglew Date: Thu, 4 Jan 2024 21:43:54 +0800 Subject: [PATCH] fix: [action] removal api --- build.gradle.kts | 4 +-- .../view/editor/EtcdKeyTreeDisplayPanel.kt | 30 +++++++++++-------- .../view/editor/EtcdValueDisplayPanel.kt | 30 +++++++++++-------- src/main/resources/META-INF/plugin.xml | 4 +++ 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 09e172e..ac9211f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "com.github.tsonglew" -version = "1.4.2" +version = "1.4.3" repositories { mavenCentral() @@ -42,7 +42,7 @@ tasks { } patchPluginXml { - sinceBuild.set("233") + sinceBuild.set("232") untilBuild.set(provider { null }) } diff --git a/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdKeyTreeDisplayPanel.kt b/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdKeyTreeDisplayPanel.kt index 4b084fd..93f6b3a 100644 --- a/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdKeyTreeDisplayPanel.kt +++ b/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdKeyTreeDisplayPanel.kt @@ -37,6 +37,7 @@ import com.github.tsonglew.etcdhelper.window.MainToolWindow import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.ActionPlaces import com.intellij.openapi.actionSystem.DefaultActionGroup +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ReadAction import com.intellij.openapi.project.Project import com.intellij.openapi.ui.LoadingDecorator @@ -117,7 +118,7 @@ class EtcdKeyTreeDisplayPanel( .apply { sortedBy { it.key.toString() } } keyDisplayLoadingDecorator.startLoading(false) keyCountLabel.text = "Key counts: ${allKeys.size}" - ReadAction.nonBlocking { + ReadAction.nonBlocking { try { flatRootNode = DefaultMutableTreeNode(etcdConnectionInfo).apply { isVisible = false @@ -127,6 +128,7 @@ class EtcdKeyTreeDisplayPanel( } finally { keyDisplayLoadingDecorator.stopLoading() } + }.submit(ThreadPoolManager.executor) } @@ -166,18 +168,20 @@ class EtcdKeyTreeDisplayPanel( if (flatRootNode == null) { return } - groupRootNode( - flatRootNode!!, - LinkedHashMap().apply { - allKeys.forEach { - this[it.key.toString()] = it - } - }, - keyValueDisplayPanel.groupSymbol.ifBlank { " " } - ) - treeModel = DefaultTreeModel(flatRootNode) - keyTree.model = treeModel - treeModel!!.reload() + ApplicationManager.getApplication().invokeLater { + groupRootNode( + flatRootNode!!, + LinkedHashMap().apply { + allKeys.forEach { + this[it.key.toString()] = it + } + }, + keyValueDisplayPanel.groupSymbol.ifBlank { " " } + ) + treeModel = DefaultTreeModel(flatRootNode) + keyTree.model = treeModel + treeModel!!.reload() + } } private fun groupRootNode( diff --git a/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdValueDisplayPanel.kt b/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdValueDisplayPanel.kt index fae1afd..06b6f62 100644 --- a/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdValueDisplayPanel.kt +++ b/src/main/kotlin/com/github/tsonglew/etcdhelper/view/editor/EtcdValueDisplayPanel.kt @@ -26,11 +26,9 @@ package com.github.tsonglew.etcdhelper.view.editor import com.github.tsonglew.etcdhelper.common.ConnectionManager import com.github.tsonglew.etcdhelper.common.EtcdConnectionInfo -import com.github.tsonglew.etcdhelper.common.ThreadPoolManager import com.github.tsonglew.etcdhelper.listener.KeyReleasedListener import com.intellij.icons.AllIcons import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.ReadAction import com.intellij.openapi.fileTypes.PlainTextLanguage import com.intellij.openapi.project.Project import com.intellij.openapi.ui.LoadingDecorator @@ -78,17 +76,24 @@ class EtcdValueDisplayPanel : JPanel(BorderLayout()) { this.loadingDecorator = loadingDecorator loadingDecorator.startLoading(false) - ReadAction.nonBlocking { + ApplicationManager.getApplication().invokeLater { try { - ApplicationManager.getApplication().invokeLater(this::initWithValue) + initWithValue() } finally { loadingDecorator.stopLoading() } - }.submit(ThreadPoolManager.executor) + } +// ReadAction.nonBlocking { +// try { +// ApplicationManager.getApplication().invokeLater(this::initWithValue) +// } finally { +// loadingDecorator.stopLoading() +// } +// }.submit(ThreadPoolManager.executor) } private val keyValue: KeyValue? - get() = connectionManager.getClient(etcdConnectionInfo)?.get(key)?.let { + get() = connectionManager.getClient(etcdConnectionInfo).get(key).let { if (it.isNotEmpty()) it[0] else null } @@ -136,11 +141,12 @@ class EtcdValueDisplayPanel : JPanel(BorderLayout()) { add(JButton("Save", AllIcons.Actions.MenuSaveall).apply { addActionListener { isEnabled = false - connectionManager.getClient(etcdConnectionInfo)?.put( - key, - valueTextArea.text, - if (ttlTextField?.text?.isBlank() == true) 0 else ttlTextField?.text?.toInt() - ?: 0) + connectionManager.getClient(etcdConnectionInfo).put( + key, + valueTextArea.text, + if (ttlTextField?.text?.isBlank() == true) 0 else ttlTextField?.text?.toInt() + ?: 0 + ) renderLabels() isEnabled = true } @@ -210,7 +216,7 @@ class EtcdValueDisplayPanel : JPanel(BorderLayout()) { modRevisionLabel.text = "Mod revision: ${kv?.modRevision}; " versionLabel.text = "Version: ${kv?.version}; " kv?.lease?.apply { - connectionManager.getClient(etcdConnectionInfo)?.getLeaseInfo(this).also { + connectionManager.getClient(etcdConnectionInfo).getLeaseInfo(this).also { leaseLabel.text = "Lease: %x; ".format(this) ttlTextField?.text = "%d".format(it) ttlTextField?.toolTipText = "%d".format(it) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index d793bf8..4367f77 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -2,6 +2,10 @@ +
    +
  • fix usage of scheduled for removal API
  • +
1.4.2
  • upgrade build tools