Rework file browser open and it improve ssh config support

This commit is contained in:
crschnick 2023-12-30 09:02:28 +00:00
parent 815787c8a9
commit ca84b90dbd
3 changed files with 8 additions and 6 deletions

View file

@ -4,8 +4,9 @@ import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef; import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.BooleanScope; import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.util.FileReference; import io.xpipe.app.util.FileReference;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystemStore; import io.xpipe.core.store.FileSystemStore;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.Property; import javafx.beans.property.Property;
@ -19,6 +20,7 @@ import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function;
@Getter @Getter
public class BrowserModel { public class BrowserModel {
@ -54,7 +56,7 @@ public class BrowserModel {
public void restoreState(BrowserSavedState.Entry e, BooleanProperty busy) { public void restoreState(BrowserSavedState.Entry e, BooleanProperty busy) {
var storageEntry = DataStorage.get().getStoreEntryIfPresent(e.getUuid()); var storageEntry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
storageEntry.ifPresent(entry -> { storageEntry.ifPresent(entry -> {
openFileSystemAsync(entry.ref(), e.getPath(), busy); openFileSystemAsync(entry.ref(), model -> e.getPath(), busy);
}); });
} }
@ -113,7 +115,7 @@ public class BrowserModel {
}); });
} }
public void openFileSystemAsync(DataStoreEntryRef<? extends FileSystemStore> store, String path, BooleanProperty externalBusy) { public void openFileSystemAsync(DataStoreEntryRef<? extends FileSystemStore> store, Function<OpenFileSystemModel, String> path, BooleanProperty externalBusy) {
if (store == null) { if (store == null) {
return; return;
} }
@ -133,7 +135,7 @@ public class BrowserModel {
} }
} }
if (path != null) { if (path != null) {
model.initWithGivenDirectory(path); model.initWithGivenDirectory(FileNames.toDirectory(path.apply(model)));
} else { } else {
model.initWithDefaultDirectory(); model.initWithDefaultDirectory();
} }

View file

@ -116,7 +116,7 @@ public abstract class LauncherInput {
var dir = Files.isDirectory(file) ? file : file.getParent(); var dir = Files.isDirectory(file) ? file : file.getParent();
AppLayoutModel.get().selectBrowser(); AppLayoutModel.get().selectBrowser();
BrowserModel.DEFAULT.openFileSystemAsync( DataStorage.get().local().ref(), dir.toString(), null); BrowserModel.DEFAULT.openFileSystemAsync( DataStorage.get().local().ref(), model -> dir.toString(), null);
} }
@Override @Override

View file

@ -16,7 +16,7 @@ public class OpenDirectoryInNewTabAction implements LeafAction {
model.getBrowserModel() model.getBrowserModel()
.openFileSystemAsync( .openFileSystemAsync(
model.getEntry(), model.getEntry(),
entries.get(0).getRawFileEntry().getPath(), m -> entries.get(0).getRawFileEntry().getPath(),
null); null);
} }