@@ -8,11 +8,16 @@ import com.intellij.openapi.actionSystem.AnAction
88import com.intellij.openapi.actionSystem.AnActionEvent
99import com.intellij.openapi.actionSystem.CommonDataKeys
1010import com.intellij.openapi.diagnostic.Logger
11+ import com.intellij.openapi.ide.CopyPasteManager
1112import com.intellij.openapi.project.Project
13+ import com.intellij.openapi.ui.DialogWrapper
1214import com.intellij.openapi.ui.Messages
15+ import java.awt.datatransfer.StringSelection
16+ import javax.swing.*
1317import com.sina.weibo.agent.extensions.core.ExtensionManager
1418import com.sina.weibo.agent.core.PluginContext
1519import com.sina.weibo.agent.core.ServiceProxyRegistry
20+ import com.sina.weibo.agent.util.ProxyConfigUtil
1621import com.sina.weibo.agent.webview.WebViewManager
1722
1823/* *
@@ -100,10 +105,83 @@ class ExtensionStatusChecker : AnAction("Check Extension Status") {
100105 sb.appendLine(" \n ❌ WebView Status Error: ${e.message} " )
101106 }
102107
108+ // Check Proxy status
109+ try {
110+ val proxyConfig = ProxyConfigUtil .getProxyConfig()
111+ sb.appendLine(" \n 🌐 Proxy Status:" )
112+
113+ val sourceDescription = when (proxyConfig.source) {
114+ " ide-pac" -> " IDE Settings (PAC)"
115+ " ide-http" -> " IDE Settings (HTTP Proxy)"
116+ " ide-none" -> " IDE Settings (No Proxy)"
117+ " env" -> " Environment Variables"
118+ " none" -> " No Proxy Configuration"
119+ " ide-error" -> " IDE Settings (Error)"
120+ " env-error" -> " Environment Variables (Error)"
121+ else -> proxyConfig.source
122+ }
123+ sb.appendLine(" Source: $sourceDescription " )
124+
125+ if (proxyConfig.hasProxy) {
126+ if (! proxyConfig.pacUrl.isNullOrEmpty()) {
127+ sb.appendLine(" PAC URL: ${proxyConfig.pacUrl} " )
128+ } else if (! proxyConfig.proxyUrl.isNullOrEmpty()) {
129+ sb.appendLine(" Proxy URL: ${proxyConfig.proxyUrl} " )
130+ }
131+
132+ if (! proxyConfig.proxyExceptions.isNullOrEmpty()) {
133+ sb.appendLine(" No Proxy For: ${proxyConfig.proxyExceptions} " )
134+ }
135+ } else {
136+ sb.appendLine(" No proxy configuration found" )
137+ }
138+ } catch (e: Exception ) {
139+ sb.appendLine(" \n ❌ Proxy Status Error: ${e.message} " )
140+ }
141+
103142 return sb.toString()
104143 }
105144
106145 private fun showStatusDialog (status : String ) {
107- Messages .showInfoMessage(status, " Extension Status" )
146+ val dialog = ExtensionStatusDialog (status)
147+ dialog.show()
148+ }
149+
150+ private class ExtensionStatusDialog (private val statusText : String ) : DialogWrapper(true ) {
151+
152+ init {
153+ title = " Extension Status"
154+ init ()
155+ }
156+
157+ override fun createCenterPanel (): JComponent {
158+ val panel = JPanel ()
159+ panel.layout = BoxLayout (panel, BoxLayout .Y_AXIS )
160+
161+ val textArea = JTextArea (statusText)
162+ textArea.isEditable = false
163+ textArea.font = JLabel ().font
164+ textArea.background = JLabel ().background
165+
166+ val scrollPane = JScrollPane (textArea)
167+ scrollPane.preferredSize = java.awt.Dimension (600 , 400 )
168+ scrollPane.verticalScrollBarPolicy = JScrollPane .VERTICAL_SCROLLBAR_AS_NEEDED
169+ scrollPane.horizontalScrollBarPolicy = JScrollPane .HORIZONTAL_SCROLLBAR_AS_NEEDED
170+
171+ panel.add(scrollPane)
172+ return panel
173+ }
174+
175+ override fun createActions (): Array <Action > {
176+ val copyAction = object : AbstractAction (" Copy to Clipboard" ) {
177+ override fun actionPerformed (e : java.awt.event.ActionEvent ? ) {
178+ val selection = StringSelection (statusText)
179+ CopyPasteManager .getInstance().setContents(selection)
180+ Messages .showInfoMessage(" Status information copied to clipboard!" , " Copied" )
181+ }
182+ }
183+
184+ return arrayOf(copyAction, okAction)
185+ }
108186 }
109187}
0 commit comments