Skip to content

Commit

Permalink
fix: [action] removal api
Browse files Browse the repository at this point in the history
  • Loading branch information
tsonglew committed Jan 4, 2024
1 parent 12da98f commit 495a38a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "com.github.tsonglew"
version = "1.4.2"
version = "1.4.3"

repositories {
mavenCentral()
Expand Down Expand Up @@ -42,7 +42,7 @@ tasks {
}

patchPluginXml {
sinceBuild.set("233")
sinceBuild.set("232")
untilBuild.set(provider { null })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,7 +118,7 @@ class EtcdKeyTreeDisplayPanel(
.apply { sortedBy { it.key.toString() } }
keyDisplayLoadingDecorator.startLoading(false)
keyCountLabel.text = "Key counts: ${allKeys.size}"
ReadAction.nonBlocking {
ReadAction.nonBlocking<Any?> {
try {
flatRootNode = DefaultMutableTreeNode(etcdConnectionInfo).apply {
isVisible = false
Expand All @@ -127,6 +128,7 @@ class EtcdKeyTreeDisplayPanel(
} finally {
keyDisplayLoadingDecorator.stopLoading()
}

}.submit(ThreadPoolManager.executor)
}

Expand Down Expand Up @@ -166,18 +168,20 @@ class EtcdKeyTreeDisplayPanel(
if (flatRootNode == null) {
return
}
groupRootNode(
flatRootNode!!,
LinkedHashMap<String, KeyValue>().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<String, KeyValue>().apply {
allKeys.forEach {
this[it.key.toString()] = it
}
},
keyValueDisplayPanel.groupSymbol.ifBlank { " " }
)
treeModel = DefaultTreeModel(flatRootNode)
keyTree.model = treeModel
treeModel!!.reload()
}
}

private fun groupRootNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Any?> {
// 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
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<idea-plugin>
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
<change-notes><![CDATA[
1.4.3<br>
<ul>
<li> fix usage of scheduled for removal API </li>
</ul>
1.4.2<br>
<ul>
<li>upgrade build tools</li>
Expand Down

0 comments on commit 495a38a

Please sign in to comment.