Skip to content

Commit

Permalink
make sure default property is initialized last, fix #162
Browse files Browse the repository at this point in the history
When importing from JSON, in the case of choosers, the selected item(s)
was/where set before the actual items, and thus ignored by the Swing
widget. This makes sure that  the default property (which is usually the
main setter) gets set last.
  • Loading branch information
nicolaspayette committed Nov 11, 2017
1 parent 8273f9d commit 51af1fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/src/main/scala/uk/ac/surrey/xw/api/ExtraWidget.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ trait ExtraWidget extends Component {
val kind: WidgetKind[this.type]

def init(propertyMap: PropertyMap): Unit =
for ((propertyKey, value) propertyMap)
setProperty(propertyKey, value)
propertyMap.toSeq
// make sure the default property gets set last
// (see https://github.com/CRESS-Surrey/eXtraWidgets/issues/162)
.sortBy { case (k, v) kind.defaultProperty.map(_.key).contains(k) }
.foreach { case (k, v) setProperty(k, v) }

def setProperty(
propertyKey: PropertyKey,
Expand Down

0 comments on commit 51af1fe

Please sign in to comment.