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

TextFieldListCell.converter_=(c) method does not work #262

Closed
atrosinenko opened this issue Feb 4, 2017 · 0 comments
Closed

TextFieldListCell.converter_=(c) method does not work #262

atrosinenko opened this issue Feb 4, 2017 · 0 comments
Labels
bug
Milestone

Comments

@atrosinenko
Copy link
Contributor

@atrosinenko atrosinenko commented Feb 4, 2017

The TextFieldListCell.converter_=(c) method does not change text converter property of the underlying delegate.

How to reproduce

Run the following test:

package issues.issue262

import javafx.util.converter.IntegerStringConverter

import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.Matchers._
import org.scalatest.junit.JUnitRunner

import scalafx.Includes._
import scalafx.scene.control.cell.TextFieldListCell
import scalafx.testutil.RunOnApplicationThread

@RunWith(classOf[JUnitRunner])
class Issue262Spec extends FlatSpec with RunOnApplicationThread {
  "TextFieldListCell" should "support changing of StringConverter" in {
    val cell = new TextFieldListCell[Integer]
    cell.converter = new IntegerStringConverter
    cell.converter.value.fromString("123") should be(123)
  }
}

When executed, it throws an exception:

[info] Issue262Spec:
[info] TextFieldListCell
[info] - should support changing of StringConverter *** FAILED ***
[info]   java.lang.NullPointerException:
[info]   at scalafx.util.UtilIncludes$$anon$1.fromString(UtilIncludes.scala:115)
[info]   at issues.issue262.Issue262Spec$$anonfun$1.apply(Issue262Spec.scala:19)
[info]   at issues.issue262.Issue262Spec$$anonfun$1.apply(Issue262Spec.scala:16)
[info]   at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
[info]   at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1682)
[info]   at org.scalatest.TestSuite$class.withFixture(TestSuite.scala:196)
[info]   at issues.issue262.Issue262Spec.scalafx$testutil$RunOnApplicationThread$$super$withFixture(Issue262Spec.scala:15)
[info]   ...
atrosinenko added a commit to atrosinenko/scalafx that referenced this issue Feb 4, 2017
Fixes scalafx#262. The `converter()` method of the `ConvertableCell` trait
was creating a fresh ScalaFX `ObjectProperty` out of the ***value***
of underlying `converterProperty()`. While it is OK when reading the
converter value, it didn't work for ***setting*** new converter through
this wrapper from ScalaFX (this can still be achieved through the
`delegate.setConverter(c)`).

This commit changes the `converter()` method to return a wrapper
for the underlying ***property*** instead of value.

This change technically can break some existing code, though,
since it changes the type of the `converter()` method.
@jpsacha jpsacha closed this in #263 Feb 9, 2017
@jpsacha jpsacha added the bug label Feb 9, 2017
@jpsacha jpsacha added this to the 8.0.*-R12 milestone Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.