mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-26 10:25:44 +00:00
Rework [stage]
This commit is contained in:
@@ -633,7 +633,7 @@ public class StoreViewState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntryCategoryChange() {
|
||||
public void onCategoryListUpdate() {
|
||||
Platform.runLater(() -> {
|
||||
synchronized (this) {
|
||||
categories.getList().forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -410,7 +409,7 @@ public abstract class DataStorage {
|
||||
}
|
||||
|
||||
if (categoryChanged) {
|
||||
listeners.forEach(storageListener -> storageListener.onEntryCategoryChange());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
listeners.forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
}
|
||||
|
||||
@@ -526,13 +525,6 @@ public abstract class DataStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCategory(DataStoreCategory category, DataStoreCategory newCategory) {
|
||||
category.setName(newCategory.getName());
|
||||
category.setParentCategory(newCategory.getParentCategory());
|
||||
updateCategoryConfig(category, newCategory.getConfig());
|
||||
saveAsync();
|
||||
}
|
||||
|
||||
public void updateCategoryConfig(DataStoreCategory category, DataStoreCategoryConfig config) {
|
||||
if (category.setConfig(config)) {
|
||||
// Update git remote if needed
|
||||
@@ -583,7 +575,7 @@ public abstract class DataStorage {
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryAdd(toMove));
|
||||
});
|
||||
|
||||
listeners.forEach(storageListener -> storageListener.onEntryCategoryChange());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
listeners.forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
|
||||
saveAsync();
|
||||
@@ -638,7 +630,7 @@ public abstract class DataStorage {
|
||||
});
|
||||
entry.setCategoryUuid(parent.get().getCategoryUuid());
|
||||
|
||||
listeners.forEach(storageListener -> storageListener.onEntryCategoryChange());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
deleteStoreCategory(breakOut.get(), false, false);
|
||||
entry.setBreakOutCategory(null);
|
||||
listeners.forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
@@ -660,7 +652,7 @@ public abstract class DataStorage {
|
||||
|
||||
child.setCategoryUuid(newCategory.getUuid());
|
||||
});
|
||||
listeners.forEach(storageListener -> storageListener.onEntryCategoryChange());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
listeners.forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
saveAsync();
|
||||
}
|
||||
@@ -690,7 +682,7 @@ public abstract class DataStorage {
|
||||
cat.setParentCategory(newParent.getUuid());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryRemove(cat));
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryAdd(cat));
|
||||
listeners.forEach(storageListener -> storageListener.onEntryCategoryChange());
|
||||
listeners.forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
listeners.forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
saveAsync();
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ public interface DataStorageListener {
|
||||
|
||||
void onCategoryRemove(DataStoreCategory category);
|
||||
|
||||
void onEntryCategoryChange();
|
||||
void onCategoryListUpdate();
|
||||
}
|
||||
|
||||
@@ -176,6 +176,8 @@ public class DataStoreCategory extends DataStorageElement {
|
||||
|
||||
public boolean isChangedForReload(DataStoreCategory other) {
|
||||
return !Objects.equals(getName(), other.getName())
|
||||
|| !Objects.equals(getOrderIndex(), other.getOrderIndex())
|
||||
|| !Objects.equals(getEffectiveIconFile(), other.getEffectiveIconFile())
|
||||
|| !Objects.equals(getConfig(), other.getConfig())
|
||||
|| !Objects.equals(getParentCategory(), other.getParentCategory());
|
||||
}
|
||||
@@ -298,4 +300,13 @@ public class DataStoreCategory extends DataStorageElement {
|
||||
Files.writeString(directory.resolve("category.json"), entryString);
|
||||
Files.writeString(directory.resolve("state.json"), stateString);
|
||||
}
|
||||
|
||||
public void applyChanges(DataStoreCategory newCategory) {
|
||||
name = newCategory.getName();
|
||||
parentCategory = newCategory.getParentCategory();
|
||||
orderIndex = newCategory.getOrderIndex();
|
||||
icon = newCategory.getIcon();
|
||||
config = newCategory.getConfig();
|
||||
notifyUpdate(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.xpipe.app.storage;
|
||||
|
||||
import io.xpipe.app.icon.SystemIconManager;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.store.*;
|
||||
import io.xpipe.app.util.JacksonMapper;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
@@ -23,7 +22,6 @@ import java.nio.file.Path;
|
||||
import java.time.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
||||
@Getter
|
||||
@@ -396,6 +394,7 @@ public class DataStoreEntry extends DataStorageElement {
|
||||
|| !Objects.equals(getColor(), other.getColor())
|
||||
|| !Objects.equals(getCategoryUuid(), other.getCategoryUuid())
|
||||
|| !Objects.equals(getOrderIndex(), other.getOrderIndex())
|
||||
|| !Objects.equals(isTemplate(), other.isTemplate())
|
||||
|| !Objects.equals(getEffectiveIconFile(), other.getEffectiveIconFile());
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public class StandardStorage extends DataStorage {
|
||||
var existing = getStoreCategoryIfPresent(c.get().getUuid());
|
||||
if (existing.isPresent()) {
|
||||
if (existing.get().isChangedForReload(c.get())) {
|
||||
updateCategory(existing.get(), c.get());
|
||||
existing.get().applyChanges(c.get());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -319,6 +319,7 @@ public class StandardStorage extends DataStorage {
|
||||
refreshStoreEntries();
|
||||
|
||||
getListeners().forEach(storageListener -> storageListener.onStoreListUpdate());
|
||||
getListeners().forEach(storageListener -> storageListener.onCategoryListUpdate());
|
||||
|
||||
this.dataStorageSyncHandler.afterStorageLoad();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user