explorer: Use built-in row selection observable instead of custom one

This commit is contained in:
Andras Slemmer 2016-09-01 15:07:21 +01:00
parent 0dae8e9f68
commit f4de05c982

View File

@ -177,7 +177,13 @@ class CashViewer : View() {
class Selected(val node: ViewerNode) : ViewerNodeSelection()
}
val selectedViewerNode = SimpleObjectProperty<ViewerNodeSelection>(ViewerNodeSelection.None)
val selectedViewerNode = Bindings.createObjectBinding({
if (cashViewerTable.selectionModel.selectedItems.size == 0) {
ViewerNodeSelection.None
} else {
ViewerNodeSelection.Selected(cashViewerTable.selectionModel.selectedItems[0].value)
}
}, arrayOf(cashViewerTable.selectionModel.selectedItems))
data class StateRow (
val originated: LocalDateTime,
@ -262,19 +268,6 @@ class CashViewer : View() {
}
}
cashViewerTable.setOnMouseClicked { event: MouseEvent ->
if (event.button == MouseButton.PRIMARY) {
val selected = cashViewerTable.selectedItem
selectedViewerNode.set(
if (selected == null) {
ViewerNodeSelection.None
} else {
ViewerNodeSelection.Selected(selected)
}
)
}
}
Bindings.bindContent(topSplitPane.items, panesShown)
rightPane.visibleProperty().bind(EasyBind.map(selectedViewerNode) {