Skip to content

Commit

Permalink
feat(shirelang): add Shire Vcs Log Action and update menu text
Browse files Browse the repository at this point in the history
Update the existing Database Action text for clarity and add a new Vcs Log Action with corresponding configurations and location in the menu bar.
  • Loading branch information
phodal committed Nov 24, 2024
1 parent 8ee1a18 commit b90f450
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class ShireActionLocation(val location: String, val description: String) {
INPUT_BOX("InputBox", "Show in Input Box"),
DATABASE_MENU("DatabaseMenu", "Show in Database panel menu bar"),
CONSOLE_MENU("ConsoleMenu", "Show in Console panel menu bar"),
VCS_LOG_MENU("VcsLogMenu", "Show in VCS Log panel menu bar"),
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.phodal.shirelang.actions.vcs

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.phodal.shirecore.config.ShireActionLocation
import com.phodal.shirecore.variable.template.VariableActionEventDataHolder
import com.phodal.shirelang.actions.ShireRunFileAction
import com.phodal.shirelang.actions.base.DynamicShireActionService

class ShireVcsLogAction : AnAction() {
override fun getActionUpdateThread() = ActionUpdateThread.EDT

private fun shireActionConfigs(project: Project) =
DynamicShireActionService.getInstance(project).getActions(ShireActionLocation.VCS_LOG_MENU)

override fun update(e: AnActionEvent) {
val project = e.project ?: return
val isOnlyOneConfig = shireActionConfigs(project).size == 1

val hobbitHole = shireActionConfigs(project).firstOrNull()?.hole
e.presentation.isVisible = isOnlyOneConfig
e.presentation.isEnabled = hobbitHole != null && hobbitHole.enabled
if (hobbitHole != null) {
e.presentation.text = hobbitHole.name ?: "<Placeholder>"
}
}

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return

VariableActionEventDataHolder.putData(VariableActionEventDataHolder(e.dataContext))

val config = shireActionConfigs(project).firstOrNull() ?: return
ShireRunFileAction.executeShireFile(project, config, null)
}
}
10 changes: 9 additions & 1 deletion shirelang/src/main/resources/com.phodal.shirelang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,18 @@
<action id="ShireDatabaseAction"
class="com.phodal.shirelang.actions.database.ShireDatabaseAction"
icon="com.phodal.shirelang.ShireIcons.DEFAULT"
text="Database Action"
text="Shire Database Action"
description="Shire database action">

</action>

<action id="ShireVcsLogAction"
class="com.phodal.shirelang.actions.vcs.ShireVcsLogAction"
icon="com.phodal.shirelang.ShireIcons.DEFAULT"
text="Shire Vcs Action"
description="Shire vcs action">

</action>
</actions>

<extensions defaultExtensionNs="com.phodal">
Expand Down

0 comments on commit b90f450

Please sign in to comment.