mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Improve remote file chooser
This commit is contained in:
parent
2172de1865
commit
a218f9ac35
6 changed files with 31 additions and 15 deletions
|
@ -140,7 +140,9 @@ public class BrowserComp extends SimpleComp {
|
|||
Comp.of(() -> createTabPane()),
|
||||
BindingsHelper.persist(Bindings.isNotEmpty(model.getOpenFileSystems())),
|
||||
new BrowserWelcomeComp(model).apply(struc -> StackPane.setAlignment(struc.get(), Pos.CENTER_LEFT)),
|
||||
BindingsHelper.persist(Bindings.isEmpty(model.getOpenFileSystems()))));
|
||||
Bindings.createBooleanBinding(() -> {
|
||||
return model.getOpenFileSystems().size() == 0 && !model.getMode().isChooser();
|
||||
}, model.getOpenFileSystems())));
|
||||
return multi.createRegion();
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,10 @@ public class BrowserModel {
|
|||
// return;
|
||||
// }
|
||||
|
||||
if (store == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
OpenFileSystemModel model;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.xpipe.app.core.AppI18n;
|
|||
import io.xpipe.app.core.AppWindowHelper;
|
||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.core.impl.FileStore;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Window;
|
||||
|
@ -13,6 +14,7 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StandaloneFileBrowser {
|
||||
|
||||
|
@ -36,7 +38,7 @@ public class StandaloneFileBrowser {
|
|||
});
|
||||
}
|
||||
|
||||
public static void openSingleFile(Consumer<FileStore> file) {
|
||||
public static void openSingleFile(Supplier<ShellStore> store, Consumer<FileStore> file) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
var model = new BrowserModel(BrowserModel.Mode.SINGLE_FILE_CHOOSER);
|
||||
var comp = new BrowserComp(model)
|
||||
|
@ -48,6 +50,7 @@ public class StandaloneFileBrowser {
|
|||
window.close();
|
||||
});
|
||||
window.show();
|
||||
model.openFileSystemAsync(null, store.get(), null, null);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.xpipe.app.fxcomps.SimpleCompStructure;
|
|||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.app.util.JfxHelper;
|
||||
import io.xpipe.core.impl.FileStore;
|
||||
import io.xpipe.core.impl.LocalStore;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -30,7 +31,7 @@ public class DsLocalFileBrowseComp extends Comp<CompStructure<Button>> {
|
|||
var button = new AtomicReference<Button>();
|
||||
button.set(new ButtonComp(null, getGraphic(), () -> {
|
||||
if (mode == DsStreamStoreChoiceComp.Mode.OPEN) {
|
||||
StandaloneFileBrowser.openSingleFile(fileStore -> {
|
||||
StandaloneFileBrowser.openSingleFile(() -> new LocalStore(), fileStore -> {
|
||||
chosenFile.setValue(fileStore);
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.xpipe.app.browser.StandaloneFileBrowser;
|
|||
import io.xpipe.app.comp.base.ButtonComp;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import io.xpipe.core.store.FileSystemStore;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
@ -45,7 +46,7 @@ public class FileStoreChoiceComp extends SimpleComp {
|
|||
.grow(false, true);
|
||||
|
||||
var fileBrowseButton = new ButtonComp(null, new FontIcon("mdi2f-folder-open-outline"), () -> {
|
||||
StandaloneFileBrowser.openSingleFile(fileStore -> {
|
||||
StandaloneFileBrowser.openSingleFile(() -> (ShellStore) fileSystem.getValue(), fileStore -> {
|
||||
if (fileStore == null) {
|
||||
filePath.setValue(null);
|
||||
fileSystem.setValue(null);
|
||||
|
|
|
@ -40,22 +40,22 @@ public class AppPrefs {
|
|||
return developerMode().getValue() && !ModuleHelper.isImage();
|
||||
}
|
||||
|
||||
private static ObservableBooleanValue bindDeveloperTrue(ObservableBooleanValue o) {
|
||||
private ObservableBooleanValue bindDeveloperTrue(ObservableBooleanValue o) {
|
||||
return Bindings.createBooleanBinding(
|
||||
() -> {
|
||||
return AppPrefs.get().developerMode().getValue() && o.get();
|
||||
return developerMode().getValue() && o.get();
|
||||
},
|
||||
o,
|
||||
AppPrefs.get().developerMode());
|
||||
developerMode());
|
||||
}
|
||||
|
||||
private static ObservableBooleanValue bindDeveloperFalse(ObservableBooleanValue o) {
|
||||
private ObservableBooleanValue bindDeveloperFalse(ObservableBooleanValue o) {
|
||||
return Bindings.createBooleanBinding(
|
||||
() -> {
|
||||
return !AppPrefs.get().developerMode().getValue() && o.get();
|
||||
return !developerMode().getValue() && o.get();
|
||||
},
|
||||
o,
|
||||
AppPrefs.get().developerMode());
|
||||
developerMode());
|
||||
}
|
||||
|
||||
private static final int tooltipDelayMin = 0;
|
||||
|
@ -240,25 +240,30 @@ public class AppPrefs {
|
|||
typed(new SimpleBooleanProperty(false), Boolean.class);
|
||||
private final BooleanField developerDisableUpdateVersionCheckField =
|
||||
BooleanField.ofBooleanType(developerDisableUpdateVersionCheck).render(() -> new CustomToggleControl());
|
||||
private final ObservableBooleanValue developerDisableUpdateVersionCheckEffective = bindDeveloperTrue(developerDisableUpdateVersionCheck);
|
||||
|
||||
private final BooleanProperty developerDisableGuiRestrictions =
|
||||
typed(new SimpleBooleanProperty(false), Boolean.class);
|
||||
private final BooleanField developerDisableGuiRestrictionsField =
|
||||
BooleanField.ofBooleanType(developerDisableGuiRestrictions).render(() -> new CustomToggleControl());
|
||||
private final ObservableBooleanValue developerDisableGuiRestrictionsEffective = bindDeveloperTrue(developerDisableGuiRestrictions);
|
||||
|
||||
private final BooleanProperty developerShowHiddenProviders = typed(new SimpleBooleanProperty(false), Boolean.class);
|
||||
private final BooleanField developerShowHiddenProvidersField =
|
||||
BooleanField.ofBooleanType(developerShowHiddenProviders).render(() -> new CustomToggleControl());
|
||||
private final ObservableBooleanValue developerShowHiddenProvidersEffective = bindDeveloperTrue(developerShowHiddenProviders);
|
||||
|
||||
private final BooleanProperty developerShowHiddenEntries = typed(new SimpleBooleanProperty(false), Boolean.class);
|
||||
private final BooleanField developerShowHiddenEntriesField =
|
||||
BooleanField.ofBooleanType(developerShowHiddenEntries).render(() -> new CustomToggleControl());
|
||||
private final ObservableBooleanValue developerShowHiddenEntriesEffective = bindDeveloperTrue(developerShowHiddenEntries);
|
||||
|
||||
private final BooleanProperty developerDisableConnectorInstallationVersionCheck =
|
||||
typed(new SimpleBooleanProperty(false), Boolean.class);
|
||||
private final BooleanField developerDisableConnectorInstallationVersionCheckField = BooleanField.ofBooleanType(
|
||||
developerDisableConnectorInstallationVersionCheck)
|
||||
.render(() -> new CustomToggleControl());
|
||||
private final ObservableBooleanValue developerDisableConnectorInstallationVersionCheckEffective = bindDeveloperTrue(developerDisableConnectorInstallationVersionCheck);
|
||||
|
||||
public ReadOnlyProperty<CloseBehaviour> closeBehaviour() {
|
||||
return closeBehaviour;
|
||||
|
@ -343,23 +348,23 @@ public class AppPrefs {
|
|||
}
|
||||
|
||||
public ObservableBooleanValue developerDisableUpdateVersionCheck() {
|
||||
return bindDeveloperTrue(developerDisableUpdateVersionCheck);
|
||||
return developerDisableUpdateVersionCheckEffective;
|
||||
}
|
||||
|
||||
public ObservableBooleanValue developerDisableGuiRestrictions() {
|
||||
return bindDeveloperTrue(developerDisableGuiRestrictions);
|
||||
return developerDisableGuiRestrictionsEffective;
|
||||
}
|
||||
|
||||
public ObservableBooleanValue developerDisableConnectorInstallationVersionCheck() {
|
||||
return bindDeveloperTrue(developerDisableConnectorInstallationVersionCheck);
|
||||
return developerDisableConnectorInstallationVersionCheckEffective;
|
||||
}
|
||||
|
||||
public ObservableBooleanValue developerShowHiddenProviders() {
|
||||
return bindDeveloperTrue(developerShowHiddenProviders);
|
||||
return developerShowHiddenProvidersEffective;
|
||||
}
|
||||
|
||||
public ObservableBooleanValue developerShowHiddenEntries() {
|
||||
return bindDeveloperTrue(developerShowHiddenEntries);
|
||||
return developerShowHiddenEntriesEffective;
|
||||
}
|
||||
|
||||
private AppPreferencesFx preferencesFx;
|
||||
|
|
Loading…
Reference in a new issue