scala-swing
scala-swing copied to clipboard
Incorrect CellEditor for Table when column is null
In scala.swing.Table the default editor behaviour differs from the expected. The TableModel interface contains the method getColumnClass which I expected to be used to determine the type of a column in order to select the right cell editor. Instead the code looks at the value in the cell and if it is null the default editor for Object is used.
// TODO: a public API for setting editors
protected def editor(row: Int, column: Int) = {
val v = apply(row, column).asInstanceOf[AnyRef]
if (v != null)
Table.this.peer.getDefaultEditor(v.getClass)
else
Table.this.peer.getDefaultEditor(classOf[Object])
Use case where this breaks: I have a date column in a table which might be null. When null I cannot enter a valid date since the wrong editor is used.
This is how I expected the code to look:
def editor(row: Int, column: Int) =
peer.getDefaultEditor(peer.getModel.getColumnClass(column))
Imported From: https://issues.scala-lang.org/browse/SI-5616?orig=1 Reporter: Johan Andrén (johanandren) Affected Versions: 2.9.1