generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shirelang): add Shire Vcs Log Action and update menu text
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
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
shirelang/src/main/kotlin/com/phodal/shirelang/actions/vcs/ShireVcsLogAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters