Make plugin compatible with idea version 2019.3
This commit is contained in:
parent
6262bda2fb
commit
32bf4dfacb
|
|
@ -1,4 +1,4 @@
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
pluginVersion = 1.0.0-192
|
pluginVersion = 1.0.0-193
|
||||||
platformVersion = 2019.2
|
platformVersion = 2019.3
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,17 @@ package de.idetools.filename_template
|
||||||
import com.intellij.icons.AllIcons
|
import com.intellij.icons.AllIcons
|
||||||
import com.intellij.ide.IdeBundle
|
import com.intellij.ide.IdeBundle
|
||||||
import com.intellij.ide.actions.CreateFileAction
|
import com.intellij.ide.actions.CreateFileAction
|
||||||
|
import com.intellij.ide.ui.newItemPopup.NewItemPopupUtil
|
||||||
|
import com.intellij.ide.ui.newItemPopup.NewItemSimplePopupPanel
|
||||||
|
import com.intellij.lang.LangBundle
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.Messages
|
import com.intellij.openapi.ui.InputValidatorEx
|
||||||
import com.intellij.psi.PsiDirectory
|
import com.intellij.psi.PsiDirectory
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import java.awt.event.InputEvent
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
|
import java.util.function.Consumer
|
||||||
|
|
||||||
class CreateFileWithFilenameTemplateAction(
|
class CreateFileWithFilenameTemplateAction(
|
||||||
text: String,
|
text: String,
|
||||||
|
|
@ -17,17 +22,33 @@ class CreateFileWithFilenameTemplateAction(
|
||||||
) :
|
) :
|
||||||
CreateFileAction(text, description, AllIcons.FileTypes.Unknown) {
|
CreateFileAction(text, description, AllIcons.FileTypes.Unknown) {
|
||||||
|
|
||||||
override fun invokeDialog(project: Project?, directory: PsiDirectory?): Array<PsiElement> {
|
override fun invokeDialog(
|
||||||
|
project: Project,
|
||||||
|
directory: PsiDirectory,
|
||||||
|
elementsConsumer: Consumer<Array<PsiElement?>?>
|
||||||
|
) {
|
||||||
val validator: MyInputValidator = MyValidator(project, directory)
|
val validator: MyInputValidator = MyValidator(project, directory)
|
||||||
Messages.showInputDialog(
|
val contentPanel = NewItemSimplePopupPanel()
|
||||||
project,
|
val nameField = contentPanel.textField
|
||||||
IdeBundle.message("prompt.enter.new.file.name"),
|
|
||||||
IdeBundle.message("title.new.file"),
|
nameField.text = processTemplate(template)
|
||||||
null,
|
|
||||||
processTemplate(template),
|
val popup = NewItemPopupUtil.createNewItemPopup(IdeBundle.message("title.new.file"), contentPanel, nameField)
|
||||||
validator
|
contentPanel.setApplyAction { event: InputEvent? ->
|
||||||
)
|
val name = nameField.text
|
||||||
return validator.createdElements
|
if (validator.checkInput(name) && validator.canClose(name)) {
|
||||||
|
popup.closeOk(event)
|
||||||
|
elementsConsumer.accept(validator.createdElements)
|
||||||
|
} else {
|
||||||
|
val errorMessage =
|
||||||
|
if (validator is InputValidatorEx)
|
||||||
|
(validator as InputValidatorEx).getErrorText(name)
|
||||||
|
else
|
||||||
|
LangBundle.message("incorrect.name")
|
||||||
|
contentPanel.setError(errorMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
popup.showCenteredInCurrentWindow(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processTemplate(template: String): String {
|
private fun processTemplate(template: String): String {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user