Storage fixes

This commit is contained in:
crschnick 2024-05-20 07:10:39 +00:00
parent 4ed6f05fbd
commit 89776bb6da
6 changed files with 24 additions and 17 deletions

View file

@ -94,7 +94,7 @@ public class DenseStoreEntryComp extends StoreEntryComp {
nameCC.setHgrow(Priority.ALWAYS);
grid.getColumnConstraints().addAll(nameCC);
var nameBox = new HBox(name, notes);
nameBox.setSpacing(8);
nameBox.setSpacing(1);
nameBox.setAlignment(Pos.CENTER_LEFT);
grid.addRow(0, nameBox);

View file

@ -31,7 +31,7 @@ public class StandardStoreEntryComp extends StoreEntryComp {
grid.getColumnConstraints().add(new ColumnConstraints(66));
var nameAndNotes = new HBox(name, notes);
nameAndNotes.setSpacing(8);
nameAndNotes.setSpacing(1);
nameAndNotes.setAlignment(Pos.CENTER_LEFT);
grid.add(nameAndNotes, 1, 0);
grid.add(createSummary(), 1, 1);

View file

@ -1,7 +1,5 @@
package io.xpipe.app.comp.store;
import io.xpipe.app.storage.DataStoreEntry;
import java.time.Instant;
import java.util.Comparator;
import java.util.List;
@ -105,12 +103,6 @@ public interface StoreSortMode {
};
List<StoreSortMode> ALL = List.of(ALPHABETICAL_DESC, ALPHABETICAL_ASC, DATE_DESC, DATE_ASC);
static Stream<DataStoreEntry> flatten(StoreSection section) {
return Stream.concat(
Stream.of(section.getWrapper().getEntry()),
section.getAllChildren().stream().flatMap(section1 -> flatten(section1)));
}
static Optional<StoreSortMode> fromId(String id) {
return ALL.stream()
.filter(storeSortMode -> storeSortMode.getId().equals(id))

View file

@ -413,6 +413,12 @@ public abstract class DataStorage {
if (!newChildren.isEmpty()) {
e.setExpanded(true);
}
// Force instant to be later in case we are really quick
ThreadHelper.sleep(1);
toAdd.forEach(nc -> {
// Update after parent entry
nc.get().notifyUpdate(false, true);
});
deleteWithChildren(toRemove.toArray(DataStoreEntry[]::new));
addStoreEntriesIfNotPresent(toAdd.stream().map(DataStoreEntryRef::get).toArray(DataStoreEntry[]::new));
@ -535,12 +541,14 @@ public abstract class DataStorage {
return;
}
for (DataStoreEntry e : es) {
var toAdd = Arrays.stream(es).filter(e -> {
if (storeEntriesSet.contains(e)
|| getStoreEntryIfPresent(e.getStore(), false).isPresent()) {
return;
return false;
}
return true;
}).toList();
for (DataStoreEntry e : toAdd) {
var syntheticParent = getSyntheticParent(e);
if (syntheticParent.isPresent()) {
addStoreEntryIfNotPresent(syntheticParent.get());
@ -558,8 +566,8 @@ public abstract class DataStorage {
p.setChildrenCache(null);
});
}
this.listeners.forEach(l -> l.onStoreAdd(es));
for (DataStoreEntry e : es) {
this.listeners.forEach(l -> l.onStoreAdd(toAdd.toArray(DataStoreEntry[]::new)));
for (DataStoreEntry e : toAdd) {
e.initializeEntry();
}
refreshValidities(true);

View file

@ -348,8 +348,11 @@ public class DataStoreEntry extends StorageElement {
}
public void setCategoryUuid(UUID categoryUuid) {
var changed = !Objects.equals(this.categoryUuid, categoryUuid);
this.categoryUuid = categoryUuid;
notifyUpdate(false, true);
if (changed) {
notifyUpdate(false, true);
}
}
@Override
@ -388,7 +391,7 @@ public class DataStoreEntry extends StorageElement {
var notesFile = directory.resolve("notes.md");
if (Files.exists(notesFile) && notes == null) {
Files.delete(notesFile);
} else {
} else if (notes != null) {
Files.writeString(notesFile, notes);
}
dirty = false;

View file

@ -59,6 +59,10 @@ public class DesktopHelper {
}
public static void browsePathLocal(Path file) {
if (file == null) {
return;
}
if (!Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) {
return;
}