mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
Fix platform thread issue
This commit is contained in:
parent
8e5cab4ec2
commit
98e1daf893
1 changed files with 40 additions and 32 deletions
|
@ -3,6 +3,7 @@ package io.xpipe.app.browser;
|
|||
import io.xpipe.app.core.AppFont;
|
||||
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 javafx.beans.property.Property;
|
||||
import javafx.stage.FileChooser;
|
||||
|
@ -14,7 +15,9 @@ import java.util.Map;
|
|||
|
||||
public class StandaloneFileBrowser {
|
||||
|
||||
public static void localOpenFileChooser(Property<FileStore> fileStoreProperty, Window owner, Map<String, List<String>> extensions) {
|
||||
public static void localOpenFileChooser(
|
||||
Property<FileStore> fileStoreProperty, Window owner, Map<String, List<String>> extensions) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle(AppI18n.get("browseFileTitle"));
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(AppI18n.get("anyFile"), "*"));
|
||||
|
@ -29,9 +32,11 @@ public class StandaloneFileBrowser {
|
|||
if (file != null && file.exists()) {
|
||||
fileStoreProperty.setValue(FileStore.local(file.toPath()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void openSingleFile(Property<FileStore> file) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
var model = new FileBrowserModel(FileBrowserModel.Mode.SINGLE_FILE_CHOOSER);
|
||||
var comp = new FileBrowserComp(model)
|
||||
.apply(struc -> struc.get().setPrefSize(1200, 700))
|
||||
|
@ -42,9 +47,11 @@ public class StandaloneFileBrowser {
|
|||
window.close();
|
||||
});
|
||||
window.show();
|
||||
});
|
||||
}
|
||||
|
||||
public static void saveSingleFile(Property<FileStore> file) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
var model = new FileBrowserModel(FileBrowserModel.Mode.SINGLE_FILE_SAVE);
|
||||
var comp = new FileBrowserComp(model)
|
||||
.apply(struc -> struc.get().setPrefSize(1200, 700))
|
||||
|
@ -55,5 +62,6 @@ public class StandaloneFileBrowser {
|
|||
window.close();
|
||||
});
|
||||
window.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue