mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Various fixes
This commit is contained in:
parent
95b716293f
commit
5f01430592
5 changed files with 39 additions and 20 deletions
|
@ -30,7 +30,7 @@ public class ConnectionInfoExchangeImpl extends ConnectionInfoExchange {
|
|||
var apply = InfoResponse.builder()
|
||||
.lastModified(e.getLastModified())
|
||||
.lastUsed(e.getLastUsed())
|
||||
.connection(e.getCategoryUuid())
|
||||
.connection(e.getUuid())
|
||||
.category(cat)
|
||||
.name(DataStorage.get().getStorePath(e))
|
||||
.rawData(e.getStore())
|
||||
|
|
|
@ -24,6 +24,10 @@ public interface LeafAction extends BrowserAction {
|
|||
default Button toButton(Region root, OpenFileSystemModel model, List<BrowserEntry> selected) {
|
||||
var b = new Button();
|
||||
b.setOnAction(event -> {
|
||||
if (model == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only accept shortcut actions in the current tab
|
||||
if (!model.equals(model.getBrowserModel().getSelectedEntry().getValue())) {
|
||||
return;
|
||||
|
|
|
@ -107,11 +107,11 @@ public class BrowserSessionTabsComp extends SimpleComp {
|
|||
.indexOf(model.getSelectedEntry().getValue()));
|
||||
|
||||
// Used for ignoring changes by the tabpane when new tabs are added. We want to perform the selections manually!
|
||||
var modifying = new SimpleBooleanProperty();
|
||||
var addingTab = new SimpleBooleanProperty();
|
||||
|
||||
// Handle selection from platform
|
||||
tabs.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (modifying.get()) {
|
||||
if (addingTab.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,16 +159,14 @@ public class BrowserSessionTabsComp extends SimpleComp {
|
|||
while (c.next()) {
|
||||
for (var r : c.getRemoved()) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
try (var b = new BooleanScope(modifying).start()) {
|
||||
var t = map.remove(r);
|
||||
tabs.getTabs().remove(t);
|
||||
}
|
||||
var t = map.remove(r);
|
||||
tabs.getTabs().remove(t);
|
||||
});
|
||||
}
|
||||
|
||||
for (var a : c.getAddedSubList()) {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
try (var b = new BooleanScope(modifying).start()) {
|
||||
try (var b = new BooleanScope(addingTab).start()) {
|
||||
var t = createTab(tabs, a);
|
||||
map.put(a, t);
|
||||
tabs.getTabs().add(t);
|
||||
|
|
|
@ -10,7 +10,7 @@ import io.xpipe.app.issue.ErrorEvent;
|
|||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.util.Hyperlinks;
|
||||
import io.xpipe.app.util.MarkdownHelper;
|
||||
|
||||
import io.xpipe.app.util.ShellTemp;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
@ -19,11 +19,11 @@ import javafx.scene.layout.StackPane;
|
|||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class MarkdownComp extends Comp<CompStructure<StackPane>> {
|
||||
|
@ -41,8 +41,30 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
|
|||
this.htmlTransformation = htmlTransformation;
|
||||
}
|
||||
|
||||
private String getHtml() {
|
||||
return MarkdownHelper.toHtml(markdown.getValue(), s -> s, htmlTransformation, null);
|
||||
private static Path TEMP;
|
||||
|
||||
private Path getHtmlFile(String markdown) {
|
||||
if (TEMP == null) {
|
||||
TEMP = ShellTemp.getLocalTempDataDirectory("wv");
|
||||
}
|
||||
|
||||
var hash = markdown.hashCode();
|
||||
var file = TEMP.resolve("md-" + hash + ".html");
|
||||
if (Files.exists(file)) {
|
||||
return file;
|
||||
}
|
||||
|
||||
var html = MarkdownHelper.toHtml(markdown, s -> s, htmlTransformation, null);
|
||||
try {
|
||||
// Workaround for https://bugs.openjdk.org/browse/JDK-8199014
|
||||
Files.createDirectories(file.getParent());
|
||||
Files.writeString(file, html);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
// Any possible IO errors can occur here
|
||||
ErrorEvent.fromThrowable(e).expected().handle();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
@ -63,15 +85,10 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
|
|||
wv.getEngine().setUserStyleSheetLocation(url.toString());
|
||||
|
||||
PlatformThread.sync(markdown).subscribe(val -> {
|
||||
// Workaround for https://bugs.openjdk.org/browse/JDK-8199014
|
||||
try {
|
||||
var file = Files.createTempFile(null, ".html");
|
||||
Files.writeString(file, getHtml());
|
||||
var file = getHtmlFile(val);
|
||||
if (file != null) {
|
||||
var contentUrl = file.toUri();
|
||||
wv.getEngine().load(contentUrl.toString());
|
||||
} catch (IOException e) {
|
||||
// Any possible IO errors can occur here
|
||||
ErrorEvent.fromThrowable(e).expected().handle();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.store-list-comp.scroll-pane > .viewport .list-box-content {
|
||||
-fx-spacing: 8;
|
||||
-fx-padding: 8 0 0 0;
|
||||
-fx-padding: 8 0 8 0;
|
||||
}
|
||||
|
||||
.store-list-comp.scroll-pane {
|
||||
|
|
Loading…
Reference in a new issue