From 396b542c59e23502ffbad83cbd17359b7123f768 Mon Sep 17 00:00:00 2001 From: "Elya.Mamedova" Date: Fri, 2 Jul 2021 19:48:01 +0000 Subject: [PATCH] [markdown] IDEA-270050 Don't set disabled format as default IJ-CR-10945 GitOrigin-RevId: 8f53281945c0e497070e95aaaa58afb6356c0bd2 --- .../markdown/fileActions/export/MarkdownExportDialog.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt b/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt index ff101f224cc1..52db4af90e4b 100644 --- a/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt +++ b/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt @@ -52,7 +52,7 @@ internal class MarkdownExportDialog( val fileTypeProperty = PropertyGraph().graphProperty { selectedFileType } fileTypeProperty.afterChange { selectedFileType = it } - selectedFileType = supportedExportProviders.first() + selectedFileType = findFirstValidProvider() ?: supportedExportProviders.first() label(MarkdownBundle.message("markdown.export.dialog.filetype.label")) fileTypeSelector = comboBox(model, fileTypeProperty, FileTypeRenderer()) .withValidationOnApply { validateFileType(it) } @@ -73,6 +73,9 @@ internal class MarkdownExportDialog( return panel } + private fun findFirstValidProvider(): MarkdownExportProvider? = + supportedExportProviders.find { it.validate(project, targetFile) == null } + private fun JComponent.visible(predicate: ComponentPredicate) { isVisible = predicate() predicate.addListener { isVisible = it } @@ -100,7 +103,8 @@ internal class MarkdownExportDialog( if (errorMessage != null) { isEnabled = false toolTipText = errorMessage - } else { + } + else { isEnabled = true } }