From 0007119fc10ae4590b8ff690e037fe64281dbf5a Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 2 Jul 2023 15:26:37 +0000 Subject: [PATCH] More fixes --- .../app/browser/BrowserBookmarkList.java | 11 ++++-- .../storage/store/DenseStoreEntryComp.java | 4 +- .../comp/storage/store/StoreEntryWrapper.java | 39 +++++++++++++------ .../java/io/xpipe/app/ext/ActionProvider.java | 3 +- .../io/xpipe/app/storage/DataStorage.java | 25 ++++++------ .../io/xpipe/app/resources/style/prefs.css | 2 +- ext/base/src/main/java/module-info.java | 1 - 7 files changed, 52 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java index 4526df46a..1cf1e4c39 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java @@ -11,6 +11,7 @@ import io.xpipe.app.storage.DataStoreEntry; import io.xpipe.app.util.BusyProperty; import io.xpipe.app.util.ThreadHelper; import io.xpipe.core.store.DataStore; +import io.xpipe.core.store.FixedHierarchyStore; import io.xpipe.core.store.ShellStore; import javafx.application.Platform; import javafx.beans.property.*; @@ -130,11 +131,15 @@ final class BrowserBookmarkList extends SimpleComp { } ThreadHelper.runFailableAsync(() -> { - BusyProperty.execute(busy, () -> { - getItem().executeRefreshAction(); - }); if (getItem().getEntry().getStore() instanceof ShellStore fileSystem) { + BusyProperty.execute(busy, () -> { + getItem().refreshIfNeeded(); + }); model.openFileSystemAsync(null, fileSystem, null, busy); + } else if (getItem().getEntry().getStore() instanceof FixedHierarchyStore) { + BusyProperty.execute(busy, () -> { + getItem().refreshWithChildren(); + }); } }); event.consume(); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/DenseStoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/DenseStoreEntryComp.java index c7ab8a961..ce3b1901c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/DenseStoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/DenseStoreEntryComp.java @@ -19,7 +19,7 @@ public class DenseStoreEntryComp extends StoreEntryComp { var name = createName().createRegion(); var grid = new GridPane(); - grid.setHgap(10); + grid.setHgap(8); if (showIcon) { var storeIcon = createIcon(30, 25); @@ -28,7 +28,7 @@ public class DenseStoreEntryComp extends StoreEntryComp { GridPane.setHalignment(storeIcon, HPos.CENTER); } else { grid.add(new Region(), 0, 0); - grid.getColumnConstraints().add(new ColumnConstraints(5)); + grid.getColumnConstraints().add(new ColumnConstraints(0)); } var custom = new ColumnConstraints(content != null ? 300 : 0); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java index 50fd909f2..19ff9fb7e 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java @@ -163,8 +163,20 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { }); } - public void executeRefreshAction() throws Exception { - var found = getDefaultActionProvider().getValue(); + public void refreshIfNeeded() throws Exception { + if (entry.getState().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) + || entry.getState().equals(DataStoreEntry.State.COMPLETE_NOT_VALIDATED)) { + getEntry().refresh(true); + } + } + + public void refreshAsync() { + ThreadHelper.runFailableAsync(() -> { + getEntry().refresh(true); + }); + } + + public void refreshWithChildren() throws Exception { getEntry().refresh(true); var hasChildren = DataStorage.get().refreshChildren(entry); PlatformThread.runLaterIfNeeded(() -> { @@ -172,24 +184,29 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { }); } - public void mutate(DataStore newValue) { + public void refreshWithChildrenAsync() { + ThreadHelper.runFailableAsync(() -> { + refreshWithChildren(); + }); + } + + public void mutateAsync(DataStore newValue) { ThreadHelper.runAsync(() -> { - DataStorage.get().setAndRefreshAsync(getEntry(), newValue); + var hasChildren = DataStorage.get().setAndRefresh(getEntry(), newValue); + PlatformThread.runLaterIfNeeded(() -> { + expanded.set(hasChildren); + }); }); } public void executeDefaultAction() throws Exception { var found = getDefaultActionProvider().getValue(); + entry.updateLastUsed(); if (found != null) { - if (entry.getState().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) - || entry.getState().equals(DataStoreEntry.State.COMPLETE_NOT_VALIDATED)) { - executeRefreshAction(); - } - - entry.updateLastUsed(); + refreshIfNeeded(); found.createAction(entry.getStore().asNeeded()).execute(); } else if (getEntry().getStore() instanceof FixedHierarchyStore) { - executeRefreshAction(); + refreshWithChildrenAsync(); } } diff --git a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java index 11e667992..b8934b91b 100644 --- a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java @@ -9,7 +9,6 @@ import javafx.beans.value.ObservableValue; import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; -import java.util.stream.Collectors; public interface ActionProvider { @@ -29,7 +28,7 @@ public interface ActionProvider { return false; } }) - .collect(Collectors.toSet())); + .toList()); } @Override diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index f9117f3b5..d100220f6 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -203,19 +203,18 @@ public abstract class DataStorage { .findFirst(); } - public void setAndRefreshAsync(DataStoreEntry entry, DataStore s) { - ThreadHelper.runAsync(() -> { - var old = entry.getStore(); - deleteChildren(entry, true); - try { - entry.setStoreInternal(s, false); - entry.refresh(true); - DataStorage.get().refreshChildren(entry); - } catch (Exception e) { - entry.setStoreInternal(old, false); - entry.simpleRefresh(); - } - }); + public boolean setAndRefresh(DataStoreEntry entry, DataStore s) { + var old = entry.getStore(); + deleteChildren(entry, true); + try { + entry.setStoreInternal(s, false); + entry.refresh(true); + return DataStorage.get().refreshChildren(entry); + } catch (Exception e) { + entry.setStoreInternal(old, false); + entry.simpleRefresh(); + return false; + } } public void refreshAsync(DataStoreEntry element, boolean deep) { diff --git a/app/src/main/resources/io/xpipe/app/resources/style/prefs.css b/app/src/main/resources/io/xpipe/app/resources/style/prefs.css index 667435bd7..b844dfee0 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/prefs.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/prefs.css @@ -41,7 +41,7 @@ visibility: hidden; } .prefs .grid { --fx-padding: 1em 2.3em 0 2.3em; +-fx-padding: 1em 2.3em 2em 2.3em; } .prefs { diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index cea97bdac..86fcb0ce8 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -48,7 +48,6 @@ open module io.xpipe.ext.base { JavapAction, JarAction; provides ActionProvider with - DeleteStoreChildrenAction, AddStoreAction, EditStoreAction, ShareStoreAction,