mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
More fixes
This commit is contained in:
parent
1ba5f7cf2a
commit
0007119fc1
7 changed files with 52 additions and 33 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
if (found != null) {
|
||||
if (entry.getState().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID)
|
||||
|| entry.getState().equals(DataStoreEntry.State.COMPLETE_NOT_VALIDATED)) {
|
||||
executeRefreshAction();
|
||||
}
|
||||
|
||||
entry.updateLastUsed();
|
||||
if (found != null) {
|
||||
refreshIfNeeded();
|
||||
found.createAction(entry.getStore().asNeeded()).execute();
|
||||
} else if (getEntry().getStore() instanceof FixedHierarchyStore) {
|
||||
executeRefreshAction();
|
||||
refreshWithChildrenAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -203,19 +203,18 @@ public abstract class DataStorage {
|
|||
.findFirst();
|
||||
}
|
||||
|
||||
public void setAndRefreshAsync(DataStoreEntry entry, DataStore s) {
|
||||
ThreadHelper.runAsync(() -> {
|
||||
public boolean setAndRefresh(DataStoreEntry entry, DataStore s) {
|
||||
var old = entry.getStore();
|
||||
deleteChildren(entry, true);
|
||||
try {
|
||||
entry.setStoreInternal(s, false);
|
||||
entry.refresh(true);
|
||||
DataStorage.get().refreshChildren(entry);
|
||||
return DataStorage.get().refreshChildren(entry);
|
||||
} catch (Exception e) {
|
||||
entry.setStoreInternal(old, false);
|
||||
entry.simpleRefresh();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshAsync(DataStoreEntry element, boolean deep) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -48,7 +48,6 @@ open module io.xpipe.ext.base {
|
|||
JavapAction,
|
||||
JarAction;
|
||||
provides ActionProvider with
|
||||
DeleteStoreChildrenAction,
|
||||
AddStoreAction,
|
||||
EditStoreAction,
|
||||
ShareStoreAction,
|
||||
|
|
Loading…
Reference in a new issue