From a315933d5548386c06e1d93532abae80b75c0d20 Mon Sep 17 00:00:00 2001 From: Marcel Schramm Date: Mon, 15 Jul 2024 20:14:02 +0200 Subject: [PATCH] Fix selection loss in classifications view when moving --- .../link/biosmarcel/baka/view/ClassificationsView.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/link/biosmarcel/baka/view/ClassificationsView.java b/src/main/java/link/biosmarcel/baka/view/ClassificationsView.java index c32bc4d..e952a77 100644 --- a/src/main/java/link/biosmarcel/baka/view/ClassificationsView.java +++ b/src/main/java/link/biosmarcel/baka/view/ClassificationsView.java @@ -117,8 +117,9 @@ protected void updateItem(@Nullable ClassificationRuleFX item, boolean empty) { state.data.classificationRules.set(index, state.data.classificationRules.get(index - 1)); state.data.classificationRules.set(index - 1, selectedClassification.rule); - // FIXME delta change - listView.getItems().setAll(convertRules(state.data.classificationRules)); + final int oldViewIndex = listView.getItems().indexOf(selectedClassification); + listView.getItems().set(oldViewIndex, listView.getItems().get(oldViewIndex - 1)); + listView.getItems().set(index - 1, selectedClassification); listView.getSelectionModel().select(selectedClassification); }); final var downButton = new Button("↓"); @@ -136,8 +137,9 @@ protected void updateItem(@Nullable ClassificationRuleFX item, boolean empty) { state.data.classificationRules.set(index, state.data.classificationRules.get(index + 1)); state.data.classificationRules.set(index + 1, selectedClassification.rule); - // FIXME delta change - listView.getItems().setAll(convertRules(state.data.classificationRules)); + final int oldViewIndex = listView.getItems().indexOf(selectedClassification); + listView.getItems().set(oldViewIndex, listView.getItems().get(oldViewIndex + 1)); + listView.getItems().set(index + 1, selectedClassification); listView.getSelectionModel().select(selectedClassification); }); final var listViewButtons = new HBox(