mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 09:40:35 +13:00
Improve view state initialization
This commit is contained in:
parent
d1c2cc27af
commit
656be93d44
3 changed files with 20 additions and 28 deletions
|
@ -43,14 +43,13 @@ public class StoreCategoryWrapper {
|
||||||
|
|
||||||
this.root = last;
|
this.root = last;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.name = new SimpleStringProperty();
|
this.name = new SimpleStringProperty(category.getName());
|
||||||
this.lastAccess = new SimpleObjectProperty<>();
|
this.lastAccess = new SimpleObjectProperty<>(category.getLastAccess());
|
||||||
this.sortMode = new SimpleObjectProperty<>();
|
this.sortMode = new SimpleObjectProperty<>(category.getSortMode());
|
||||||
this.share = new SimpleObjectProperty<>();
|
this.share = new SimpleObjectProperty<>(category.isShare());
|
||||||
this.children = FXCollections.observableArrayList();
|
this.children = FXCollections.observableArrayList();
|
||||||
this.containedEntries = FXCollections.observableArrayList();
|
this.containedEntries = FXCollections.observableArrayList();
|
||||||
setupListeners();
|
setupListeners();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoreCategoryWrapper getRoot() {
|
public StoreCategoryWrapper getRoot() {
|
||||||
|
@ -117,7 +116,6 @@ public class StoreCategoryWrapper {
|
||||||
sortMode.setValue(category.getSortMode());
|
sortMode.setValue(category.getSortMode());
|
||||||
share.setValue(category.isShare());
|
share.setValue(category.isShare());
|
||||||
|
|
||||||
if (StoreViewState.get() != null) {
|
|
||||||
containedEntries.setAll(StoreViewState.get().getAllEntries().stream()
|
containedEntries.setAll(StoreViewState.get().getAllEntries().stream()
|
||||||
.filter(entry -> contains(entry.getEntry()))
|
.filter(entry -> contains(entry.getEntry()))
|
||||||
.toList());
|
.toList());
|
||||||
|
@ -131,7 +129,6 @@ public class StoreCategoryWrapper {
|
||||||
storeCategoryWrapper.update();
|
storeCategoryWrapper.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name.getValue();
|
return name.getValue();
|
||||||
|
|
|
@ -61,7 +61,6 @@ public class StoreEntryWrapper {
|
||||||
});
|
});
|
||||||
this.defaultActionProvider = new SimpleObjectProperty<>();
|
this.defaultActionProvider = new SimpleObjectProperty<>();
|
||||||
setupListeners();
|
setupListeners();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTo(DataStoreCategory category) {
|
public void moveTo(DataStoreCategory category) {
|
||||||
|
@ -136,9 +135,7 @@ public class StoreEntryWrapper {
|
||||||
deletable.setValue(entry.getConfiguration().isDeletable()
|
deletable.setValue(entry.getConfiguration().isDeletable()
|
||||||
|| AppPrefs.get().developerDisableGuiRestrictions().getValue());
|
|| AppPrefs.get().developerDisableGuiRestrictions().getValue());
|
||||||
|
|
||||||
if (StoreViewState.get() != null) {
|
|
||||||
category.setValue(StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategoryIfPresent(entry.getCategoryUuid()).orElseThrow()));
|
category.setValue(StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategoryIfPresent(entry.getCategoryUuid()).orElseThrow()));
|
||||||
}
|
|
||||||
|
|
||||||
actionProviders.keySet().forEach(dataStoreActionProvider -> {
|
actionProviders.keySet().forEach(dataStoreActionProvider -> {
|
||||||
if (!isInStorage()) {
|
if (!isInStorage()) {
|
||||||
|
|
|
@ -131,7 +131,9 @@ public class StoreViewState {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new StoreViewState();
|
INSTANCE = new StoreViewState();
|
||||||
|
INSTANCE.categories.forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
||||||
|
INSTANCE.allEntries.forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
|
@ -173,10 +175,6 @@ public class StoreViewState {
|
||||||
storeCategoryWrapper.getCategory().getUuid().equals(DataStorage.DEFAULT_CATEGORY_UUID))
|
storeCategoryWrapper.getCategory().getUuid().equals(DataStorage.DEFAULT_CATEGORY_UUID))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow()));
|
.orElseThrow()));
|
||||||
|
|
||||||
INSTANCE = this;
|
|
||||||
categories.forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
|
||||||
allEntries.forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addStorageListeners() {
|
private void addStorageListeners() {
|
||||||
|
|
Loading…
Reference in a new issue