Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MC-XiaoHei committed Jun 2, 2024
1 parent 226db97 commit 2e149ca
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package cn.xor7.xiaohei.leavesknife.activities

import cn.xor7.xiaohei.leavesknife.CommonBundle
import cn.xor7.xiaohei.leavesknife.services.LEAVESKNIFE_CONFIG_FILE
import cn.xor7.xiaohei.leavesknife.services.leavesknifeConfigService
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
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.project.guessProjectDir
import com.intellij.openapi.startup.ProjectActivity
Expand All @@ -28,29 +22,15 @@ class ProjectStartupActivity : ProjectActivity {
)
) {
project.leavesknifeConfigService.enablePlugin = true
// TODO 检查配置文件合法性
return@let
}
GradleConnector.newConnector()
.forProjectDirectory(File(it.path))
.connect().use { connection ->
val ideaProject: IdeaProject = connection.getModel(IdeaProject::class.java)
if (ideaProject.modules.any { it.name == "paper-api-generator" }) {

Check notice on line 32 in src/main/kotlin/cn/xor7/xiaohei/leavesknife/activities/ProjectStartupActivity.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Nested lambda has shadowed implicit parameter

Implicit parameter 'it' of enclosing lambda is shadowed
@Suppress("DialogTitleCapitalization")
NotificationGroupManager.getInstance()
.getNotificationGroup("LeavesKnife")
.createNotification(
CommonBundle.message("notification.configure.title"),
NotificationType.INFORMATION
)
.addAction(object : NotificationAction(
CommonBundle.message("notification.configure.action")
) {
override fun actionPerformed(e: AnActionEvent, notification: Notification) {
project.leavesknifeConfigService.enablePlugin = true
notification.hideBalloon()
}
})
.notify(project)
project.leavesknifeConfigService.needConfigure = true
return@let
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package cn.xor7.xiaohei.leavesknife.dialogs

class PluginConfigurationDialog {

Check notice on line 3 in src/main/kotlin/cn/xor7/xiaohei/leavesknife/dialogs/PluginConfigurationDialog.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Replace empty class body

Redundant empty class body

Check warning on line 3 in src/main/kotlin/cn/xor7/xiaohei/leavesknife/dialogs/PluginConfigurationDialog.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "PluginConfigurationDialog" is never used
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package cn.xor7.xiaohei.leavesknife.services

import cn.xor7.xiaohei.leavesknife.CommonBundle
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
Expand All @@ -19,7 +25,30 @@ class ProjectConfigService(private val project: Project) {
?.isAvailable = value
}
}
var needConfigure = false
set(value) {
if (field == value) return
field = value
if (value) {
@Suppress("DialogTitleCapitalization")
NotificationGroupManager.getInstance()
.getNotificationGroup("LeavesKnife")
.createNotification(
CommonBundle.message("notification.configure.title"),
NotificationType.INFORMATION
)
.addAction(object : NotificationAction(
CommonBundle.message("notification.configure.action")
) {
override fun actionPerformed(e: AnActionEvent, notification: Notification) {
project.leavesknifeConfigService.enablePlugin = true
notification.hideBalloon()
}
})
.notify(project)
}
}
}

val Project.leavesknifeConfigService: ProjectConfigService
get() = this.getService(ProjectConfigService::class.java)
get() = this.getService(ProjectConfigService::class.java)

0 comments on commit 2e149ca

Please sign in to comment.