Intellij idea 如何在对话框中显示IntelliJ JSON编辑器?
我想在下面展示我正在为Kotlin和Java开发的插件的对话框中的一种编辑器。我尝试了下面的代码片段Intellij idea 如何在对话框中显示IntelliJ JSON编辑器?,intellij-idea,jetbrains-ide,intellij-plugin,intellij-idea-2016,Intellij Idea,Jetbrains Ide,Intellij Plugin,Intellij Idea 2016,我想在下面展示我正在为Kotlin和Java开发的插件的对话框中的一种编辑器。我尝试了下面的代码片段 editorTextField.setEnabled(true); editorTextField.setOneLineMode(false); editorTextField.setFileType(new JsonFileType()); 有人能指出如何做到这一点吗 特别是我需要的行号,JSON语法突出和代码折叠,我可以看到所有的代码规范。请帮助我学习如何在插件中使
editorTextField.setEnabled(true);
editorTextField.setOneLineMode(false);
editorTextField.setFileType(new JsonFileType());
有人能指出如何做到这一点吗
特别是我需要的行号,JSON语法突出和代码折叠,我可以看到所有的代码规范。请帮助我学习如何在插件中使用它们
JSON编辑器:
class JsonOutputDialog(language: Language, project: Project, text: String) : DialogWrapper(project) {
private val panel = JPanel(BorderLayout())
init {
super.setOKActionEnabled(false)
init()
val editorTextField = CustomEditorField(language, project, text)
editorTextField.setOneLineMode(false)
editorTextField.preferredSize = Dimension(800, 600)
editorTextField.isVisible = true
panel.add(editorTextField)
editorTextField.setCaretPosition(0)
}
override fun createCenterPanel() = panel
}
class CustomEditorField(language: Language, project: Project, s: String) : LanguageTextField(language, project, s) {
override fun createEditor(): EditorEx {
val editor = super.createEditor()
editor.setVerticalScrollbarVisible(true)
editor.setHorizontalScrollbarVisible(true)
val settings = editor.settings
settings.isLineNumbersShown = true
settings.isAutoCodeFoldingEnabled = true
settings.isFoldingOutlineShown = true
settings.isAllowSingleLogicalLineFolding = true
settings.isRightMarginShown=true
return editor
}
}
这就是你需要做的。这里的关键是使用LanguageTextField
而不是EditorTextField
,并覆盖createEditor()
方法来配置您要查找的所有选项,如行号和代码折叠