Disable action when no template is configured

This commit is contained in:
Matthias Gugel 2021-03-20 14:37:44 +01:00
parent eb94b71723
commit 525b76b208

View File

@ -5,6 +5,7 @@ import com.intellij.ide.IdeBundle
import com.intellij.ide.actions.CreateFileAction
import com.intellij.ide.ui.newItemPopup.NewItemPopupUtil
import com.intellij.lang.LangBundle
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.InputValidatorEx
import com.intellij.openapi.util.Trinity
@ -29,6 +30,14 @@ class CreateFileWithFilenameTemplateAction :
DefaultPlaceholder()
)
override fun update(e: AnActionEvent) {
if (FilenameTemplateSettingsState.instance.filenameTemplates.isEmpty()) {
e.presentation.isEnabledAndVisible = false
} else {
super.update(e)
}
}
override fun invokeDialog(
project: Project,
directory: PsiDirectory,