diff --git a/build.gradle.kts b/build.gradle.kts
index 7dc64671..5ec85aa8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,10 +1,20 @@
+
+val dartVersion: String by project
+val flutterVersion: String by project
+val sinceBuildVersion: String by project
+val untilBuildVersion: String by project
+val ideaVersion: String by project
+val ideaType: String by project
+val pluginVersion: String by project
+
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.0-RC"
- id("org.jetbrains.intellij") version "1.15.0"
- id("org.jetbrains.kotlin.plugin.serialization") version "1.8.21"
+ id("org.jetbrains.intellij") version "1.16.0"
+ id("org.jetbrains.kotlin.plugin.serialization") version "1.9.20-RC"
}
group = "shop.itbug"
-version = "3.5.1.as"
+version = pluginVersion
+
repositories {
mavenCentral()
google()
@@ -16,20 +26,20 @@ repositories {
+
intellij {
- version.set("2022.3.1.18")
- type.set("AI")
+ version.set(ideaVersion)
+ type.set(ideaType)
plugins.set(
listOf(
"yaml",
- "Dart:223.8950",
- "io.flutter:74.0.3",
+ "Dart:$dartVersion",
+ "io.flutter:$flutterVersion",
"org.intellij.plugins.markdown",
- "terminal"
+ "terminal",
)
)
}
-
kotlin {
sourceSets.all {
languageSettings {
@@ -41,25 +51,18 @@ kotlin {
}
dependencies {
- implementation("com.squareup.retrofit2:retrofit:2.9.0")
- implementation("com.squareup.retrofit2:converter-gson:2.9.0")
- implementation("com.github.ben-manes.caffeine:caffeine:3.1.5")
- implementation("cn.hutool:hutool-all:5.8.15")
- implementation("org.smartboot.socket:aio-core:1.6.3")
- implementation("com.alibaba.fastjson2:fastjson2:2.0.25")
- implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.25")
- implementation("org.apache.commons:commons-lang3:3.12.0")
- implementation("com.google.code.gson:gson:2.10.1")
- implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
- implementation("org.xerial:sqlite-jdbc:3.40.1.0")
- implementation("io.ktor:ktor-client-cio-jvm:2.2.4")
- implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
+ implementation("com.squareup.retrofit2:retrofit:latest.release")
+ implementation("com.squareup.retrofit2:converter-gson:latest.release")
+ implementation("cn.hutool:hutool-all:latest.release")
+ implementation("org.smartboot.socket:aio-core:latest.release")
+ implementation("com.alibaba.fastjson2:fastjson2:latest.release")
+ implementation("com.alibaba.fastjson2:fastjson2-kotlin:latest.release")
+ implementation("com.google.code.gson:gson:latest.release")
+ implementation("org.xerial:sqlite-jdbc:latest.release")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:latest.release")
}
-
-
-
var javaVersion = "17"
tasks {
@@ -76,10 +79,77 @@ tasks {
}
patchPluginXml {
- sinceBuild.set("223")
- untilBuild.set("223.*")
+ sinceBuild.set(sinceBuildVersion)
+ untilBuild.set(untilBuildVersion)
changeNotes.set(
"""
+
+
3.7.0
+
+ - Dependency version detection using
ExternalAnnotator
override
+ - Change the plugin name to: FlutterX
+ - Removed Hive tool window, functionality is currently under development
+ - Subsequent version update logs are only written in English
+ - Add the 'Ignore Dependency Version Detection' feature
+
+ -
+ New parameter inline display
+
+
+
+
+
+
+
+
3.6.1
+
+
+
+
+
+
+
+
+
+
+
+
+
3.6.0
+
+ - Bug 修复
+ - 添加shared_preferences查看工具
+
+
+
+ - Bug fix
+ - Add `shared_Preferences` viewing tool
+
+
+
+ - bug修復
+ - 添加“shared_Preferences”查看工具
+
+
+
+ - けっかん修复
+ - shared _ Preferences表示ツールの追加
+
+
+
+ - 결함修复
+ - shared_Preferences 보기 도구 추가
+
+
3.5.1.as (2023-07-27)
diff --git a/gradle.properties b/gradle.properties
index 17c81963..2ca6a817 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,25 @@
-kotlin.stdlib.default.dependency = true
+kotlin.stdlib.default.dependency=true
kotlin.incremental.useClasspathSnapshot=false
-kotlin.experimental.tryK2=true
\ No newline at end of file
+kotlin.experimental.tryK2=true
+pluginVersion=3.7.3
+# AS release version : https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
+dartVersion=223.8950
+flutterVersion=75.1.2
+sinceBuildVersion=223
+untilBuildVersion=232.*
+ideaVersion=2022.3.1.18
+ideaType=AI
+# AS Canary version : https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
+#dartVersion=232.9559.10
+#flutterVersion=75.1.4
+#sinceBuildVersion=232
+#untilBuildVersion=232.*
+#ideaVersion=2023.2.1.7
+#ideaType=AI
+# idea eap
+#dartVersion=232.9559.10
+#flutterVersion=75.1.4
+#sinceBuildVersion=232
+#untilBuildVersion=232.*
+#ideaVersion=LATEST-EAP-SNAPSHOT
+#ideaType=IC
\ No newline at end of file
diff --git a/hive.md b/hive.md
new file mode 100644
index 00000000..3c21717e
--- /dev/null
+++ b/hive.md
@@ -0,0 +1,45 @@
+# Hive - Use of toolbars
+
+To use this tool, add `dd_check_plugin` with a version number greater than or equal to `3.0.2`
+
+```yaml
+ dd_check_plugin: ^3.0.2
+```
+
+# example
+
+```dart
+
+void main() {
+ DdCheckPlugin().init(Dio(),
+ initHost: '127.0.0.1', //Replace it with your PC's native IP
+ port: 9999, //Replace it with your dio listening port, which defaults to 9999
+ projectName: "app project name",
+ extend: [
+
+ ///Here, add your box list here
+ ///It needs to implement the DdPluginHiveBox interface
+ HiveToolManager(boxList: [
+ DemoHiveBox()
+ ])
+ ]
+ );
+}
+
+```
+
+```dart
+
+class DemoHiveBox implements DdPluginHiveBox {
+
+
+ @override
+ String get boxName => 'demo_box';
+
+ @override
+ Future> get getBox => Hive.isBoxOpen(boxName) ? Future.value(Hive.box(boxName)) : Hive.openBox(boxName);
+
+}
+
+```
+
diff --git a/images/WX20230923-155830@2x.png b/images/WX20230923-155830@2x.png
new file mode 100644
index 00000000..f464f6ad
Binary files /dev/null and b/images/WX20230923-155830@2x.png differ
diff --git a/images/do_not_check.png b/images/do_not_check.png
new file mode 100644
index 00000000..cd41bc05
Binary files /dev/null and b/images/do_not_check.png differ
diff --git a/images/inlay_param_new.png b/images/inlay_param_new.png
new file mode 100644
index 00000000..9259c23b
Binary files /dev/null and b/images/inlay_param_new.png differ
diff --git a/note.md b/note.md
new file mode 100644
index 00000000..09f4771b
--- /dev/null
+++ b/note.md
@@ -0,0 +1,4 @@
+```kotlin
+//重新分析文件
+DaemonCodeAnalyzer.getInstance(project).restart(it)
+```
\ No newline at end of file
diff --git a/src/main/kotlin/note/jdbc/SqliteConnect.kt b/src/main/kotlin/note/jdbc/SqliteConnect.kt
index cd675008..62aface3 100644
--- a/src/main/kotlin/note/jdbc/SqliteConnect.kt
+++ b/src/main/kotlin/note/jdbc/SqliteConnect.kt
@@ -64,7 +64,6 @@ object SqliteConnectManager {
}
Class.forName("org.sqlite.JDBC")
connect = DriverManager.getConnection("jdbc:sqlite:$filePath")
- println("连接数据库成功!")
} catch (e: SQLException) {
println("连接sql失败:$e")
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt
index b92b726d..b24f44d7 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt
@@ -2,6 +2,7 @@ package shop.itbug.fluttercheckversionx.actions
import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.JSONWriter
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.document.copyTextToClipboard
@@ -43,4 +44,8 @@ class ApiCopyAll:MyAction({"Copy All"}) {
e.presentation.isEnabled = e.api()!=null
super.update(e)
}
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyPathAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyPathAction.kt
index 2da5a8bc..15865dad 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyPathAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyPathAction.kt
@@ -1,6 +1,7 @@
package shop.itbug.fluttercheckversionx.actions
import cn.hutool.core.util.URLUtil
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.document.copyTextToClipboard
@@ -14,7 +15,7 @@ class ApiCopyPathAction: MyAction({"Copy Path"}) {
val path = URLUtil.getPath(url)
path.copyTextToClipboard().apply {
- e.apiListProject()?.toast("Copy succeeded!")
+ e.project?.toast("Copy succeeded!")
}
}
@@ -23,4 +24,8 @@ class ApiCopyPathAction: MyAction({"Copy Path"}) {
super.update(e)
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioRequestBodyToFreezedAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioRequestBodyToFreezedAction.kt
new file mode 100644
index 00000000..37cdf7a2
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioRequestBodyToFreezedAction.kt
@@ -0,0 +1,31 @@
+package shop.itbug.fluttercheckversionx.actions
+
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.components.service
+import shop.itbug.fluttercheckversionx.common.jsonToFreezedRun
+import shop.itbug.fluttercheckversionx.form.socket.getDataString
+import shop.itbug.fluttercheckversionx.form.socket.isParseToJson
+import shop.itbug.fluttercheckversionx.socket.service.AppService
+
+
+///json 转 freezed
+class DioRequestBodyToFreezedAction : AnAction() {
+
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val currentSelectRequest = service().currentSelectRequest
+ e.project?.jsonToFreezedRun(currentSelectRequest!!.getDataString())
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+
+ override fun update(e: AnActionEvent) {
+ val currentSelectRequest = service().currentSelectRequest
+ e.presentation.isEnabled = currentSelectRequest?.isParseToJson() == true
+ super.update(e)
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAnActionEx.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAnActionEx.kt
index 5637148b..7b1c21cf 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAnActionEx.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAnActionEx.kt
@@ -2,10 +2,9 @@ package shop.itbug.fluttercheckversionx.actions
import com.alibaba.fastjson2.JSON
import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.DataKey
-import com.intellij.openapi.project.Project
-import shop.itbug.fluttercheckversionx.form.components.ApiListPanel
+import com.intellij.openapi.components.service
import shop.itbug.fluttercheckversionx.form.socket.Request
+import shop.itbug.fluttercheckversionx.socket.service.AppService
fun Request.getDataJson() : Any {
@@ -18,10 +17,7 @@ fun Request.getDataJson() : Any {
return data ?: ""
}
+///获取当前选中的项目
fun AnActionEvent.api(): Request? {
- return getData(DataKey.create(ApiListPanel.SELECT_KEY))
+ return service().currentSelectRequest
}
-
- fun AnActionEvent.apiListProject() : Project? {
- return getData(DataKey.create(ApiListPanel.PROJECT_KEY))
-}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAutoScrollToMaxAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAutoScrollToMaxAction.kt
index 08a33b5a..ccdf5df6 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAutoScrollToMaxAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowAutoScrollToMaxAction.kt
@@ -1,11 +1,13 @@
package shop.itbug.fluttercheckversionx.actions
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.components.service
+import com.intellij.openapi.actionSystem.DataKey
import com.intellij.openapi.project.DumbAware
import shop.itbug.fluttercheckversionx.common.MyToggleAction
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
+import shop.itbug.fluttercheckversionx.form.components.ApiListPanel
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
-import shop.itbug.fluttercheckversionx.socket.service.AppService
/**
* 自动滚动到最底部
@@ -13,13 +15,22 @@ import shop.itbug.fluttercheckversionx.socket.service.AppService
class DioWindowAutoScrollToMaxAction : MyToggleAction(PluginBundle.getLazyMessage("auto.scroll.to.the.bottom")),
DumbAware {
- private val appService = service()
override fun isSelected(e: AnActionEvent): Boolean {
- return appService.apiListAutoScrollerToMax
+ val setting = DioxListingUiConfig.setting
+ return setting.autoScroller
}
override fun setSelected(e: AnActionEvent, state: Boolean) {
- appService.setIsAutoScrollToMax(state)
+ val panel = e.getData(DataKey.create(ApiListPanel.PANEL))
+ panel?.let {
+ it.autoscrolls = state
+ }
+ DioxListingUiConfig.changeSetting { it.copy(autoScroller = state) }
+ }
+
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowCopyAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowCopyAction.kt
index 0ab93486..e17581cf 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowCopyAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowCopyAction.kt
@@ -1,5 +1,6 @@
package shop.itbug.fluttercheckversionx.actions
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.document.copyTextToClipboard
@@ -12,14 +13,18 @@ import shop.itbug.fluttercheckversionx.util.toast
class DioWindowCopyAction : MyAction(PluginBundle.getLazyMessage("window.idea.dio.view.copy")) {
override fun actionPerformed(e: AnActionEvent) {
e.api()?.url?.copyTextToClipboard()?.apply {
- e.apiListProject()?.toast("Copy succeeded!")
+ e.project?.toast("Copy succeeded!")
}
}
override fun update(e: AnActionEvent) {
- e.presentation.isEnabled = e.apiListProject() != null && e.api() != null
+ e.presentation.isEnabled = e.api() != null
super.update(e)
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewGetParamsAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewGetParamsAction.kt
index 09859ccf..8dcf6a88 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewGetParamsAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewGetParamsAction.kt
@@ -1,6 +1,7 @@
package shop.itbug.fluttercheckversionx.actions
import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction
@@ -14,13 +15,13 @@ open class DioWindowViewGetParamsAction : MyDumbAwareAction(PluginBundle.getLazy
override fun actionPerformed(e: AnActionEvent) {
val api = e.api()!!
- api.queryParams?.let { SimpleJsonViewDialog.show(it, e.apiListProject()!!) }
+ api.queryParams?.let { SimpleJsonViewDialog.show(it, e.project!!) }
}
override fun update(e: AnActionEvent) {
super.update(e)
- e.presentation.isEnabled = e.api()?.queryParams?.isNotEmpty() == true && e.apiListProject() !=null
+ e.presentation.isEnabled = e.api()?.queryParams?.isNotEmpty() == true && e.project !=null
}
@@ -29,4 +30,7 @@ open class DioWindowViewGetParamsAction : MyDumbAwareAction(PluginBundle.getLazy
val instance: AnAction = ActionManager.getInstance().getAction("dio-window-view-GET")
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewHeadersAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewHeadersAction.kt
index 5b247a29..f8f20bdc 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewHeadersAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewHeadersAction.kt
@@ -1,5 +1,6 @@
package shop.itbug.fluttercheckversionx.actions
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.dialog.SimpleJsonViewDialog
@@ -10,11 +11,15 @@ import shop.itbug.fluttercheckversionx.i18n.PluginBundle
*/
class DioWindowViewHeadersAction : MyAction(PluginBundle.getLazyMessage("view.request.headers")) {
override fun actionPerformed(e: AnActionEvent) {
- e.api()?.headers?.apply { SimpleJsonViewDialog.show(this, e.apiListProject()!!) }
+ e.api()?.headers?.apply { SimpleJsonViewDialog.show(this, e.project!!) }
}
override fun update(e: AnActionEvent) {
- e.presentation.isEnabled = e.apiListProject()!=null && e.api()?.headers?.isNotEmpty() == true
+ e.presentation.isEnabled = e.project!=null && e.api()?.headers?.isNotEmpty() == true
super.update(e)
}
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewPostParamsAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewPostParamsAction.kt
index dac8dc4b..19570788 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewPostParamsAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/DioWindowViewPostParamsAction.kt
@@ -1,5 +1,6 @@
package shop.itbug.fluttercheckversionx.actions
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.dialog.SimpleJsonViewDialog
@@ -11,12 +12,16 @@ import shop.itbug.fluttercheckversionx.i18n.PluginBundle
class DioWindowViewPostParamsAction : MyAction(PluginBundle.getLazyMessage("dio.toolbar.post.params")) {
override fun actionPerformed(e: AnActionEvent) {
val api = e.api()!!
- api.body?.let { SimpleJsonViewDialog.show(it, e.apiListProject()!!) }
+ api.body?.let { SimpleJsonViewDialog.show(it, e.project!!) }
}
override fun update(e: AnActionEvent) {
super.update(e)
- e.presentation.isEnabled = e.api()?.body is Map<*, *> && e.apiListProject() != null
+ e.presentation.isEnabled = e.api()?.body is Map<*, *> && e.project != null
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/FxModelToFreezedModel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/FxModelToFreezedModel.kt
index 1cd4e204..4cda9303 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/FxModelToFreezedModel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/FxModelToFreezedModel.kt
@@ -1,5 +1,6 @@
package shop.itbug.fluttercheckversionx.actions
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import shop.itbug.fluttercheckversionx.common.MyAction
import shop.itbug.fluttercheckversionx.dialog.FreezedCovertDialog
@@ -23,5 +24,8 @@ class FxModelToFreezedModel : MyAction() {
super.update(e)
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/GenerateFunctionDocument.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/GenerateFunctionDocument.kt
index d096ef50..b9962998 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/GenerateFunctionDocument.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/GenerateFunctionDocument.kt
@@ -63,3 +63,4 @@ class GenerateFunctionDocument : MyAction() {
}
}
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/JsonToFreezedModelAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/JsonToFreezedModelAction.kt
new file mode 100644
index 00000000..b5c5f079
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/JsonToFreezedModelAction.kt
@@ -0,0 +1,28 @@
+package shop.itbug.fluttercheckversionx.actions
+
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.openapi.actionSystem.AnActionEvent
+import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction
+import shop.itbug.fluttercheckversionx.common.jsonToFreezedRun
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.util.toastWithError
+
+class JsonToFreezedModelAction(private val text: String) : MyDumbAwareAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ jsonToFreezedModel(e)
+ }
+ private fun jsonToFreezedModel(event: AnActionEvent) {
+ val text = text.trim()
+ if (text.isEmpty()) {
+ event.project?.toastWithError(PluginBundle.get("input.your.json"))
+ return
+ }
+ try {
+ JSONObject.parseObject(text)
+ } catch (e: Exception) {
+ event.project?.toastWithError(PluginBundle.get("json.format.verification.failed"))
+ return
+ }
+ event.project?.jsonToFreezedRun(text)
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/context/CovertToActionsGroup.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/context/CovertToActionsGroup.kt
new file mode 100644
index 00000000..f6a2bfb8
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/context/CovertToActionsGroup.kt
@@ -0,0 +1,9 @@
+package shop.itbug.fluttercheckversionx.actions.context
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+
+class CovertToActionsGroup : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt
index f3c995f7..fa30b481 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt
@@ -6,7 +6,6 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
@@ -16,6 +15,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
+import com.intellij.util.messages.MessageBusConnection
import io.flutter.sdk.FlutterSdk
import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig
import shop.itbug.fluttercheckversionx.icons.MyIcons
@@ -30,7 +30,10 @@ import shop.itbug.fluttercheckversionx.util.RunUtil
* 当项目打开的时候,会执行这个类的runActivity方法
* 在这里启动一个子线程去检测项目中的pubspec.yaml文件.并执行检测新版本
*/
-class FlutterProjectOpenActivity : StartupActivity, Disposable {
+class FlutterProjectOpenActivity : StartupActivity.Background, Disposable {
+
+
+ private lateinit var connect: MessageBusConnection
/**
* 项目在idea中打开时执行函数
@@ -48,14 +51,14 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
}
override fun dispose() {
-
+ connect.disconnect()
}
-
fun run(project: Project) {
///监听assets资源目录更改事件
- ApplicationManager.getApplication().messageBus.connect(this).subscribe(VirtualFileManager.VFS_CHANGES, object :
+ connect = project.messageBus.connect(this)
+ connect.subscribe(VirtualFileManager.VFS_CHANGES, object :
BulkFileListener {
override fun after(events: MutableList) {
val projectPath = project.basePath
@@ -76,6 +79,8 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
})
cleanPubPluginsCache()
+
+ CacheUtil.clean()
}
@@ -85,9 +90,6 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
}
-
-
-
/**
* 检测 flutter最新版本
*/
@@ -102,7 +104,7 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
release?.let { r ->
if (r.version != it.versionText) {
println("has new version")
- showTip(r,project)
+ showTip(r, project)
}
}
}
@@ -114,7 +116,7 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
/**
* 弹出通知
*/
- fun showTip(release: Release,project: Project) {
+ fun showTip(release: Release, project: Project) {
val createNotification =
NotificationGroupManager.getInstance().getNotificationGroup("flutter_version_check").createNotification(
"The new Flutter version is ready",
@@ -128,7 +130,7 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
createNotification.addAction(
object : AnAction("Upgrade") {
override fun actionPerformed(p0: AnActionEvent) {
- RunUtil.runCommand(project,"flutter upgrade","flutter upgrade")
+ RunUtil.runCommand(project, "flutter upgrade", "flutter upgrade")
createNotification.hideBalloon()
}
@@ -143,7 +145,7 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
},
)
- createNotification.addAction(object : AnAction("Cancel"){
+ createNotification.addAction(object : AnAction("Cancel") {
override fun actionPerformed(p0: AnActionEvent) {
createNotification.hideBalloon()
@@ -152,6 +154,7 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable {
createNotification.notify(project)
}
+
override fun runActivity(project: Project) {
run(project)
checkFlutterLastVersion(project)
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/bus/SocketMessageBus.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/bus/SocketMessageBus.kt
index 47749c12..b1f4e718 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/bus/SocketMessageBus.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/bus/SocketMessageBus.kt
@@ -1,36 +1,33 @@
package shop.itbug.fluttercheckversionx.bus
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.util.messages.Topic
-import shop.itbug.fluttercheckversionx.form.socket.Request
import shop.itbug.fluttercheckversionx.socket.ProjectSocketService
interface SocketMessageBus {
fun handleData(data: ProjectSocketService.SocketResponseModel?)
- companion object {
- private val CHANGE_ACTION_TOPIC = Topic.create("dio request send", SocketMessageBus::class.java)
- private val messageBus = ApplicationManager.getApplication().messageBus
-
- /**
- * 将模型发送给监听者
- */
- fun fire(model: Request) {
- messageBus.syncPublisher(CHANGE_ACTION_TOPIC).handleData(model)
- }
-
- /**'
- * 监听api进入
- */
- fun listening(apiCallback:(req: Request)->Unit) {
- messageBus.connect().subscribe(CHANGE_ACTION_TOPIC,object : SocketMessageBus{
- override fun handleData(data: ProjectSocketService.SocketResponseModel?) {
- data?.let { apiCallback.invoke(it) }
- }
- })
- }
-
-
- }
+// companion object {
+// private val CHANGE_ACTION_TOPIC = Topic.create("dio request send", SocketMessageBus::class.java)
+// private val messageBus = ApplicationManager.getApplication().messageBus
+//
+// /**
+// * 将模型发送给监听者
+// */
+// fun fire(model: Request) {
+// messageBus.syncPublisher(CHANGE_ACTION_TOPIC).handleData(model)
+// }
+//
+// /**'
+// * 监听api进入
+// */
+// fun listening(apiCallback: (req: Request) -> Unit) {
+// messageBus.connect().subscribe(CHANGE_ACTION_TOPIC, object : SocketMessageBus {
+// override fun handleData(data: ProjectSocketService.SocketResponseModel?) {
+// data?.let { apiCallback.invoke(it) }
+// }
+// })
+// }
+//
+//
+// }
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/cache/DartPluginIgnoreConfig.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/cache/DartPluginIgnoreConfig.kt
new file mode 100644
index 00000000..597aca67
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/cache/DartPluginIgnoreConfig.kt
@@ -0,0 +1,59 @@
+package shop.itbug.fluttercheckversionx.cache
+
+import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.State
+import com.intellij.openapi.components.Storage
+import com.intellij.openapi.project.Project
+import com.intellij.util.xmlb.XmlSerializerUtil
+
+@State(name = "DartPluginIgnoreConfig", storages = [Storage("DartPluginIgnoreConfig.xml")])
+class DartPluginIgnoreConfig private constructor() : PersistentStateComponent{
+
+
+ var names = mutableListOf() //忽略的插件名字
+
+ override fun getState(): DartPluginIgnoreConfig {
+ return this
+ }
+
+ override fun loadState(state: DartPluginIgnoreConfig) {
+ XmlSerializerUtil.copyBean(state, this)
+ }
+
+ ///忽略检测插件名
+ fun add(pluginName: String) {
+ if(names.contains(pluginName).not()){
+ names.add(pluginName)
+ loadState(this)
+ }else{
+ remove(pluginName)
+ }
+ }
+
+
+ ///移除忽略检测插件名
+ fun remove(pluginName: String) {
+ if(names.contains(pluginName)){
+ names.remove(pluginName)
+ loadState(this)
+ }
+
+ }
+
+
+ fun isIg(pluginName: String): Boolean {
+ return names.contains(pluginName)
+ }
+
+ companion object {
+
+ ///获取实例
+ fun getInstance(project: Project) : DartPluginIgnoreConfig {
+ return project.getService(DartPluginIgnoreConfig::class.java).state
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt
index ff21d7b2..ae2c224b 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt
@@ -20,7 +20,7 @@ fun Any.toJsonFormart(): String {
/**
* 设置为滚动面板
*/
-fun JComponent.scroll(): JComponent {
+fun JComponent.scroll(): JBScrollPane {
return JBScrollPane(this)
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt
index b88ad8e1..b095919e 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt
@@ -1,5 +1,6 @@
package shop.itbug.fluttercheckversionx.common
+import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.actionSystem.ex.ComboBoxAction
@@ -16,6 +17,9 @@ abstract class MyAction : AnAction {
constructor(name: Supplier, icon: Icon) : super(name, icon)
constructor(title: String, desc: String, icon: Icon) : super(title, desc, icon)
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
abstract class MyDumbAwareAction : DumbAwareAction {
@@ -26,17 +30,22 @@ abstract class MyDumbAwareAction : DumbAwareAction {
constructor(title: String, desc: String, icon: Icon) : super(title, desc, icon)
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
-abstract class MyToggleAction : ToggleAction {
+abstract class MyToggleAction(name: Supplier) : ToggleAction(name) {
- constructor()
- constructor(name: Supplier) : super(name)
-
- constructor(name: String, desc: String, icon: Icon) : super(name, desc, icon)
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
abstract class MyComboBoxAction : ComboBoxAction() {
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/config/DoxListingUiConfig.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/config/DoxListingUiConfig.kt
index da59c182..3e98cb4b 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/config/DoxListingUiConfig.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/config/DoxListingUiConfig.kt
@@ -1,11 +1,23 @@
package shop.itbug.fluttercheckversionx.config
+import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service
+import com.intellij.util.messages.Topic
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+///ui 渲染样式
+enum class DioRequestUIStyle(val string: String) {
+ //默认样式 (宽松)
+ DefaultStyle(PluginBundle.get("relaxed.mode")),
+
+ //紧凑模式
+ CompactStyle(PluginBundle.get("compact.mode"))
+}
+
data class DioxListeningSetting(
//是否展示前缀host
var showHost: Boolean = true,
@@ -20,25 +32,37 @@ data class DioxListeningSetting(
//显示时间
var showDate: Boolean = true,
//粗体链接
- var urlBold : Boolean = true,
+ var urlBold: Boolean = true,
//是否使用旧版本的UI
var uiRenderVersionCode: String = "2",
+ //ui渲染样式
+ var uiStyle: DioRequestUIStyle = DioRequestUIStyle.DefaultStyle,
+
+ ///是否自动滚动到地步
+ var autoScroller: Boolean = true,
+
+ ///显示项目名字
+ var showProjectName: Boolean = true
+
)
/**
* dio的功能设置
*/
-@State(name = "DoxListingUiConfig",storages = [Storage("DoxListingUiConfig.xml")])
-class DioxListingUiConfig private constructor(): PersistentStateComponent {
+@State(name = "DoxListingUiConfig", storages = [Storage("DoxListingUiConfig.xml")])
+class DioxListingUiConfig private constructor() : PersistentStateComponent {
private var config = DioxListeningSetting()
override fun getState(): DioxListeningSetting {
- return config
+ return config
}
+
override fun loadState(state: DioxListeningSetting) {
+ val old = config
config = state
+ DioSettingChangeEvent.fire(old, state)
}
companion object {
@@ -46,7 +70,38 @@ class DioxListingUiConfig private constructor(): PersistentStateComponent()
}
- val setting : DioxListeningSetting get() = getInstance().state ?: DioxListeningSetting()
+ val setting: DioxListeningSetting get() = getInstance().state ?: DioxListeningSetting()
+
+ ///更改设置
+ fun changeSetting(doChange: (old: DioxListeningSetting) -> DioxListeningSetting) =
+ getInstance().loadState(doChange(setting))
}
+}
+
+typealias DioSettingChangeEventChangeFun = (old: DioxListeningSetting, setting: DioxListeningSetting) -> Unit
+
+
+///当 dio 的一些设置变化后,会发送这个通知事件,可以做一些 UI 上面的更新
+interface DioSettingChangeEvent {
+
+ fun doChange(old: DioxListeningSetting, setting: DioxListeningSetting)
+
+ companion object {
+ private val TOPIC = Topic.create("DioSettingChangeEvent", DioSettingChangeEvent::class.java)
+
+ ///发送更改事件
+ fun fire(old: DioxListeningSetting, setting: DioxListeningSetting) {
+ ApplicationManager.getApplication().messageBus.syncPublisher(TOPIC).doChange(old, setting)
+ }
+
+ ///监听更改事件
+ fun listen(call: DioSettingChangeEventChangeFun) {
+ ApplicationManager.getApplication().messageBus.connect().subscribe(TOPIC, object : DioSettingChangeEvent {
+ override fun doChange(old: DioxListeningSetting, setting: DioxListeningSetting) {
+ call.invoke(old, setting)
+ }
+ })
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt
index 29cce768..9a96d758 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiFileFactory
import com.intellij.psi.PsiManager
import com.intellij.ui.components.JBLabel
import com.intellij.ui.components.JBTabbedPane
+import com.intellij.ui.dsl.builder.Align
import com.intellij.ui.dsl.builder.bindSelected
import com.intellij.ui.dsl.builder.bindText
import com.intellij.ui.dsl.builder.panel
@@ -32,13 +33,13 @@ import javax.swing.JPanel
class FreezedClassesGenerateDialog(
- override val project: Project,
- private val freezedClasses: MutableList
-) :
- MyDialogWrapper(project) {
+ override val project: Project, private val freezedClasses: MutableList
+) : MyDialogWrapper(project) {
private val settingInstance = JsonToFreezedSettingModelConfig.getInstance(project)
private val setting = settingInstance.state
- private val tabView = JBTabbedPane()
+ private val tabView = JBTabbedPane().apply {
+ border = null
+ }
private var fileName: String = DEFAULT_CLASS_NAME
private var filePath: String = setting.generateToPath
private val widgets: MutableList = mutableListOf()
@@ -83,30 +84,29 @@ class FreezedClassesGenerateDialog(
row(PluginBundle.get("save.to.directory")) {
textFieldWithBrowseButton(
fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
- .withRoots(ProjectRootManager.getInstance(project).contentRoots.first()),
- project = project
+ .withRoots(ProjectRootManager.getInstance(project).contentRoots.first()), project = project
).bindText({
filePath
}, {
filePath = it
filePathLabel.text = it
- })
+ }).align(Align.FILL)
}
row(PluginBundle.get("file.name")) {
textField().bindText({ fileName }, {
fileName = it
- })
+ }).align(Align.FILL)
}
row {
checkBox("${PluginBundle.get("automatic.operation.command")} flutter pub run build_runner build").bindSelected(
{ setting.autoRunDartBuilder },
{ v ->
settingInstance.changeState { it.copy(autoRunDartBuilder = v) }
- })
+ }).align(Align.FILL)
}
}
}
- return settingPanel
+ return settingPanel.apply { border = null }
}
@@ -116,9 +116,8 @@ class FreezedClassesGenerateDialog(
///保存此路径
settingInstance.changeState { it.copy(generateToPath = filePath) }
- val psiFile =
- PsiFileFactory.getInstance(project)
- .createFileFromText("$fileName.dart", DartLanguage.INSTANCE, generateFileText())
+ val psiFile = PsiFileFactory.getInstance(project)
+ .createFileFromText("$fileName.dart", DartLanguage.INSTANCE, generateFileText())
val virtualFile = filePath.getVirtualFile()
if (virtualFile == null) {
project.toastWithError(PluginBundle.get("unable.to.find.directory"))
@@ -133,8 +132,7 @@ class FreezedClassesGenerateDialog(
}
project.toast(PluginBundle.get("build.succeeded"))
if (setting.autoRunDartBuilder) {
- TerminalView.getInstance(project)
- .createLocalShellWidget(project.basePath, "freezed gen")
+ TerminalView.getInstance(project).createLocalShellWidget(project.basePath, "freezed gen")
.executeCommand("flutter pub run build_runner build")
}
FileBasedIndex.getInstance().requestReindex(virtualFile)
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedCovertDialog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedCovertDialog.kt
index 1e51f0b0..ed1e7faa 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedCovertDialog.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedCovertDialog.kt
@@ -2,14 +2,12 @@ package shop.itbug.fluttercheckversionx.dialog
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
-import com.intellij.ui.LanguageTextField
import com.intellij.ui.components.JBScrollPane
-import com.jetbrains.lang.dart.DartLanguage
import shop.itbug.fluttercheckversionx.model.FreezedCovertModel
import shop.itbug.fluttercheckversionx.model.getPropertiesString
import shop.itbug.fluttercheckversionx.util.MyDartPsiElementUtil
+import shop.itbug.fluttercheckversionx.widget.DartEditorTextPanel
import java.awt.BorderLayout
-import java.awt.Dimension
import javax.swing.JComponent
import javax.swing.JPanel
@@ -26,14 +24,9 @@ class FreezedCovertDialog(val project: Project, val model: FreezedCovertModel) :
className = model.className
}
- private val editView = LanguageTextField(
- DartLanguage.INSTANCE,
- project,
- "",
- false
- ).apply {
- minimumSize = Dimension(400,400)
- }
+
+ private var editView = DartEditorTextPanel(project)
+
init {
super.init()
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/JsonToFreezedInputDialog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/JsonToFreezedInputDialog.kt
index fbd7ed5e..4f3223f3 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/JsonToFreezedInputDialog.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/JsonToFreezedInputDialog.kt
@@ -1,23 +1,23 @@
package shop.itbug.fluttercheckversionx.dialog
import com.alibaba.fastjson2.JSONObject
-import com.intellij.json.JsonLanguage
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ValidationInfo
-import com.intellij.ui.LanguageTextField
import com.intellij.ui.components.JBScrollPane
import shop.itbug.fluttercheckversionx.common.jsonToFreezedRun
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.widget.JsonEditorTextPanel
import javax.swing.JComponent
class JsonToFreezedInputDialog(val project: Project) : DialogWrapper(project) {
- private val jsonEditView = LanguageTextField(
- JsonLanguage.INSTANCE,
- project,
- "",
- false
- )
+// private val jsonEditView = LanguageTextField(
+// JsonLanguage.INSTANCE,
+// project,
+// "",
+// false
+// )
+private val jsonEditView = JsonEditorTextPanel(project)
init {
super.init()
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/document/DartDocumentExt.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/document/DartDocumentExt.kt
index c5a6850e..8b2a8b77 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/document/DartDocumentExt.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/document/DartDocumentExt.kt
@@ -27,7 +27,6 @@ class DartDocumentExt : AbstractDocumentationProvider(), ExternalDocumentationPr
element.containingFile.virtualFile,
element.textOffset
)
- println("文档result是否为空:${result.isEmpty()}")
if (result.isEmpty()) return ""
val docInfo = result.first()
val dartFormalParameterList =
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt
index 4ebe53af..312e0338 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt
@@ -4,42 +4,109 @@ import com.intellij.openapi.ui.DialogPanel
import com.intellij.ui.dsl.builder.panel
import com.intellij.util.ui.JBFont
import com.intellij.util.ui.UIUtil
+import shop.itbug.fluttercheckversionx.config.DioRequestUIStyle
import shop.itbug.fluttercheckversionx.config.DioxListeningSetting
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
import shop.itbug.fluttercheckversionx.form.socket.Request
+import java.awt.Dimension
import java.net.URI
import javax.swing.BorderFactory
-fun String.formatUrl(setting: DioxListeningSetting): String {
- if(setting.showHost.not()){
- return URI(this).path
+//获取 URL 显示
+fun Request.formatUrl(setting: DioxListeningSetting): String {
+ val uri = URI(url ?: "")
+ val host = uri.host
+ val scheme = uri.scheme + "://"
+
+ val param = uri.rawQuery
+ var string = this.url ?: ""
+ if (setting.showHost.not()) {
+ string = string.replace(scheme, "").replace(host, "")
+ if (string.startsWith(":${uri.port}")) {
+ string = string.replace(":${uri.port}", "")
+ }
+ }
+ if (setting.showQueryParams.not()) {
+ string = string.replace("?$param", "")
+
}
- return this
+ return string
}
/**
* 新版的请求UI
*/
-fun requestDetailLayout(request: Request, isSelected: Boolean,setting: DioxListeningSetting): DialogPanel {
+fun requestDetailLayout(request: Request, isSelected: Boolean): DialogPanel {
+
+ val setting = DioxListingUiConfig.setting
val color = UIUtil.getLabelDisabledForeground()
+
+
val p = panel {
+
row {
- label(request.url!!.formatUrl(setting)).component.apply {
- foreground = if(isSelected) UIUtil.getListSelectionForeground(false) else UIUtil.getLabelForeground()
+
+ // (在紧凑模式下有效,请求方式)
+ label(
+ request.method ?: ""
+ ).visible(setting.uiStyle == DioRequestUIStyle.CompactStyle && setting.showMethod).component.apply {
+ font = JBFont.small()
+ foreground = color
+ minimumSize = Dimension(30, minimumSize.height)
+ }
+ // (在紧凑模式下有效,状态码)
+ label("${request.statusCode ?: -1}").visible(setting.uiStyle == DioRequestUIStyle.CompactStyle && setting.showStatusCode).component.apply {
+ font = JBFont.smallOrNewUiMedium()
+ foreground =
+ if (request.statusCode == 200) UIUtil.getLabelSuccessForeground() else UIUtil.getErrorForeground()
+ }
+
+ label(request.formatUrl(setting)).component.apply {
+ foreground = if (isSelected) UIUtil.getListSelectionForeground(false) else UIUtil.getLabelForeground()
+ if (setting.urlBold) {
+ font = JBFont.medium().asBold()
+ }
+ }
+
+ ///扩展备注
+ request.extendNotes.map {
+ label(it).component.apply {
+ font = JBFont.small()
+ foreground = color
+ }
+ }
+
+ //其他一些次要的 (在紧凑模式下显示)
+ label(request.timestamp!!.toString() + "ms").visible(setting.showTimestamp && setting.uiStyle == DioRequestUIStyle.CompactStyle).component.apply {
+ font = JBFont.small()
+ foreground = color
+ }
+ label(request.createDate).visible(setting.showDate && setting.uiStyle == DioRequestUIStyle.CompactStyle).component.apply {
+ font = JBFont.small()
+ foreground = color
+ }
+ label(
+ request.projectName
+ ).visible(setting.uiStyle == DioRequestUIStyle.CompactStyle && setting.showProjectName).component.apply {
+ font = JBFont.small()
+ foreground = color
}
}
- row {
- label(request.statusCode!!.toString())
- .visible(setting.showStatusCode).component.apply {
+
+ //如果是紧凑模式,这些数据就不要显示了
+ if (setting.uiStyle == DioRequestUIStyle.DefaultStyle) row {
+ label(request.statusCode!!.toString()).visible(setting.showStatusCode).component.apply {
font = JBFont.small()
- foreground = if(request.statusCode == 200) UIUtil.getLabelInfoForeground() else UIUtil.getErrorForeground()
+ foreground =
+ if (request.statusCode == 200) UIUtil.getLabelInfoForeground() else UIUtil.getErrorForeground()
}
label(request.method!!).visible(setting.showMethod).component.apply {
font = JBFont.small()
foreground = color
}
- label(request.timestamp!!.toString()+"ms").visible(setting.showTimestamp).component.apply {
+ label(request.timestamp!!.toString() + "ms").visible(setting.showTimestamp).component.apply {
font = JBFont.small()
foreground = color
}
@@ -47,12 +114,13 @@ fun requestDetailLayout(request: Request, isSelected: Boolean,setting: DioxListe
font = JBFont.small()
foreground = color
}
- label(request.projectName?:"").component.apply {
+ label(request.projectName).visible(setting.showProjectName).component.apply {
font = JBFont.small()
foreground = color
}
- }.visible(setting.showStatusCode || setting.showMethod || setting.showTimestamp || setting.showDate)
+ }.visible(setting.showStatusCode || setting.showMethod || setting.showTimestamp || setting.showDate || setting.showProjectName)
}
- p.background = if(isSelected) UIUtil.getListBackground(true,false) else UIUtil.getPanelBackground()
- return p.withBorder(BorderFactory.createEmptyBorder(0,12,0,12))
-}
\ No newline at end of file
+ p.background = if (isSelected) UIUtil.getListBackground(true, false) else UIUtil.getPanelBackground()
+ return p.withBorder(BorderFactory.createEmptyBorder(0, 12, 0, 12))
+}
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/DioRequestSearch.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/DioRequestSearch.kt
index 39c1910c..c66aa2c3 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/DioRequestSearch.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/DioRequestSearch.kt
@@ -1,11 +1,22 @@
package shop.itbug.fluttercheckversionx.form.actions
import com.intellij.ui.SearchTextField
+import com.intellij.util.ui.JBUI
import shop.itbug.fluttercheckversionx.bus.DioWindowApiSearchBus
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.widget.MyComboActionNew
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener
+class DioApiSearchAction : MyComboActionNew.MySearchAnAction() {
+
+ override fun changeText(text: String, e: DocumentEvent) {
+ DioWindowApiSearchBus.fire(text)
+ }
+
+}
+
/**
* 接口搜索框,当用户输入接口URL后,只显示匹配的结果
*/
@@ -13,7 +24,10 @@ class DioRequestSearch : SearchTextField(), DocumentListener {
init {
addDocumentListener(this)
+ textEditor.border = JBUI.Borders.empty()
+ textEditor.emptyText.text = PluginBundle.get("dio.search.empty.text")
}
+
/**
* 提取用户输入的字符串
*/
@@ -31,5 +45,6 @@ class DioRequestSearch : SearchTextField(), DocumentListener {
}
override fun changedUpdate(e: DocumentEvent?) {
+ handleDocument(e)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/ProjectFilter.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/ProjectFilter.kt
index 524ee486..b9a5f91b 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/ProjectFilter.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/actions/ProjectFilter.kt
@@ -1,21 +1,13 @@
package shop.itbug.fluttercheckversionx.form.actions
-import com.intellij.openapi.actionSystem.*
-import com.intellij.openapi.application.ModalityState
+import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
-import com.intellij.openapi.project.DumbAware
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.util.Condition
-import com.intellij.util.ModalityUiUtil
-import shop.itbug.fluttercheckversionx.bus.ProjectListChangeBus
-import shop.itbug.fluttercheckversionx.common.MyAction
-import shop.itbug.fluttercheckversionx.common.MyComboBoxAction
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
import shop.itbug.fluttercheckversionx.icons.MyIcons
import shop.itbug.fluttercheckversionx.socket.service.AppService
-import shop.itbug.fluttercheckversionx.util.projectClosed
-import java.util.*
-import javax.swing.JComponent
+import shop.itbug.fluttercheckversionx.widget.MyComboActionNew
/**
@@ -23,105 +15,54 @@ import javax.swing.JComponent
* 因为可能会多开多个项目,所以要支持过滤
* 当然socket也根据项目分离Request请求
*/
-class ProjectFilter : MyComboBoxAction(), DumbAware {
+class ProjectFilter : MyComboActionNew.ComboBoxSettingAction() {
- private val actions = mutableListOf()
- private var projectNames = emptyList()
- private var ideaProject: MutableList = Collections.synchronizedList(mutableListOf())
private val appService = service()
- private fun createDefaultGroup(): DefaultActionGroup {
- val group = DefaultActionGroup()
- group.addAll(actions)
- return group
- }
-
- override fun createPopupActionGroup(button: JComponent, dataContext: DataContext): DefaultActionGroup {
- return createDefaultGroup()
- }
- override fun update(e: AnActionEvent) {
- super.update(e)
- e.project?.apply {
- if (!ideaProject.contains(this)) {
- ideaProject.add(this)
- val changeNameRunnable = Runnable {}
- appService.addListening(changeNameRunnable)
- this.projectClosed {
- appService.removeListening(changeNameRunnable)
- }
- ProjectListChangeBus.lisening {
- projectNames = it
- changeProjectNameAction()
- }
-
- }
- }
- doUpdate(e)
- }
+ override val reGetActions: Boolean
+ get() = true
- override fun createPopupActionGroup(p0: JComponent?): DefaultActionGroup {
- return createDefaultGroup()
- }
+ override val availableOptions: MutableList
+ get() = appService.flutterProjects.keys.toMutableList()
- private fun changeProjectNameAction() {
- actions.clear()
- actions.addAll(projectNames.map { ProjectAnAction(it) })
- }
- private fun doUpdate(e: AnActionEvent) {
- ModalityUiUtil.invokeLaterIfNeeded(ModalityState.defaultModalityState()) {
- updateSelect(e)
+ ///
+ override var value: String
+ get() = appService.currentSelectName.get() ?: ""
+ set(value) {
+ value
}
- }
- //更新选中
- private fun updateSelect(e: AnActionEvent) {
- if (actions.isEmpty()) {
+ override fun update(e: AnActionEvent) {
+ super.update(e)
+ if (appService.flutterProjects.keys.isEmpty()) {
e.presentation.isEnabled = false
e.presentation.text = PluginBundle.get("empty")
- e.presentation.icon = MyIcons.flutter
- } else {
- e.presentation.isEnabled = true
- }
-
- val appName = appService.currentSelectName.get()
- if (appName != null) {
- changeText(e.presentation, appName)
- }
- if (appName == null && actions.size == 1) {
- appService.changeCurrentSelectFlutterProjectName(actions[0].getText())
- }
-
- //主要是解决新开项目后选项会被禁用的问题
- if (appName != null && actions.isEmpty()) {
- projectNames = appService.projectNames
- changeProjectNameAction()
}
+ e.presentation.icon = MyIcons.flutter
}
- private fun changeText(presentation: Presentation, name: String) {
- presentation.text = name
- presentation.icon = MyIcons.flutter
+ override fun getText(option: String): String {
+ return option
}
- override fun getPreselectCondition(): Condition {
- return Condition { t -> t is ProjectAnAction && t.getText() == appService.currentSelectName.get() }
+
+ override fun getActionUpdateThread() = ActionUpdateThread.BGT
+
+ override fun setNewValue(value: String, e: AnActionEvent) {
+ service().changeCurrentSelectFlutterProjectName(value, e.project)
}
+ companion object {
+ ///获取实例
+ val instance: ProjectFilter = ActionManager.getInstance().getAction("FlutterProjects") as ProjectFilter
+ }
}
-/**
- * 项目选择操作
- */
-class ProjectAnAction(private val projectName: String) : MyAction({ projectName }, MyIcons.flutter) {
- override fun actionPerformed(e: AnActionEvent) {
- service().changeCurrentSelectFlutterProjectName(projectName)
- }
- fun getText() = projectName
-}
\ No newline at end of file
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt
index b5ae3f99..870944c5 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt
@@ -1,9 +1,10 @@
package shop.itbug.fluttercheckversionx.form.components
import com.intellij.ide.BrowserUtil
+import com.intellij.ide.DataManager
import com.intellij.openapi.actionSystem.ActionGroup
import com.intellij.openapi.actionSystem.ActionManager
-import com.intellij.openapi.actionSystem.impl.AsyncDataContext
+import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.popup.JBPopupFactory
@@ -15,14 +16,16 @@ import com.intellij.util.ui.JBUI
import shop.itbug.fluttercheckversionx.bus.DioWindowApiSearchBus
import shop.itbug.fluttercheckversionx.bus.DioWindowCleanRequests
import shop.itbug.fluttercheckversionx.bus.FlutterApiClickBus
-import shop.itbug.fluttercheckversionx.bus.SocketMessageBus
+import shop.itbug.fluttercheckversionx.config.DioSettingChangeEvent
import shop.itbug.fluttercheckversionx.dialog.RewardDialog
import shop.itbug.fluttercheckversionx.form.socket.MyCustomItemRender
import shop.itbug.fluttercheckversionx.form.socket.Request
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.listeners.FlutterProjectChangeEvent
+import shop.itbug.fluttercheckversionx.socket.ProjectSocketService
import shop.itbug.fluttercheckversionx.socket.service.AppService
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
import shop.itbug.fluttercheckversionx.util.Util
-import shop.itbug.fluttercheckversionx.util.projectClosed
import java.awt.Point
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
@@ -31,41 +34,59 @@ import javax.swing.SwingUtilities
import javax.swing.event.ListSelectionEvent
import javax.swing.event.ListSelectionListener
+
/**
* api列表
*/
-class ApiListPanel(val project: Project) : JBList(), ListSelectionListener {
+class ApiListPanel(val project: Project) : JBList(), ListSelectionListener, DataProvider,
+ DioApiService.HandleFlutterApiModel, FlutterProjectChangeEvent {
+
+ private val appService = service()
+ private fun listModel(): ItemModel = model as ItemModel
+
fun createPopupMenu(): ListPopup {
- return JBPopupFactory.getInstance()
- .createActionGroupPopup(PluginBundle.get("menu"), myActionGroup, myDataContext, true, { dispose() }, 10)
+ return JBPopupFactory.getInstance().createActionGroupPopup(
+ null, myActionGroup, DataManager.getInstance().getDataContext(this), true, { }, 10
+ )
}
- private val myDataContext: AsyncDataContext = object : AsyncDataContext {
- override fun getData(dataId: String): Any? {
- if (dataId == "select-api") {
- return this@ApiListPanel.selectedValue
- } else if (dataId == PROJECT_KEY) {
- return project
- }
- return null
- }
- }
- private val appService = service()
- private fun listModel(): DefaultListModel = model as DefaultListModel
-
init {
- model = DefaultListModel()
+ register()
+ connectFlutterProjectChangeEvent()
+ model = ItemModel(mutableListOf())
cellRenderer = MyCustomItemRender()
- setNewApiInChangeList()
setApiListEmptyText()
addListSelectionListener(this)
- addListening()
addRightPopupMenuClick()
+ border = null
DioWindowApiSearchBus.listing { doSearch(it) }
DioWindowCleanRequests.listening { listModel().clear() }
+ DioSettingChangeEvent.listen { _, _ ->
+ refreshUi()
+ }
+ SwingUtilities.invokeLater {
+ appService.refreshProjectRequest(project)
+ }
+ }
+
+
+ override fun setDataProvider(provider: DataProvider) {
+ super.setDataProvider { s ->
+ {
+ if (s == SELECT_KEY) {
+ this.selectedValue
+ }
+ }
+ }
+ }
+
+
+ ///重新构建一下 UI
+ private fun refreshUi() {
+ model = ItemModel(listModel().list)
}
/**
@@ -78,6 +99,7 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
if (e != null && SwingUtilities.isRightMouseButton(e)) {
val index = this@ApiListPanel.locationToIndex(e.point)
selectedIndex = index
+ appService.currentSelectRequest = selectedValue
SwingUtilities.invokeLater {
createPopupMenu().show(RelativePoint(Point(e.locationOnScreen)))
}
@@ -91,14 +113,6 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
get() = ActionManager.getInstance().getAction("dio-window-view-params") as ActionGroup
- /**
- * 菜单销毁回调
- */
- private fun dispose() {
-
- }
-
-
/**
* 搜索接口
*/
@@ -118,51 +132,12 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
}
}
- /**
- * 项目切换监听
- */
- private fun addListening() {
- SwingUtilities.invokeLater {
- val runnable = Runnable { projectChange() }
- service().addListening(runnable)
- project.projectClosed { service().removeListening(runnable) }
- }
- }
-
- /**
- * 项目被切换事件
- */
- private fun projectChange() {
- val appService = service()
- val projectName = appService.currentSelectName.get()
- projectName?.let {
- val apis = appService.getRequestsWithProjectName(projectName)
- changeApis(apis)
- }
- }
/**
* 更新api列表
*/
- private fun changeApis(apis: List) {
- listModel().apply {
- clear()
- addAll(apis)
- }
- }
-
- /**
- * 监听到api进入,更新模型
- */
- private fun setNewApiInChangeList() {
- val appService = service()
- SocketMessageBus.listening {
- val currentProjectName = appService.currentSelectName.get()
- //如果没有选中项目, 或者当前选中项目等于进入api的项目,才被加进列表中
- if (currentProjectName == null || currentProjectName == it.projectName) {
- listModel().addElement(it)
- }
- }
+ private fun changeApisModel(apis: MutableList) {
+ model = ItemModel(apis)
}
@@ -174,8 +149,7 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
appendLine("")
appendLine(
PluginBundle.get("help"), SimpleTextAttributes(
- SimpleTextAttributes.STYLE_PLAIN,
- JBUI.CurrentTheme.Link.Foreground.ENABLED
+ SimpleTextAttributes.STYLE_PLAIN, JBUI.CurrentTheme.Link.Foreground.ENABLED
)
) {
BrowserUtil.open("https://github.com/mdddj/dd_flutter_idea_plugin/blob/master/dio.md")
@@ -194,13 +168,11 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
) {
BrowserUtil.open("https://github.com/mdddj/dd_flutter_idea_plugin/issues")
}
- appendLine(
- "IP:${
- Util.resolveLocalAddresses()
- .filter { it.hostAddress.split('.').size == 4 && it.hostAddress.split(".")[2] != "0" }
- .map { it.hostAddress }
- }", SimpleTextAttributes.GRAYED_ATTRIBUTES
- ) {}
+ appendLine("IP:${
+ Util.resolveLocalAddresses()
+ .filter { it.hostAddress.split('.').size == 4 && it.hostAddress.split(".")[2] != "0" }
+ .map { it.hostAddress }
+ }", SimpleTextAttributes.GRAYED_ATTRIBUTES) {}
}
}
@@ -208,6 +180,7 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
if (e != null && !project.isDisposed) {
if (!e.valueIsAdjusting && selectedValue != null) {
FlutterApiClickBus.fire(selectedValue)
+ appService.currentSelectRequest = selectedValue
}
}
}
@@ -215,9 +188,32 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe
companion object {
const val SELECT_KEY = "select-api"
- const val PROJECT_KEY = "project-"
+ const val PANEL = "panel"
}
-}
+ override fun getData(p0: String): Any? {
+ if (p0 == PANEL) {
+ return this
+ }
+ return null
+ }
+
+
+ override fun handleModel(model: ProjectSocketService.SocketResponseModel) {
+
+ changeApisModel(appService.getCurrentProjectAllRequest().toMutableList())
+ super.handleModel(model)
+ }
+ private inner class ItemModel(val list: MutableList) : DefaultListModel() {
+ init {
+ addAll(list)
+ }
+ }
+
+ //更新项目
+ override fun changeProject(projectName: String, project: Project?) {
+ changeApisModel(appService.getCurrentProjectAllRequest().toMutableList())
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt
new file mode 100644
index 00000000..46c90b00
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt
@@ -0,0 +1,23 @@
+package shop.itbug.fluttercheckversionx.form.components
+
+import shop.itbug.fluttercheckversionx.config.DioRequestUIStyle
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
+import shop.itbug.fluttercheckversionx.widget.MyComboActionNew
+
+///切换dio请求ui样式
+class ChangeDioRequestItemUi() :
+ MyComboActionNew.ToggleActionGroup(DioRequestUIStyle.entries.toTypedArray()) {
+ var setting = DioxListingUiConfig.setting
+
+ override var value: DioRequestUIStyle
+ get() = setting.uiStyle
+ set(value) {
+ DioxListingUiConfig.changeSetting { it.copy(uiStyle = value) }
+ setting = DioxListingUiConfig.setting
+ }
+
+ override fun getText(value: DioRequestUIStyle): String {
+ return value.string
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt
new file mode 100644
index 00000000..b36d9857
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt
@@ -0,0 +1,68 @@
+package shop.itbug.fluttercheckversionx.form.components
+
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.project.DumbAware
+import com.intellij.openapi.project.DumbAwareToggleAction
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+
+
+///显示设置
+enum class DioUiSettingMenu(val title: String) {
+ Domain(PluginBundle.get("display_domain_name")),
+ Params(PluginBundle.get("display.query.parameters")),
+ Method(PluginBundle.get("show.request.method")),
+ Status(PluginBundle.get("display.status.code")),
+ Time(PluginBundle.get("display.time")),
+ RequestTime(PluginBundle.get("time")),
+ ProjectName(PluginBundle.get("dio.setting.project.name.show.option"))
+}
+
+
+internal class DioUIShowActionGroup : DumbAware, ActionGroup() {
+ override fun getChildren(e: AnActionEvent?): Array {
+ val actions = ArrayList()
+ actions.addAll(DioUiSettingMenu.entries.map { DioUiRenderOption(it) })
+ return actions.toTypedArray()
+ }
+}
+
+
+private class DioUiRenderOption(val menu: DioUiSettingMenu) : DumbAwareToggleAction() {
+
+ override fun isSelected(e: AnActionEvent): Boolean {
+ val setting = DioxListingUiConfig.setting
+ return when (menu) {
+ DioUiSettingMenu.Domain -> setting.showHost
+ DioUiSettingMenu.Params -> setting.showQueryParams
+ DioUiSettingMenu.Method -> setting.showMethod
+ DioUiSettingMenu.Status -> setting.showStatusCode
+ DioUiSettingMenu.Time -> setting.showTimestamp
+ DioUiSettingMenu.RequestTime -> setting.showDate
+ DioUiSettingMenu.ProjectName -> setting.showProjectName
+ }
+ }
+
+ override fun setSelected(e: AnActionEvent, state: Boolean) {
+ when (menu) {
+ DioUiSettingMenu.Domain -> DioxListingUiConfig.changeSetting { it.copy(showHost = state) }
+ DioUiSettingMenu.Params -> DioxListingUiConfig.changeSetting { it.copy(showQueryParams = state) }
+ DioUiSettingMenu.Method -> DioxListingUiConfig.changeSetting { it.copy(showMethod = state) }
+ DioUiSettingMenu.Status -> DioxListingUiConfig.changeSetting { it.copy(showStatusCode = state) }
+ DioUiSettingMenu.Time -> DioxListingUiConfig.changeSetting { it.copy(showTimestamp = state) }
+ DioUiSettingMenu.RequestTime -> DioxListingUiConfig.changeSetting { it.copy(showDate = state) }
+ DioUiSettingMenu.ProjectName -> DioxListingUiConfig.changeSetting { it.copy(showProjectName = state) }
+ }
+ }
+
+ override fun update(e: AnActionEvent) {
+ e.presentation.text = menu.title
+ Toggleable.setSelected(e.presentation, isSelected(e))
+ super.update(e)
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt
index b79c5443..c3793d79 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt
@@ -1,26 +1,10 @@
package shop.itbug.fluttercheckversionx.form.components
-import com.alibaba.fastjson2.JSON
-import com.alibaba.fastjson2.JSONObject
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.project.Project
+import com.intellij.util.ui.components.BorderLayoutPanel
import shop.itbug.fluttercheckversionx.bus.FlutterApiClickBus
-import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction
-import shop.itbug.fluttercheckversionx.common.jsonToFreezedRun
import shop.itbug.fluttercheckversionx.form.socket.Request
-import shop.itbug.fluttercheckversionx.form.socket.createWithToolbar
import shop.itbug.fluttercheckversionx.form.sub.JsonValueRender
-import shop.itbug.fluttercheckversionx.i18n.PluginBundle
-import shop.itbug.fluttercheckversionx.icons.MyIcons
-import shop.itbug.fluttercheckversionx.util.toastWithError
-import shop.itbug.fluttercheckversionx.widget.MyActionButton
-import shop.itbug.fluttercheckversionx.widget.WidgetUtil
-import java.awt.BorderLayout
-import javax.swing.BorderFactory
-import javax.swing.JComponent
-import javax.swing.JPanel
/**
* 请求详情
@@ -28,7 +12,7 @@ import javax.swing.JPanel
* print("hello world");
* ```
*/
-class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) {
+class RightDetailPanel(val project: Project) : BorderLayoutPanel() {
/**
* 详情对象
@@ -38,13 +22,12 @@ class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) {
/**
* json视图
*/
- private var jsonView: JsonValueRender = JsonValueRender(project = project)
+ private var jsonView: JsonValueRender = JsonValueRender(p = project)
init {
- border = BorderFactory.createEmptyBorder()
+ border = null
jsonViewInit()
- add(actionsToolBar(), BorderLayout.NORTH)
FlutterApiClickBus.listening {
changeShowValue(it)
}
@@ -60,7 +43,7 @@ class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) {
}
private fun jsonViewInit() {
- add(jsonView, BorderLayout.CENTER)
+ addToCenter(jsonView)
}
/**
@@ -70,52 +53,10 @@ class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) {
jsonView.changeValue("")
}
- private fun actionsToolBar() : JComponent
- {
- val toolbar = DefaultActionGroup(*createAnActions()).createWithToolbar("Request Json Toolbar")
- toolbar.targetComponent = this
- return toolbar.component
- }
-
- private fun createAnActions() : Array {
- return arrayOf(
- MyActionButton(jsonToFreezedModelAction).action,
- WidgetUtil.getCopyAnAction(jsonView.text),
- WidgetUtil.getDiscordAction()
- )
- }
- private val jsonToFreezedModelAction: MyDumbAwareAction
- get() =
- object : MyDumbAwareAction("Json To Freezed Model","将json转换成freezed 模型",MyIcons.freezed) {
- override fun actionPerformed(e: AnActionEvent) {
- jsonToFreezedModel()
- }
- override fun update(e: AnActionEvent) {
- e.presentation.isEnabled = jsonView.text.trim().isNotEmpty() && JSON.isValid(jsonView.text)
- super.update(e)
- }
+ fun getText() = jsonView.text
- }
-
- /**
- * 将json转成freezed模型对象
- */
- private fun jsonToFreezedModel() {
- val text = jsonView.text.trim()
- if (text.isEmpty()) {
- project.toastWithError(PluginBundle.get("input.your.json"))
- return
- }
- try {
- JSONObject.parseObject(jsonView.text)
- } catch (e: Exception) {
- project.toastWithError(PluginBundle.get("json.format.verification.failed"))
- return
- }
- project.jsonToFreezedRun(text)
- }
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/LeftActionTools.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/LeftActionTools.kt
index 1ad85dcd..132b673e 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/LeftActionTools.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/LeftActionTools.kt
@@ -2,54 +2,31 @@ package shop.itbug.fluttercheckversionx.form.socket
import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.*
-import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.components.service
-import com.intellij.openapi.project.Project
-import shop.itbug.fluttercheckversionx.actions.OpenSettingAnAction
-import shop.itbug.fluttercheckversionx.i18n.PluginBundle
import shop.itbug.fluttercheckversionx.socket.service.AppService
-//左侧工具栏操作区域
-class LeftActionTools(
- val project: Project,
-) : DefaultActionGroup() {
-
- private val deleteButton = DelButton()
-
-
-
- init {
- add(deleteButton.action)
- add(OpenSettingAnAction.getInstance())
+//清理接口列表
+class DioRequestCleanAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ service().cleanAllRequest()
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+ override fun update(e: AnActionEvent) {
+ e.presentation.icon = AllIcons.Actions.GC
+// e.presentation.description = PluginBundle.get("window.idea.dio.view.clean.desc")
+// e.presentation.text = PluginBundle.get("clean")
+ super.update(e)
+ }
}
-//清理
-class DelButton : ActionButton(
- object :
- AnAction(PluginBundle.get("clean"), PluginBundle.get("window.idea.dio.view.clean.desc"), AllIcons.Actions.GC) {
- override fun actionPerformed(e: AnActionEvent) {
- service().cleanAllRequest()
- }
-
- },
- Presentation("清除全部记录"),
- "Dio Tool Left Action Sort",
- ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE
-)
-
-
-
fun DefaultActionGroup.create(place: String): ActionPopupMenu {
return ActionManager.getInstance().createActionPopupMenu(place, this)
}
-fun DefaultActionGroup.createWithToolbar(place: String, horizontal: Boolean = true): ActionToolbar {
- return ActionManager.getInstance().createActionToolbar(place, this, horizontal)
-}
-
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/MyDefaultListModel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/MyDefaultListModel.kt
index 260b07fd..05596c77 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/MyDefaultListModel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/MyDefaultListModel.kt
@@ -1,100 +1,37 @@
package shop.itbug.fluttercheckversionx.form.socket
-import cn.hutool.core.net.url.UrlBuilder
-import com.intellij.ui.ColorUtil
-import com.intellij.ui.JBColor
-import com.intellij.util.ui.UIUtil
-import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
+import com.intellij.ui.ColoredListCellRenderer
+import com.intellij.ui.components.JBLabel
import shop.itbug.fluttercheckversionx.dsl.requestDetailLayout
-import shop.itbug.fluttercheckversionx.icons.MyIcons
import java.awt.Component
-import javax.swing.*
+import javax.swing.JList
-class MyDefaultListModel(datas: List) :
- AbstractListModel() {
- var list = datas
-
- override fun getSize(): Int {
- return list.size
- }
+///渲染请求列表
+class MyCustomItemRender : ColoredListCellRenderer() {
- override fun getElementAt(index: Int): Request {
- return list[index]
+ override fun customizeCellRenderer(
+ list: JList,
+ value: Request?,
+ index: Int,
+ selected: Boolean,
+ hasFocus: Boolean
+ ) {
}
-}
-
-///渲染请求列表
-class MyCustomItemRender : ListCellRenderer {
-
- private val setting = DioxListingUiConfig.setting
override fun getListCellRendererComponent(
list: JList?,
value: Request?,
index: Int,
- isSelected: Boolean,
- cellHasFocus: Boolean
+ selected: Boolean,
+ hasFocus: Boolean
): Component {
- if (value == null) return JLabel("未知请求")
- return requestDetailLayout(value,isSelected,setting)
+ if (value == null) {
+ return JBLabel()
+ }
+ return requestDetailLayout(value, selected)
}
}
-///请求列表item布局
-class MyRequestItemPanel(request: Request, isSelected: Boolean) : Box(BoxLayout.X_AXIS) {
- init {
- //icon
- add(JLabel(MyIcons.apiIcon))
- add(createHorizontalStrut(4))
-
- UrlBuilder.ofHttp(request.url)
-
- //path
- val pathLabel = JLabel(request.url).apply {
- foreground = UIUtil.getLabelForeground()
- }
- add(pathLabel)
- add(createHorizontalStrut(4))
-
-
- //method
- val methodLabel = JLabel(request.method).apply {
- foreground = JBColor.GRAY
- }
- add(methodLabel)
- add(createHorizontalStrut(4))
-
- //状态码
- val codeLabel = JLabel("${request.statusCode}").apply {
- foreground = if (request.statusCode != 200) {
- JBColor.RED
- } else {
- ColorUtil.fromHex("#79bf2d")
- }
- }
- add(codeLabel)
- add(createHorizontalStrut(4))
-
-
-
- if (isSelected) {
- background = UIUtil.getListSelectionBackground(false)
- }
-
-
- ///请求耗时label
- val timerLabel = JLabel((request.timestamp).toString() + "毫秒")
- timerLabel.foreground = JBColor.GRAY
- if (isSelected) {
- timerLabel.background = UIUtil.getListSelectionBackground(false)
- } else {
- timerLabel.background = UIUtil.getListBackground()
- }
- add(timerLabel)
- }
-
-
-}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt
index c4b75327..40fcb66d 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt
@@ -1,151 +1,139 @@
package shop.itbug.fluttercheckversionx.form.socket
+import com.alibaba.fastjson2.JSON
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.DefaultActionGroup
-import com.intellij.openapi.components.service
+import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
+import com.intellij.ui.JBColor
import com.intellij.ui.OnePixelSplitter
-import com.intellij.ui.components.JBScrollPane
+import com.intellij.util.ui.JBUI
import com.intellij.util.ui.components.BorderLayoutPanel
-import org.smartboot.socket.StateMachineEnum
-import org.smartboot.socket.transport.AioSession
-import shop.itbug.fluttercheckversionx.bus.SocketMessageBus
+import shop.itbug.fluttercheckversionx.common.scroll
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
import shop.itbug.fluttercheckversionx.form.actions.DioRequestSearch
-import shop.itbug.fluttercheckversionx.form.actions.ProjectFilter
import shop.itbug.fluttercheckversionx.form.components.ApiListPanel
import shop.itbug.fluttercheckversionx.form.components.RightDetailPanel
import shop.itbug.fluttercheckversionx.socket.ProjectSocketService.SocketResponseModel
-import shop.itbug.fluttercheckversionx.socket.service.AppService
import shop.itbug.fluttercheckversionx.socket.service.DioApiService
-import shop.itbug.fluttercheckversionx.util.toastWithError
-import java.awt.CardLayout
-import javax.swing.JPanel
-import javax.swing.SwingUtilities
+
typealias Request = SocketResponseModel
+///是否可以转换到 json 对象
+fun SocketResponseModel.isParseToJson(): Boolean {
+ data?.let {
+ println(it::class.java)
+ when (it) {
+ is String -> {
+ return JSON.isValid(it)
+ }
+
+ is Map<*, *> -> {
+ return true
+ }
+
+ is List<*> -> {
+ return true
+ }
+
+ else -> false
+ }
+ }
+ return false
+}
+
+fun SocketResponseModel.getDataString(): String {
+ data?.let {
+ return when (it) {
+ is String -> it
+ is Map<*, *> -> JSONObject.toJSONString(it)
+ is List<*> -> JSONObject.toJSONString(it)
+ else -> "$it"
+ }
+ }
+ return ""
+}
+
// 监听http请求的窗口
-class SocketRequestForm(val project: Project, private val toolWindow: ToolWindow) : BorderLayoutPanel(),
+class SocketRequestForm(val project: Project, private val toolWindow: ToolWindow) : OnePixelSplitter(),
DioApiService.HandleFlutterApiModel {
- private val appService = service()
-
- //项目筛选
- private val projectFilterBox = ProjectFilter()
+ ///接口列表
+ private val apiPanel = ApiListPanel(project)
- //搜索输入框
- private var searchTextField = DioRequestSearch()
- //接口列表组件
- private var apiList = ApiListPanel(project)
+ private val leftPanel = LeftPanel()
- private val apiListWrapper = JBScrollPane(apiList)
//右侧面板
private val rightFirstPanel = RightDetailPanel(project)
- private val myRightComponent = JPanel(CardLayout()).apply {
- add(rightFirstPanel, "response_body_panel")
- }
- //左侧工具栏
- private var leftToolBarCore = LeftActionTools(project)
-
- //顶部组件
- private val createTopToolbarGroup: DefaultActionGroup = object : DefaultActionGroup() {
- init {
- this.add(projectFilterBox)
- }
+ init {
+ firstComponent = leftPanel
+ secondComponent = rightFirstPanel
+ splitterProportionKey = SPLIT_KEY
+ register()
}
- //左侧大面板 - 顶部工具栏
- private val apiTopToolbar =
- createTopToolbarGroup.createWithToolbar(TOP_KET)
- .apply { targetComponent = toolWindow.component }.component.apply {
- this.add(searchTextField)
- }
+ private inner class LeftPanel : BorderLayoutPanel() {
+ private val topActions =
+ ActionManager.getInstance().getAction("FlutterX Window Top Actions") as DefaultActionGroup
- //左侧大面板 - 左边工具栏
- private val apiToolLeftToolbar =
- leftToolBarCore.createWithToolbar(LEFT_KEY, false).apply { targetComponent = toolWindow.component }.component
+ //创建工具栏
+ private val topToolbar =
+ ActionManager.getInstance().createActionToolbar("Dio Toolbar", topActions, true)
- //左侧大面板
- private val myFirstComponent = BorderLayoutPanel().apply {
- addToLeft(apiToolLeftToolbar)
- addToCenter(apiListWrapper)
- addToTop(BorderLayoutPanel().apply {
- addToRight(apiTopToolbar)
- addToCenter(searchTextField)
- })
- }
- //主面板
- private var mainPanel = OnePixelSplitter().apply {
- firstComponent = myFirstComponent
- secondComponent = myRightComponent
- splitterProportionKey = SPLIT_KEY
- }
+ private val apiList = apiPanel.scroll().apply {
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ }
+
+ init {
+ topToolbar.targetComponent = toolWindow.component
+ addToTop(BorderLayoutPanel().apply {
+ addToCenter(DioRequestSearch())
+ addToRight(topToolbar.component)
+ })
+ addToCenter(apiList)
- init {
- SwingUtilities.invokeLater {
- addToCenter(mainPanel)
}
- SocketMessageBus.listening {
- autoScrollToMax()
+
+
+ ///滚动到底部.
+ fun scrollToBottom() {
+ val verticalScrollBar = apiList.verticalScrollBar
+ verticalScrollBar.value = verticalScrollBar.maximum
}
}
-
/**
* 自动滚动到最底部
*/
private fun autoScrollToMax() {
- if (appService.apiListAutoScrollerToMax) {
- SwingUtilities.invokeLater {
- apiListWrapper.verticalScrollBar.apply {
- value = maximum
- }
+ val setting = DioxListingUiConfig.setting
+ if (setting.autoScroller) {
+ ApplicationManager.getApplication().invokeLater {
+ leftPanel.scrollToBottom()
}
}
}
- companion object {
- const val SPLIT_KEY = "Dio Panel Re Key"
- const val TOP_KET = "Dio Top Toolbar Key"
- const val LEFT_KEY = "Dio Left Toolbar Key"
- }
-
override fun handleModel(model: SocketResponseModel) {
- val flutterProjects = appService.flutterProjects
- val reqs = flutterProjects[model.projectName] ?: emptyList()
- val reqsAdded = reqs.plus(model)
- model.projectName?.apply {
- if (!flutterProjects.keys.contains(this)) {
- val old = mutableListOf()
- flutterProjects.keys.forEach {
- old.add(it)
- }
- old.add(this)
- appService.fireFlutterNamesChangeBus(old.toList())
- }
-
- flutterProjects[this] = reqsAdded
- }
- appService.projectNames = flutterProjects.keys.toList()
- SocketMessageBus.fire(model)
+ autoScrollToMax()
}
- override fun stateEvent(session: AioSession?, stateMachineEnum: StateMachineEnum?, throwable: Throwable?) {
-
+ companion object {
+ const val SPLIT_KEY = "Dio Panel Re Key"
}
- override fun covertJsonError(e: Exception, aio: AioSession?) {
- project.toastWithError("$e")
- }
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/JsonValueRender.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/JsonValueRender.kt
index 1b9de36f..6cf53314 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/JsonValueRender.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/JsonValueRender.kt
@@ -2,14 +2,9 @@ package shop.itbug.fluttercheckversionx.form.sub
import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.JSONWriter
-import com.intellij.json.JsonLanguage
+import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.project.Project
-import com.intellij.ui.LanguageTextField
-import com.intellij.ui.components.JBScrollPane
-import com.intellij.util.ui.UIUtil
-import java.awt.BorderLayout
-import javax.swing.BorderFactory
-import javax.swing.JPanel
+import shop.itbug.fluttercheckversionx.widget.JsonEditorTextPanel
/**
* json viewer
@@ -19,22 +14,7 @@ import javax.swing.JPanel
*
*/
-class JsonValueRender(var project: Project) : JPanel(BorderLayout()) {
-
-
- private var jsonView: LanguageTextField = LanguageTextField(JsonLanguage.INSTANCE, project, "", false)
-
- val text: String get() = jsonView.text
-
- init {
- border = BorderFactory.createEmptyBorder()
- jsonView.border = BorderFactory.createEmptyBorder()
- jsonView.background = UIUtil.getPanelBackground()
- val s = JBScrollPane(jsonView)
- s.border = BorderFactory.createEmptyBorder()
- add(s, BorderLayout.CENTER)
- background = UIUtil.getPanelBackground()
- }
+class JsonValueRender(p: Project) : JsonEditorTextPanel(p) {
/**
@@ -43,7 +23,10 @@ class JsonValueRender(var project: Project) : JPanel(BorderLayout()) {
fun changeValue(json: Any?) {
if (json != null && !project.isDisposed) {
val changeJson = changeJson(json)
- jsonView.text = changeJson
+ WriteCommandAction.runWriteCommandAction(project) {
+ text = changeJson
+ }
+ super.scrollToTop()
}
}
@@ -70,3 +53,12 @@ class JsonValueRender(var project: Project) : JPanel(BorderLayout()) {
}
+//private fun T.createAnActions(text: String): Array {
+// return arrayOf(
+// MyActionButton(JsonToFreezedModelAction(text)).action,
+// WidgetUtil.getCopyAnAction(text),
+// WidgetUtil.getDiscordAction()
+// )
+//}
+
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveDefaultActionGroup.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveDefaultActionGroup.kt
new file mode 100644
index 00000000..6f8d6de8
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveDefaultActionGroup.kt
@@ -0,0 +1,30 @@
+package shop.itbug.fluttercheckversionx.hive.action
+
+import com.intellij.openapi.actionSystem.ActionGroup
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.components.service
+import shop.itbug.fluttercheckversionx.form.actions.ProjectFilter
+import shop.itbug.fluttercheckversionx.hive.model.HiveActionGetBox
+import shop.itbug.fluttercheckversionx.socket.service.AppService
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
+
+
+///获取盒子列表
+class HiveGetBoxListAction : AnAction() {
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val project = service().currentSelectName.get() ?: ""
+ DioApiService.sendByAnyObject(HiveActionGetBox(projectName = project))
+ }
+
+ override fun update(e: AnActionEvent) {
+ e.presentation.isEnabled = (service().currentSelectName.get() ?: "").isNotEmpty()
+ super.update(e)
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveTutorialHelp.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveTutorialHelp.kt
new file mode 100644
index 00000000..fe32234f
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/action/HiveTutorialHelp.kt
@@ -0,0 +1,17 @@
+package shop.itbug.fluttercheckversionx.hive.action
+
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+
+
+//hive使用文档 // todo 编写使用文档
+class HiveTutorialHelp : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ println("前往文档")
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveBoxListComponent.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveBoxListComponent.kt
new file mode 100644
index 00000000..f08a7b32
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveBoxListComponent.kt
@@ -0,0 +1,161 @@
+package shop.itbug.fluttercheckversionx.hive.component
+
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.openapi.components.service
+import com.intellij.openapi.project.Project
+import com.intellij.ui.ColoredListCellRenderer
+import com.intellij.ui.JBColor
+import com.intellij.ui.OnePixelSplitter
+import com.intellij.ui.components.JBLabel
+import com.intellij.ui.components.JBList
+import com.intellij.util.ui.JBFont
+import com.intellij.util.ui.JBUI
+import com.intellij.util.ui.UIUtil
+import com.intellij.util.ui.components.BorderLayoutPanel
+import org.smartboot.socket.transport.AioSession
+import shop.itbug.fluttercheckversionx.common.scroll
+import shop.itbug.fluttercheckversionx.hive.model.HiveActionGetKeys
+import shop.itbug.fluttercheckversionx.hive.model.HiveActionGetValue
+import shop.itbug.fluttercheckversionx.socket.service.AppService
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
+import javax.swing.BorderFactory
+import javax.swing.DefaultListModel
+import javax.swing.JList
+import javax.swing.event.ListSelectionEvent
+import javax.swing.event.ListSelectionListener
+
+///盒子列表
+class HiveBoxListComponent(project: Project) : OnePixelSplitter() {
+
+
+ private val hiveBoxList = HiveBoxList()
+ private val keysList = HiveKeysList(hiveBoxList)
+
+ init {
+ firstComponent = BorderLayoutPanel().apply {
+ addToTop(JBLabel("Box list").apply {
+ border = BorderFactory.createEmptyBorder(3, 3, 3, 3)
+ font = JBFont.label()
+ foreground = UIUtil.getLabelDisabledForeground()
+ })
+ addToCenter(hiveBoxList.scroll().apply {
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ })
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ }
+ secondComponent = BorderLayoutPanel().apply {
+ addToTop(JBLabel("Key list").apply {
+ border = BorderFactory.createEmptyBorder(3, 3, 3, 3)
+ font = JBFont.label()
+ foreground = UIUtil.getLabelDisabledForeground()
+ })
+ addToCenter(keysList.scroll().apply {
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ })
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ }
+ splitterProportionKey = "hive-box-and-list"
+ }
+}
+
+///盒子列表
+class HiveBoxList : JBList(), DioApiService.NativeMessageProcessing, ListSelectionListener {
+
+ init {
+ DioApiService.addHandle(this)
+ cellRenderer = ItemRender()
+ addListSelectionListener(this)
+ }
+
+
+ override fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?) {
+ jsonObject?.apply {
+ val type = getString("type")
+ if (type == "getBoxList") {
+ val arr = getJSONArray("data").map { it.toString() }
+ model = ItemModel(arr)
+ }
+ }
+ }
+
+
+ private inner class ItemModel(list: List) : DefaultListModel() {
+ init {
+ addAll(list)
+ }
+ }
+
+ private inner class ItemRender : ColoredListCellRenderer() {
+ override fun customizeCellRenderer(
+ list: JList, value: String?, index: Int, selected: Boolean, hasFocus: Boolean
+ ) {
+ append(value ?: "")
+ }
+
+ }
+
+ override fun valueChanged(e: ListSelectionEvent?) {
+ if (e != null && e.valueIsAdjusting.not() && selectedValue != null) {
+ val projectName = service().currentSelectName.get() ?: ""
+ DioApiService.sendByAnyObject(HiveActionGetKeys(projectName = projectName, boxName = selectedValue))
+ }
+ }
+
+}
+
+
+///盒子里面的 key 列表
+class HiveKeysList(private val boxList: JBList) : JBList(), DioApiService.NativeMessageProcessing,
+ ListSelectionListener {
+
+
+ init {
+ cellRenderer = ItemRender()
+ addListSelectionListener(this)
+ register()
+ }
+
+ override fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?) {
+ jsonObject?.apply {
+ val type = getString("type")
+ if (type == "getKeys") {
+ val arr = getJSONArray("data").map { it.toString() }
+ model = ItemModel(arr)
+ }
+ }
+ }
+
+ override fun valueChanged(e: ListSelectionEvent?) {
+ if (e != null && e.valueIsAdjusting.not() && selectedValue != null) {
+ val projectName = service().currentSelectName.get() ?: ""
+ val boxName = boxList.selectedValue
+ DioApiService.sendByAnyObject(
+ HiveActionGetValue(
+ projectName = projectName, boxName = boxName, key = selectedValue
+ )
+ )
+ }
+
+ }
+
+
+ private inner class ItemModel(list: List) : DefaultListModel() {
+ init {
+ addAll(list)
+ }
+ }
+
+ private inner class ItemRender : ColoredListCellRenderer() {
+ override fun customizeCellRenderer(
+ list: JList, value: String?, index: Int, selected: Boolean, hasFocus: Boolean
+ ) {
+ append(value ?: "")
+ }
+
+ }
+
+ fun clean() {
+ model = ItemModel(emptyList())
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveValueComponent.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveValueComponent.kt
new file mode 100644
index 00000000..a48e03ba
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/component/HiveValueComponent.kt
@@ -0,0 +1,36 @@
+package shop.itbug.fluttercheckversionx.hive.component
+
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.openapi.project.Project
+import com.intellij.util.ui.components.BorderLayoutPanel
+import org.smartboot.socket.transport.AioSession
+import shop.itbug.fluttercheckversionx.form.sub.JsonValueRender
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
+
+///显示 json
+class HiveValueComponent(project: Project) : BorderLayoutPanel(), DioApiService.NativeMessageProcessing {
+
+
+ private val jsonEditor = JsonValueRender(p = project)
+
+ init {
+ addToCenter(jsonEditor)
+ register()
+ }
+
+
+ ///更新值
+ private fun changeJsonValue(value: Any) {
+ jsonEditor.changeValue(value)
+ }
+
+ override fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?) {
+ jsonObject?.apply {
+ val type = getString("type")
+ if (type == "getValue" && get("data") != null) {
+ changeJsonValue(get("data"))
+
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/model/HiveAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/model/HiveAction.kt
new file mode 100644
index 00000000..7bfe7616
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/model/HiveAction.kt
@@ -0,0 +1,12 @@
+package shop.itbug.fluttercheckversionx.hive.model
+
+///hive操作模型
+data class HiveActionGetKeys(val action: String = "getKeys", val projectName: String, val boxName: String)
+data class HiveActionGetBox(val action: String = "getBoxList", val projectName: String)
+data class HiveActionGetValue(
+ val action: String = "getValue",
+ val projectName: String,
+ val key: String,
+ val boxName: String
+)
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/widget.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/widget.kt
new file mode 100644
index 00000000..07f0d1ee
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/hive/widget.kt
@@ -0,0 +1,47 @@
+package shop.itbug.fluttercheckversionx.hive
+
+import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.DefaultActionGroup
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.ToolWindow
+import com.intellij.ui.JBColor
+import com.intellij.ui.OnePixelSplitter
+import com.intellij.util.ui.JBUI
+import com.intellij.util.ui.components.BorderLayoutPanel
+import shop.itbug.fluttercheckversionx.hive.component.HiveBoxListComponent
+import shop.itbug.fluttercheckversionx.hive.component.HiveValueComponent
+
+///hive工具窗口
+class HiveWidget(project: Project, toolWindow: ToolWindow) : BorderLayoutPanel() {
+
+
+ private val boxAndKeys = HiveBoxListComponent(project)
+ private val jsonRender = HiveValueComponent(project).apply {
+ border = JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0)
+ }
+
+
+ private val mainPanel = OnePixelSplitter().apply {
+ firstComponent = boxAndKeys
+ secondComponent = jsonRender
+ splitterProportionKey = "HiveKey"
+ }
+
+
+ //操作栏
+ private val toolbar = ActionManager.getInstance().createActionToolbar(
+ "Hive Tool Bar",
+ ActionManager.getInstance()
+ .getAction("shop.itbug.fluttercheckversionx.hive.action.HiveDefaultActionGroup") as DefaultActionGroup,
+ true
+ ).apply {
+ targetComponent = toolWindow.component
+ }
+
+ init {
+ addToTop(toolbar.component)
+ addToCenter(mainPanel)
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt
index e30934fe..906f82c3 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt
@@ -67,7 +67,7 @@ class HintsInlayPresentationFactory(private val factory: PresentationFactory) {
}
- fun iconRoundClick(icon: Icon,clicked: InlayPresentationClickHandle? = null): InlayPresentation {
+ fun iconRoundClick(icon: Icon, clicked: InlayPresentationClickHandle? = null): InlayPresentation {
return factory.smallScaledIcon(icon).addRoundBg().clickHandle(clicked)
}
@@ -168,7 +168,6 @@ class HintsInlayPresentationFactory(private val factory: PresentationFactory) {
val imageIcon: Icon = ImageIcon(i)
return factory.icon(imageIcon).addTip(basePath)
} catch (e: Exception) {
- println("$path 读取图片失败:$e")
null
}
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/PluginInlayHintsProvider.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/PluginInlayHintsProvider.kt
index fe582e1d..421ca6b9 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/PluginInlayHintsProvider.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/PluginInlayHintsProvider.kt
@@ -4,70 +4,54 @@ import com.intellij.codeInsight.hints.*
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
-import com.intellij.psi.util.PsiTreeUtil
-import org.jetbrains.yaml.psi.impl.YAMLKeyValueImpl
-import shop.itbug.fluttercheckversionx.inlay.json.DefaulImmediateConfigurable
-import shop.itbug.fluttercheckversionx.util.isDartPluginElement
+import com.intellij.ui.components.JBLabel
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import javax.swing.JComponent
-class PluginInlayHintsProvider : InlayHintsProvider {
+class PluginInlayHintsProvider : InlayHintsProvider {
- companion object {
- private val KEY: SettingsKey = SettingsKey("plug.hint.provider")
- }
-
- data class Settings(
- val show: Boolean = true
- )
-
- override val key: SettingsKey
- get() = KEY
+ override val key: SettingsKey
+ get() = SettingsKey(PluginBundle.get("flutterX-Dart-Plugin-Ignore"))
override val name: String
- get() = "settings.inlay.menus"
+ get() = PluginBundle.get("flutterX-Dart-Plugin-Ignore")
override val previewText: String
- get() = """
-dependencies:
- extended_image: ^6.0.2+1
- flutter_easyrefresh: ^2.2.1
- """.trimIndent()
+ get() = PluginBundle.get("flutterX-Dart-Plugin-Ignore")
- /**
- * Creates configurable, that immediately applies changes from UI to [settings]
- */
- override fun createConfigurable(settings: Settings): ImmediateConfigurable {
- return DefaulImmediateConfigurable()
- }
-
- override fun createSettings(): Settings {
- return Settings()
+ override fun createSettings(): PluginInlayHintsProvider {
+ TODO("Not yet implemented")
}
override fun getCollectorFor(
file: PsiFile,
editor: Editor,
- settings: Settings,
+ settings: PluginInlayHintsProvider,
sink: InlayHintsSink
): InlayHintsCollector {
- return object : FactoryInlayHintsCollector(editor) {
+ return object : InlayHintsCollector {
+
override fun collect(element: PsiElement, editor: Editor, sink: InlayHintsSink): Boolean {
- if (element.isDartPluginElement()) {
- PsiTreeUtil.findChildOfAnyType(element, YAMLKeyValueImpl::class.java)
-// pathElement?.let {
-// if (pathElement.keyText == "path" || pathElement.keyText == "github") {
-// editor.foldingModel.runBatchFoldingOperation {
-// editor.foldingModel.addFoldRegion(
-// element.startOffset,
-// element.endOffset,
-// "引入本地插件"
-// )
-// }
-// }
+// val ex = YamlExtends(element)
+// val config = DartPluginIgnoreConfig.getInstance(file.project)
+// if (ex.isDartPluginElement() && config.isIg(ex.getDartPluginNameAndVersion()?.name ?: "") ) {
+// sink.addPresentation(InlineInlayPosition(element.endOffset, true, 0), emptyList(), "", true) {
+// this.text(PluginBundle.get("flutterX-Dart-Plugin-Ignore")) //提示忽略检测
// }
- }
+// sink.addInlineElement(element.endOffset)
+// }
return true
}
+
}
}
+ override fun createConfigurable(settings: PluginInlayHintsProvider): ImmediateConfigurable {
+ return object : ImmediateConfigurable {
+ override fun createComponent(listener: ChangeListener): JComponent {
+ return JBLabel("none")
+ }
+
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt
index b30cc8d1..b9e505d2 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt
@@ -4,9 +4,11 @@ import com.intellij.codeInsight.hints.*
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
+import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.suggested.endOffset
+import com.intellij.refactoring.suggested.startOffset
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService
-import com.jetbrains.lang.dart.psi.impl.DartComponentNameImpl
+import com.jetbrains.lang.dart.psi.impl.DartSimpleFormalParameterImpl
import com.jetbrains.lang.dart.psi.impl.DartVarAccessDeclarationImpl
import com.jetbrains.lang.dart.psi.impl.DartVarDeclarationListImpl
import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig
@@ -21,7 +23,6 @@ import java.awt.datatransfer.StringSelection
class DartTypeInlayHintsProvider : InlayHintsProvider {
-
override val key: SettingsKey
get() = SettingsKey("dart.type.inlay.hints.provider")
override val name: String
@@ -36,6 +37,7 @@ class DartTypeInlayHintsProvider : InlayHintsProvider()
- if (nameComm.isNotEmpty()) {
- val filterIsInstanceWithName = nameComm[0]
- val filterIsInstance =
- filterIsInstanceWithName.children.filterIsInstance()[0]
- filterIsInstance.parent.nextSibling ?: return true
-
- val analysisGethover = DartAnalysisServerService.getInstance(file.project)
- .analysis_getHover(file.virtualFile, filterIsInstance.textOffset)
- if (analysisGethover.isNotEmpty()) {
- val staticType = analysisGethover[0].staticType
- analysisGethover[0].dartdoc
+ val dartVar = PsiTreeUtil.findChildOfType(element, DartVarAccessDeclarationImpl::class.java)
+ if (dartVar != null) {
+ val comName = dartVar.componentName
+ val type = dartVar.type
+ if(type!=null){
+ return true //如果有类型就不显示了
+ }
+ val result = DartAnalysisServerService.getInstance(file.project)
+ .analysis_getHover(file.virtualFile, comName.textOffset)
+ if (result.isNotEmpty()) {
+ val staticType = result[0].staticType
+ result[0].dartdoc
if (staticType != null) {
val ins =
- hintsInlayPresentationFactory.simpleText(staticType, "类型:$staticType") { _, _ ->
+ hintsInlayPresentationFactory.simpleText(" :$staticType", staticType) { _, _ ->
val ss = StringSelection(staticType)
val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
clipboard.setContents(ss, null)
}
sink.addInlineElement(
- filterIsInstanceWithName.endOffset, false, ins, false
+ comName.endOffset, false, ins, false
)
}
}
}
}
-
- //资产图片的展示
-// if (element.lastChild is DartReferenceExpressionImpl && settings.showImageIconInEditor) {
-// element.reference?.let {
-// val referenceValElement = it.resolve()?.parent?.parent
-// if (referenceValElement is DartVarDeclarationListImpl && referenceValElement.lastChild is DartVarInitImpl) {
-// val varInitElement = referenceValElement.lastChild
-// if (varInitElement.lastChild is DartStringLiteralExpressionImpl) {
-// val path = varInitElement.lastChild.text.replace("'", "").replace("\"", "")
-// hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path)
-// ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) }
-// }
-// }
-// }
-//
-// }
-
-
-// if(element is DartStringLiteralExpressionImpl) {
-// val path = element.text.replace("'", "").replace("\"", "")
-// hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path)
-// ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) }
-// }
-
+ if(element is DartSimpleFormalParameterImpl){
+ if(element.type == null) {
+ val result = DartAnalysisServerService.getInstance(file.project)
+ .analysis_getHover(file.virtualFile, element.textOffset)
+ if(result.isNotEmpty()){
+ val staticType = result[0].staticType
+ if(staticType != null){
+ val ins =
+ hintsInlayPresentationFactory.simpleText("$staticType: ", staticType) { _, _ ->
+ val ss = StringSelection(staticType)
+ val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
+ clipboard.setContents(ss, null)
+ }
+ sink.addInlineElement(
+ element.startOffset, false, ins, false
+ )
+ }
+ }
+ }
+ }
return true
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt
index 7f4fb2ca..e648aaee 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt
@@ -16,6 +16,8 @@ import com.intellij.ui.dsl.builder.panel
import com.jetbrains.lang.dart.psi.impl.DartClassDefinitionImpl
import com.jetbrains.lang.dart.psi.impl.DartFactoryConstructorDeclarationImpl
import shop.itbug.fluttercheckversionx.common.MyAction
+import shop.itbug.fluttercheckversionx.config.DioxListeningSetting
+import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
import shop.itbug.fluttercheckversionx.dialog.JsonToFreezedInputDialog
import shop.itbug.fluttercheckversionx.inlay.HintsInlayPresentationFactory
import shop.itbug.fluttercheckversionx.manager.DartClassManager
@@ -28,31 +30,30 @@ import java.awt.event.MouseEvent
import javax.swing.JComponent
-data class FreezedInlaySetting(var show: Boolean)
-class FreezedInlay : InlayHintsProvider {
- override val key: SettingsKey
+class FreezedInlay : InlayHintsProvider {
+ override val key: SettingsKey
get() = SettingsKey("freezed inlay")
override val name: String
get() = "FreezedInlay"
override val previewText: String
- get() = "@freezed" +
+ get() = "@freezed\n" +
"class Test {}"
- override fun createSettings(): FreezedInlaySetting {
- return FreezedInlaySetting(true)
+ override fun createSettings(): DioxListeningSetting {
+ return DioxListingUiConfig.setting
}
override fun getCollectorFor(
file: PsiFile,
editor: Editor,
- settings: FreezedInlaySetting,
+ settings: DioxListeningSetting,
sink: InlayHintsSink
): InlayHintsCollector {
return FreezedInlayCollector(editor)
}
- override fun createConfigurable(settings: FreezedInlaySetting): ImmediateConfigurable {
+ override fun createConfigurable(settings: DioxListeningSetting): ImmediateConfigurable {
return FreezedInlayPanel()
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/linemark/PluginDartIconLineMark.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/linemark/PluginDartIconLineMark.kt
index 4255f5a6..b30603a7 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/linemark/PluginDartIconLineMark.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/linemark/PluginDartIconLineMark.kt
@@ -16,16 +16,17 @@ import note.jdbc.FlutterCollectService
import note.jdbc.SqliteConnectManager
import org.jetbrains.yaml.psi.impl.YAMLKeyValueImpl
import shop.itbug.fluttercheckversionx.actions.PUB_URL
+import shop.itbug.fluttercheckversionx.cache.DartPluginIgnoreConfig
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
import shop.itbug.fluttercheckversionx.icons.MyIcons
import shop.itbug.fluttercheckversionx.util.getPluginName
import shop.itbug.fluttercheckversionx.util.isDartPluginElement
+import shop.itbug.fluttercheckversionx.util.restartAnalyzer
import shop.itbug.fluttercheckversionx.util.toast
import java.awt.event.MouseEvent
import javax.swing.Icon
-
class PluginDartIconLineMark : LineMarkerProvider {
override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo? {
@@ -35,7 +36,7 @@ class PluginDartIconLineMark : LineMarkerProvider {
element.firstChild, element.firstChild.textRange,
if(isExits) MyIcons.collect else MyIcons.dartPackageIcon, { element.text }, PluginDartIconLineMarkNavHandler(element),
GutterIconRenderer.Alignment.LEFT
- ) { "111" }
+ ) { "" }
}
return null
}
@@ -45,13 +46,13 @@ class PluginDartIconLineMark : LineMarkerProvider {
class PluginDartIconLineMarkNavHandler(val element: PsiElement) : GutterIconNavigationHandler {
override fun navigate(e: MouseEvent?, elt: PsiElement?) {
if ((e != null) && (e.clickCount == 1)) {
- JBPopupFactory.getInstance().createListPopup(PluginDartIconActioinMenuList(element = element))
- .show(RelativePoint(e.locationOnScreen))
+ JBPopupFactory.getInstance().createListPopup(PluginDartIconActioinMenuList(element = element)).show(RelativePoint(e.locationOnScreen))
}
}
}
data class PluginDartIconActionMenuItem(val title: String, val type: String, val icon: Icon)
+
class PluginDartIconActioinMenuList(val element: PsiElement) : BaseListPopupStep() {
private val isExites = FlutterCollectService.exits(element.getPluginName()) //是否已经收藏
@@ -67,7 +68,8 @@ class PluginDartIconActioinMenuList(val element: PsiElement) : BaseListPopupStep
PluginBundle.get("plugin.collect"),
"collect",
if (isExites) MyIcons.collect else MyIcons.collectUn
- )
+ ),
+ PluginDartIconActionMenuItem(PluginBundle.get("ig.version.check"),"ig-check", icon = AllIcons.General.Beta)
)
init {
@@ -88,6 +90,10 @@ class PluginDartIconActioinMenuList(val element: PsiElement) : BaseListPopupStep
menus[1].type -> {
addToCollect()
}
+ menus[2].type -> {
+ DartPluginIgnoreConfig.getInstance(element.project).add(element.getPluginName())
+ element.project.restartAnalyzer()
+ }
}
return super.onChosen(selectedValue, finalChoice)
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/listeners/FlutterProjectChangeEvent.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/listeners/FlutterProjectChangeEvent.kt
new file mode 100644
index 00000000..3e0aecda
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/listeners/FlutterProjectChangeEvent.kt
@@ -0,0 +1,18 @@
+package shop.itbug.fluttercheckversionx.listeners
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.project.Project
+import com.intellij.util.messages.Topic
+
+interface FlutterProjectChangeEvent {
+
+ fun changeProject(projectName: String, project: Project?)
+
+ fun connectFlutterProjectChangeEvent() {
+ ApplicationManager.getApplication().messageBus.connect().subscribe(topic, this)
+ }
+
+ companion object {
+ val topic = Topic.create("FlutterProjectChangeEvent", FlutterProjectChangeEvent::class.java)
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/Blog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/Blog.kt
index 895f247c..062990e6 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/Blog.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/Blog.kt
@@ -1,8 +1,5 @@
package shop.itbug.fluttercheckversionx.model
-import kotlinx.serialization.SerialName
-import kotlinx.serialization.Serializable
-
data class BlogCategory (
val createTime: String,
val id: Long,
@@ -11,16 +8,3 @@ data class BlogCategory (
val name: String
)
-@Serializable
-data class BlogWriteModel (
- var title: String = "",
- var content: String = "",
- var tags: List = emptyList(),
-
- @SerialName("categoryId")
- var categoryID: Long? = null,
-
- var alias: String = "",
- var thumbnail: String = "",
- var id: Long? = null
-)
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/DartClassProperty.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/DartClassProperty.kt
index 0abdf278..2bd26625 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/DartClassProperty.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/DartClassProperty.kt
@@ -76,9 +76,25 @@ private fun String.dartNameStandard(): String {
* 对命名进行驼峰格式化
*/
private fun String.nomenclatureOfHumps(isEnable: Boolean): String {
- return if (isEnable) CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, this) else this
+
+
+
+
+ var s = this.replaceFirstChar { it.lowercase() }
+
+ if(!isEnable){
+ return s
+ }
+
+ if(s.contains("_")){
+ s = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, s)
+ }
+
+ return s
}
+
+
fun DartClassProperty.formatType(useDefaultValue: Boolean, isJson: Boolean = true): String {
if (useDefaultValue && isJson) {
return type.removeSuffix("?")
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/PubVersionDataModel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/PubVersionDataModel.kt
index eb14c3b1..dd2eaf1c 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/model/PubVersionDataModel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/model/PubVersionDataModel.kt
@@ -1,22 +1,23 @@
package shop.itbug.fluttercheckversionx.model
-import kotlin.text.toCharArray
-
data class PubVersionDataModel(
val name: String,
val latest: Latest,
val versions: List
) {
- private val lastVersion get() = '^' + latest.version
+ val lastVersion get() = '^' + latest.version
/**
* 判断版本是否为最新版本.将传入的[version]和[latest.version]进行比如,如果不是最新版则执行[apply]函数
* [apply] 函数回调一个最新版本
+ * @return true 已经是最新版本 false 不是最新版本
*/
- fun judge(version: String, apply: (lastVersionString: String) -> Unit) {
+ fun judge(version: String, apply: (lastVersionString: String) -> Unit) : Boolean {
if (lastVersion != version) {
apply.invoke(lastVersion)
+ return false
}
+ return true
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/NotifUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/NotifUtil.kt
deleted file mode 100644
index 00d2395c..00000000
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/NotifUtil.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package shop.itbug.fluttercheckversionx.notif
-
-import com.intellij.notification.NotificationGroupManager
-import com.intellij.notification.NotificationType
-import com.intellij.openapi.project.Project
-import org.jetbrains.annotations.NotNull
-
-class NotifUtils {
-
- companion object {
-
- // 显示有新版本升级提示的通知
- fun showNewPluginTips(@NotNull project: Project, msg: String){
- NotificationGroupManager.getInstance()
- .getNotificationGroup("plugin_new_version_notify")
- .createNotification(msg,NotificationType.INFORMATION)
- .notify(project)
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/PubPluginVersionCheckNotification.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/PubPluginVersionCheckNotification.kt
index b0b7f170..f380315c 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/PubPluginVersionCheckNotification.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/notif/PubPluginVersionCheckNotification.kt
@@ -79,13 +79,19 @@ class YamlFileNotificationPanel(private val fileEditor: FileEditor, val project:
//
// }
// myLinksPanel.add(reIndex)
+
+
}
private fun checkNewVersions() {
val file = project.getPubspecYAMLFile()
file?.containingFile?.let { DaemonCodeAnalyzer.getInstance(project).restart(it) }
val component = JBPopupFactory.getInstance()
- .createComponentPopupBuilder(AllPluginsCheckVersion(project), fileEditor.component).createPopup()
+ .createComponentPopupBuilder(AllPluginsCheckVersion(project) {
+ file?.containingFile?.let {
+ DaemonCodeAnalyzer.getInstance(project).restart(it)
+ }
+ }, fileEditor.component).createPopup()
component.show(RelativePoint(checkLabel.locationOnScreen))
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt
index adb71283..120b35d9 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt
@@ -17,7 +17,7 @@ import javax.swing.JToolBar
import javax.swing.SwingConstants
-class RequestPanelUi(private val toolWindow: ToolWindow,private val project: Project): BorderLayoutPanel() {
+class RequestPanelUi(private val toolWindow: ToolWindow, private val project: Project) : BorderLayoutPanel() {
private val apiInput = JBTextField()
private val generateButton = JButton("Send")
@@ -39,22 +39,21 @@ class RequestPanelUi(private val toolWindow: ToolWindow,private val project: Pro
return toolbar
}
- private fun getApiJson() {
+ private fun getApiJson() {
val api = apiInput.text
- if(validUrl(api)){
- try{
- val response = HttpUtil.get(api)
- println(response)
- }catch (e:Exception){
+ if (validUrl(api)) {
+ try {
+ val response = HttpUtil.get(api)
+ } catch (e: Exception) {
project.toast(e.localizedMessage)
}
- }else {
+ } else {
project.toastWithError("Unable to access URL")
}
}
- private fun validUrl(urlString: String) : Boolean {
+ private fun validUrl(urlString: String): Boolean {
try {
val url = URL(urlString)
val connection: HttpURLConnection = url.openConnection() as HttpURLConnection
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveActionListen.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveActionListen.kt
new file mode 100644
index 00000000..bd9817bd
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveActionListen.kt
@@ -0,0 +1,115 @@
+package shop.itbug.fluttercheckversionx.save
+
+import com.intellij.openapi.editor.Document
+import com.intellij.openapi.fileEditor.FileDocumentManager
+import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer
+import com.intellij.openapi.progress.ProgressIndicator
+import com.intellij.openapi.progress.ProgressManager
+import com.intellij.openapi.progress.Task
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.project.ProjectManager
+import com.intellij.openapi.vfs.VirtualFile
+import shop.itbug.fluttercheckversionx.util.RunUtil
+import shop.itbug.fluttercheckversionx.util.toastWithError
+import java.io.BufferedReader
+import java.io.File
+import java.io.InputStream
+import java.io.InputStreamReader
+
+
+class DartFileDocumentSynchronizationVetoer : FileDocumentSynchronizationVetoer() {
+
+
+ var indicator : ProgressIndicator? = null
+
+ override fun maySaveDocument(document: Document, isSaveExplicit: Boolean): Boolean {
+
+ val state = DartFileSaveSettingState.getInstance().state
+ if (isSaveExplicit && state.enable) {
+ runCommand(state, document)
+ }
+ return super.maySaveDocument(document, isSaveExplicit)
+ }
+
+ private fun runCommand(state: DartFileSaveSettingModel, document: Document) {
+ var command = state.command
+
+ if (command.contains("{path}")) {
+ command = command.replace("{path}", document.getPath())
+ }
+ document.getProject()?.let {
+ if (state.runType) {
+ if (command.isNotBlank()) {
+ RunUtil.runCommand(it, state.title.ifBlank { "Dog" }, command)
+ println("执行完毕")
+ }
+
+ } else {
+ if (command.isNotBlank()) {
+ if(indicator!=null && indicator!!.isRunning){
+ indicator!!.cancel()
+ }
+ val task = createTask(command, it,state)
+ ProgressManager.getInstance().run(task)
+ }
+ }
+ }
+ }
+
+ private fun createTask(command: String, project: Project,state: DartFileSaveSettingModel): Task.Backgroundable {
+ return object : Task.Backgroundable(project, state.title.ifBlank { command }) {
+ override fun run(indicator: ProgressIndicator) {
+ this@DartFileDocumentSynchronizationVetoer.indicator = indicator
+ try {
+ val exec = Runtime.getRuntime().exec(command,null, File(project.basePath?:""))
+ val code = exec.waitFor()
+ if(code != 0){
+ val errorStream: InputStream = exec.errorStream
+ val errorReader = BufferedReader(InputStreamReader(errorStream))
+ var errorLine: String
+ while (errorReader.readLine().also { errorLine = it } != null) {
+ project.toastWithError("任务非正常结束:$errorLine")
+ }
+ }
+ exec.destroy()
+ }catch (e:Exception){
+ project.toastWithError("执行任务失败:$command $e ")
+ }
+ this@DartFileDocumentSynchronizationVetoer.indicator = null
+ }
+
+ }
+ }
+
+// fun Document.reformat() {
+// getProject()?.let {
+// getFile()?.apply {
+// PsiManager.getInstance(it).findFile(this)?.reformatText()
+// }
+// }
+// }
+
+ private fun getProjectFun(document: Document): Project? {
+ val file = FileDocumentManager.getInstance().getFile(document)
+ val openProjects = ProjectManager.getInstance().openProjects
+ if (file != null) {
+ openProjects.forEach {
+ if (file.path.startsWith(it.basePath ?: "")) {
+ return it
+ }
+ }
+ }
+ return null
+ }
+
+ private fun Document.getFile(): VirtualFile? {
+ return FileDocumentManager.getInstance().getFile(this)
+ }
+ private fun Document.getPath(): String {
+ return getFile()?.path ?: ""
+ }
+
+ private fun Document.getProject(): Project? = getProjectFun(this)
+}
+
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveSettingPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveSettingPanel.kt
new file mode 100644
index 00000000..67c5599d
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/save/DartFileSaveSettingPanel.kt
@@ -0,0 +1,94 @@
+package shop.itbug.fluttercheckversionx.save
+
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.State
+import com.intellij.openapi.components.Storage
+import com.intellij.openapi.components.service
+import com.intellij.openapi.ui.DialogPanel
+import com.intellij.openapi.util.Disposer
+import com.intellij.ui.dsl.builder.bindSelected
+import com.intellij.ui.dsl.builder.bindText
+import com.intellij.ui.dsl.builder.panel
+import com.intellij.ui.dsl.builder.rows
+import com.intellij.util.Alarm
+import com.intellij.util.lateinitVal
+import javax.swing.SwingUtilities
+
+
+data class DartFileSaveSettingModel(
+ var enable: Boolean = false,
+ var command: String = "",
+ var runType: Boolean = false,
+ var title: String = ""
+)
+
+@State(name = "DartFileSaveSettingState", storages = [Storage("DartFileSaveSettingState.xml")])
+class DartFileSaveSettingState private constructor() : PersistentStateComponent {
+ private var setting = DartFileSaveSettingModel()
+ override fun getState(): DartFileSaveSettingModel {
+ return setting
+ }
+
+ override fun loadState(state: DartFileSaveSettingModel) {
+ this.setting = state
+ }
+
+
+ companion object {
+
+ //获取实例
+ fun getInstance(): DartFileSaveSettingState {
+ return service()
+ }
+ }
+
+}
+
+
+fun dartFileSaveSettingPanel(
+ disposable: Disposable,
+ state: DartFileSaveSettingModel,
+ valueChanged: (v: Boolean) -> Unit
+): DialogPanel {
+
+ var p by lateinitVal()
+
+ p = panel {
+ row {
+ checkBox("是否启用此功能").bindSelected(state::enable)
+ }
+ row {
+ checkBox("执行方式: 默认静默无感执行,会在后台开启一个线程执行,勾选后会打开Terminal执行").bindSelected(state::runType)
+ }
+ row {
+ textField().bindText(state::title).comment("自定义后台任务名称")
+ }
+ row {
+ textArea().bindText(state::command).rows(3)
+ }.comment("执行命令 (提示: 使用{path},在执行的时候会替换成保存的文件路径)")
+
+
+ }
+
+
+ val alarm = Alarm(disposable)
+
+
+ fun initValidation() {
+ alarm.addRequest({
+ valueChanged.invoke(p.isModified())
+ initValidation()
+ }, 1000)
+ }
+
+ SwingUtilities.invokeLater {
+ initValidation()
+ }
+
+ val newD = Disposer.newDisposable()
+ p.registerValidators(newD)
+ Disposer.register(newD, disposable)
+
+ return p
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt
index eafba5d4..5b9b0936 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt
@@ -114,8 +114,9 @@ class MyUserAccountBar(var project: Project) : CustomStatusBarWidget {
)
}
+ @OptIn(ExperimentalStdlibApi::class)
private fun createPop(): JBPopup {
- return JBPopupFactory.getInstance().createPopupChooserBuilder(entries)
+ return JBPopupFactory.getInstance().createPopupChooserBuilder(PluginActions.entries.toList())
.setItemChosenCallback { doActions(it) }
.setRenderer { _, value, _, _, _ ->
return@setRenderer JBLabel(value.title).apply {
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/actions/SocketConnectComboxAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/actions/SocketConnectComboxAction.kt
new file mode 100644
index 00000000..7bdd4b24
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/actions/SocketConnectComboxAction.kt
@@ -0,0 +1,50 @@
+package shop.itbug.fluttercheckversionx.services.actions
+
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.DefaultActionGroup
+import com.intellij.openapi.ui.popup.JBPopup
+import com.intellij.openapi.ui.popup.JBPopupFactory
+import shop.itbug.fluttercheckversionx.common.MyAction
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
+import shop.itbug.fluttercheckversionx.widget.MyExpandableComboAction
+
+/**
+ * socket 链接列表
+ */
+class SocketConnectComboxAction: MyExpandableComboAction() {
+
+ var selectSessionId = ""
+
+ private fun createGroup() = object : DefaultActionGroup() {
+ init {
+ addAll(DioApiService.getSessions().map {
+ object : MyAction({it.sessionID}){
+ override fun actionPerformed(e: AnActionEvent) {
+ println("勾选。。。")
+ selectSessionId = it.sessionID
+ }
+ }
+ })
+ }
+ }
+
+
+
+ override fun update(e: AnActionEvent) {
+ val sessions = DioApiService.getSessions()
+ if(sessions.isEmpty()){
+ e.presentation.description = "Empty"
+ e.presentation.text = PluginBundle.get("empty")
+ }
+
+ super.update(e)
+ }
+
+
+
+ override fun createPopup(event: AnActionEvent): JBPopup? {
+ val pop = JBPopupFactory.getInstance().createActionGroupPopup(null,createGroup(),event.dataContext,JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,true)
+ return pop
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/event/UserLoginStatusEvent.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/event/UserLoginStatusEvent.kt
index b82a0af4..3e04922f 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/event/UserLoginStatusEvent.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/event/UserLoginStatusEvent.kt
@@ -12,10 +12,10 @@ interface UserLoginStatusEvent {
fun loginSuccess(user: User?)
companion object {
- val TOPIC = Topic.create("dd-user-login-status-change",UserLoginStatusEvent::class.java)
- fun listening(onUser: (user: User?)->Unit) {
+ val TOPIC = Topic.create("dd-user-login-status-change", UserLoginStatusEvent::class.java)
+ fun listening(onUser: (user: User?) -> Unit) {
ApplicationManager.getApplication().messageBus.connect()
- .subscribe(UserLoginStatusEvent.TOPIC, object : UserLoginStatusEvent {
+ .subscribe(TOPIC, object : UserLoginStatusEvent {
override fun loginSuccess(user: User?) {
onUser.invoke(user)
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/AppConfig.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/AppConfig.kt
index 5358dc46..8d945c05 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/AppConfig.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/AppConfig.kt
@@ -9,6 +9,8 @@ import shop.itbug.fluttercheckversionx.config.DioxListingUiConfig
import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig
import shop.itbug.fluttercheckversionx.dsl.settingPanel
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.save.DartFileSaveSettingState
+import shop.itbug.fluttercheckversionx.save.dartFileSaveSettingPanel
import shop.itbug.fluttercheckversionx.services.AppStateModel
import shop.itbug.fluttercheckversionx.services.PluginStateService
import javax.swing.JComponent
@@ -20,18 +22,25 @@ class AppConfig : Configurable, Disposable {
private var dioSetting = DioxListingUiConfig.getInstance().state ?: DioxListeningSetting()
private val generaAssetsSettingPanel = GenerateAssetsClassConfig.getGenerateAssetsSetting()
+ private val dartSaveSettingState = DartFileSaveSettingState.getInstance().state
private var generaAssetsSettingPanelModelIs = false
+ private var dartFileSaveSettingPanelModelIs = false
private var generateSettingPanel =
GeneraAssetsSettingPanel(settingModel = generaAssetsSettingPanel, parentDisposable = this@AppConfig) {
generaAssetsSettingPanelModelIs = it
}
+ private var dog = dartFileSaveSettingPanel(this,dartSaveSettingState){
+ dartFileSaveSettingPanelModelIs = it
+ }
+
override fun createComponent(): JComponent {
return JBTabbedPane().apply {
add(PluginBundle.get("basic"), panel)
add(PluginBundle.get("assets.gen"), generateSettingPanel)
+ add("保存后执行", dog )
}
}
@@ -42,23 +51,26 @@ class AppConfig : Configurable, Disposable {
private val panel: JComponent get() = dialog
override fun isModified(): Boolean {
- return dialog.isModified() || generaAssetsSettingPanelModelIs
+ return dialog.isModified() || generaAssetsSettingPanelModelIs || dartFileSaveSettingPanelModelIs
}
override fun apply() {
dialog.apply()
generateSettingPanel.doApply()
+ dog.apply()
PluginStateService.getInstance().loadState(model)
DioxListingUiConfig.getInstance().loadState(dioSetting)
GenerateAssetsClassConfig.getInstance().loadState(generaAssetsSettingPanel)
+ DartFileSaveSettingState.getInstance().loadState(dartSaveSettingState)
}
override fun getDisplayName(): String {
- return PluginBundle.get("setting")
+ return PluginBundle.get("setting.flutterx")
}
override fun reset() {
dialog.reset()
+ dog.reset()
super.reset()
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt
index c28d0afb..133f79dc 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt
@@ -89,6 +89,10 @@ class GeneraAssetsSettingPanel(
super.update(e)
}
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+
},
WidgetUtil.getHelpAnAction { it ->
it.inputEvent?.let {
@@ -177,6 +181,9 @@ fun getGeneraAssetsPanel(
}
+
+
+
/**
* 忽略的文件或者后缀
*/
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/ProjectSocketService.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/ProjectSocketService.kt
index 2c35edc3..0f94ff72 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/ProjectSocketService.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/ProjectSocketService.kt
@@ -36,10 +36,13 @@ class ProjectSocketService {
var timestamp: Int?,
///项目名称
- var projectName: String?,
+ var projectName: String = "",
///生成成功
- var createDate: String = DateUtil.now()
+ var createDate: String = DateUtil.now(),
+
+ ///扩展label列表
+ var extendNotes: List = listOf()
)
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/AppService.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/AppService.kt
index 2dd12c61..0bd9a9dd 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/AppService.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/AppService.kt
@@ -1,18 +1,17 @@
package shop.itbug.fluttercheckversionx.socket.service
-import com.google.common.collect.ImmutableSet
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
+import com.intellij.openapi.project.Project
import org.smartboot.socket.StateMachineEnum
-import org.smartboot.socket.transport.AioQuickServer
import org.smartboot.socket.transport.AioSession
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import shop.itbug.fluttercheckversionx.bus.DioWindowCleanRequests
-import shop.itbug.fluttercheckversionx.bus.ProjectListChangeBus
import shop.itbug.fluttercheckversionx.form.socket.Request
+import shop.itbug.fluttercheckversionx.listeners.FlutterProjectChangeEvent
import shop.itbug.fluttercheckversionx.model.resource.ResourceCategory
import shop.itbug.fluttercheckversionx.model.resource.ResourceCategoryTypeEnum
import shop.itbug.fluttercheckversionx.model.user.User
@@ -24,16 +23,11 @@ import shop.itbug.fluttercheckversionx.services.event.UserLoginStatusEvent
import shop.itbug.fluttercheckversionx.socket.ProjectSocketService
import shop.itbug.fluttercheckversionx.util.CredentialUtil
import java.util.concurrent.atomic.AtomicReference
-import javax.swing.SwingUtilities
@Service
class AppService : DioApiService.HandleFlutterApiModel {
-
- // 全局的socket监听服务
- private lateinit var server: AioQuickServer
-
//用户信息
var user: User? = null
@@ -52,25 +46,36 @@ class AppService : DioApiService.HandleFlutterApiModel {
//项目名称列表
var projectNames: List = emptyList()
- //监听列表
- private var listenings = AtomicReference>(ImmutableSet.of())
//当前选中的项目
var currentSelectName: AtomicReference = AtomicReference(null)
val dioServerStatus: StateMachineEnum? get() = socketServerState
- //自动滚动到底部
- var apiListAutoScrollerToMax = true
+ //右键选中的项目
+ var currentSelectRequest: Request? = null
private val messageBus get() = ApplicationManager.getApplication().messageBus
+
+ ///接口列表
+ private var requestsList = mutableListOf()
+
+ ///添加一下接口
+ private fun addRequest(item: Request) {
+ if (requestsList.isEmpty()) {
+ changeCurrentSelectFlutterProjectName(item.projectName, null)
+ }
+ requestsList.add(item)
+ }
+
+
/**
* 存储了flutter项目
* 键是项目名称
* 值是请求列表
*/
- var flutterProjects = mutableMapOf>()
+ val flutterProjects get() = requestsList.groupBy { it.projectName }
private val userRunStartManager = Thread(UserRunStartService())
@@ -81,13 +86,7 @@ class AppService : DioApiService.HandleFlutterApiModel {
userRunStartManager.start()
chatRoomLoadManager.start()
note.jdbc.SqliteConnectManager
- }
-
- /**
- * 如果监听到api接口请求,是否自动滚动到最底部
- */
- fun setIsAutoScrollToMax(value: Boolean) {
- apiListAutoScrollerToMax = value
+ register()
}
@@ -103,84 +102,50 @@ class AppService : DioApiService.HandleFlutterApiModel {
*/
val dioIsStart get() = socketIsInit
- //添加监听
- fun addListening(runnable: Runnable) {
- listenings.updateAndGet { old ->
- val toMutableList = old.toMutableList()
- toMutableList.add(runnable)
- ImmutableSet.copyOf(toMutableList)
- }
- }
-
- //移除监听
- fun removeListening(runnable: Runnable) {
- listenings.updateAndGet { old ->
- val toMutableList = old.toMutableList()
- toMutableList.remove(runnable)
- ImmutableSet.copyOf(toMutableList)
- }
- }
-
- //通知更新
- private fun fireChangeToListening() {
- SwingUtilities.invokeLater {
- for (runnable in listenings.get()) {
- try {
- runnable.run()
- } catch (e: Exception) {
- println("警告: 更新失败:$e")
- }
- }
- }
- }
-
//更新当前选中的项目名称
- fun changeCurrentSelectFlutterProjectName(appName: String) {
+ fun changeCurrentSelectFlutterProjectName(appName: String, project: Project?) {
currentSelectName.updateAndGet { appName }
- fireChangeToListening()
+ ApplicationManager.getApplication().messageBus.syncPublisher(FlutterProjectChangeEvent.topic)
+ .changeProject(appName, project)
}
- fun fireFlutterNamesChangeBus(list: List) {
- ProjectListChangeBus.fire(list)
- }
-
- fun getRequestsWithProjectName(projectName: String): List {
- val d = flutterProjects.filter { it.key == projectName }
- if (d.isNotEmpty()) {
- return d.getValue(projectName)
- }
- return emptyList()
- }
-
/**
* 获取全部的请求,不区分项目
*/
fun getAllRequest(): List {
- val all = mutableListOf()
- flutterProjects.values.forEach {
- all.addAll(it)
- }
- return all
+ return requestsList
}
+ ///获取当前选中项目的接口列表
fun getCurrentProjectAllRequest(): List {
- if (currentSelectName.get() != null) {
- return flutterProjects[currentSelectName.get()!!]?.toList() ?: emptyList()
+ currentSelectName.get()?.let {
+ return flutterProjects[it] ?: emptyList()
}
return emptyList()
}
+ ///刷新接口列表
+ fun refreshProjectRequest(project: Project) {
+ currentSelectName.get()?.let {
+ changeCurrentSelectFlutterProjectName(it, project)
+ }
+ }
+
/**
* 只支持当前选中的项目
* 清空全部的请求
*/
fun cleanAllRequest() {
currentSelectName.get()?.apply {
- flutterProjects[this] = emptyList()
- DioWindowCleanRequests.fire()
+ val result = requestsList.removeAll { it.projectName == this }
+ if (result) {
+ DioWindowCleanRequests.fire()
+ } else {
+ println("删除失败")
+ }
}
}
@@ -217,8 +182,7 @@ class AppService : DioApiService.HandleFlutterApiModel {
val call = SERVICE.create().getResourceCategorys(ResourceCategoryTypeEnum.chatRoom.type)
call.enqueue(object : Callback>> {
override fun onResponse(
- call: Call>>,
- response: Response>>
+ call: Call>>, response: Response>>
) {
response.body()?.apply {
if (state == 200) {
@@ -241,6 +205,7 @@ class AppService : DioApiService.HandleFlutterApiModel {
}
override fun handleModel(model: ProjectSocketService.SocketResponseModel) {
+ addRequest(model)
}
override fun stateEvent(session: AioSession?, stateMachineEnum: StateMachineEnum?, throwable: Throwable?) {
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/DioApiService.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/DioApiService.kt
index 508aa683..54a5eda1 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/DioApiService.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/socket/service/DioApiService.kt
@@ -1,27 +1,103 @@
package shop.itbug.fluttercheckversionx.socket.service
+import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.JSONObject
import org.smartboot.socket.MessageProcessor
import org.smartboot.socket.StateMachineEnum
import org.smartboot.socket.transport.AioQuickServer
import org.smartboot.socket.transport.AioSession
+import org.smartboot.socket.transport.WriteBuffer
import shop.itbug.fluttercheckversionx.socket.ProjectSocketService
import shop.itbug.fluttercheckversionx.socket.StringProtocol
+
object DioApiService {
- interface HandleFlutterApiModel {
- fun handleModel(model: ProjectSocketService.SocketResponseModel)
+
+
+ private fun AioSession.send(message: String) {
+ val writeBuffer: WriteBuffer = writeBuffer()
+ val data = message.toByteArray()
+ writeBuffer.write(data)
+ writeBuffer.flush()
+ }
+
+ private val sessions = mutableSetOf()
+ private val messageProcessor = MyMessageProcessor
+
+ ///添加消息处理程序
+ fun addHandle(processor: NativeMessageProcessing) {
+ messageProcessor.addHandle(processor)
+ }
+
+ fun getSessions() = sessions
+
+ fun addSession(session: AioSession?) {
+ session?.let { sessions.add(it) }
+ }
+
+ fun removeSession(session: AioSession?) {
+ session?.let { sessions.remove(it) }
+ }
+
+ private fun sendMessage(message: String) {
+ sessions.forEach {
+ it.send(message)
+ }
+ }
+
+
+ fun sendByMap(map: MutableMap) {
+ sendMessage(JSONObject.toJSONString(map))
+ }
+
+ fun sendByAnyObject(obj: Any) {
+ val json = JSON.toJSONString(obj)
+ sendByMap(JSON.parseObject(json))
+ }
+
+
+ interface NativeMessageProcessing {
+
+
+ fun register() {
+ addHandle(this)
+ }
+
+ /**
+ * 处理 app 那边发过来的消息
+ * @param nativeMessage 字符串消息
+ * @param jsonObject 会尝试转换字符串消息为JSON,注意判空
+ */
+ fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?)
+
fun stateEvent(
- session: AioSession?,
- stateMachineEnum: StateMachineEnum?,
- throwable: Throwable?
- )
+ session: AioSession?, stateMachineEnum: StateMachineEnum?, throwable: Throwable?
+ ) {
+ }
+ }
+
+
+ ///flutter api 接口模型
+ interface HandleFlutterApiModel : NativeMessageProcessing {
+ fun handleModel(model: ProjectSocketService.SocketResponseModel) {}
+
+ fun covertJsonError(e: Exception, aio: AioSession?) {}
- fun covertJsonError(e: Exception, aio: AioSession?)
+ override fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?) {
+ try {
+ jsonObject?.to(ProjectSocketService.SocketResponseModel::class.java)?.let {
+ if (it.projectName.isNotBlank()) {
+ handleModel(it)
+ }
+ }
+ } catch (e: Exception) {
+ covertJsonError(e, aio)
+ }
+ }
}
- fun builder(port: Int, handle: HandleFlutterApiModel): AioQuickServer {
- val server = AioQuickServer(port, StringProtocol(), MyMessageProcessor(handle))
+ fun builder(port: Int): AioQuickServer {
+ val server = AioQuickServer(port, StringProtocol(), messageProcessor)
server.setBannerEnabled(false)
server.setReadBufferSize(10485760 * 2) // 20m
return server
@@ -30,7 +106,14 @@ object DioApiService {
}
-class MyMessageProcessor(private val handle: DioApiService.HandleFlutterApiModel) : MessageProcessor {
+object MyMessageProcessor : MessageProcessor {
+
+ private var handle = setOf()
+
+ fun addHandle(processor: DioApiService.NativeMessageProcessing) {
+ handle = handle.plus(processor)
+ }
+
override fun process(session: AioSession?, msg: String?) {
if (msg != null) {
jsonStringToModel(msg, session)
@@ -39,17 +122,39 @@ class MyMessageProcessor(private val handle: DioApiService.HandleFlutterApiModel
private fun jsonStringToModel(msg: String, session: AioSession?) {
try {
- val responseModel = JSONObject.parseObject(msg, ProjectSocketService.SocketResponseModel::class.java)
- handle.handleModel(responseModel)
- } catch (e: Exception) {
- handle.covertJsonError(e, session)
+ val json = JSONObject.parse(msg)
+ handle.forEach {
+ it.handleFlutterAppMessage(msg, json, session)
+ }
+ } catch (_: Exception) {
+ handle.forEach {
+ it.handleFlutterAppMessage(msg, null, session)
+ }
}
}
override fun stateEvent(session: AioSession?, stateMachineEnum: StateMachineEnum?, throwable: Throwable?) {
- handle.stateEvent(session, stateMachineEnum, throwable)
+ handle.forEach {
+ it.stateEvent(session, stateMachineEnum, throwable)
+ }
+ defaultEventHandle(session, stateMachineEnum)
super.stateEvent(session, stateMachineEnum, throwable)
}
+ private fun defaultEventHandle(session: AioSession?, stateMachineEnum: StateMachineEnum?) {
+ when (stateMachineEnum) {
+ StateMachineEnum.NEW_SESSION -> {
+ DioApiService.addSession(session)
+ }
+
+ StateMachineEnum.INPUT_SHUTDOWN -> DioApiService.removeSession(session)
+ StateMachineEnum.SESSION_CLOSING -> DioApiService.removeSession(session)
+ StateMachineEnum.SESSION_CLOSED -> DioApiService.removeSession(session)
+ StateMachineEnum.REJECT_ACCEPT -> DioApiService.removeSession(session)
+ StateMachineEnum.ACCEPT_EXCEPTION -> DioApiService.removeSession(session)
+ else -> {}
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ActionsTool.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ActionsTool.kt
new file mode 100644
index 00000000..55e68f3b
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ActionsTool.kt
@@ -0,0 +1,7 @@
+package shop.itbug.fluttercheckversionx.tools
+
+object ActionsTool {
+
+ fun findAction(){
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/AutoVersionTool.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/AutoVersionTool.kt
deleted file mode 100644
index 70b2dc5a..00000000
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/AutoVersionTool.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-package shop.itbug.fluttercheckversionx.tools
-
-import com.intellij.codeInspection.LocalInspectionTool
-import com.intellij.codeInspection.ProblemHighlightType
-import com.intellij.codeInspection.ProblemsHolder
-import com.intellij.psi.PsiElementVisitor
-import com.intellij.psi.PsiFile
-import com.intellij.util.indexing.FileBasedIndex
-import shop.itbug.fluttercheckversionx.fix.NewVersionFix
-import shop.itbug.fluttercheckversionx.i18n.PluginBundle
-import shop.itbug.fluttercheckversionx.model.FlutterPluginElementModel
-import shop.itbug.fluttercheckversionx.util.ApiService
-import shop.itbug.fluttercheckversionx.util.CacheUtil
-import shop.itbug.fluttercheckversionx.util.MyPsiElementUtil
-
-
-/**
- * yaml 版本自动补全
- */
-class AutoVersionTool : LocalInspectionTool() {
-
- /// 访问了文件
- override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
- return YamlElementVisitor(holder)
- }
-
- override fun runForWholeFile(): Boolean {
- return false
- }
-}
-
-
-///检测版本
-class YamlElementVisitor(
- private val holder: ProblemsHolder
-) : PsiElementVisitor() {
-
-
-
- private val plugins = MyPsiElementUtil.getAllFlutters(holder.project)
- private val pubFile = MyPsiElementUtil.getPubSecpYamlFile(holder.project)
-
-
- override fun visitFile(file: PsiFile) {
- super.visitFile(file)
-
- for (arr in plugins.values) {
- arr.forEach { ele ->
- regProblem(ele)
- }
- }
- }
-
-
-
-
- /**
- * 问题注册器,并新增快速修复功能更
- */
- private fun regProblem(ele: FlutterPluginElementModel) {
-
- var cacheModel = CacheUtil.getCatch().getIfPresent(ele.name)
- if(cacheModel == null){
- cacheModel = ApiService.getPluginDetail(ele.name)
- }
- cacheModel?.let { model ->
- CacheUtil.set(ele.name,cacheModel)
- val currentVersionString = ele.element.valueText
- cacheModel.judge(currentVersionString) {
- holder.registerProblem(
- ele.element.lastChild,
- "${PluginBundle.get("version.tip.1")}:${it} (${PluginBundle.get("version.tip.2")}:${cacheModel.lastVersionUpdateTimeString})",
- ProblemHighlightType.WARNING,
- NewVersionFix(ele.element, it,model){
- }
- )
- }
- }
- }
-
-
- private fun re() {
- }
-
- private fun reIndex() {
-
- pubFile?.let { psiFile ->
- FileBasedIndex.getInstance().requestReindex(psiFile.virtualFile)
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt
new file mode 100644
index 00000000..cd62ce76
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt
@@ -0,0 +1,105 @@
+package shop.itbug.fluttercheckversionx.tools
+
+import com.intellij.codeInsight.intention.IntentionAction
+import com.intellij.lang.annotation.AnnotationHolder
+import com.intellij.lang.annotation.ExternalAnnotator
+import com.intellij.lang.annotation.HighlightSeverity
+import com.intellij.openapi.application.runReadAction
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiFile
+import com.intellij.psi.PsiRecursiveElementWalkingVisitor
+import shop.itbug.fluttercheckversionx.cache.DartPluginIgnoreConfig
+import shop.itbug.fluttercheckversionx.i18n.PluginBundle
+import shop.itbug.fluttercheckversionx.model.PubVersionDataModel
+import shop.itbug.fluttercheckversionx.util.*
+
+
+///插件版本检查
+class DartPluginVersionCheck : ExternalAnnotator>() {
+
+ data class Input(val file: PsiFile,val element: List)
+ data class Problem(val textRange: TextRange,val model : PubVersionDataModel,val element: PsiElement)
+
+ override fun collectInformation(file: PsiFile): Input {
+ val elements = mutableListOf()
+ file.originalElement.accept(object : PsiRecursiveElementWalkingVisitor(){
+ override fun visitElement(element: PsiElement) {
+ val ext = YamlExtends(element)
+ if(ext.isDartPluginElement() && DartPluginIgnoreConfig.getInstance(file.project).isIg(ext.getDartPluginNameAndVersion()?.name?:"").not()){
+ elements.add(element)
+ }
+ super.visitElement(element)
+ }
+ })
+ return Input(file,elements)
+ }
+
+
+
+
+ //执行长时间操作
+ override fun doAnnotate(collectedInfo: Input?): List {
+ val arr = mutableListOf()
+ collectedInfo?.let {
+ val pluginElements = it.element //插件列表
+ pluginElements.forEach { ele ->
+ val ext = YamlExtends(ele)
+ var plugin : DartPluginVersionName? = null
+ runReadAction {
+ plugin = ext.getDartPluginNameAndVersion()
+ }
+ if(plugin!=null){
+ val model = ApiService.getPluginDetail(plugin!!.name)
+ if(model != null && model.judge(plugin!!.version){}.not()){
+ //有新版本
+ arr.add(Problem(ele.lastChild.textRange,model,ele))
+ }
+ }
+
+ }
+ }
+ return arr
+ }
+
+
+ override fun apply(file: PsiFile, annotationResult: List?, holder: AnnotationHolder) {
+ annotationResult?.forEach {
+
+ holder.newAnnotation(HighlightSeverity.WARNING,"${PluginBundle.get("version.tip.1")}:${it.model.lastVersion}")
+ .newFix(object : IntentionAction {
+ val fixText = PluginBundle.get("version.tip.3") + it.model.lastVersion
+ var available = true
+ override fun startInWriteAction(): Boolean {
+ return true
+ }
+
+ override fun getFamilyName(): String {
+ return fixText
+ }
+
+ override fun getText(): String {
+ return fixText
+ }
+
+ override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
+ return available
+ }
+
+ override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
+ MyPsiElementUtil.modifyPsiElementText(it.element.lastChild,it.model.lastVersion)
+ available = false
+ project.restartPubFileAnalyzer();
+ }
+
+
+ }).registerFix().range(it.element.lastChild).needsUpdateOnTyping().create()
+
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPublicFunctionFix.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPublicFunctionFix.kt
deleted file mode 100644
index 9c49fe01..00000000
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPublicFunctionFix.kt
+++ /dev/null
@@ -1,133 +0,0 @@
-package shop.itbug.fluttercheckversionx.tools
-
-import com.intellij.codeInspection.LocalInspectionTool
-import com.intellij.codeInspection.LocalQuickFixOnPsiElement
-import com.intellij.codeInspection.ProblemHighlightType
-import com.intellij.codeInspection.ProblemsHolder
-import com.intellij.openapi.application.runWriteAction
-import com.intellij.openapi.project.Project
-import com.intellij.psi.PsiElement
-import com.intellij.psi.PsiElementVisitor
-import com.intellij.psi.PsiFile
-import com.intellij.psi.util.PsiTreeUtil
-import com.jetbrains.lang.dart.psi.impl.*
-import com.jetbrains.lang.dart.util.DartElementGenerator
-import shop.itbug.fluttercheckversionx.util.MyDartPsiElementUtil
-
-
-val checkSuperClassNames = listOf("StatefulWidget")
-
-/**
- * 自动修复功能: Avoid using private types in public APIs.
- * 解释: [https://dart-lang.github.io/linter/lints/library_private_types_in_public_api.html]
- */
-class DartPublicFunctionFix : LocalInspectionTool() {
-
- override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
- return DartPublicFunctionApiFixVisitor(holder = holder)
- }
-
-
-}
-
-class DartPublicFunctionApiFixVisitor(val holder: ProblemsHolder) : PsiElementVisitor() {
-
- fun getMethodCallRefre(dmdElement: DartMethodDeclarationImpl): PsiElement? {
- ///获取返回值
- val dartFuntionBodyList = dmdElement.childrenOfType()
- if (dartFuntionBodyList.isNotEmpty()) {
- val dartCallExpressionList = dartFuntionBodyList.first().childrenOfType()
- if (dartCallExpressionList.isNotEmpty()) {
- val dartReferenceExpessionList =
- dartCallExpressionList.first().childrenOfType()
- if (dartReferenceExpessionList.isNotEmpty()) {
- return dartReferenceExpessionList.first()
- }
- }
- }
- return null
- }
-
- override fun visitElement(element: PsiElement) {
- //如果节点是一个类
- if (element is DartClassDefinitionImpl) {
-
- //判断是不是继承自StatefulWidget类
- val superClassList = element.childrenOfType()
- if (superClassList.isNotEmpty()) {
- val c2 = superClassList.first().childrenOfType()
- if (c2.isNotEmpty()) {
- val superClassName = c2.first().text
- if (checkSuperClassNames.contains(superClassName)) {
- ///包含需要待检测的类
- val methods =
- element.childrenOfType().first().childrenOfType()
- .first().childrenOfType()
- val names =
- methods.filter { it.childrenOfType().first().text == "createState" }
- if (names.isNotEmpty()) {
- val dmdElement = names.first() //DartMethodDeclarationImpl节点
- val name = dmdElement.childrenOfType().first().text
- if (name.equals("createState")) {
- val returnTypes = dmdElement.childrenOfType()
- if (returnTypes.isNotEmpty()) {
- val returnTypeEle = returnTypes.first()
- if (returnTypeEle.text.indexOf("_") == 0) {
- holder.registerProblem(
- returnTypes.first(),
- "梁典典: dart建议将返回类型修改为公有变量",
- ProblemHighlightType.WARNING,
- PublicApiRenameFix(returnTypeEle, returnTypeEle.text, dmdElement)
- )
- }
-
- }
- }
-
-
- }
- }
- }
-
- }
- }
- super.visitElement(element)
- }
-}
-
-///修复类
-class PublicApiRenameFix(val element: PsiElement, val className: String, var functionElement: PsiElement) :
- LocalQuickFixOnPsiElement(element) {
- private val renameText = className.removePrefix("_")
-
- override fun getFamilyName(): String {
- return "重命名为$renameText"
- }
-
- override fun getText(): String {
- return familyName
- }
-
- override fun invoke(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement) {
- val createExpressionFromText = DartElementGenerator.createExpressionFromText(project, renameText)
- createExpressionFromText?.let {
- val classReferences = PsiTreeUtil.findChildrenOfAnyType(file, DartReferenceExpressionImpl::class.java,DartComponentNameImpl::class.java)
- .filter { v -> v.text == className }
- if (classReferences.isNotEmpty()) {
- classReferences.forEach { el ->
- runWriteAction {
- el.replace(createExpressionFromText)
- }
- }
- }
- }
-
-
- }
-
-}
-
-
-inline fun PsiElement.childrenOfType(): List {
- return this.children.filterIsInstance()
-}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ExtensionsUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ExtensionsUtil.kt
new file mode 100644
index 00000000..ed109090
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/ExtensionsUtil.kt
@@ -0,0 +1,34 @@
+package shop.itbug.fluttercheckversionx.tools
+
+import kotlinx.coroutines.*
+
+
+/**
+ * 闭包使用:launchIO({异步},{挂起函数同步主线程},{异常返回,可以省略})
+ *
+ * @param block 异步协程,{可以实现delay()、repeat()、async()、await()、suspend()等}
+ * @param callback 同步主协程,view更新
+ * @param error 异常返回
+ * @return 可操作协程 job.cancelAndJoin()
+ */
+@OptIn(DelicateCoroutinesApi::class)
+fun launchIOToMain(
+ block: suspend CoroutineScope.() -> T,
+ callback:(T) -> Unit,
+ error: ((Exception) -> Unit) = {}
+): Job {
+ return GlobalScope.launch {
+ try {
+ val data = withContext(Dispatchers.IO) { //协程切换,得到IO协程的泛型结果
+ block()
+ }
+ withContext(Dispatchers.Main) {//协程切换主协程
+ callback(data)
+ }
+ } catch (e: Exception) {
+ withContext(Dispatchers.Main) {//异常
+ error.invoke(e)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyFileUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyFileUtil.kt
index 4f3c58e5..93995e2e 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyFileUtil.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyFileUtil.kt
@@ -1,10 +1,33 @@
package shop.itbug.fluttercheckversionx.util
+import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
+import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
+import javax.swing.SwingUtilities
+///重新启用分析
+fun Project.restartAnalyzer() {
+ SwingUtilities.invokeLater {
+ runReadAction {
+ DaemonCodeAnalyzer.getInstance(this).restart()
+ }
+ }
+}
+
+///重新分析依赖文件
+fun Project.restartPubFileAnalyzer() {
+ SwingUtilities.invokeLater {
+ runReadAction {
+ MyPsiElementUtil.getPubSecpYamlFile(this)?.let {
+ DaemonCodeAnalyzer.getInstance(this).restart(it)
+ }
+ }
+ }
+}
+
typealias HandleVirtualFile = (virtualFile: VirtualFile) -> Unit
fun VirtualFile.fileNameWith(folderName: String) : String {
val indexOf = this.path.indexOf(folderName)
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt
index 476b6251..a61e1c6a 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt
@@ -13,6 +13,7 @@ import com.intellij.psi.util.parents
import com.intellij.testFramework.LightVirtualFile
import com.intellij.util.IncorrectOperationException
import com.jetbrains.lang.dart.DartFileType
+import io.flutter.sdk.FlutterSdk
import org.jetbrains.yaml.YAMLElementGenerator
import org.jetbrains.yaml.YAMLLanguage
import org.jetbrains.yaml.YAMLUtil
@@ -111,6 +112,10 @@ class MyPsiElementUtil {
* 获取项目pubspec.yaml 文件
*/
fun getPubSecpYamlFile(project: Project): PsiFile? {
+ val sdk = FlutterSdk.getFlutterSdk(project)?.version?.versionText
+ if(sdk.isNullOrBlank()){
+ return null
+ }
val pubspecYamlFile =
LocalFileSystem.getInstance()
.findFileByIoFile(File("${project.stateStore.projectBasePath}/pubspec.yaml"))
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/NotifactionUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/NotifactionUtil.kt
index c10c6be7..938bbf4f 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/NotifactionUtil.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/NotifactionUtil.kt
@@ -1,12 +1,17 @@
package shop.itbug.fluttercheckversionx.util
+import com.intellij.ide.BrowserUtil
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
+import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.wm.ToolWindowManager
+import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction
import shop.itbug.fluttercheckversionx.dialog.LoginDialogV2
+import shop.itbug.fluttercheckversionx.document.copyTextToClipboard
+import shop.itbug.fluttercheckversionx.i18n.i18n
import shop.itbug.fluttercheckversionx.icons.MyIcons
import javax.swing.JComponent
@@ -22,6 +27,12 @@ class MyNotificationUtil {
.createNotification(message, type).apply {
icon = MyIcons.flutter
}
+ .addAction(object : MyDumbAwareAction({"bug-feedback".i18n()}){
+ override fun actionPerformed(e: AnActionEvent) {
+ message.copyTextToClipboard()
+ BrowserUtil.open("https://github.com/mdddj/dd_flutter_idea_plugin/issues")
+ }
+ })
.notify(project)
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt
index a9646648..7fc6bf25 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt
@@ -6,6 +6,7 @@ import org.jetbrains.plugins.terminal.TerminalView
object RunUtil {
fun runCommand(project: Project,title: String,command: String){
+// TerminalToolWindowManager.getInstance(project).createLocalShellWidget(project.basePath,title).executeCommand(command)
TerminalView.getInstance(project).createLocalShellWidget(project.basePath,title).executeCommand(command)
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/SwingUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/SwingUtil.kt
index ca868bef..e29440cc 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/SwingUtil.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/SwingUtil.kt
@@ -107,7 +107,7 @@ object SwingUtil {
fun getMkEditor(project: Project, initText: String = ""): MarkdownEditorWithPreview {
val vF = LightVirtualFile("D", MarkdownFileType.INSTANCE, initText)
val mkEdit =
- FileEditorProviderManager.getInstance().getProviders(project, vF).first() as MarkdownSplitEditorProvider
+ FileEditorProviderManager.getInstance().getProviderList(project, vF).first() as MarkdownSplitEditorProvider
val edit = mkEdit.createEditor(project, vF)
return edit as MarkdownEditorWithPreview
}
@@ -115,7 +115,7 @@ object SwingUtil {
fun getDartEditor(project: Project,initText: String="") : PsiAwareTextEditorImpl {
val vF = LightVirtualFile("freezed.dart", DartLanguage.INSTANCE, initText)
val mkEdit =
- FileEditorProviderManager.getInstance().getProviders(project, vF).first()
+ FileEditorProviderManager.getInstance().getProviderList(project, vF).first()
val edit = mkEdit.createEditor(project, vF)
return edit as PsiAwareTextEditorImpl
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/YamlExtends.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/YamlExtends.kt
new file mode 100644
index 00000000..d01e9fd5
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/YamlExtends.kt
@@ -0,0 +1,39 @@
+package shop.itbug.fluttercheckversionx.util
+
+import com.intellij.psi.PsiElement
+import com.intellij.psi.impl.source.tree.LeafPsiElement
+import com.intellij.psi.util.PsiTreeUtil
+import org.jetbrains.yaml.psi.impl.YAMLBlockMappingImpl
+import org.jetbrains.yaml.psi.impl.YAMLKeyValueImpl
+
+
+data class DartPluginVersionName(val name: String,val version: String)
+/**
+ * yaml工具类
+ */
+class YamlExtends(val element: PsiElement) {
+
+ ///判断是不是dart plugin 节点
+ fun isDartPluginElement(): Boolean {
+ if (element is YAMLKeyValueImpl && element.parent is YAMLBlockMappingImpl && element.parent.parent is YAMLKeyValueImpl && PsiTreeUtil.findChildOfType(element,YAMLBlockMappingImpl::class.java)==null) {
+ val root = element.parent.parent as YAMLKeyValueImpl
+ if (root.firstChild is LeafPsiElement ) {
+ val temp = root.firstChild.text
+ if (temp == "dependencies" || temp == "dependency_overrides" || temp == "dev_dependencies") {
+ return true
+ }
+ }
+ }
+ return false
+ }
+
+ ///获取依赖名字
+ fun getDartPluginNameAndVersion(): DartPluginVersionName? {
+ if (isDartPluginElement()) {
+ val ele = (element as YAMLKeyValueImpl)
+ return DartPluginVersionName(name = ele.keyText, version = ele.valueText)
+ }
+ return null
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt
index c3af3dcf..b420e0f4 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt
@@ -1,744 +1,47 @@
package shop.itbug.fluttercheckversionx.widget
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
-import com.intellij.ide.ui.UISettings
-import com.intellij.openapi.Disposable
-import com.intellij.openapi.actionSystem.CommonDataKeys
-import com.intellij.openapi.actionSystem.DataProvider
-import com.intellij.openapi.actionSystem.PlatformDataKeys
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.application.ModalityState
-import com.intellij.openapi.command.CommandProcessor
-import com.intellij.openapi.command.UndoConfirmationPolicy
-import com.intellij.openapi.editor.*
-import com.intellij.openapi.editor.colors.EditorColors
-import com.intellij.openapi.editor.colors.EditorColorsScheme
-import com.intellij.openapi.editor.colors.EditorColorsUtil
-import com.intellij.openapi.editor.event.DocumentEvent
-import com.intellij.openapi.editor.event.DocumentListener
+import com.intellij.json.JsonLanguage
import com.intellij.openapi.editor.ex.EditorEx
-import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory
-import com.intellij.openapi.editor.impl.EditorImpl
-import com.intellij.openapi.fileEditor.FileDocumentManager
-import com.intellij.openapi.fileTypes.FileType
-import com.intellij.openapi.fileTypes.FileTypes
import com.intellij.openapi.project.Project
-import com.intellij.openapi.project.ProjectManager
-import com.intellij.openapi.project.ProjectManagerListener
-import com.intellij.openapi.util.Disposer
-import com.intellij.openapi.util.Key
-import com.intellij.openapi.util.text.StringUtil
-import com.intellij.openapi.wm.IdeFocusManager
-import com.intellij.openapi.wm.ex.AbstractDelegatingToRootTraversalPolicy
-import com.intellij.psi.PsiDocumentManager
-import com.intellij.psi.PsiFileFactory
-import com.intellij.ui.ComponentUtil
-import com.intellij.ui.EditorSettingsProvider
-import com.intellij.ui.EditorTextComponent
-import com.intellij.ui.TextAccessor
-import com.intellij.ui.components.panels.NonOpaquePanel
-import com.intellij.ui.scale.JBUIScale.scale
-import com.intellij.util.IJSwingUtilities
-import com.intellij.util.LocalTimeCounter
-import com.intellij.util.containers.ContainerUtil
-import com.intellij.util.ui.JBInsets
-import com.intellij.util.ui.JBUI
-import com.intellij.util.ui.StartupUiUtil
-import com.intellij.util.ui.UIUtil
-import java.awt.*
-import java.awt.event.*
-import javax.swing.CellRendererPane
-import javax.swing.JComponent
-import javax.swing.KeyStroke
-import javax.swing.UIManager
+import com.intellij.ui.LanguageTextField
+import com.jetbrains.lang.dart.DartLanguage
-open class EditorTextPanel @JvmOverloads constructor(
- document: Document?,
- project: Project?,
- fileType: FileType?,
- isViewer: Boolean = false,
- oneLineMode: Boolean = true
-) :
- NonOpaquePanel(), EditorTextComponent, DocumentListener, DataProvider,
- TextAccessor, FocusListener, MouseListener {
- private var myDocument: Document? = null
- val project: Project?
- private var fileType: FileType? = null
- private var myEditor: EditorEx? = null
- private var myWholeTextSelected = false
- private val myDocumentListeners = ContainerUtil.createLockFreeCopyOnWriteList()
- private val myFocusListeners = ContainerUtil.createLockFreeCopyOnWriteList()
- private val myMouseListeners = ContainerUtil.createLockFreeCopyOnWriteList()
- private var myIsListenerInstalled = false
- private var isViewer = false
- private var myIsSupplementary = false
- private var myInheritSwingFont = true
- private var myEnforcedBgColor: Color? = null
+open class JsonEditorTextPanel(project: Project) : LanguageTextField(JsonLanguage.INSTANCE, project, "", false) {
- private var isOneLineMode = false
- private var myEnsureWillComputePreferredSize = false
- private var myPassivePreferredSize: Dimension? = null
- private var myHintText: CharSequence? = null
- private var myIsRendererWithSelection = false
- private var myRendererBg: Color? = null
- private var myRendererFg: Color? = null
- private var myPreferredWidth = -1
- private var myCaretPosition = -1
- private val mySettingsProviders: MutableList = ArrayList()
- private var myDisposable: Disposable? = null
- @JvmOverloads
- constructor(text: String = "") : this(EditorFactory.getInstance().createDocument(text), null, FileTypes.PLAIN_TEXT)
- constructor(text: String, project: Project?, fileType: FileType?) : this(
- EditorFactory.getInstance().createDocument(text), project, fileType, false, true
- )
-
- constructor(project: Project?, fileType: FileType?) : this(null, project, fileType, false, false)
-
- init {
- isOneLineMode = oneLineMode
- this.isViewer = isViewer
- setDocument(document)
- this.project = project
- this.fileType = fileType
- layout = BorderLayout()
- enableEvents(AWTEvent.KEY_EVENT_MASK)
- isFocusable = true
- super.addFocusListener(object : FocusAdapter() {
- override fun focusGained(e: FocusEvent) {
- requestFocus()
- }
- })
- isFocusTraversalPolicyProvider = true
- focusTraversalPolicy = Jdk7DelegatingToRootTraversalPolicy()
- font = UIManager.getFont("TextField.font")
- }
-
- fun setSupplementary(supplementary: Boolean) {
- myIsSupplementary = supplementary
- if (myEditor != null) {
- myEditor!!.putUserData(SUPPLEMENTARY_KEY, supplementary)
- }
- }
-
- fun setFontInheritedFromLAF(b: Boolean) {
- myInheritSwingFont = b
- setDocument(myDocument) // reinit editor.
- }
-
- override fun getText(): String {
- return myDocument!!.text
- }
-
- override fun setBackground(bg: Color) {
- super.setBackground(bg)
- myEnforcedBgColor = bg
- if (myEditor != null) {
- myEditor!!.backgroundColor = bg
- }
- }
-
- override fun getComponent(): JComponent {
- return this
- }
-
- override fun addDocumentListener(listener: DocumentListener) {
- myDocumentListeners.add(listener)
- installDocumentListener()
- }
-
- override fun removeDocumentListener(listener: DocumentListener) {
- myDocumentListeners.remove(listener)
- uninstallDocumentListener(false)
- }
-
- override fun beforeDocumentChange(event: DocumentEvent) {
- for (documentListener in myDocumentListeners) {
- documentListener.beforeDocumentChange(event)
- }
- }
-
- override fun documentChanged(event: DocumentEvent) {
- for (documentListener in myDocumentListeners) {
- documentListener.documentChanged(event)
- }
- }
-
- override fun getDocument(): Document {
- if (myDocument == null) {
- myDocument = createDocument()
- }
- return myDocument!!
- }
-
- private fun setDocument(document: Document?) {
- if (myDocument != null) {
- uninstallDocumentListener(true)
- }
- myDocument = document
- installDocumentListener()
- if (myEditor != null) {
- val isFocused = isFocusOwner
- val newEditor = createEditor()
- releaseEditor(myEditor)
- myEditor = newEditor
- add(myEditor!!.component, BorderLayout.CENTER)
- validate()
- if (isFocused) {
- IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown {
- IdeFocusManager.getGlobalInstance().requestFocus(newEditor.contentComponent, true)
- }
- }
- }
- }
-
- private fun installDocumentListener() {
- if (myDocument != null && myDocumentListeners.isNotEmpty() && !myIsListenerInstalled) {
- myIsListenerInstalled = true
- myDocument!!.addDocumentListener(this)
- }
- }
-
- private fun uninstallDocumentListener(force: Boolean) {
- if (myDocument != null && myIsListenerInstalled && (force || myDocumentListeners.isEmpty())) {
- myIsListenerInstalled = false
- myDocument!!.removeDocumentListener(this)
- }
- }
-
- override fun setText(text: String?) {
- CommandProcessor.getInstance().executeCommand(
- project,
- {
- ApplicationManager.getApplication().runWriteAction {
- myDocument!!.replaceString(
- 0,
- myDocument!!.textLength,
- StringUtil.notNullize(text)
- )
- if (myEditor != null) {
- val caretModel = myEditor!!.caretModel
- if (caretModel.offset >= myDocument!!.textLength) {
- caretModel.moveToOffset(myDocument!!.textLength)
- }
- }
- }
- }, null, null, UndoConfirmationPolicy.DEFAULT, document
- )
- }
-
- /**
- * Allows to define [editor's placeholder][EditorEx.setPlaceholder]. The trick here is that the editor
- * is instantiated lazily by the editor text field and provided placeholder text is applied to the editor during its
- * actual construction then.
- *
- * @param text [editor's placeholder][EditorEx.setPlaceholder] text to use
- */
- fun setPlaceholder(text: CharSequence?) {
- myHintText = text
- if (myEditor != null) {
- myEditor!!.setPlaceholder(text)
- }
- }
-
- fun selectAll() {
- if (myEditor != null) {
- doSelectAll(myEditor!!)
- } else {
- myWholeTextSelected = true
- }
- }
-
- fun removeSelection() {
- if (myEditor != null) {
- myEditor!!.selectionModel.removeSelection()
- } else {
- myWholeTextSelected = false
- }
- }
-
- /**
- * @see javax.swing.text.JTextComponent.setCaretPosition
- */
- fun setCaretPosition(position: Int) {
- val document = document
- require(!(position > document.textLength || position < 0)) { "bad position: $position" }
- if (myEditor != null) {
- myEditor!!.caretModel.moveToOffset(position)
- } else {
- myCaretPosition = position
- }
- }
-
- val caretModel: CaretModel
- get() = myEditor!!.caretModel
-
- override fun isFocusOwner(): Boolean {
- return if (myEditor != null) {
- IJSwingUtilities.hasFocus(myEditor!!.contentComponent)
- } else super.isFocusOwner()
- }
-
- override fun addNotify() {
- myDisposable = Disposer.newDisposable("ETF dispose")
- Disposer.register(myDisposable!!) { releaseEditorLater() }
- if (project != null) {
- val listener: ProjectManagerListener = object : ProjectManagerListener {
- override fun projectClosing(project: Project) {
- releaseEditor(myEditor)
- myEditor = null
- }
- }
- ProjectManager.getInstance().addProjectManagerListener(project, listener)
- Disposer.register(
- myDisposable!!
- ) {
- ProjectManager.getInstance().removeProjectManagerListener(project, listener)
- }
- }
- if (myEditor != null) {
- releaseEditorLater()
- }
- val isFocused = isFocusOwner
- initEditor()
- super.addNotify()
- revalidate()
- if (isFocused) {
- IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown { requestFocus() }
- }
- }
-
- private fun initEditor() {
- myEditor = createEditor()
- myEditor!!.contentComponent.isEnabled = isEnabled
- if (myCaretPosition >= 0) {
- myEditor!!.caretModel.moveToOffset(myCaretPosition)
- myEditor!!.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
- }
- val tooltip = toolTipText
- if (StringUtil.isNotEmpty(tooltip)) {
- myEditor!!.contentComponent.toolTipText = tooltip
- }
- add(myEditor!!.component, BorderLayout.CENTER)
- }
-
- override fun removeNotify() {
- super.removeNotify()
- if (myDisposable != null) {
- Disposer.dispose(myDisposable!!)
- }
- }
-
- private fun releaseEditor(editor: Editor?) {
- if (editor == null) return
- if (project != null && !project.isDisposed && isViewer) {
- val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.document)
- if (psiFile != null) {
- DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(psiFile, true)
- }
- }
- remove(editor.component)
- editor.contentComponent.removeFocusListener(this)
- editor.contentComponent.removeMouseListener(this)
- if (!editor.isDisposed) {
- EditorFactory.getInstance().releaseEditor(editor)
- }
- }
-
- private fun releaseEditorLater() {
- val editor = myEditor
- ApplicationManager.getApplication()
- .invokeLater({ releaseEditor(editor) }, ModalityState.stateForComponent(this))
- myEditor = null
- }
-
- override fun setFont(font: Font) {
- super.setFont(font)
- if (myEditor != null) {
- setupEditorFont(myEditor!!)
- }
- }
-
- private fun initOneLineMode(editor: EditorEx) {
- val isOneLineMode = isOneLineMode
-
- // set mode in editor
- editor.isOneLineMode = isOneLineMode
- val customGlobalScheme = editor.colorsScheme
- editor.colorsScheme = editor.createBoundColorSchemeDelegate(if (isOneLineMode) customGlobalScheme else null)
- editor.settings.isCaretRowShown = false
- }
-
- private fun createDocument(): Document? {
- val factory = PsiFileFactory.getInstance(project)
- val stamp = LocalTimeCounter.currentTime()
- val psiFile = factory.createFileFromText(
- "Dummy." + fileType!!.defaultExtension,
- fileType!!, "", stamp, true, false
- )
- return PsiDocumentManager.getInstance(project!!).getDocument(psiFile)
- }
-
- private fun createEditor(): EditorEx {
- val document = document
- val factory = EditorFactory.getInstance()
- val editor = (if (isViewer) factory.createViewer(document, project) else factory.createEditor(
- document,
- project
- )) as EditorEx
- setupTextFieldEditor(editor)
- editor.setCaretEnabled(!isViewer)
- if (project != null) {
- val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.document)
- if (psiFile != null) {
- DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(psiFile, !isViewer)
- }
- }
- if (project != null) {
- val highlighterFactory = EditorHighlighterFactory.getInstance()
- val virtualFile = if (myDocument == null) null else FileDocumentManager.getInstance().getFile(
- myDocument!!
- )
- val highlighter = if (virtualFile != null) highlighterFactory.createEditorHighlighter(
- project, virtualFile
- ) else if (fileType != null) highlighterFactory.createEditorHighlighter(
- project,
- fileType!!
- ) else null
- if (highlighter != null) editor.highlighter = highlighter
- }
- editor.settings.isCaretRowShown = false
- editor.isOneLineMode = isOneLineMode
- editor.caretModel.moveToOffset(document.textLength)
- if (!shouldHaveBorder()) {
- editor.setBorder(null)
- }
- if (isViewer) {
- editor.selectionModel.removeSelection()
- } else if (myWholeTextSelected) {
- doSelectAll(editor)
- myWholeTextSelected = false
- }
- editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary)
- editor.contentComponent.isFocusCycleRoot = false
- editor.contentComponent.addFocusListener(this)
- editor.contentComponent.addMouseListener(this)
- editor.setPlaceholder(myHintText)
- initOneLineMode(editor)
- if (myIsRendererWithSelection) {
- (editor as EditorImpl).isPaintSelection = true
- editor.getColorsScheme().setColor(EditorColors.SELECTION_BACKGROUND_COLOR, myRendererBg)
- editor.getColorsScheme().setColor(EditorColors.SELECTION_FOREGROUND_COLOR, myRendererFg)
- editor.selectionModel.setSelection(0, document.textLength)
- editor.setBackgroundColor(myRendererBg)
- }
- for (provider in mySettingsProviders) {
- provider.customizeSettings(editor)
- }
- return editor
- }
-
- private fun setupEditorFont(editor: EditorEx) {
- if (myInheritSwingFont) {
- (editor as EditorImpl).setUseEditorAntialiasing(false)
- editor.getColorsScheme().editorFontName = font.fontName
- editor.getColorsScheme().editorFontSize = font.size
- return
- }
- val settings = UISettings.getInstance()
- if (settings.presentationMode) editor.setFontSize(settings.presentationModeFontSize)
+ override fun createEditor(): EditorEx {
+ return myCreateEditor(super.createEditor())
}
- private fun shouldHaveBorder(): Boolean {
- return true
- }
-
- override fun setEnabled(enabled: Boolean) {
- if (isEnabled != enabled) {
- super.setEnabled(enabled)
- isFocusTraversalPolicyProvider = enabled
- setViewerEnabled(enabled)
- val editor = myEditor
- if (editor != null) {
- releaseEditor(editor)
- initEditor()
- revalidate()
- }
- }
- }
-
- private fun setViewerEnabled(enabled: Boolean) {
- isViewer = !enabled
- }
-
- override fun getBackground(): Color {
- return getBackgroundColor(isEnabled, EditorColorsUtil.getGlobalOrDefaultColorScheme())
- }
-
- private fun getBackgroundColor(enabled: Boolean, colorsScheme: EditorColorsScheme): Color {
- if (myEnforcedBgColor != null) return myEnforcedBgColor!!
- if (ComponentUtil.getParentOfType(
- CellRendererPane::class.java as Class,
- this as Component
- ) != null && (StartupUiUtil
- .isUnderDarcula() || UIUtil.isUnderIntelliJLaF())
- ) {
- return parent.background
- }
- if (StartupUiUtil.isUnderDarcula()) return UIUtil.getTextFieldBackground()
- return if (enabled) colorsScheme.defaultBackground else UIUtil.getInactiveTextFieldBackgroundColor()
- }
-
- override fun addImpl(comp: Component, constraints: Any, index: Int) {
- if (myEditor == null || comp !== myEditor!!.component) {
- assert(false) { "You are not allowed to add anything to EditorTextField" }
- }
- super.addImpl(comp, constraints, index)
- }
-
- override fun getPreferredSize(): Dimension {
- if (isPreferredSizeSet) {
- return super.getPreferredSize()
- }
- var toReleaseEditor = false
- if (myEditor == null && myEnsureWillComputePreferredSize) {
- myEnsureWillComputePreferredSize = false
- initEditor()
- toReleaseEditor = true
- }
- var size: Dimension = JBUI.size(100, 10)
- if (myEditor != null) {
- val preferredSize = myEditor!!.component.preferredSize
- if (myPreferredWidth != -1) {
- preferredSize.width = myPreferredWidth
- }
- JBInsets.addTo(preferredSize, insets)
- size = preferredSize
- } else if (myPassivePreferredSize != null) {
- size = myPassivePreferredSize as Dimension
- }
- if (toReleaseEditor) {
- releaseEditor(myEditor)
- myEditor = null
- myPassivePreferredSize = size
- }
- return size
- }
-
- override fun getMinimumSize(): Dimension {
- if (isMinimumSizeSet) {
- return super.getMinimumSize()
- }
- val size: Dimension = JBUI.size(1, 10)
- if (myEditor != null) {
- size.height = myEditor!!.lineHeight
- if (UIUtil.isUnderDefaultMacTheme() || StartupUiUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
- size.height = size.height.coerceAtLeast(scale(16))
- }
- JBInsets.addTo(size, insets)
- JBInsets.addTo(size, myEditor!!.insets)
- }
- return size
- }
-
- fun setPreferredWidth(preferredWidth: Int) {
- myPreferredWidth = preferredWidth
- }
-
-
-
- override fun processKeyBinding(ks: KeyStroke, e: KeyEvent, condition: Int, pressed: Boolean): Boolean {
- return if (e.isConsumed || myEditor != null && !myEditor!!.processKeyTyped(e)) {
- super.processKeyBinding(ks, e, condition, pressed)
- } else true
- }
-
- override fun requestFocus() {
- if (myEditor != null) {
- IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown {
- if (myEditor != null) IdeFocusManager.getGlobalInstance().requestFocus(
- myEditor!!.contentComponent, true
- )
- }
- myEditor!!.scrollingModel.scrollToCaret(ScrollType.RELATIVE)
- }
- }
-
- override fun requestFocusInWindow(): Boolean {
- return if (myEditor != null) {
- val b = myEditor!!.contentComponent.requestFocusInWindow()
- myEditor!!.scrollingModel.scrollToCaret(ScrollType.RELATIVE)
- b
- } else {
- super.requestFocusInWindow()
- }
- }
-
- val editor: Editor?
- /**
- * @return null if the editor is not initialized (e.g. if the field is not added to a container)
- * @see .createEditor
- * @see .addNotify
- */
- get() = myEditor
- val focusTarget: JComponent
- get() = if (myEditor == null) this else myEditor!!.contentComponent
-
- @Synchronized
- override fun addFocusListener(l: FocusListener) {
- myFocusListeners.add(l)
- }
- @Synchronized
- override fun removeFocusListener(l: FocusListener) {
- myFocusListeners.remove(l)
+ fun scrollToTop() {
+ editor?.scrollingModel?.scrollVertically(0)
}
+}
- override fun focusGained(e: FocusEvent) {
- for (listener in myFocusListeners) {
- listener.focusGained(e)
- }
- }
-
- override fun focusLost(e: FocusEvent) {
- for (listener in myFocusListeners) {
- listener.focusLost(e)
- }
- }
+class DartEditorTextPanel(project: Project) : LanguageTextField(DartLanguage.INSTANCE, project, "", false) {
- override fun addMouseListener(l: MouseListener) {
- myMouseListeners.add(l)
- }
-
- override fun removeMouseListener(l: MouseListener) {
- myMouseListeners.remove(l)
- }
-
- override fun mouseClicked(e: MouseEvent) {
- for (listener in myMouseListeners) {
- listener.mouseClicked(e)
- }
- }
-
- override fun mousePressed(e: MouseEvent) {
- for (listener in myMouseListeners) {
- listener.mousePressed(e)
- }
- }
-
- override fun mouseReleased(e: MouseEvent) {
- for (listener in myMouseListeners) {
- listener.mouseReleased(e)
- }
- }
-
- override fun mouseEntered(e: MouseEvent) {
- for (listener in myMouseListeners) {
- listener.mouseEntered(e)
- }
- }
-
- override fun mouseExited(e: MouseEvent) {
- for (listener in myMouseListeners) {
- listener.mouseExited(e)
- }
- }
-
- override fun getData(dataId: String): Any? {
- if (myEditor != null && myEditor!!.isRendererMode) {
- return if (PlatformDataKeys.COPY_PROVIDER.`is`(dataId)) {
- myEditor!!.copyProvider
- } else null
- }
- return if (CommonDataKeys.EDITOR.`is`(dataId)) {
- myEditor
- } else null
- }
-
- fun setFileType(fileType: FileType) {
- setNewDocumentAndFileType(fileType, document)
- }
-
- fun setNewDocumentAndFileType(fileType: FileType, document: Document?) {
- this.fileType = fileType
- setDocument(document)
- }
-
- fun ensureWillComputePreferredSize() {
- myEnsureWillComputePreferredSize = true
- }
-
- fun setAsRendererWithSelection(backgroundColor: Color?, foregroundColor: Color?) {
- myIsRendererWithSelection = true
- myRendererBg = backgroundColor
- myRendererFg = foregroundColor
- }
-
- fun addSettingsProvider(provider: EditorSettingsProvider) {
- mySettingsProviders.add(provider)
- }
-
- fun removeSettingsProvider(provider: EditorSettingsProvider): Boolean {
- return mySettingsProviders.remove(provider)
+ init {
+ border = null
}
- private class Jdk7DelegatingToRootTraversalPolicy : AbstractDelegatingToRootTraversalPolicy() {
- private var invokedFromBeforeOrAfter = false
- override fun getFirstComponent(aContainer: Container): Container? {
- return getDefaultComponent(aContainer)
- }
-
- override fun getLastComponent(aContainer: Container): Container? {
- return getDefaultComponent(aContainer)
- }
-
- override fun getComponentAfter(aContainer: Container, aComponent: Component): Component? {
- invokedFromBeforeOrAfter = true
- val after: Component
- after = try {
- super.getComponentAfter(aContainer, aComponent)
- } finally {
- invokedFromBeforeOrAfter = false
- }
- return if (after !== aComponent) after else null // escape our container
- }
-
- override fun getComponentBefore(aContainer: Container, aComponent: Component): Component? {
- val before = super.getComponentBefore(aContainer, aComponent)
- return if (before !== aComponent) before else null // escape our container
- }
-
- override fun getDefaultComponent(aContainer: Container): Container? {
- if (invokedFromBeforeOrAfter) return null // escape our container
- val editor = if (aContainer is EditorTextPanel) aContainer.editor else null
- return editor?.contentComponent ?: aContainer
- }
+ override fun createEditor(): EditorEx {
+ return myCreateEditor(super.createEditor())
}
+}
- companion object {
- val SUPPLEMENTARY_KEY = Key.create("Supplementary")
- private fun doSelectAll(editor: Editor) {
- editor.caretModel.removeSecondaryCarets()
- editor.caretModel.primaryCaret.setSelection(0, editor.document.textLength, false)
- }
- fun setupTextFieldEditor(editor: EditorEx) {
- val settings = editor.settings
- settings.additionalLinesCount = 0
- settings.additionalColumnsCount = 1
- settings.isRightMarginShown = false
- settings.setRightMargin(-1)
- settings.isFoldingOutlineShown = true
- settings.isLineNumbersShown = true
- settings.isLineMarkerAreaShown = true
- settings.isIndentGuidesShown = true
- settings.isVirtualSpace = false
- settings.isWheelFontChangeEnabled = false
- settings.isAdditionalPageAtBottom = false
- editor.setHorizontalScrollbarVisible(true)
- editor.setVerticalScrollbarVisible(true)
- settings.lineCursorWidth = 1
- }
- }
+///创建编辑器
+private fun myCreateEditor(ex: EditorEx): EditorEx {
+ ex.setVerticalScrollbarVisible(true)
+ ex.setHorizontalScrollbarVisible(true)
+ ex.setBorder(null)
+ val settings = ex.settings
+ settings.isLineNumbersShown = true
+ settings.isAutoCodeFoldingEnabled = true
+ settings.isFoldingOutlineShown = true
+ settings.isAllowSingleLogicalLineFolding = true
+ settings.isRightMarginShown = true
+ return ex
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/FreezedCovertModelWidget.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/FreezedCovertModelWidget.kt
index c65b307d..0416852a 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/FreezedCovertModelWidget.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/FreezedCovertModelWidget.kt
@@ -1,10 +1,8 @@
package shop.itbug.fluttercheckversionx.widget
import com.intellij.openapi.application.runWriteAction
-import com.intellij.openapi.fileTypes.PlainTextLanguage
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogPanel
-import com.intellij.ui.LanguageTextField
import com.intellij.ui.components.JBPanel
import com.intellij.ui.components.JBScrollPane
import com.intellij.ui.dsl.builder.bindSelected
@@ -18,12 +16,13 @@ import java.awt.BorderLayout
class FreezedCovertModelWidget(var model: FreezedCovertModel, val project: Project) :
JBPanel(BorderLayout()) {
-
-// private val editView = SwingUtil.getDartEditor(project,"")
- private val editView = LanguageTextField(PlainTextLanguage.INSTANCE,project,"",false)
+ private val editView = DartEditorTextPanel(project)
init {
- add(JBScrollPane(editView.component), BorderLayout.CENTER)
+ border = null
+ add(JBScrollPane(editView.component).apply {
+ border = null
+ }, BorderLayout.CENTER)
generateFreezedModel()
add(getSettingPanel(), BorderLayout.SOUTH)
@@ -34,12 +33,18 @@ class FreezedCovertModelWidget(var model: FreezedCovertModel, val project: Proje
*/
private fun generateFreezedModel() {
val genFreezedClass =
- MyDartPsiElementUtil.genFreezedClass(project, model.className, model.getPropertiesString(),model.addConstructorFun,model.addFromJson)
+ MyDartPsiElementUtil.genFreezedClass(
+ project,
+ model.className,
+ model.getPropertiesString(),
+ model.addConstructorFun,
+ model.addFromJson
+ )
changeText(genFreezedClass.text)
}
- private fun changeText(value:String){
+ private fun changeText(value: String) {
runWriteAction {
editView.text = value
}
@@ -47,7 +52,13 @@ class FreezedCovertModelWidget(var model: FreezedCovertModel, val project: Proje
private fun changeModel(newModel: FreezedCovertModel) {
val genFreezedClass =
- MyDartPsiElementUtil.genFreezedClass(project, newModel.className, newModel.getPropertiesString(),model.addConstructorFun,model.addFromJson)
+ MyDartPsiElementUtil.genFreezedClass(
+ project,
+ newModel.className,
+ newModel.getPropertiesString(),
+ model.addConstructorFun,
+ model.addFromJson
+ )
changeText(genFreezedClass.text)
}
@@ -80,11 +91,11 @@ fun freezedCovertModelSetting(
checkBox(PluginBundle.get("default.value.tip")).bindSelected(model::useDefaultValueIfNull)
}
- row (PluginBundle.get("addConstructorFun")) {
+ row(PluginBundle.get("addConstructorFun")) {
checkBox(PluginBundle.get("addConstructorFun")).bindSelected(model::addConstructorFun)
}
- row (PluginBundle.get("addFromJson")){
+ row(PluginBundle.get("addFromJson")) {
checkBox(PluginBundle.get("addFromJson")).bindSelected(model::addFromJson)
}
@@ -95,5 +106,7 @@ fun freezedCovertModelSetting(
}
}
}
- return p
+ return p.apply {
+ border = null
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyComboActionNew.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyComboActionNew.kt
new file mode 100644
index 00000000..1f1e06f4
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyComboActionNew.kt
@@ -0,0 +1,198 @@
+package shop.itbug.fluttercheckversionx.widget
+
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.actionSystem.ex.ComboBoxAction
+import com.intellij.openapi.actionSystem.ex.CustomComponentAction
+import com.intellij.openapi.project.DumbAware
+import com.intellij.openapi.project.DumbAwareToggleAction
+import com.intellij.ui.SearchTextField
+import com.intellij.util.ArrayUtil
+import com.intellij.util.containers.ContainerUtil
+import org.jetbrains.annotations.Nls
+import org.jetbrains.annotations.Unmodifiable
+import javax.swing.JComponent
+import javax.swing.event.DocumentEvent
+import javax.swing.event.DocumentListener
+
+class MyComboActionNew {
+
+ //
+ // 下拉类型的 action
+ //
+ abstract class ComboBoxSettingAction : ComboBoxAction(), DumbAware {
+ private var myActions: DefaultActionGroup? = null
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+
+ override fun update(e: AnActionEvent) {
+ val presentation = e.presentation
+ presentation.text = getText(value)
+ }
+
+ override fun createPopupActionGroup(button: JComponent, context: DataContext): DefaultActionGroup {
+ return actions
+ }
+
+ ///重新获取actions
+ protected abstract val reGetActions: Boolean
+
+ val actions: DefaultActionGroup
+ get() {
+ if (reGetActions) {
+ myActions = null
+ }
+ if (myActions == null) {
+ myActions = DefaultActionGroup()
+ for (setting in availableOptions) {
+ myActions!!.add(MyAction(setting))
+ }
+ }
+ return myActions!!
+ }
+
+ protected abstract val availableOptions: @Unmodifiable MutableList
+
+ protected abstract var value: T
+
+ open fun setNewValue(value: T, e: AnActionEvent) {}
+
+ @Nls
+ protected abstract fun getText(option: T): String
+
+ private inner class MyAction(private val myOption: T) : AnAction(getText(myOption)), Toggleable, DumbAware {
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+
+ override fun update(e: AnActionEvent) {
+ Toggleable.setSelected(e.presentation, value === myOption)
+ super.update(e)
+ }
+
+ override fun actionPerformed(e: AnActionEvent) {
+ value = myOption
+ setNewValue(myOption, e)
+ super.update(e)
+ }
+ }
+ }
+
+
+ /**
+ * 枚举类型的 action
+ */
+ abstract class EnumPolicySettingAction>(private val policies: Array) : ComboBoxSettingAction() {
+
+
+ override fun update(e: AnActionEvent) {
+ super.update(e)
+ e.presentation.isEnabledAndVisible = policies.size > 1
+ }
+
+
+ override val reGetActions: Boolean
+ get() = false
+
+
+ override val availableOptions: MutableList
+ get() = ContainerUtil.sorted(listOf(*policies))
+
+ fun getValue(): T {
+ val value = storedValue
+ if (ArrayUtil.contains(value, *policies)) return value
+
+ val substitutes = getValueSubstitutes(value)
+ for (substitute in substitutes) {
+ if (ArrayUtil.contains(substitute, *policies)) return substitute
+ }
+
+ return policies[0]
+ }
+
+
+ protected abstract val storedValue: T
+
+ protected fun getValueSubstitutes(value: T): List {
+ return emptyList()
+ }
+ }
+
+
+ ///开关样式的操作
+ abstract class ToggleActionGroup(private val values: Array) : ActionGroup(), DumbAware {
+
+
+ abstract fun getText(value: T): String
+
+ abstract var value: T
+
+
+ override fun getChildren(e: AnActionEvent?): Array {
+ val actions = ArrayList()
+ actions.addAll(values.map { MyAction(it) })
+ return actions.toTypedArray()
+ }
+
+
+ private inner class MyAction(val item: T) : DumbAwareToggleAction({ getText(item) }) {
+ override fun isSelected(e: AnActionEvent): Boolean {
+ return value == item
+ }
+
+ override fun setSelected(e: AnActionEvent, state: Boolean) {
+ value = item
+ }
+
+ override fun getActionUpdateThread() = ActionUpdateThread.EDT
+
+
+ override fun update(e: AnActionEvent) {
+ Toggleable.setSelected(e.presentation, isSelected(e))
+ super.update(e)
+ }
+
+ }
+
+ override fun getActionUpdateThread() = ActionUpdateThread.EDT
+ }
+
+
+ ///自定义搜索的 action
+ abstract class MySearchAnAction : AnAction(), CustomComponentAction, DocumentListener {
+ private val searchTextField = SearchTextField()
+
+
+ override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
+ searchTextField.addDocumentListener(this)
+ return searchTextField
+ }
+
+ override fun changedUpdate(e: DocumentEvent?) {
+ e?.let {
+ val text = e.document.getText(0, e.document.length)
+ changeText(text, e)
+ }
+ }
+
+ abstract fun changeText(text: String, e: DocumentEvent)
+
+ override fun insertUpdate(e: DocumentEvent?) {
+ changedUpdate(e)
+ }
+
+ override fun removeUpdate(e: DocumentEvent?) {
+ changedUpdate(e)
+ }
+
+ override fun actionPerformed(e: AnActionEvent) {
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.EDT
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyExpandableComboAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyExpandableComboAction.kt
new file mode 100644
index 00000000..c7ed43ff
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/MyExpandableComboAction.kt
@@ -0,0 +1,29 @@
+package shop.itbug.fluttercheckversionx.widget
+
+import com.intellij.ide.DataManager
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.Presentation
+import com.intellij.openapi.actionSystem.ex.CustomComponentAction
+import com.intellij.openapi.ui.popup.JBPopup
+import com.intellij.openapi.wm.impl.ToolbarComboWidget
+import java.awt.event.InputEvent
+import javax.swing.JComponent
+
+abstract class MyExpandableComboAction : AnAction(), CustomComponentAction {
+ override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
+ return object : ToolbarComboWidget() {
+ override fun doExpand(e: InputEvent?) {
+ val dataContext = DataManager.getInstance().getDataContext(this)
+ val anActionEvent = AnActionEvent.createFromInputEvent(e, place, presentation, dataContext)
+ createPopup(anActionEvent)?.showUnderneathOf(this)
+ }
+ }
+ }
+
+ protected abstract fun createPopup(event: AnActionEvent): JBPopup?
+
+ override fun actionPerformed(e: AnActionEvent) {
+ e.project?.let { createPopup(e)?.showCenteredInCurrentWindow(it) }
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/AllPluginsCheckVersion.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/AllPluginsCheckVersion.kt
index dbc87b0e..c5f851ca 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/AllPluginsCheckVersion.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/AllPluginsCheckVersion.kt
@@ -19,7 +19,7 @@ import java.awt.Component
import javax.swing.*
///检测版本小窗口
-class AllPluginsCheckVersion(val project: Project) : JPanel(BorderLayout()) {
+class AllPluginsCheckVersion(val project: Project, val onDone: () -> Unit) : JPanel(BorderLayout()) {
private var topTipLabel = JBLabel("check")
private var bottomTipLabel = JBLabel("loading...")
@@ -70,6 +70,8 @@ class AllPluginsCheckVersion(val project: Project) : JPanel(BorderLayout()) {
}
}
bottomTipLabel.text = "Done"
+ onDone()
+
}
}
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/DartPluginsWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/DartPluginsWindow.kt
index d020122f..319763eb 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/DartPluginsWindow.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/DartPluginsWindow.kt
@@ -73,7 +73,7 @@ class DartPluginsWindow(private val toolwindow: ToolWindow, val project: Project
}
init {
- addToCenter(JBScrollPane(list))
+ addToCenter(JBScrollPane(list).apply { border = null })
addToTop(toolbar.component)
}
@@ -95,6 +95,7 @@ class DartPluginList(val project: Project) : JBList() {
FlutterPluginCollectEventType.remove -> refresh()
}
}
+ border = null
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt
index 76579ca0..ded6e876 100644
--- a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt
@@ -1,11 +1,13 @@
package shop.itbug.fluttercheckversionx.window
import com.intellij.execution.ui.RunContentManagerImpl
+import com.intellij.icons.AllIcons
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
import shop.itbug.fluttercheckversionx.form.socket.SocketRequestForm
+import shop.itbug.fluttercheckversionx.hive.HiveWidget
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
import shop.itbug.fluttercheckversionx.icons.MyIcons
import shop.itbug.fluttercheckversionx.services.PluginStateService
@@ -13,6 +15,7 @@ import shop.itbug.fluttercheckversionx.socket.service.AppService
import shop.itbug.fluttercheckversionx.socket.service.DioApiService
import shop.itbug.fluttercheckversionx.util.toastWithError
import shop.itbug.fluttercheckversionx.widget.jobs.JobsWindow
+import shop.itbug.fluttercheckversionx.window.sp.SpWindow
//是否开启找工作窗口
const val ENABLE_FIND_JOBS_WINDOW = false
@@ -39,7 +42,7 @@ class SocketWindow : ToolWindowFactory {
if (AppService.getInstance().dioIsStart.not()) {
p1.activate {
try {
- DioApiService.builder(port, socketRequestForm).start()
+ DioApiService.builder(port).start()
p1.setIcon(RunContentManagerImpl.getLiveIndicator(MyIcons.flutter))
AppService.getInstance().setDioSocketState(true)
} catch (e: Exception) {
@@ -73,16 +76,22 @@ class SocketWindow : ToolWindowFactory {
//flutter收藏窗口
val dartPluginWindow = DartPluginsWindow(p1, p0)
- val dartPluginContent = instance.createContent(dartPluginWindow, "Plugin Collects", false)
+ val dartPluginContent =
+ instance.createContent(dartPluginWindow, PluginBundle.get("plugin.collects.title"), false)
p1.contentManager.addContent(dartPluginContent)
+ // sp工具
+ val spWindow = SpWindow(p0, p1)
+ val spContent = instance.createContent(spWindow, "Shared Preferences ${PluginBundle.get("tool")}", false)
+ p1.contentManager.addContent(spContent)
- //简单的一个处理请求的函数
-// val requestPanel = RequestPanelUi(p1,p0)
-// val requestPanelContent = instance.createContent(requestPanel,"Simple Request",false)
-// p1.contentManager.addContent(requestPanelContent)
+ //hive 工具 开发中
+ val hiveWindow = HiveWidget(p0, p1)
+ val hiveContent = instance.createContent(hiveWindow, "Hive ${PluginBundle.get("tool")}", false)
+ hiveContent.icon = AllIcons.General.Beta
+ p1.contentManager.addContent(hiveContent)
}
}
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/hive/HiveWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/hive/HiveWindow.kt
new file mode 100644
index 00000000..981501b9
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/hive/HiveWindow.kt
@@ -0,0 +1,12 @@
+package shop.itbug.fluttercheckversionx.window.hive
+
+import com.intellij.ui.components.JBLabel
+import com.intellij.util.ui.components.BorderLayoutPanel
+import shop.itbug.fluttercheckversionx.i18n.i18n
+
+class HiveWindow: BorderLayoutPanel() {
+
+ init {
+ addToCenter(JBLabel("future".i18n()))
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpManager.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpManager.kt
new file mode 100644
index 00000000..e3fe85f8
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpManager.kt
@@ -0,0 +1,87 @@
+package shop.itbug.fluttercheckversionx.window.sp
+
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.util.messages.Topic
+
+val bus = ApplicationManager.getApplication().messageBus
+
+data class SPResult(
+ val type: String,
+ val jsonString: String,
+ val runtimeType: String
+)
+
+data class SPKeysModel(
+ val keys: List,
+ val runtimeType: String
+)
+
+data class SPValueModel(
+ val value: Any?,
+ val runtimeType: String
+)
+
+class SpManager(message: String) {
+
+ private val jsonObject: SPResult = JSONObject.parseObject(message, SPResult::class.java)
+ fun handle() {
+ val type = jsonObject.type
+ when (type) {
+ KEYS -> keysHandle()
+ VALUE_GET -> valueHandle()
+ else -> {}
+ }
+ }
+
+ private fun valueHandle() {
+ val valueModel = JSONObject.parseObject(jsonObject.jsonString, SPValueModel::class.java)
+ SpManagerListen.fireValue(valueModel)
+ }
+
+ //处理key
+ private fun keysHandle() {
+ val spKeysModel = JSONObject.parseObject(jsonObject.jsonString, SPKeysModel::class.java)
+ SpManagerListen.fire(spKeysModel)
+ }
+
+ companion object {
+ const val KEYS = "SP_KEY"
+ const val VALUE_GET = "SP_GET_VALUE"
+ }
+}
+
+typealias SPKeysHandle = (model: SPKeysModel) -> Unit
+
+typealias SPValueHandle = (value: SPValueModel?) -> Unit
+
+interface SpManagerListen {
+ fun handle(model: SPKeysModel) {}
+
+ fun handleValue(valueModel: SPValueModel?) {}
+
+ companion object {
+ val topic = Topic.create("sp-keys", SpManagerListen::class.java)
+
+ fun fire(model: SPKeysModel) {
+ bus.syncPublisher(topic).handle(model)
+ }
+
+ fun fireValue(model: SPValueModel?) {
+ bus.syncPublisher(topic).handleValue(model)
+ }
+
+ fun listen(modelHandel: SPKeysHandle?, valueHandle: SPValueHandle?) {
+ bus.connect().subscribe(topic, object : SpManagerListen {
+ override fun handle(model: SPKeysModel) {
+ modelHandel?.invoke(model)
+ }
+
+ override fun handleValue(valueModel: SPValueModel?) {
+ valueHandle?.invoke(valueModel)
+ }
+ })
+ }
+ }
+}
+
diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpWindow.kt
new file mode 100644
index 00000000..cdf606c9
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/sp/SpWindow.kt
@@ -0,0 +1,130 @@
+package shop.itbug.fluttercheckversionx.window.sp
+
+import com.alibaba.fastjson2.JSONObject
+import com.intellij.icons.AllIcons
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.project.DumbAwareAction
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.ToolWindow
+import com.intellij.ui.OnePixelSplitter
+import com.intellij.ui.components.JBList
+import com.intellij.ui.components.JBScrollPane
+import com.intellij.util.ui.components.BorderLayoutPanel
+import org.smartboot.socket.transport.AioSession
+import shop.itbug.fluttercheckversionx.form.sub.JsonValueRender
+import shop.itbug.fluttercheckversionx.socket.service.DioApiService
+import java.awt.Dimension
+import javax.swing.BorderFactory
+import javax.swing.DefaultListModel
+import javax.swing.JButton
+import javax.swing.event.ListSelectionEvent
+import javax.swing.event.ListSelectionListener
+
+class SpWindow(project: Project, private val toolWindow: ToolWindow) : BorderLayoutPanel(),
+ DioApiService.NativeMessageProcessing {
+
+
+ val button = JButton("获取所有Key")
+ private val left = SpWindowLeft()
+ private val right = SpWindowRight(project)
+
+
+ val content = OnePixelSplitter().apply {
+ firstComponent = JBScrollPane(left).apply { border = null }
+ secondComponent = right
+ this.splitterProportionKey = "sp-window-key"
+ border = BorderFactory.createEmptyBorder()
+ }
+
+ init {
+ getAllKeys()
+ addToTop(createToolbar().component)
+ addToCenter(content)
+ }
+
+ private fun getAllKeys() {
+ DioApiService.sendByMap(mutableMapOf("action" to "SP_KEY"))
+ }
+
+
+ private fun createToolbar(): ActionToolbar {
+ return ActionManager.getInstance().createActionToolbar("sp tool bar", DefaultActionGroup().apply {
+ this.add(ActionManager.getInstance().getAction("shop.itbug.fluttercheckversionx.window.sp.SpRefreshAction"))
+ }, true).apply {
+ this.targetComponent = toolWindow.component
+ }
+ }
+
+ override fun handleFlutterAppMessage(nativeMessage: String, jsonObject: JSONObject?, aio: AioSession?) {
+ if (jsonObject != null) {
+ val type = jsonObject.getString("type")
+ if (type == SpManager.KEYS || type == SpManager.VALUE_GET) {
+ SpManager(nativeMessage).handle()
+ }
+ }
+
+ }
+
+}
+
+
+///刷新sp keys操作
+class SpRefreshAction : DumbAwareAction(AllIcons.Actions.Refresh) {
+ override fun actionPerformed(e: AnActionEvent) {
+ DioApiService.sendByMap(mutableMapOf("action" to "SP_KEY"))
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+
+}
+
+///数据展示区域
+class SpWindowRight(project: Project) : BorderLayoutPanel() {
+ private var jsonView: JsonValueRender = JsonValueRender(p = project)
+
+ init {
+ addToCenter(JBScrollPane(jsonView).apply {
+ this.border = BorderFactory.createEmptyBorder()
+ })
+ SpManagerListen.listen(null) {
+ jsonView.changeValue(it?.value)
+ }
+ border = null
+ }
+
+
+}
+
+
+/// keys 列表
+class SpWindowLeft : JBList(), ListSelectionListener {
+ init {
+ SpManagerListen.listen(modelHandel = {
+ this.model = DefaultListModel().apply {
+ this.addAll(it.keys)
+ }
+ }, valueHandle = null)
+ addListSelectionListener(this)
+ border = null
+ }
+
+
+ override fun valueChanged(e: ListSelectionEvent?) {
+ if (e != null && e.valueIsAdjusting.not() && selectedValue != null) {
+ DioApiService.sendByMap(mutableMapOf("action" to "SP_GET_VALUE", "data" to selectedValue))
+ }
+ }
+
+
+ override fun getPreferredSize(): Dimension {
+ return Dimension(200, -1)
+ }
+
+ override fun getMinimumSize(): Dimension {
+ return preferredSize
+ }
+
+}
+
diff --git a/src/main/resources/META-INF/actions.xml b/src/main/resources/META-INF/actions.xml
index 57cd6df7..eea085e7 100644
--- a/src/main/resources/META-INF/actions.xml
+++ b/src/main/resources/META-INF/actions.xml
@@ -26,7 +26,7 @@
text="Model to Freezed">
+ text="Function Params To Freezed"/>
@@ -59,6 +59,8 @@
+
+
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index e1915898..09efb821 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -1,6 +1,6 @@
shop.itbug.FlutterCheckVersionX
- FlutterCheckVersionX
+ FlutterX
梁典典
com.intellij.modules.platform
- com.intellij.java
org.jetbrains.plugins.yaml
com.intellij.modules.lang
com.intellij.modules.lang
Dart
io.flutter
+ Git4Idea
org.jetbrains.kotlin
org.intellij.plugins.markdown
org.jetbrains.plugins.terminal
@@ -56,28 +56,14 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -144,22 +132,32 @@
icon="/icons/flutter.svg"/>
-
+
-
+
-
+
+
+
+
-
-
+
+
+
+
+
+
@@ -181,7 +179,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/src/main/resources/messages/pluginBundle.properties b/src/main/resources/messages/pluginBundle.properties
index a3270af6..bb30af25 100644
--- a/src/main/resources/messages/pluginBundle.properties
+++ b/src/main/resources/messages/pluginBundle.properties
@@ -1,20 +1,19 @@
-account.text = 账号
-password.text = 密码
-
-window.chat.loginDialog.text = 登录
-window.chat.noMessage = 暂时没有人聊天,快去发言吧
-window.chat.sendInput.desc = 说点什么吧 (按Enter键发送)
-window.chat.loginDialog.register.comment = 没有账号?注册一个
+account.text=账号
+password.text=密码
+window.chat.loginDialog.text=登录
+window.chat.noMessage=暂时没有人聊天,快去发言吧
+window.chat.sendInput.desc=说点什么吧 (按Enter键发送)
+window.chat.loginDialog.register.comment=没有账号?注册一个
window.idea.dio.title=Dio API监听
-window.idea.chat.title = 聊天室
-window.chat.loginDialog.title = 典典账号登录
-window.idea.loginDialog.remember = 记住密码
+window.idea.chat.title=聊天室
+window.chat.loginDialog.title=典典账号登录
+window.idea.loginDialog.remember=记住密码
set.default=设置为默认
switch.rooms=切换房间
empty=空空如也
reward=打赏
help=使用教程
-setting=Flutter CheckX 设置
+setting.flutterx=FlutterX
clean=清除记录
open=开启
setting.new.tips=新接口提醒
@@ -55,7 +54,7 @@ ass.3=触发长度
ass.5=扫描文件夹
dio.toolbar.get.params=查看Get查询参数
dio.toolbar.post.params=查看Post请求体
-bugs=意见&bug反馈
+bugs=Bug反馈
replace.with=更换为
nav.to=跳转到
version.tip.1=此插件有新版本
@@ -109,4 +108,18 @@ flutter.clean=执行命令:flutter clean
dart.pub.publish=执行命令:dart pub publish
addConstructorFun=添加构造函数
addFromJson=添加FromJson函数
-plugin.collect=收藏
\ No newline at end of file
+plugin.collect=收藏
+bug-feedback=Bug 反馈
+future=这个功能在下个版本中推出
+version.tip.3=更改为:
+flutterX-Dart-Plugin-Ignore=以后将不再检测此插件新版本
+ig.version.check=不检测最新版本
+window.idea.dio.view.detail.desc=
+dio.apis.option.title=显示选项
+compact.mode=紧凑模式
+relaxed.mode=宽松模式(默认)
+ui.render=UI样式
+dio.setting.project.name.show.option=显示项目名字
+plugin.collects.title=插件收藏
+tool=工具
+dio.search.empty.text=输入URL关键字来搜索
\ No newline at end of file
diff --git a/src/main/resources/messages/pluginBundle_en.properties b/src/main/resources/messages/pluginBundle_en.properties
index d7230d40..a125d637 100644
--- a/src/main/resources/messages/pluginBundle_en.properties
+++ b/src/main/resources/messages/pluginBundle_en.properties
@@ -1,20 +1,19 @@
-account.text = Account
-password.text = Password
+account.text=Account
+password.text=Password
window.chat.loginDialog.text=Sign in
-
-window.chat.noMessage = No one is chatting for the time being. Go to speak quickly
-window.chat.sendInput.desc = Say something (press Enter to send)
-window.chat.loginDialog.register.comment = No account, go to register
+window.chat.noMessage=No one is chatting for the time being. Go to speak quickly
+window.chat.sendInput.desc=Say something (press Enter to send)
+window.chat.loginDialog.register.comment=No account, go to register
window.idea.dio.title=Dio Requests
-window.idea.chat.title = Chat Room
-window.chat.loginDialog.title = Diandian Account Login
+window.idea.chat.title=Chat Room
+window.chat.loginDialog.title=Diandian Account Login
window.idea.loginDialog.remember=Remember password
switch.rooms=Switch rooms
set.default=Set as default
empty=Empty Items
reward=Reward
help=Tutorials
-setting=Flutter CheckX Setting
+setting.flutterx=FlutterX
clean=Clear Records
open=Open
setting.new.tips=New api reminder
@@ -113,3 +112,16 @@ plugin.collect=Collect Plugin
comment.api.new.tips=When monitoring the interface, a reminder pops up in the window, which is enabled by default
window.idea.dio.view.detail=View detailed information of the interface
window.idea.dio.view.detail.desc=Copy Interface
+bug-feedback=Bug feedback
+future=This feature will be launched in the next version
+version.tip.3=Change to:
+flutterX-Dart-Plugin-Ignore=No new versions of this plugin will be detected in the future
+ig.version.check=Do not detect the latest version
+dio.apis.option.title=Display options
+compact.mode=Compact mode
+relaxed.mode=Relaxed mode (default)
+ui.render=UI Style
+dio.setting.project.name.show.option=Display project name
+plugin.collects.title=Plugin Collection
+tool=tool
+dio.search.empty.text=输入URL关键字来搜索
diff --git a/src/main/resources/messages/pluginBundle_hk.properties b/src/main/resources/messages/pluginBundle_hk.properties
index fab00112..189c03e7 100644
--- a/src/main/resources/messages/pluginBundle_hk.properties
+++ b/src/main/resources/messages/pluginBundle_hk.properties
@@ -1,19 +1,19 @@
-account.text = 帳戶
-password.text = 密碼
+account.text=帳戶
+password.text=密碼
window.chat.loginDialog.text=登入
-window.chat.noMessage = 暫時沒人聊天。快去說話
-window.chat.sendInput.desc = 說些什麼(按 Enter 發送)
-window.chat.loginDialog.register.comment = 沒有賬號,請前往註冊
+window.chat.noMessage=暫時沒人聊天。快去說話
+window.chat.sendInput.desc=說些什麼(按 Enter 發送)
+window.chat.loginDialog.register.comment=沒有賬號,請前往註冊
window.idea.dio.title=Dio 請求
-window.idea.chat.title = 聊天室
-window.chat.loginDialog.title = 帳號登錄
+window.idea.chat.title=聊天室
+window.chat.loginDialog.title=帳號登錄
window.idea.loginDialog.remember=記住密碼
switch.rooms=切換房間
set.default=設為默認
empty=空
reward=打賞
help=教程
-setting=Flutter CheckX 設定
+setting.flutterx=FlutterX
clean=清除記錄
open=打開
setting.new.tips=新API提醒
@@ -112,3 +112,16 @@ plugin.collect=收藏插件
comment.api.new.tips=當監聽到介面的時候,在視窗中彈出一個提醒,默認開啟
window.idea.dio.view.detail=查看介面的詳情資訊
window.idea.dio.view.detail.desc=複製介面
+bug-feedback=bug迴響
+future=這個功能在下個版本中推出
+version.tip.3=更改為:
+flutterX-Dart-Plugin-Ignore=以後將不再檢測此挿件新版本
+ig.version.check=不檢測最新版本
+dio.apis.option.title=顯示選項
+compact.mode=緊湊模式
+relaxed.mode=寬鬆模式(預設)
+ui.render=UI樣式
+dio.setting.project.name.show.option=顯示項目名字
+plugin.collects.title=挿件收藏
+tool=工具
+dio.search.empty.text=輸入URL關鍵字來搜索
diff --git a/src/main/resources/messages/pluginBundle_ja.properties b/src/main/resources/messages/pluginBundle_ja.properties
index 5ee87424..89895996 100644
--- a/src/main/resources/messages/pluginBundle_ja.properties
+++ b/src/main/resources/messages/pluginBundle_ja.properties
@@ -14,7 +14,7 @@ set.default=デフォルトに設定
empty=空のアイテム
reward=に報いる
help=チュートリアル
-setting=Flutter CheckX 設定#セッテイ#
+setting.flutterx=FlutterX
clean=レコードの消去
comment.api.new.tips=インタフェースを傍受しているときは、ウィンドウにアラームをポップアップし、デフォルトでオンにします
open=オープン
@@ -112,4 +112,17 @@ flutter.clean=コマンドの実行: flutter clean
dart.pub.publish=コマンドの実行: dart pub publish
addConstructorFun=コンストラクタの追加
addFromJson=FromJson関数の追加
-plugin.collect=コレクション
\ No newline at end of file
+plugin.collect=コレクション
+bug-feedback=バグフィードバック
+future=この機能は次のバージョンで提供されます
+version.tip.3=次のように変更します:
+flutterX-Dart-Plugin-Ignore=このプラグインの新しいバージョンは今後検出されません
+ig.version.check=最新バージョンを検出しない
+dio.apis.option.title=表示オプション
+compact.mode=コンパクトモード
+relaxed.mode=リラックスモード (デフォルト)
+ui.render=UIスタイル
+dio.setting.project.name.show.option=アイテム名を表示
+plugin.collects.title=プラグインコレクション
+tool=道具
+dio.search.empty.text=検索する URL キーワードを入力します
\ No newline at end of file
diff --git a/src/main/resources/messages/pluginBundle_ko.properties b/src/main/resources/messages/pluginBundle_ko.properties
index 76a0c95a..a35e3abb 100644
--- a/src/main/resources/messages/pluginBundle_ko.properties
+++ b/src/main/resources/messages/pluginBundle_ko.properties
@@ -14,7 +14,7 @@ set.default=기본값으로 설정
empty=빈 항목
reward=보상
help=자습서
-setting=Flutter CheckX 설치
+setting.flutterx=FlutterX
clean=레코드 지우기
comment.api.new.tips=인터페이스를 감지할 때 창에 알림이 뜨고 기본적으로 켜짐
open=오픈
@@ -112,4 +112,17 @@ flutter.clean=명령 실행: flutter clean
dart.pub.publish=명령 실행: dart pub publish
addConstructorFun=생성자 추가
addFromJson=FromJson 함수 추가
-plugin.collect=모음집
\ No newline at end of file
+plugin.collect=모음집
+bug-feedback=bug 피드백
+future=이 기능은 다음 릴리즈에서 제공됩니다.
+version.tip.3=다음으로 변경:
+flutterX-Dart-Plugin-Ignore=이 플러그인의 새 버전은 더 이상 감지되지 않습니다.
+ig.version.check=최신 버전을 테스트하지 않음
+dio.apis.option.title=표시 옵션
+compact.mode=컴팩트 모드
+relaxed.mode=편안한 모드(기본값)
+ui.render=UI 스타일
+dio.setting.project.name.show.option=항목 이름 표시
+plugin.collects.title=플러그인 모음
+tool=도구
+dio.search.empty.text=검색할 URL 키워드를 입력합니다
\ No newline at end of file