Skip to content

Commit

Permalink
release 4.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mdddj committed Jul 4, 2024
1 parent 4e628fb commit c06a1a9
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 157 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.stdlib.default.dependency=false
pluginVersion=4.6.0.
pluginVersion=4.7.0.
#===============================> 231
#dartVersion=231.9411
#sinceBuildVersion=231
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
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
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
Expand All @@ -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<JBTextField>
private lateinit var dirField: Cell<TextFieldWithBrowseButton>

init {
super.init()
Expand Down Expand Up @@ -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 {
Expand All @@ -115,23 +133,23 @@ 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"))
}
}
}.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"))
}
}
}.bind(generateConfig::propertyNameFormat)
buttonsGroup("fromJson ${PluginBundle.get("freezed.gen.formatname.fromjson.type")}:") {
row {
FormJsonType.entries.forEach {
FormJsonType.values().forEach {
radioButton(it.value, it)
}
}
Expand All @@ -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() }
Expand Down Expand Up @@ -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)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import shop.itbug.fluttercheckversionx.widget.MyComboActionNew

///切换dio请求ui样式
class ChangeDioRequestItemUi :
MyComboActionNew.ToggleActionGroup<DioRequestUIStyle>(DioRequestUIStyle.entries.toTypedArray()) {
MyComboActionNew.ToggleActionGroup<DioRequestUIStyle>(DioRequestUIStyle.values()) {
var setting = DioListingUiConfig.setting

override var value: DioRequestUIStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum class DioUiSettingMenu(val title: String) {
internal class DioUIShowActionGroup : DumbAware, ActionGroup() {
override fun getChildren(e: AnActionEvent?): Array<AnAction> {
val actions = ArrayList<AnAction>()
actions.addAll(DioUiSettingMenu.entries.map { DioUiRenderOption(it) })
actions.addAll(DioUiSettingMenu.values().map { DioUiRenderOption(it) })
return actions.toTypedArray()
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class DartPluginVersionCheck : ExternalAnnotator<DartPluginVersionCheck.Input, L
override fun getFamilyName() = fixText
override fun getText() = fixText
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement): Boolean {
if (element.text == it.lastVersion) return false
return true
return element.text != it.lastVersion
}

override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MyPsiElementUtil {
val coreElement = yaml.firstChild.firstChild
val coreElementChildren = coreElement.childrenOfType<YAMLKeyValueImpl>()
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()
Expand Down
35 changes: 29 additions & 6 deletions src/main/kotlin/shop/itbug/fluttercheckversionx/util/RunUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
}
}
Loading

0 comments on commit c06a1a9

Please sign in to comment.