mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Jump to only filter result left
This commit is contained in:
parent
9529dceb5c
commit
0c1f63d3c9
3 changed files with 28 additions and 6 deletions
|
@ -28,7 +28,8 @@ public class StoreCategoryWrapper {
|
|||
private final Property<StoreSortMode> sortMode;
|
||||
private final Property<Boolean> sync;
|
||||
private final ObservableList<StoreCategoryWrapper> children;
|
||||
private final ObservableList<StoreEntryWrapper> containedEntries;
|
||||
private final ObservableList<StoreEntryWrapper> directContainedEntries;
|
||||
private final ObservableList<StoreEntryWrapper> allContainedEntries;
|
||||
private final BooleanProperty expanded = new SimpleBooleanProperty();
|
||||
private final Property<DataColor> color = new SimpleObjectProperty<>();
|
||||
|
||||
|
@ -52,7 +53,8 @@ public class StoreCategoryWrapper {
|
|||
this.sortMode = new SimpleObjectProperty<>(category.getSortMode());
|
||||
this.sync = new SimpleObjectProperty<>(category.isSync());
|
||||
this.children = FXCollections.observableArrayList();
|
||||
this.containedEntries = FXCollections.observableArrayList();
|
||||
this.allContainedEntries = FXCollections.observableArrayList();
|
||||
this.directContainedEntries = FXCollections.observableArrayList();
|
||||
this.color.setValue(category.getColor());
|
||||
setupListeners();
|
||||
}
|
||||
|
@ -70,7 +72,7 @@ public class StoreCategoryWrapper {
|
|||
}
|
||||
|
||||
public boolean contains(StoreEntryWrapper entry) {
|
||||
return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || containedEntries.contains(entry);
|
||||
return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || allContainedEntries.contains(entry);
|
||||
}
|
||||
|
||||
public void select() {
|
||||
|
@ -135,7 +137,12 @@ public class StoreCategoryWrapper {
|
|||
expanded.setValue(category.isExpanded());
|
||||
color.setValue(category.getColor());
|
||||
|
||||
containedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream()
|
||||
directContainedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream()
|
||||
.filter(entry -> {
|
||||
return entry.getEntry().getCategoryUuid().equals(category.getUuid());
|
||||
})
|
||||
.toList());
|
||||
allContainedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream()
|
||||
.filter(entry -> {
|
||||
return entry.getEntry().getCategoryUuid().equals(category.getUuid())
|
||||
|| (AppPrefs.get()
|
||||
|
|
|
@ -55,6 +55,7 @@ public class StoreViewState {
|
|||
INSTANCE = new StoreViewState();
|
||||
INSTANCE.updateContent();
|
||||
INSTANCE.initSections();
|
||||
INSTANCE.initFilterJump();
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
|
@ -94,6 +95,20 @@ public class StoreViewState {
|
|||
}
|
||||
}
|
||||
|
||||
private void initFilterJump() {
|
||||
var all = getAllConnectionsCategory();
|
||||
filter.addListener((observable, oldValue, newValue) -> {
|
||||
var matchingCats = categories.getList().stream().filter(storeCategoryWrapper -> storeCategoryWrapper.getRoot().equals(all))
|
||||
.filter(storeCategoryWrapper -> storeCategoryWrapper.getDirectContainedEntries()
|
||||
.stream()
|
||||
.anyMatch(wrapper -> wrapper.matchesFilter(newValue)))
|
||||
.toList();
|
||||
if (matchingCats.size() == 1) {
|
||||
activeCategory.setValue(matchingCats.getFirst());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initContent() {
|
||||
allEntries
|
||||
.getList()
|
||||
|
|
|
@ -109,7 +109,7 @@ public class StoreCategoryComp extends SimpleComp {
|
|||
}))
|
||||
.styleClass("status-button");
|
||||
|
||||
var shownList = new DerivedObservableList<>(category.getContainedEntries(), true)
|
||||
var shownList = new DerivedObservableList<>(category.getAllContainedEntries(), true)
|
||||
.filtered(
|
||||
storeEntryWrapper -> {
|
||||
return storeEntryWrapper.matchesFilter(
|
||||
|
@ -117,7 +117,7 @@ public class StoreCategoryComp extends SimpleComp {
|
|||
},
|
||||
StoreViewState.get().getFilterString())
|
||||
.getList();
|
||||
var count = new CountComp<>(shownList, category.getContainedEntries(), string -> "(" + string + ")");
|
||||
var count = new CountComp<>(shownList, category.getAllContainedEntries(), string -> "(" + string + ")");
|
||||
|
||||
var showStatus = hover.or(new SimpleBooleanProperty(DataStorage.get().supportsSharing()))
|
||||
.or(showing);
|
||||
|
|
Loading…
Reference in a new issue