Skip to content

Incorrect CellEditor for Table when column is null #139

Open
@scabug

Description

@scabug

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))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions