Skip to content

Commit

Permalink
合并拉取请求 #30
Browse files Browse the repository at this point in the history
1.9.0
  • Loading branch information
mdddj authored Jul 4, 2024
2 parents 2a4f6d8 + 8c6819c commit 51b1f89
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@



## [1.9.0] -2024-07-04

- 更新插件名字和图标
- 新增sea-orm-cli可视化面板 <a href='https://mdddj.github.io/SalvoRsToolDocument/sea-orm-command-tool.html'>文档</a>
- <a href='https://mdddj.github.io/SalvoRsToolDocument/changelog%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97.html#1-9-0'>更新日志</a>

## [1.8.0] - 2024-06-21

- 添加json生成sea orm migration代码功能,<a href='https://mdddj.github.io/SalvoRsToolDocument/sea-orm-json-gen-migration-code.html'>查看文档</a>
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("org.jetbrains.intellij.platform") version "2.0.0-beta7"
id("org.jetbrains.intellij.platform") version "2.0.0-beta8"
id("org.jetbrains.changelog") version "2.2.0"
}

group = "shop.itbug"
version = "1.8.0"
version = "1.9.0"

repositories {
mavenCentral()
Expand All @@ -24,7 +24,7 @@ repositories {

dependencies {
intellijPlatform {
rustRover("2024.1.2")
rustRover("2024.1.3")
bundledPlugins("com.jetbrains.rust","JavaScriptBase")
zipSigner()
instrumentationTools()
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package shop.itbug.salvorstool.action.seaorm

import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.ui.dsl.builder.bindText
import com.intellij.ui.dsl.builder.panel
import shop.itbug.salvorstool.dialog.GenerateEntityDialog
import shop.itbug.salvorstool.help.SeaOrmCommandHelp
import shop.itbug.salvorstool.i18n.MyI18n
import shop.itbug.salvorstool.icons.MyIcon
import javax.swing.JComponent


class SeamOrmCommandActionGroup: DefaultActionGroup() {

override fun update(e: AnActionEvent) {
val vf = e.getData(PlatformDataKeys.VIRTUAL_FILE)
e.presentation.isEnabledAndVisible = vf != null && vf.isDirectory && e.project != null && vf.findChild("Cargo.toml") != null
e.presentation.icon = MyIcon.pluginIcon
super.update(e)
}

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
}

abstract class SeamOrmCommandBaseAction : AnAction() {
override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}

fun AnActionEvent.getProj(): Project = this.project!!
private fun AnActionEvent.getVf() = this.getData(CommonDataKeys.VIRTUAL_FILE)!!
fun AnActionEvent.getSeaOrmHelper() = SeaOrmCommandHelp(getVf().path, getProj())
}

///初始化
class SeaOrmInitAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().migrateInit()
}
}

///创建table
class SeaOrmCreateTableFileAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
Dialog(e.getProj()) {
e.getSeaOrmHelper().migrateGenerate(it.filename)
}.show()
}

private class Dialog(project: Project, val ok: (model: Model) -> Unit) : DialogWrapper(project, true) {
data class Model(var filename: String = "")

val configModel = Model()

init {
super.init()
title = "Seam Orm Create Table File"
}

override fun createCenterPanel(): JComponent {
return panel {
row(MyI18n.getMessage("file_name")) {
textField().bindText(configModel::filename)
}
}
}

override fun doOKAction() {
super.doOKAction()
ok.invoke(configModel)
}
}
}


/// 生成实体
class SeaOrmRunGenerateEntityAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
GenerateEntityDialog(e.getProj()) { _, s ->
run {
e.getSeaOrmHelper().customRunCommand(*s.split(" ").toTypedArray())
}
}.show()
}

}


/// up
class SeaOrmRunUpAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().runUp()
}
}

/// Down
class SeaOrmRunDownAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().runDown()
}
}

/// check status
class SeaOrmRunCheckStatusAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().checkStatus()
}
}

/// check status
class SeaOrmRunFreshAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().runFresh()
}
}

/// refresh
class SeaOrmRunRefreshAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().runRefresh()
}
}

// reset
class SeaOrmRunResetAction : SeamOrmCommandBaseAction() {
override fun actionPerformed(e: AnActionEvent) {
e.getSeaOrmHelper().runReset()
}
}

15 changes: 15 additions & 0 deletions src/main/kotlin/shop/itbug/salvorstool/cache/SeaOrmCache.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package shop.itbug.salvorstool.cache

import com.intellij.openapi.components.*
import com.intellij.openapi.project.Project
import shop.itbug.salvorstool.dialog.GenerateEntityDialog

@Service(Service.Level.PROJECT)
@State(name = "SeaOrmGenerateEntityConfig.xml", category = SettingsCategory.PLUGINS)
@Storage(roamingType = RoamingType.DEFAULT)
class SeaOrmCache: SimplePersistentStateComponent<GenerateEntityDialog.Config>(GenerateEntityDialog.Config()) {

companion object{
fun getInstance(project: Project): SeaOrmCache = project.service<SeaOrmCache>()
}
}
Loading

0 comments on commit 51b1f89

Please sign in to comment.