From c06a1a9e7fa25f0047345693b13ddc0e3b8abebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=85=B8=E5=85=B8?= <413153189@qq.com> Date: Thu, 4 Jul 2024 09:47:02 +0800 Subject: [PATCH] release 4.7.0 --- CHANGELOG.md | 9 +++ gradle.properties | 26 +++---- .../dialog/freezed/StringToFreezedDialog.kt | 61 +++++++++++----- .../form/components/ChangeDioRequestItemUi.kt | 2 +- .../form/components/DioUiSettingsMenu.kt | 2 +- .../form/sub/CustomListRender.kt | 73 ------------------- ...actoryConstructorDeclarationImplManager.kt | 2 +- .../tools/DartPluginVersionCheck.kt | 3 +- .../fluttercheckversionx/util/MyPsiUtil.kt | 2 +- .../fluttercheckversionx/util/RunUtil.kt | 35 +++++++-- src/main/resources/META-INF/plugin.xml | 8 +- .../messages/pluginBundle.properties | 40 +--------- .../messages/pluginBundle_en.properties | 2 + .../messages/pluginBundle_hk.properties | 2 + .../messages/pluginBundle_ja.properties | 2 + .../messages/pluginBundle_ko.properties | 2 + 16 files changed, 114 insertions(+), 157 deletions(-) delete mode 100644 src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/CustomListRender.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e816dfa..66361bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## Unreleased +## [4.7.0] - 2024-07-03 + +- Reconstructed the `json to freezed class code gen` tool, +- Optimize the repair logic of `package` new version detection +- Removed some third-party dependencies and reduced the plug-in package to 1M +- If you encounter problems during use, please submit an issue +- This is the last updated version below `2023.*`. If you want to receive subsequent updates, please update your idea to + version `2024.*` and `above`. + ## [4.6.0] - 2024-06-18 - After optimizing the terminal running logic, windows will no longer be created repeatedly. diff --git a/gradle.properties b/gradle.properties index 731010a0..a3cb318c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ kotlin.stdlib.default.dependency=false -pluginVersion=4.6.0. +pluginVersion=4.7.0. #===============================> 231 #dartVersion=231.9411 #sinceBuildVersion=231 @@ -22,19 +22,19 @@ pluginVersion=4.6.0. #ideaType= #type=233 #=============================================== 241 idea -dartVersion=241.17502 -sinceBuildVersion=241 -untilBuildVersion=241.* -ideaVersion=2024.1 -ideaType= -type=241 -#========================================242 idea -#dartVersion=242.19533.43 -#sinceBuildVersion=242 -#untilBuildVersion=242.* -#ideaVersion=242-EAP-SNAPSHOT +#dartVersion=241.17502 +#sinceBuildVersion=241 +#untilBuildVersion=241.* +#ideaVersion=2024.1 #ideaType= -#type=242 +#type=241 +#========================================242 idea +dartVersion=242.19533.43 +sinceBuildVersion=242 +untilBuildVersion=242.* +ideaVersion=242-EAP-SNAPSHOT +ideaType= +type=242 # proxy systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyPort=7890 diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/freezed/StringToFreezedDialog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/freezed/StringToFreezedDialog.kt index ed1977bf..d871a51d 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/freezed/StringToFreezedDialog.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/freezed/StringToFreezedDialog.kt @@ -1,5 +1,7 @@ package shop.itbug.fluttercheckversionx.dialog.freezed +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory @@ -7,14 +9,17 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogPanel import com.intellij.openapi.ui.DialogWrapper +import com.intellij.openapi.ui.TextFieldWithBrowseButton +import com.intellij.openapi.ui.ValidationInfo import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiFileFactory import com.intellij.psi.PsiManager import com.intellij.ui.components.JBTabbedPane +import com.intellij.ui.components.JBTextField import com.intellij.ui.dsl.builder.* -import com.intellij.ui.dsl.validation.Level +import com.intellij.ui.layout.ValidationInfoBuilder import com.intellij.util.Alarm import com.intellij.util.ui.components.BorderLayoutPanel import com.jetbrains.lang.dart.DartFileType @@ -38,6 +43,8 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr private val generateConfig = FreezedClassConfigStateService.getInstance(project).state private val alarm = Alarm(disposable) private lateinit var settingPanel: DialogPanel + private lateinit var filenameField: Cell + private lateinit var dirField: Cell init { super.init() @@ -85,19 +92,30 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr panel { group(PluginBundle.get("save.to.directory")) { row(PluginBundle.get("g.2")) { - textField().align(Align.FILL).bindText(generateConfig::saveFileName).cellValidation { - addInputRule(VerifyFileDir.ENTER_YOU_FILE_NAME, Level.ERROR) { - it.text.trim().isBlank() + filenameField = textField().align(Align.FILL).bindText(generateConfig::saveFileName) + filenameField.addValidationRule(VerifyFileDir.ENTER_YOU_FILE_NAME) { + it.text.trim().isBlank() + } + filenameField.validationOnInput { + println("text:${it.text}") + if (it.text.trim().isBlank()) { + return@validationOnInput error(VerifyFileDir.ENTER_YOU_FILE_NAME) } + return@validationOnInput null } } row(PluginBundle.get("g.3")) { - textFieldWithBrowseButton( + dirField = textFieldWithBrowseButton( "Select Dir", project, FileChooserDescriptorFactory.createSingleFolderDescriptor() - ) { it.path }.bindText(generateConfig::saveDirectory).align(Align.FILL).cellValidation { - addInputRule(VerifyFileDir.ERROR_MSG, Level.ERROR) { + ) { it.path }.bindText(generateConfig::saveDirectory).align(Align.FILL) + .addValidationRule(VerifyFileDir.ERROR_MSG) { VerifyFileDir.validDirByComponent(it) } + dirField.validationOnInput { + if (VerifyFileDir.validDirByComponent(dirField.component)) { + return@validationOnInput ValidationInfoBuilder(it.textField).error(VerifyFileDir.ERROR_MSG) + } + return@validationOnInput null } } row { @@ -115,7 +133,7 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr collapsibleGroup(PluginBundle.get("freezed.gen.base.opt")) { buttonsGroup(PluginBundle.get("freezed.gen.formatname.classname") + ":") { row { - NameFormat.entries.forEach { + NameFormat.values().forEach { radioButton(it.title, it) contextHelp(it.example, PluginBundle.get("freezed.gen.formatname.example")) } @@ -123,7 +141,7 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr }.bind(generateConfig::classNameFormat) buttonsGroup(PluginBundle.get("freezed.gen.formatname.properties") + ":") { row { - NameFormat.entries.forEach { + NameFormat.values().forEach { radioButton(it.title, it) contextHelp(it.example, PluginBundle.get("freezed.gen.formatname.example")) } @@ -131,7 +149,7 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr }.bind(generateConfig::propertyNameFormat) buttonsGroup("fromJson ${PluginBundle.get("freezed.gen.formatname.fromjson.type")}:") { row { - FormJsonType.entries.forEach { + FormJsonType.values().forEach { radioButton(it.value, it) } } @@ -149,6 +167,14 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr return BorderLayoutPanel().addToCenter(tabs).addToBottom(settingPanel) } + override fun doValidate(): ValidationInfo? { + val d = VerifyFileDir.validDirByPath(generateConfig.saveDirectory) + if (d) { + return ValidationInfoBuilder(dirField.component).error(VerifyFileDir.ERROR_MSG) + } + return super.doValidate() + } + override fun doOKAction() { settingPanel.apply() doCreateFile { super.doOKAction() } @@ -186,18 +212,17 @@ class StringToFreezedDialog(val project: Project, jsonString: String) : DialogWr } onSuccess.invoke() } catch (e: Exception) { - // todo 创建失败,执行命令失败 - println("创建文件失败:$e") + showErrorMessage("${PluginBundle.get("freezed.gen.create.error")}:${e.localizedMessage}") } - } else { - // todo 查找目录失败 - println("查找目录失败2") } - } else { - // todo 查找目录失败 - println("查找目录失败1") } } + + private fun showErrorMessage(msg: String) { + val groupId = "json_to_freezed_tooltip" + NotificationGroupManager.getInstance().getNotificationGroup(groupId) + .createNotification(msg, NotificationType.ERROR).notify(project) + } } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt index 1ebca3f5..da5fda9d 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ChangeDioRequestItemUi.kt @@ -6,7 +6,7 @@ import shop.itbug.fluttercheckversionx.widget.MyComboActionNew ///切换dio请求ui样式 class ChangeDioRequestItemUi : - MyComboActionNew.ToggleActionGroup(DioRequestUIStyle.entries.toTypedArray()) { + MyComboActionNew.ToggleActionGroup(DioRequestUIStyle.values()) { var setting = DioListingUiConfig.setting override var value: DioRequestUIStyle diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt index c0a02494..ef435455 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/DioUiSettingsMenu.kt @@ -24,7 +24,7 @@ enum class DioUiSettingMenu(val title: String) { internal class DioUIShowActionGroup : DumbAware, ActionGroup() { override fun getChildren(e: AnActionEvent?): Array { val actions = ArrayList() - actions.addAll(DioUiSettingMenu.entries.map { DioUiRenderOption(it) }) + actions.addAll(DioUiSettingMenu.values().map { DioUiRenderOption(it) }) return actions.toTypedArray() } } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/CustomListRender.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/CustomListRender.kt deleted file mode 100644 index 689e0e03..00000000 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/sub/CustomListRender.kt +++ /dev/null @@ -1,73 +0,0 @@ -package shop.itbug.fluttercheckversionx.form.sub - -import com.intellij.openapi.project.Project -import com.intellij.util.ui.UIUtil -import shop.itbug.fluttercheckversionx.socket.ProjectSocketService -import java.awt.Dimension -import javax.swing.Box -import javax.swing.BoxLayout -import javax.swing.JLabel -import javax.swing.JPanel - -///jlist自定义渲染 -class CustomListRender(private val model: ProjectSocketService.SocketResponseModel, val project: Project) : JPanel(){ - - - init { - initComponentUi() - } - - private fun initComponentUi(){ - - - val dimension = Dimension() - dimension.height = 100 - - layout = BoxLayout(this,BoxLayout.PAGE_AXIS) - - - add(StringValueRender("Url",model.url?:"")) - add(Box.createVerticalStrut(6)) - add(StringValueRender("Methed",model.method?:"")) - add(Box.createVerticalStrut(6)) - add(StringValueRender("Status Code",model.statusCode.toString())) - if(model.data!=null){ - add(Box.createVerticalStrut(6)) - add(JsonValueRender(project)) - } - add(Box.createVerticalStrut(6)) - add(JsonValueRender(project)) - add(Box.createVerticalStrut(6)) - add(JsonValueRender(project)) - } - - - /** - * 渲染普通类型的值 - */ - class StringValueRender(title: String, value: String): JPanel() { - - init { - - - layout = BoxLayout(this,BoxLayout.PAGE_AXIS) - - val jLabel = JLabel(title) - add(jLabel) - add(Box.createVerticalStrut(6)) - - val valueLabel = JLabel(value) - if(value == "200"){ - valueLabel.foreground = UIUtil.getLabelInfoForeground() - }else if(value == "500"){ - valueLabel.foreground = UIUtil.getErrorForeground() - valueLabel.text = "500 (服务器错误)" - } - add(valueLabel) - - } - - } - - -} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt index e751d355..5820db51 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt @@ -374,7 +374,7 @@ class DartDefaultFormalNamedParameterActionManager(val element: DartDefaultForma ///获取 dart 类型 fun getMyDartType(): MyDartType? { - return MyDartType.entries.find { it.dartType == dartType } + return MyDartType.values().find { it.dartType == dartType } } } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt index bb67614d..ab17bd9b 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/tools/DartPluginVersionCheck.kt @@ -105,8 +105,7 @@ class DartPluginVersionCheck : ExternalAnnotator() if (coreElementChildren.isNotEmpty()) { - FlutterPluginType.entries.forEach { type -> + FlutterPluginType.values().forEach { type -> val l = coreElementChildren.filter { it.keyText == type.type }.toList() if (l.isNotEmpty()) { val pluginDevs = l.first() diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt index ff051bc6..3e86eb39 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt @@ -3,7 +3,6 @@ package shop.itbug.fluttercheckversionx.util import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project import com.intellij.openapi.wm.ToolWindowManager -import com.intellij.terminal.ui.TerminalWidget import org.jetbrains.plugins.terminal.TerminalToolWindowFactory import org.jetbrains.plugins.terminal.TerminalToolWindowManager @@ -13,7 +12,7 @@ object RunUtil { runCommand(project, "Flutter Builder", "flutter pub run build_runner build") } - fun runCommand(project: Project, title: String, command: String) { + private fun runFlutterCommandBy233(project: Project, title: String, command: String) { ApplicationManager.getApplication().invokeLater { val instance = TerminalToolWindowManager.getInstance(project) var toolWindow = instance.toolWindow @@ -28,24 +27,48 @@ object RunUtil { toolWindow.show() } } + toolWindow.activate { + // 241-- + instance.createLocalShellWidget(project.basePath, title).executeCommand(command) + } + } + } + private fun runCommandBy244(project: Project, title: String, command: String) { + ApplicationManager.getApplication().invokeLater { + val instance = TerminalToolWindowManager.getInstance(project) + var toolWindow = instance.toolWindow + + //显示窗口 + if (toolWindow == null) { + toolWindow = + ToolWindowManager.getInstance(project).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID) + toolWindow?.show() + } else { + if (toolWindow.isAvailable) { + toolWindow.show() + } + } val find = toolWindow.contentManager.findContent(title) if (find != null) { val tw = TerminalToolWindowManager.findWidgetByContent(find) + tw?.let { println(tw::class.java) } tw?.requestFocus() tw?.sendCommandToExecute(command) tw?.setCursorVisible(true) toolWindow.contentManager.setSelectedContent(find) } else { toolWindow.activate { - // 241-- -// instance.createLocalShellWidget(project.basePath, title).executeCommand(command) - // 241+ - val terminal: TerminalWidget = instance.createShellWidget(project.basePath, title, true, true) + val terminal = instance.createShellWidget(project.basePath, title, true, true) terminal.sendCommandToExecute(command) } } } } + + fun runCommand(project: Project, title: String, command: String) { + runCommandBy244(project, title, command) +// runFlutterCommandBy233(project, title, command) + } } \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index af984cd2..cb67eb91 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -333,10 +333,10 @@ - - - + + + + diff --git a/src/main/resources/messages/pluginBundle.properties b/src/main/resources/messages/pluginBundle.properties index b9c5f0e1..7b6fe985 100644 --- a/src/main/resources/messages/pluginBundle.properties +++ b/src/main/resources/messages/pluginBundle.properties @@ -136,76 +136,42 @@ check_flutter_version_comment=打开Dart项目时,启动一个进程检查远程 open_flutterx_setting=打开设置 create_a_new_class_name=输入一个新的名称 simple_class_to_freezed_object_f1=构造函数转成freezed - - preview_title=代码预览 - copy_code_dialog_title=拷贝代码 - scan_privacy=扫描 - click_open_the_file=点击打开文件 - not_found_the_privacy_file=没找到 - privacy_info_tips=已经忽略没有iOS目录的package - are_you_ok_betch_insert_privacy_file=确认批量插入吗 - are_you_ok_betch_insert_privacy_file_title=确认 - are_you_ok_betch_insert_privacy_file_ok=批量添加 - are_you_ok_betch_insert_privacy_file_cancel=取消 - are_you_ok_betch_insert_privacy_file_insert=正在添加 - are_you_ok_betch_insert_privacy_file_file=文件 - are_you_ok_betch_insert_privacy_file_button_title=批量修复 - are_you_ok_betch_insert_privacy_file_window_title=隐私扫描工具 - pubspec_yaml_file_re_index=重新索引 - find_the_project_dart_lib_names=找到项目定义的library - get_package_verion_task_title=获取版本列表 - dio.setting.show.data.size=显示数据大小 - freezed.gen.group.title=全局设置 - freezed.gen.group.add.structure.fun=添加构造函数 - freezed.gen.group.add.fromjson.fun=添加函数 - freezed.gen.formatname.original=原始,不改变 - freezed.gen.formatname.tf=驼峰命名规则 - freezed.gen.formatname.classname=类名命名规则 - freezed.gen.formatname.properties=属性命名规则 - freezed.gen.formatname.example=示例 - freezed.gen.formatname.start=之前 - freezed.gen.formatname.after=之后 - freezed.gen.formatname.fromjson.type=类型 - freezed.gen.base.setting=设置 - freezed.gen.base.opt=命名规则和类型声明 - freezed.gen.base.set.default.value=设置默认值 - freezed.gen.base.file.dir.error=不是有效的目录 - freezed.gen.base.open.in.editor=成功后在编辑器打开文件 - freezed.gen.create.task.title=正在生成代码文件,请稍等 - freezed.gen.create.enter.you.file.name=请输入文件名 + + +freezed.gen.create.error=操作失败 diff --git a/src/main/resources/messages/pluginBundle_en.properties b/src/main/resources/messages/pluginBundle_en.properties index 78aaa418..091f7ec7 100644 --- a/src/main/resources/messages/pluginBundle_en.properties +++ b/src/main/resources/messages/pluginBundle_en.properties @@ -192,3 +192,5 @@ freezed.gen.base.open.in.editor=Open the file in the editor after success freezed.gen.create.task.title=Generating code file, please wait freezed.gen.create.enter.you.file.name=Please enter a file name + +freezed.gen.create.error=operation failed diff --git a/src/main/resources/messages/pluginBundle_hk.properties b/src/main/resources/messages/pluginBundle_hk.properties index 6bb3ec0e..e5014dc5 100644 --- a/src/main/resources/messages/pluginBundle_hk.properties +++ b/src/main/resources/messages/pluginBundle_hk.properties @@ -209,3 +209,5 @@ freezed.gen.base.open.in.editor=成功後在編輯器打開文件 freezed.gen.create.task.title=正在生成程式碼檔案,請稍等 freezed.gen.create.enter.you.file.name=請輸入檔名 + +freezed.gen.create.error=操作失敗 diff --git a/src/main/resources/messages/pluginBundle_ja.properties b/src/main/resources/messages/pluginBundle_ja.properties index 62b7f428..74b6b6b3 100644 --- a/src/main/resources/messages/pluginBundle_ja.properties +++ b/src/main/resources/messages/pluginBundle_ja.properties @@ -180,3 +180,5 @@ freezed.gen.base.open.in.editor=成功したらエディタでファイルを開 freezed.gen.create.task.title=コードファイルを生成しています。少々お待ちください freezed.gen.create.enter.you.file.name=ファイル名を入力してください + +freezed.gen.create.error=操作に失敗しました diff --git a/src/main/resources/messages/pluginBundle_ko.properties b/src/main/resources/messages/pluginBundle_ko.properties index 8f58ec0f..cae19182 100644 --- a/src/main/resources/messages/pluginBundle_ko.properties +++ b/src/main/resources/messages/pluginBundle_ko.properties @@ -212,3 +212,5 @@ freezed.gen.base.open.in.editor=성공하면 편집기에서 파일 열기 freezed.gen.create.task.title=코드 파일을 생성하는 중입니다. 잠시만 기다려 주십시오. freezed.gen.create.enter.you.file.name=파일 이름을 입력하십시오. + +freezed.gen.create.error=작업 실패