I think I found the reason why cell edit is not working. When Accordion
is expanded a TitledPane
does an animation. Looks that a SpreadSheetView
is not rendered completely till that animation is finished. You need to wait for that off the JavaFX Application Thread, otherwise you will block the animation from finishing. Here is a modified code for onAction
that does the wait:
onAction = (_: ActionEvent) => {
val ord = "005" //Hardcoded order number only for testing
val prt = "010" //Hardcoded part number only for testing
val paneWithFauf: List[TitledPane] = titledPaneList filter (pane => pane.text.toString.contains(ord))
if
(paneWithFauf.nonEmpty) {
val selectedPane: TitledPane = paneWithFauf.head
accordion.expandedPane = selectedPane //expand the right TitledPane with the given order
val sheetIndex: Int
= titledPaneList.indexOf(selectedPane)
// TitledPane does animation when it expends, default duration is 350ms.
// Need to wait till that animation finishes, we will add extra 50ms to have "transition"
// The wait need to happen off JavaFX Application Thread, so a new thread is created
val th = new Thread(() => {
// Wait for TitledPane animation to finish + 50ms
Thread.sleep(350+50)
Platform.runLater {
// Prepare selected cell for editing
val selectedSheet: SpreadsheetView = spreadSheetViewList(sheetIndex)
val selectedColumn: SpreadsheetColumn = selectedSheet.getColumns.toList(1
)
selectedSheet.getSelectionModel.clearAndSelect(2, selectedColumn)
selectedSheet.edit(2, selectedColumn)
selectedSheet.getSelectionModel.focus(2, selectedColumn)
}
})
th.setDaemon(true)
th.start()
}
}
}
Hope this helps,
Jarek
Google groups reader does strange rendering of the code in the last message, so here it again:
Thank you so much for that!
That does the trick.
I would feel much better if I could check somehow if the rendering of the spreadsheetView is completed before I call the edit-Method.
I checked all of the properties of the TitledPane that are remotely connected to this (animated, expended, collapsible, focused, pressed), but they are all set before the animation starts (I checked).
Therefore, I have to get it out of the spreadsheetView, but could not find something in the doku.
You don't happen to know a way to do this?
But, anyway. You found the problem and your solution works. Thank you very much for your effort.