Kotlin Facet: Suppress selection on plugin options tab

#KT-17046 Fixed
This commit is contained in:
Alexey Sedunov
2017-04-03 16:35:48 +03:00
parent 746ec48176
commit 7e0bb089e2
@@ -16,10 +16,10 @@
package org.jetbrains.kotlin.idea.facet package org.jetbrains.kotlin.idea.facet
import com.intellij.facet.ui.* import com.intellij.facet.ui.FacetEditorTab
import com.intellij.openapi.Disposable import com.intellij.facet.ui.FacetEditorValidator
import com.intellij.openapi.util.Disposer import com.intellij.facet.ui.FacetValidatorsManager
import com.intellij.openapi.util.text.StringUtil import com.intellij.facet.ui.ValidationResult
import com.intellij.ui.ScrollPaneFactory import com.intellij.ui.ScrollPaneFactory
import com.intellij.ui.table.JBTable import com.intellij.ui.table.JBTable
import org.jetbrains.kotlin.compiler.plugin.CliOptionValue import org.jetbrains.kotlin.compiler.plugin.CliOptionValue
@@ -88,37 +88,29 @@ class KotlinFacetCompilerPluginsTab(
} }
} }
override fun setValueAt(aValue: Any?, rowIndex: Int, columnIndex: Int) {
if (columnIndex == 1) {
val oldValue = pluginInfos[rowIndex].options
val newValue = StringUtil.splitByLines(aValue as? String ?: "").toList()
pluginInfos[rowIndex].options = newValue
isModified = oldValue != newValue
}
}
override fun isCellEditable(rowIndex: Int, columnIndex: Int) = true override fun isCellEditable(rowIndex: Int, columnIndex: Int) = true
} }
private class OptionRendererAndEditor : AbstractCellEditor(), TableCellEditor, TableCellRenderer { private class OptionRendererAndEditor : AbstractCellEditor(), TableCellEditor, TableCellRenderer {
private val textPane = JTextPane() private val textPane = JTextPane().apply {
isEditable = false
}
private fun setupComponent(table: JTable, value: Any?) { private fun setupComponent(table: JTable, value: Any?): Component {
textPane.font = table.font return textPane.apply {
textPane.text = value as? String ?: "" font = table.font
textPane.isEditable = false text = value as? String ?: ""
background = table.background
foreground = table.foreground
}
} }
override fun getTableCellRendererComponent(table: JTable, value: Any?, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component { override fun getTableCellRendererComponent(table: JTable, value: Any?, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component {
setupComponent(table, value) return setupComponent(table, value)
textPane.background = if (isSelected) table.selectionBackground else table.background
textPane.foreground = if (isSelected) table.selectionForeground else table.foreground
return textPane
} }
override fun getTableCellEditorComponent(table: JTable, value: Any?, isSelected: Boolean, row: Int, column: Int): Component { override fun getTableCellEditorComponent(table: JTable, value: Any?, isSelected: Boolean, row: Int, column: Int): Component {
setupComponent(table, value) return setupComponent(table, value)
return textPane
} }
override fun getCellEditorValue() = textPane.text!! override fun getCellEditorValue() = textPane.text!!