mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Fix store editing and state handling
This commit is contained in:
parent
734d4fdff8
commit
111c62da52
5 changed files with 13 additions and 4 deletions
|
@ -170,7 +170,12 @@ public class StoreCreationComp extends DialogComp {
|
|||
if (!DataStorage.get().getStoreEntries().contains(e)) {
|
||||
DataStorage.get().addStoreEntryIfNotPresent(newE);
|
||||
} else {
|
||||
DataStorage.get().updateEntry(e, newE);
|
||||
// We didn't change anything
|
||||
if (e.getStore().equals(newE.getStore())) {
|
||||
e.setName(newE.getName());
|
||||
} else {
|
||||
DataStorage.get().updateEntry(e, newE);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ public interface EnabledStoreProvider extends DataStoreProvider {
|
|||
|
||||
@Override
|
||||
default StoreEntryComp customEntryComp(StoreSection sec, boolean preferLarge) {
|
||||
if (sec.getWrapper().getValidity().getValue() != DataStoreEntry.Validity.COMPLETE) {
|
||||
if (sec.getWrapper().getValidity().getValue() == DataStoreEntry.Validity.LOAD_FAILED) {
|
||||
return StoreEntryComp.create(sec, null, preferLarge);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DataStoreListChoiceComp<T extends DataStore> extends SimpleComp {
|
|||
});
|
||||
return new HorizontalComp(List.of(label, Comp.hspacer(), delete)).styleClass("entry");
|
||||
},
|
||||
true)
|
||||
false)
|
||||
.padding(new Insets(0))
|
||||
.apply(struc -> struc.get().setMinHeight(0))
|
||||
.apply(struc -> ((VBox) struc.get().getContent()).setSpacing(5));
|
||||
|
|
|
@ -273,6 +273,10 @@ public abstract class DataStorage {
|
|||
}
|
||||
|
||||
public void updateEntry(DataStoreEntry entry, DataStoreEntry newEntry) {
|
||||
var state = entry.getStorePersistentState();
|
||||
var newState = state.mergeCopy(newEntry.getStorePersistentState());
|
||||
newEntry.setStorePersistentState(newState);
|
||||
|
||||
var oldParent = DataStorage.get().getDefaultDisplayParent(entry);
|
||||
var newParent = DataStorage.get().getDefaultDisplayParent(newEntry);
|
||||
var sameParent = Objects.equals(oldParent, newParent);
|
||||
|
|
|
@ -19,6 +19,6 @@ public class EnabledStoreState extends DataStoreState {
|
|||
@Override
|
||||
public DataStoreState mergeCopy(DataStoreState newer) {
|
||||
var n = (EnabledStoreState) newer;
|
||||
return EnabledStoreState.builder().enabled(n.enabled).build();
|
||||
return EnabledStoreState.builder().enabled(enabled || n.enabled).build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue