Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect CellEditor for Table when column is null #139

Open
scabug opened this issue Mar 27, 2012 · 1 comment
Open

Incorrect CellEditor for Table when column is null #139

scabug opened this issue Mar 27, 2012 · 1 comment
Assignees

Comments

@scabug
Copy link

scabug commented Mar 27, 2012

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))
@scabug
Copy link
Author

scabug commented Mar 27, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5616?orig=1
Reporter: Johan Andrén (johanandren)
Affected Versions: 2.9.1

@scabug scabug closed this as completed Jul 17, 2015
@SethTisue SethTisue transferred this issue from scala/bug Nov 19, 2020
@SethTisue SethTisue reopened this Nov 19, 2020
@scala scala deleted a comment from scabug Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants