From 486699dc782538005b11cc7a0ca9e5b13bbd8b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=85=B8=E5=85=B8?= <413153189@qq.com> Date: Sat, 17 Aug 2024 11:26:30 +0800 Subject: [PATCH] bug fix --- .../shop/itbug/salvorstool/window/ApiScanWindow.kt | 9 +++++---- .../kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt b/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt index 02f30a7..40cb487 100644 --- a/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt +++ b/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt @@ -12,7 +12,6 @@ import com.intellij.openapi.ui.popup.ListPopup import com.intellij.openapi.wm.ToolWindow import com.intellij.openapi.wm.ToolWindowManager import com.intellij.openapi.wm.ex.ToolWindowManagerListener -import com.intellij.platform.ide.impl.statistic.ToolWindowStateListener import com.intellij.ui.ColoredListCellRenderer import com.intellij.ui.ColoredText import com.intellij.ui.SearchTextField @@ -210,16 +209,18 @@ class SalvoApiItemRender : ColoredListCellRenderer() { } +/** + * 监听salvo窗口的显示,然后刷新api列表 + */ class ApiScanListen(val project: Project) : ToolWindowManagerListener { override fun stateChanged( toolWindowManager: ToolWindowManager, - toolWindow: ToolWindow, changeType: ToolWindowManagerListener.ToolWindowManagerEventType ) { - if(changeType == ToolWindowManagerListener.ToolWindowManagerEventType.ActivateToolWindow && toolWindow.isSalvoWindow()){ + if(changeType == ToolWindowManagerListener.ToolWindowManagerEventType.ActivateToolWindow && isSalvoWindow(toolWindowManager.activeToolWindowId)){ SalvoApiService.getInstance(project).startScan() } - super.stateChanged(toolWindowManager, toolWindow, changeType) + super.stateChanged(toolWindowManager, changeType) } } diff --git a/src/main/kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt b/src/main/kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt index 4090cfb..e4b8f16 100644 --- a/src/main/kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt +++ b/src/main/kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt @@ -15,10 +15,14 @@ class SalvoWindow : ToolWindowFactory { val tempWindow = TempFilesWindow(project) val tempWindowContent = contentFactory.createContent(tempWindow,"Temp",false) toolWindow.contentManager.addContent(tempWindowContent) - } + } fun ToolWindow.isSalvoWindow(): Boolean { - return this.id == "Salvo" + return isSalvoWindow(this.id) +} + +fun isSalvoWindow(id: String?): Boolean { + return id == "Salvo" } \ No newline at end of file