Skip to content

Commit 4059966

Browse files
authored
[CORDA-2203]: Demobench ends up with a stuck tab when you unselect notary type for the first node. (fix) (corda#4235)
1 parent e8b6f5f commit 4059966

File tree

1 file changed

+33
-21
lines changed
  • tools/demobench/src/main/kotlin/net/corda/demobench/views

1 file changed

+33
-21
lines changed

tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt

+33-21
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,43 @@ class NodeTabView : Fragment() {
114114

115115
fieldset("Additional configuration") {
116116
styleClass.addAll("services-panel")
117-
val extraServices = if (nodeController.hasNotary()) {
118-
listOf(USD, GBP, CHF, EUR).map { CurrencyIssuer(it) }
119-
} else {
120-
listOf(NotaryService(true), NotaryService(false))
121-
}
122-
123-
val servicesList = CheckListView(extraServices.observable()).apply {
124-
vboxConstraints { vGrow = Priority.ALWAYS }
125-
model.item.extraServices.set(checkModel.checkedItems)
126-
if (!nodeController.hasNotary()) {
127-
checkModel.check(0)
128-
checkModel.checkedItems.addListener(ListChangeListener { change ->
129-
while (change.next()) {
130-
if (change.wasAdded()) {
131-
val item = change.addedSubList.last()
132-
val idx = checkModel.getItemIndex(item)
133-
checkModel.checkedIndices.forEach {
134-
if (it != idx) checkModel.clearCheck(it)
117+
if (nodeController.hasNotary()) {
118+
val extraServices: List<ExtraService> = listOf(USD, GBP, CHF, EUR).map { CurrencyIssuer(it) }
119+
val servicesList = CheckListView(extraServices.observable()).apply {
120+
vboxConstraints { vGrow = Priority.ALWAYS }
121+
model.item.extraServices.set(checkModel.checkedItems)
122+
if (!nodeController.hasNotary()) {
123+
checkModel.check(0)
124+
checkModel.checkedItems.addListener(ListChangeListener { change ->
125+
while (change.next()) {
126+
if (change.wasAdded()) {
127+
val item = change.addedSubList.last()
128+
val idx = checkModel.getItemIndex(item)
129+
checkModel.checkedIndices.forEach {
130+
if (it != idx) checkModel.clearCheck(it)
131+
}
135132
}
136133
}
137-
}
138-
})
134+
})
135+
}
136+
}
137+
add(servicesList)
138+
} else {
139+
val notaryTypes = listOf(NotaryService(true), NotaryService(false))
140+
val notaryTypeToggleGroup = togglegroup()
141+
notaryTypeToggleGroup.selectedValueProperty<NotaryService>().addListener { observValue, oldValue, newValue ->
142+
oldValue?.let {
143+
model.item.extraServices.removeAll(it)
144+
}
145+
newValue?.let {
146+
model.item.extraServices.add(it)
147+
}
148+
}
149+
notaryTypes.forEachIndexed { index, notaryType ->
150+
val toggle = radiobutton(notaryType.toString(), notaryTypeToggleGroup, notaryType)
151+
toggle.isSelected = index == 0
139152
}
140153
}
141-
add(servicesList)
142154
}
143155
}
144156

0 commit comments

Comments
 (0)