Fix category select on connection edit

This commit is contained in:
crschnick
2025-12-01 05:54:36 +00:00
parent c06f522525
commit d5409ee97f
2 changed files with 14 additions and 15 deletions
@@ -63,9 +63,7 @@ public class StoreCreationDialog {
.getStoreCategoryIfPresent(e.getCategoryUuid())
.orElseThrow();
PlatformThread.runLaterIfNeeded(() -> {
StoreViewState.get()
.getActiveCategory()
.setValue(StoreViewState.get().getCategoryWrapper(cat));
StoreViewState.get().selectCategoryIntoViewIfNeeded(StoreViewState.get().getCategoryWrapper(cat));
});
c.accept(e);
@@ -106,9 +104,7 @@ public class StoreCreationDialog {
.getStoreCategoryIfPresent(e.getCategoryUuid())
.orElseThrow();
PlatformThread.runLaterIfNeeded(() -> {
StoreViewState.get()
.getActiveCategory()
.setValue(StoreViewState.get().getCategoryWrapper(cat));
StoreViewState.get().selectCategoryIntoViewIfNeeded(StoreViewState.get().getCategoryWrapper(cat));
});
}
} catch (Exception ex) {
@@ -12,7 +12,6 @@ import io.xpipe.app.storage.DataStoreCategory;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.StorageListener;
import io.xpipe.app.util.ThreadHelper;
import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
@@ -247,17 +246,21 @@ public class StoreViewState {
.toList();
if (matchingCats.size() == 1) {
var onlyMatch = matchingCats.getFirst();
StoreCategoryWrapper matchingParent = onlyMatch;
while ((matchingParent = matchingParent.getParent()) != null) {
if (matchingParent.equals(activeCategory.getValue())) {
break;
}
}
selectCategoryIntoViewIfNeeded(onlyMatch);
}
}
if (matchingParent == null) {
activeCategory.setValue(onlyMatch);
public void selectCategoryIntoViewIfNeeded(StoreCategoryWrapper category) {
StoreCategoryWrapper matchingParent = category;
while ((matchingParent = matchingParent.getParent()) != null) {
if (matchingParent.equals(activeCategory.getValue())) {
break;
}
}
if (matchingParent == null) {
activeCategory.setValue(category);
}
}
private void initBatchListeners() {