Skip to content

Commit

Permalink
合并拉取请求 #52
Browse files Browse the repository at this point in the history
2.0.8
  • Loading branch information
mdddj authored Aug 17, 2024
2 parents 5b1c9c2 + 486699d commit 614c925
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -210,16 +209,18 @@ class SalvoApiItemRender : ColoredListCellRenderer<SalvoApiItem>() {
}


/**
* 监听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)
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/shop/itbug/salvorstool/window/SalvoWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 614c925

Please sign in to comment.