This commit is contained in:
crschnick 2024-06-23 22:40:50 +00:00
parent d1b506415c
commit eeeef57b8f
74 changed files with 314 additions and 187 deletions

View file

@ -1,6 +1,7 @@
package io.xpipe.app.beacon;
import io.xpipe.beacon.BeaconClientException;
import lombok.Value;
import java.util.HashSet;
@ -13,7 +14,10 @@ public class AppBeaconCache {
Set<BeaconShellSession> shellSessions = new HashSet<>();
public BeaconShellSession getShellSession(UUID uuid) throws BeaconClientException {
var found = shellSessions.stream().filter(beaconShellSession -> beaconShellSession.getEntry().getUuid().equals(uuid)).findFirst();
var found = shellSessions.stream()
.filter(beaconShellSession ->
beaconShellSession.getEntry().getUuid().equals(uuid))
.findFirst();
if (found.isEmpty()) {
throw new BeaconClientException("No active shell session known for id " + uuid);
}

View file

@ -1,7 +1,5 @@
package io.xpipe.app.beacon;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
@ -9,6 +7,9 @@ import io.xpipe.app.util.MarkdownHelper;
import io.xpipe.beacon.BeaconConfig;
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.util.XPipeInstallation;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import lombok.Getter;
import java.io.IOException;

View file

@ -1,7 +1,5 @@
package io.xpipe.app.beacon;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
@ -9,6 +7,9 @@ import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.beacon.*;
import io.xpipe.core.util.JacksonMapper;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import lombok.SneakyThrows;
import java.io.IOException;
@ -67,16 +68,22 @@ public class BeaconRequestHandler<T> implements HttpHandler {
} else {
try (InputStream is = exchange.getRequestBody()) {
var read = is.readAllBytes();
var rawDataRequestClass = beaconInterface.getRequestClass().getDeclaredFields().length == 1 &&
beaconInterface.getRequestClass().getDeclaredFields()[0].getType().equals(byte[].class);
var rawDataRequestClass = beaconInterface.getRequestClass().getDeclaredFields().length == 1
&& beaconInterface
.getRequestClass()
.getDeclaredFields()[0]
.getType()
.equals(byte[].class);
if (!new String(read, StandardCharsets.US_ASCII).trim().startsWith("{") && rawDataRequestClass) {
object = createRawDataRequest(beaconInterface, read);
} else {
var tree = JacksonMapper.getDefault().readTree(read);
TrackEvent.trace("Parsed raw request:\n" + tree.toPrettyString());
var emptyRequestClass = tree.isEmpty() && beaconInterface.getRequestClass().getDeclaredFields().length == 0;
object = emptyRequestClass ? createDefaultRequest(beaconInterface) : JacksonMapper.getDefault().treeToValue(tree,
beaconInterface.getRequestClass());
var emptyRequestClass = tree.isEmpty()
&& beaconInterface.getRequestClass().getDeclaredFields().length == 0;
object = emptyRequestClass
? createDefaultRequest(beaconInterface)
: JacksonMapper.getDefault().treeToValue(tree, beaconInterface.getRequestClass());
TrackEvent.trace("Parsed request object:\n" + object);
}
}
@ -163,8 +170,11 @@ public class BeaconRequestHandler<T> implements HttpHandler {
c.setAccessible(true);
var b = c.invoke(null);
var setMethod = Arrays.stream(b.getClass().getDeclaredMethods()).filter(method -> method.getParameterCount() == 1 &&
method.getParameters()[0].getType().equals(byte[].class)).findFirst().orElseThrow();
var setMethod = Arrays.stream(b.getClass().getDeclaredMethods())
.filter(method -> method.getParameterCount() == 1
&& method.getParameters()[0].getType().equals(byte[].class))
.findFirst()
.orElseThrow();
setMethod.invoke(b, (Object) s);
var m = b.getClass().getDeclaredMethod("build");

View file

@ -1,6 +1,7 @@
package io.xpipe.app.beacon;
import io.xpipe.beacon.BeaconClientInformation;
import lombok.Value;
@Value

View file

@ -3,6 +3,7 @@ package io.xpipe.app.beacon;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.ShellTemp;
import io.xpipe.beacon.BeaconClientException;
import org.apache.commons.io.FileUtils;
import java.io.ByteArrayInputStream;
@ -60,7 +61,7 @@ public class BlobManager {
try (var fileOut = Files.newOutputStream(file)) {
blob.transferTo(fileOut);
}
fileBlobs.put(uuid,file);
fileBlobs.put(uuid, file);
}
public InputStream getBlob(UUID uuid) throws Exception {

View file

@ -1,12 +1,13 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.util.AskpassAlert;
import io.xpipe.app.util.SecretManager;
import io.xpipe.app.util.SecretQueryState;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.AskpassExchange;
import com.sun.net.httpserver.HttpExchange;
public class AskpassExchangeImpl extends AskpassExchange {
@Override
@ -33,8 +34,6 @@ public class AskpassExchangeImpl extends AskpassExchange {
if (p.getState() != SecretQueryState.NORMAL) {
throw new BeaconClientException(SecretQueryState.toErrorMessage(p.getState()));
}
return Response.builder()
.value(secret.inPlace())
.build();
return Response.builder().value(secret.inPlace()).build();
}
}

View file

@ -1,11 +1,12 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.beacon.api.ConnectionQueryExchange;
import io.xpipe.core.store.StorePath;
import com.sun.net.httpserver.HttpExchange;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@ -41,7 +42,9 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
continue;
}
if (!typeMatcher.matcher(storeEntry.getProvider().getId().toLowerCase()).matches()) {
if (!typeMatcher
.matcher(storeEntry.getProvider().getId().toLowerCase())
.matches()) {
continue;
}

View file

@ -1,9 +1,10 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.beacon.api.DaemonFocusExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonFocusExchangeImpl extends DaemonFocusExchange {
@Override

View file

@ -1,14 +1,14 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.DaemonModeExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonModeExchangeImpl extends DaemonModeExchange {
@Override
public Object handle(HttpExchange exchange, Request msg)
throws BeaconClientException {
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException {
var mode = OperationMode.map(msg.getMode());
if (!mode.isSupported()) {
throw new BeaconClientException("Unsupported mode: " + msg.getMode().getDisplayName() + ". Supported: "

View file

@ -1,17 +1,17 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.launcher.LauncherInput;
import io.xpipe.app.util.PlatformState;
import io.xpipe.beacon.BeaconServerException;
import io.xpipe.beacon.api.DaemonOpenExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonOpenExchangeImpl extends DaemonOpenExchange {
@Override
public Object handle(HttpExchange exchange, Request msg)
throws BeaconServerException {
public Object handle(HttpExchange exchange, Request msg) throws BeaconServerException {
if (msg.getArguments().isEmpty()) {
if (!OperationMode.switchToSyncIfPossible(OperationMode.GUI)) {
throw new BeaconServerException(PlatformState.getLastError());

View file

@ -1,9 +1,10 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.beacon.api.DaemonStatusExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonStatusExchangeImpl extends DaemonStatusExchange {
@Override

View file

@ -1,10 +1,11 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.beacon.api.DaemonStopExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonStopExchangeImpl extends DaemonStopExchange {
@Override

View file

@ -1,9 +1,10 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.core.AppProperties;
import io.xpipe.beacon.api.DaemonVersionExchange;
import com.sun.net.httpserver.HttpExchange;
public class DaemonVersionExchangeImpl extends DaemonVersionExchange {
@Override

View file

@ -1,8 +1,9 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.BlobManager;
import io.xpipe.beacon.api.FsBlobExchange;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
import java.util.UUID;
@ -16,9 +17,9 @@ public class FsBlobExchangeImpl extends FsBlobExchange {
var size = exchange.getRequestBody().available();
if (size > 100_000_000) {
BlobManager.get().store(id,exchange.getRequestBody());
BlobManager.get().store(id, exchange.getRequestBody());
} else {
BlobManager.get().store(id,exchange.getRequestBody().readAllBytes());
BlobManager.get().store(id, exchange.getRequestBody().readAllBytes());
}
return Response.builder().blob(id).build();
}

View file

@ -1,12 +1,13 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BlobManager;
import io.xpipe.app.util.FixedSizeInputStream;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.FsReadExchange;
import io.xpipe.core.store.ConnectionFileSystem;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
import java.io.BufferedInputStream;
@ -29,15 +30,17 @@ public class FsReadExchangeImpl extends FsReadExchange {
if (size > 100_000_000) {
var file = BlobManager.get().newBlobFile();
try (var in = fs.openInput(msg.getPath().toString())) {
try (var fileOut = Files.newOutputStream(file.resolve(msg.getPath().getFileName()));
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size)) {
try (var fileOut =
Files.newOutputStream(file.resolve(msg.getPath().getFileName()));
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size)) {
fixedIn.transferTo(fileOut);
}
in.transferTo(OutputStream.nullOutputStream());
}
exchange.sendResponseHeaders(200, size);
try (var fileIn = Files.newInputStream(file); var out = exchange.getResponseBody()) {
try (var fileIn = Files.newInputStream(file);
var out = exchange.getResponseBody()) {
fileIn.transferTo(out);
}
return Response.builder().build();

View file

@ -1,10 +1,11 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BlobManager;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.beacon.api.FsScriptExchange;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
import java.nio.charset.StandardCharsets;
@ -20,7 +21,10 @@ public class FsScriptExchangeImpl extends FsScriptExchange {
data = new String(in.readAllBytes(), StandardCharsets.UTF_8);
}
var file = ScriptHelper.getExecScriptFile(shell.getControl());
shell.getControl().getShellDialect().createScriptTextFileWriteCommand(shell.getControl(), data, file.toString()).execute();
shell.getControl()
.getShellDialect()
.createScriptTextFileWriteCommand(shell.getControl(), data, file.toString())
.execute();
return Response.builder().path(file).build();
}
}

View file

@ -1,10 +1,11 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BlobManager;
import io.xpipe.beacon.api.FsWriteExchange;
import io.xpipe.core.store.ConnectionFileSystem;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
public class FsWriteExchangeImpl extends FsWriteExchange {
@ -15,7 +16,7 @@ public class FsWriteExchangeImpl extends FsWriteExchange {
var shell = AppBeaconServer.get().getCache().getShellSession(msg.getConnection());
var fs = new ConnectionFileSystem(shell.getControl());
try (var in = BlobManager.get().getBlob(msg.getBlob());
var os = fs.openOutput(msg.getPath().toString(), in.available())) {
var os = fs.openOutput(msg.getPath().toString(), in.available())) {
in.transferTo(os);
}
return Response.builder().build();

View file

@ -1,6 +1,5 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BeaconSession;
import io.xpipe.app.prefs.AppPrefs;
@ -8,6 +7,8 @@ import io.xpipe.beacon.BeaconAuthMethod;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.HandshakeExchange;
import com.sun.net.httpserver.HttpExchange;
import java.util.UUID;
public class HandshakeExchangeImpl extends HandshakeExchange {
@ -18,8 +19,7 @@ public class HandshakeExchangeImpl extends HandshakeExchange {
}
@Override
public Object handle(HttpExchange exchange, Request body)
throws BeaconClientException {
public Object handle(HttpExchange exchange, Request body) throws BeaconClientException {
if (!checkAuth(body.getAuth())) {
throw new BeaconClientException("Authentication failed");
}

View file

@ -1,8 +1,9 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.beacon.api.ShellExecExchange;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
import java.util.concurrent.atomic.AtomicReference;

View file

@ -1,12 +1,13 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BeaconShellSession;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.ShellStartExchange;
import io.xpipe.core.store.ShellStore;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
public class ShellStartExchangeImpl extends ShellStartExchange {
@ -30,6 +31,11 @@ public class ShellStartExchangeImpl extends ShellStartExchange {
if (existing.isEmpty()) {
AppBeaconServer.get().getCache().getShellSessions().add(new BeaconShellSession(e, control));
}
return Response.builder().shellDialect(control.getShellDialect()).osType(control.getOsType()).osName(control.getOsName()).temp(control.getSystemTemporaryDirectory()).build();
return Response.builder()
.shellDialect(control.getShellDialect())
.osType(control.getOsType())
.osName(control.getOsName())
.temp(control.getSystemTemporaryDirectory())
.build();
}
}

View file

@ -1,8 +1,9 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.beacon.api.ShellStopExchange;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
public class ShellStopExchangeImpl extends ShellStopExchange {

View file

@ -2,17 +2,13 @@ package io.xpipe.app.beacon.impl;
import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.BeaconServerException;
import io.xpipe.beacon.api.TerminalLaunchExchange;
import com.sun.net.httpserver.HttpExchange;
import java.io.IOException;
public class TerminalLaunchExchangeImpl extends TerminalLaunchExchange {
@Override
public Object handle(HttpExchange exchange, Request msg)
throws BeaconClientException {
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException {
var r = TerminalLauncherManager.performLaunch(msg.getRequest());
return Response.builder().targetFile(r).build();
}

View file

@ -7,12 +7,9 @@ import io.xpipe.beacon.api.TerminalWaitExchange;
import com.sun.net.httpserver.HttpExchange;
import java.io.IOException;
public class TerminalWaitExchangeImpl extends TerminalWaitExchange {
@Override
public Object handle(HttpExchange exchange, Request msg)
throws BeaconClientException, BeaconServerException {
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException, BeaconServerException {
TerminalLauncherManager.waitForCompletion(msg.getRequest());
return Response.builder().build();
}

View file

@ -6,6 +6,7 @@ import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.storage.DataStoreEntry;
import javafx.beans.binding.Bindings;
import javafx.beans.property.*;
import javafx.beans.value.ObservableValue;
@ -23,13 +24,14 @@ public final class BrowserBookmarkComp extends SimpleComp {
private final Predicate<StoreEntryWrapper> applicable;
private final BiConsumer<StoreEntryWrapper, BooleanProperty> action;
private final Property<StoreCategoryWrapper> category;
private final Property<String> filter ;
private final Property<String> filter;
public BrowserBookmarkComp(
ObservableValue<DataStoreEntry> selected,
Predicate<StoreEntryWrapper> applicable,
BiConsumer<StoreEntryWrapper, BooleanProperty> action, Property<StoreCategoryWrapper> category, Property<String> filter
) {
BiConsumer<StoreEntryWrapper, BooleanProperty> action,
Property<StoreCategoryWrapper> category,
Property<String> filter) {
this.selected = selected;
this.applicable = applicable;
this.action = action;
@ -62,7 +64,11 @@ public final class BrowserBookmarkComp extends SimpleComp {
var section = new StoreSectionMiniComp(
StoreSection.createTopLevel(
StoreViewState.get().getAllEntries(), this::filter, filter, category, StoreViewState.get().getEntriesListUpdateObservable()),
StoreViewState.get().getAllEntries(),
this::filter,
filter,
category,
StoreViewState.get().getEntriesListUpdateObservable()),
augment,
entryWrapper -> action.accept(entryWrapper, busy),
true);

View file

@ -1,6 +1,5 @@
package io.xpipe.app.browser;
import atlantafx.base.theme.Styles;
import io.xpipe.app.comp.store.StoreCategoryWrapper;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.AppFont;
@ -8,10 +7,13 @@ import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.FilterComp;
import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.layout.Region;
import atlantafx.base.theme.Styles;
import lombok.Getter;
import java.util.List;
@ -19,7 +21,8 @@ import java.util.List;
@Getter
public final class BrowserBookmarkHeaderComp extends SimpleComp {
private final Property<StoreCategoryWrapper> category = new SimpleObjectProperty<>(StoreViewState.get().getActiveCategory().getValue());
private final Property<StoreCategoryWrapper> category =
new SimpleObjectProperty<>(StoreViewState.get().getActiveCategory().getValue());
private final Property<String> filter = new SimpleStringProperty();
@Override
@ -30,13 +33,17 @@ public final class BrowserBookmarkHeaderComp extends SimpleComp {
this.category)
.styleClass(Styles.LEFT_PILL)
.apply(struc -> AppFont.medium(struc.get()));
var filter = new FilterComp(this.filter).styleClass(Styles.RIGHT_PILL).apply(struc -> AppFont.medium(struc.get())).hgrow();
var filter = new FilterComp(this.filter)
.styleClass(Styles.RIGHT_PILL)
.apply(struc -> AppFont.medium(struc.get()))
.hgrow();
var top = new HorizontalComp(List.of(category, filter))
.apply(struc -> struc.get().setFillHeight(true))
.apply(struc -> {
((Region) struc.get().getChildren().get(0)).prefHeightProperty().bind(
((Region) struc.get().getChildren().get(1)).heightProperty());
((Region) struc.get().getChildren().get(0))
.prefHeightProperty()
.bind(((Region) struc.get().getChildren().get(1)).heightProperty());
})
.styleClass("bookmarks-header")
.createRegion();

View file

@ -28,9 +28,9 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import atlantafx.base.theme.Styles;
import javafx.scene.shape.Rectangle;
import org.kordamp.ikonli.javafx.FontIcon;
public class BrowserNavBar extends Comp<BrowserNavBar.Structure> {

View file

@ -10,6 +10,7 @@ import io.xpipe.app.fxcomps.augment.DragOverPseudoClassAugment;
import io.xpipe.app.fxcomps.impl.*;
import io.xpipe.app.fxcomps.util.DerivedObservableList;
import io.xpipe.app.fxcomps.util.PlatformThread;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
@ -18,6 +19,7 @@ import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Region;
import org.kordamp.ikonli.javafx.FontIcon;
import java.io.File;
@ -100,7 +102,8 @@ public class BrowserTransferComp extends SimpleComp {
return p;
});
var listBox = new VerticalComp(List.of(list, dragNotice)).padding(new Insets(10, 10, 5, 10))
var listBox = new VerticalComp(List.of(list, dragNotice))
.padding(new Insets(10, 10, 5, 10))
.apply(struc -> struc.get().setMinHeight(200))
.apply(struc -> struc.get().setMaxHeight(200));
var stack = LoadingOverlayComp.noProgress(

View file

@ -163,13 +163,15 @@ public class OpenFileSystemComp extends SimpleComp {
var statusBar = new BrowserStatusBarComp(model);
fileListElements.add(statusBar);
}
var fileList = new VerticalComp(fileListElements).styleClass("browser-content").apply(struc -> {
struc.get().focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
struc.get().getChildren().getFirst().requestFocus();
}
});
});
var fileList = new VerticalComp(fileListElements)
.styleClass("browser-content")
.apply(struc -> {
struc.get().focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
struc.get().getChildren().getFirst().requestFocus();
}
});
});
var home = new BrowserOverviewComp(model).styleClass("browser-content");
var stack = new MultiContentComp(Map.of(

View file

@ -98,8 +98,7 @@ public class BrowserChooserComp extends SimpleComp {
var bookmarkTopBar = new BrowserBookmarkHeaderComp();
var bookmarksList = new BrowserBookmarkComp(
BindingsHelper.map(
model.getSelectedEntry(), v -> v.getEntry().get()),
BindingsHelper.map(model.getSelectedEntry(), v -> v.getEntry().get()),
applicable,
action,
bookmarkTopBar.getCategory(),

View file

@ -13,6 +13,7 @@ import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.ShellStore;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
@ -66,21 +67,22 @@ public class BrowserSessionComp extends SimpleComp {
var bookmarkTopBar = new BrowserBookmarkHeaderComp();
var bookmarksList = new BrowserBookmarkComp(
BindingsHelper.map(
model.getSelectedEntry(), v -> v.getEntry().get()),
applicable,
action,
bookmarkTopBar.getCategory(),
bookmarkTopBar.getFilter());
BindingsHelper.map(model.getSelectedEntry(), v -> v.getEntry().get()),
applicable,
action,
bookmarkTopBar.getCategory(),
bookmarkTopBar.getFilter());
var bookmarksContainer = new StackComp(List.of(bookmarksList)).styleClass("bookmarks-container");
bookmarksContainer.apply(struc -> {
var rec = new Rectangle();
rec.widthProperty().bind(struc.get().widthProperty());
rec.heightProperty().bind(struc.get().heightProperty());
rec.setArcHeight(7);
rec.setArcWidth(7);
struc.get().getChildren().getFirst().setClip(rec);
}).vgrow();
bookmarksContainer
.apply(struc -> {
var rec = new Rectangle();
rec.widthProperty().bind(struc.get().widthProperty());
rec.heightProperty().bind(struc.get().heightProperty());
rec.setArcHeight(7);
rec.setArcWidth(7);
struc.get().getChildren().getFirst().setClip(rec);
})
.vgrow();
var localDownloadStage = new BrowserTransferComp(model.getLocalTransfersStage())
.hide(PlatformThread.sync(Bindings.createBooleanBinding(
() -> {
@ -94,10 +96,12 @@ public class BrowserSessionComp extends SimpleComp {
model.getSelectedEntry())));
localDownloadStage.prefHeight(200);
localDownloadStage.maxHeight(200);
var vertical = new VerticalComp(List.of(bookmarkTopBar, bookmarksContainer, localDownloadStage)).styleClass("left");
var vertical =
new VerticalComp(List.of(bookmarkTopBar, bookmarksContainer, localDownloadStage)).styleClass("left");
var split = new SimpleDoubleProperty();
var tabs = new BrowserSessionTabsComp(model, split).apply(struc -> struc.get().setViewOrder(1))
var tabs = new BrowserSessionTabsComp(model, split)
.apply(struc -> struc.get().setViewOrder(1))
.apply(struc -> struc.get().setPickOnBounds(false));
var splitPane = new SideSplitPaneComp(vertical, tabs)
.withInitialWidth(AppLayoutModel.get().getSavedState().getBrowserConnectionsWidth())

View file

@ -71,28 +71,30 @@ public class BrowserSessionTabsComp extends SimpleComp {
Styles.toggleStyleClass(tabs, TabPane.STYLE_CLASS_FLOATING);
toggleStyleClass(tabs, DENSE);
tabs.skinProperty().subscribe(newValue -> {
if (newValue != null) {
Platform.runLater(() -> {
tabs.setClip(null);
tabs.setPickOnBounds(false);
tabs.lookupAll(".tab-header-area").forEach(node -> {
node.setClip(null);
node.setPickOnBounds(false);
});
tabs.lookupAll(".headers-region").forEach(node -> {
node.setClip(null);
node.setPickOnBounds(false);
});
if (newValue != null) {
Platform.runLater(() -> {
tabs.setClip(null);
tabs.setPickOnBounds(false);
tabs.lookupAll(".tab-header-area").forEach(node -> {
node.setClip(null);
node.setPickOnBounds(false);
});
tabs.lookupAll(".headers-region").forEach(node -> {
node.setClip(null);
node.setPickOnBounds(false);
});
Region headerArea = (Region) tabs.lookup(".tab-header-area");
headerArea.paddingProperty().bind(Bindings.createObjectBinding(() -> new Insets(0, 0, 0, -leftPadding.get() + 2), leftPadding));
});
}
Region headerArea = (Region) tabs.lookup(".tab-header-area");
headerArea
.paddingProperty()
.bind(Bindings.createObjectBinding(
() -> new Insets(0, 0, 0, -leftPadding.get() + 2), leftPadding));
});
}
});
var map = new HashMap<BrowserSessionTab<?>, Tab>();
var map = new HashMap<BrowserSessionTab<?>, Tab>();
// Restore state
model.getSessionEntries().forEach(v -> {

View file

@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.ButtonBase;

View file

@ -54,7 +54,9 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
.setUserDataDirectory(
AppProperties.get().getDataDir().resolve("webview").toFile());
wv.setPageFill(Color.TRANSPARENT);
var theme = AppPrefs.get() != null && AppPrefs.get().theme.getValue() != null && AppPrefs.get().theme.getValue().isDark()
var theme = AppPrefs.get() != null
&& AppPrefs.get().theme.getValue() != null
&& AppPrefs.get().theme.getValue().isDark()
? "misc/github-markdown-dark.css"
: "misc/github-markdown-light.css";
var url = AppResources.getResourceURL(AppResources.XPIPE_MODULE, theme).orElseThrow();

View file

@ -13,6 +13,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.update.UpdateAvailableAlert;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.Hyperlinks;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
@ -159,8 +160,8 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
{
var b = new IconButtonComp(
"mdi2c-code-json",
() -> Hyperlinks.open("http://localhost:"
+ AppBeaconServer.get().getPort()))
() -> Hyperlinks.open(
"http://localhost:" + AppBeaconServer.get().getPort()))
.tooltipKey("api")
.apply(simpleBorders)
.accessibleTextKey("api");

View file

@ -137,8 +137,11 @@ public class StoreCreationComp extends DialogComp {
}
// Don't use the all connections category
if (targetCategory.equals(DataStorage.get().getAllConnectionsCategory().getUuid())) {
targetCategory = DataStorage.get().getDefaultConnectionsCategory().getUuid();
if (targetCategory.equals(
DataStorage.get().getAllConnectionsCategory().getUuid())) {
targetCategory = DataStorage.get()
.getDefaultConnectionsCategory()
.getUuid();
}
return DataStoreEntry.createNew(

View file

@ -405,7 +405,6 @@ public abstract class StoreEntryComp extends SimpleComp {
}
order.getItems().add(top);
var bottom = new MenuItem(AppI18n.get("stickToBottom"), new FontIcon("mdi2o-order-bool-ascending"));
bottom.setOnAction(event -> {
wrapper.setOrder(DataStoreEntry.Order.BOTTOM);

View file

@ -16,9 +16,9 @@ import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import atlantafx.base.controls.Popover;
import javafx.scene.paint.Color;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

View file

@ -6,12 +6,14 @@ import io.xpipe.app.fxcomps.util.DerivedObservableList;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.beans.value.ObservableIntegerValue;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import lombok.Value;
import java.util.ArrayList;
@ -61,7 +63,8 @@ public class StoreSection {
}
private static DerivedObservableList<StoreSection> sorted(
DerivedObservableList<StoreSection> list, ObservableValue<StoreCategoryWrapper> category,
DerivedObservableList<StoreSection> list,
ObservableValue<StoreCategoryWrapper> category,
ObservableIntegerValue updateObservable) {
if (category == null) {
return list;
@ -112,16 +115,15 @@ public class StoreSection {
Predicate<StoreEntryWrapper> entryFilter,
ObservableValue<String> filterString,
ObservableValue<StoreCategoryWrapper> category,
ObservableIntegerValue updateObservable
) {
ObservableIntegerValue updateObservable) {
var topLevel = all.filtered(
section -> {
return DataStorage.get().isRootEntry(section.getEntry());
},
category,
updateObservable);
var cached = topLevel.mapped(
storeEntryWrapper -> create(List.of(), storeEntryWrapper, 1, all, entryFilter, filterString, category, updateObservable));
var cached = topLevel.mapped(storeEntryWrapper ->
create(List.of(), storeEntryWrapper, 1, all, entryFilter, filterString, category, updateObservable));
var ordered = sorted(cached, category, updateObservable);
var shown = ordered.filtered(
section -> {
@ -178,7 +180,8 @@ public class StoreSection {
updateObservable);
var l = new ArrayList<>(parents);
l.add(e);
var cached = allChildren.mapped(c -> create(l, c, depth + 1, all, entryFilter, filterString, category, updateObservable));
var cached = allChildren.mapped(
c -> create(l, c, depth + 1, all, entryFilter, filterString, category, updateObservable));
var ordered = sorted(cached, category, updateObservable);
var filtered = ordered.filtered(
section -> {

View file

@ -82,8 +82,8 @@ public class StoreViewState {
private void initSections() {
try {
currentTopLevelSection =
StoreSection.createTopLevel(allEntries, storeEntryWrapper -> true, filter, activeCategory, entriesListUpdateObservable);
currentTopLevelSection = StoreSection.createTopLevel(
allEntries, storeEntryWrapper -> true, filter, activeCategory, entriesListUpdateObservable);
} catch (Exception exception) {
currentTopLevelSection = new StoreSection(
null,

View file

@ -8,9 +8,11 @@ import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.LicenseProvider;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.stage.Stage;
import lombok.Getter;
import lombok.SneakyThrows;

View file

@ -6,6 +6,7 @@ import io.xpipe.app.launcher.LauncherInput;
import javafx.scene.control.Alert;
import javafx.scene.input.Clipboard;
import javafx.scene.input.DataFormat;
import lombok.Setter;
import java.util.List;

View file

@ -10,10 +10,10 @@ import io.xpipe.app.util.LicenseProvider;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
@ -74,13 +74,23 @@ public class AppLayoutModel {
new Entry(
AppI18n.observable("browser"),
"mdi2f-file-cabinet",
new BrowserSessionComp(BrowserSessionModel.DEFAULT), new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.CONTROL_DOWN)),
new Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp(), new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.CONTROL_DOWN)),
new Entry(AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new AppPrefsComp(), new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN)),
new BrowserSessionComp(BrowserSessionModel.DEFAULT),
new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("connections"),
"mdi2c-connection",
new StoreLayoutComp(),
new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("settings"),
"mdsmz-miscellaneous_services",
new AppPrefsComp(),
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("explorePlans"),
"mdi2p-professional-hexagon",
LicenseProvider.get().overviewPage(), null)));
LicenseProvider.get().overviewPage(),
null)));
return l;
}

View file

@ -1,6 +1,5 @@
package io.xpipe.app.core;
import atlantafx.base.theme.*;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.fxcomps.util.PlatformThread;
@ -8,6 +7,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
@ -23,6 +23,8 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.util.Duration;
import atlantafx.base.theme.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.SneakyThrows;

View file

@ -4,8 +4,8 @@ import io.xpipe.app.browser.file.LocalFileSystem;
import io.xpipe.app.browser.icon.FileIconManager;
import io.xpipe.app.core.App;
import io.xpipe.app.core.AppGreetings;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.core.check.AppPtbCheck;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;

View file

@ -11,6 +11,7 @@ import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.CloseBehaviourAlert;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Rectangle2D;
@ -22,17 +23,18 @@ import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import lombok.Builder;
import lombok.Getter;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import javax.imageio.ImageIO;
public class AppMainWindow {

View file

@ -2,6 +2,7 @@ package io.xpipe.app.core.window;
import io.xpipe.app.core.App;
import io.xpipe.core.process.OsType;
import javafx.geometry.Rectangle2D;
import javafx.stage.Screen;
import javafx.stage.Stage;

View file

@ -8,6 +8,7 @@ import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.InputHelper;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.css.PseudoClass;

View file

@ -4,6 +4,7 @@ import javafx.scene.control.Alert;
import javafx.scene.control.Dialog;
import javafx.stage.Stage;
import javafx.stage.Window;
import lombok.SneakyThrows;
public class ModifiedAlertStage {
@ -22,9 +23,10 @@ public class ModifiedAlertStage {
var stageField = c.getDeclaredField("stage");
stageField.setAccessible(true);
var m = new Stage() {
var m = new Stage() {
@SneakyThrows
@Override public void centerOnScreen() {
@Override
public void centerOnScreen() {
Window owner = getOwner();
if (owner != null) {
positionStageMethod.invoke(dialog);
@ -36,6 +38,6 @@ public class ModifiedAlertStage {
}
};
stageField.set(alert,m);
stageField.set(alert, m);
}
}

View file

@ -3,6 +3,7 @@ package io.xpipe.app.core.window;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
@ -11,6 +12,7 @@ import javafx.css.PseudoClass;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import lombok.SneakyThrows;
public class ModifiedStage extends Stage {
@ -21,7 +23,7 @@ public class ModifiedStage extends Stage {
var windowsField = Window.class.getDeclaredField("windows");
windowsField.setAccessible(true);
ObservableList<Window> list = (ObservableList<Window>) windowsField.get(null);
list.addListener((ListChangeListener<Window>) c -> {
list.addListener((ListChangeListener<Window>) c -> {
if (c.next() && c.wasAdded()) {
var added = c.getAddedSubList().getFirst();
if (added instanceof Stage stage) {
@ -55,7 +57,9 @@ public class ModifiedStage extends Stage {
}
var ctrl = new NativeWinWindowControl(stage);
ctrl.setWindowAttribute(DmwaWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE.get(), AppPrefs.get().theme.getValue().isDark());
ctrl.setWindowAttribute(
DmwaWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE.get(),
AppPrefs.get().theme.getValue().isDark());
boolean backdrop;
if (AppPrefs.get().performanceMode().get()) {
backdrop = false;

View file

@ -1,12 +1,13 @@
package io.xpipe.app.core.window;
import javafx.stage.Window;
import com.sun.jna.Library;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinNT;
import javafx.stage.Window;
import lombok.Getter;
import lombok.SneakyThrows;
@ -51,8 +52,7 @@ public class NativeWinWindowControl {
windowHandle,
DmwaWindowAttribute.DWMWA_SYSTEMBACKDROP_TYPE.get(),
new WinDef.DWORDByReference(new WinDef.DWORD(backdrop.get())),
WinDef.DWORD.SIZE
);
WinDef.DWORD.SIZE);
return r.longValue() == 0;
}

View file

@ -93,8 +93,11 @@ public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
};
var section = new StoreSectionMiniComp(
StoreSection.createTopLevel(
StoreViewState.get().getAllEntries(), applicable, filterText, selectedCategory, StoreViewState.get()
.getEntriesListUpdateObservable()),
StoreViewState.get().getAllEntries(),
applicable,
filterText,
selectedCategory,
StoreViewState.get().getEntriesListUpdateObservable()),
(s, comp) -> {
if (!applicable.test(s.getWrapper())) {
comp.disable(new SimpleBooleanProperty(true));

View file

@ -93,10 +93,11 @@ public class PrettyImageComp extends SimpleComp {
stack.getChildren().add(storeIcon);
Consumer<String> update = val -> {
var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark();
var useDark = AppPrefs.get() != null
&& AppPrefs.get().theme.get() != null
&& AppPrefs.get().theme.get().isDark();
var fixed = val != null
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "."
+ FileNames.getExtension(val)
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "." + FileNames.getExtension(val)
: null;
image.set(fixed);

View file

@ -88,10 +88,11 @@ public class PrettySvgComp extends SimpleComp {
}
Consumer<String> update = val -> {
var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark();
var useDark = AppPrefs.get() != null
&& AppPrefs.get().theme.get() != null
&& AppPrefs.get().theme.get().isDark();
var fixed = val != null
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "."
+ FileNames.getExtension(val)
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "." + FileNames.getExtension(val)
: null;
image.set(fixed);
};

View file

@ -14,12 +14,14 @@ import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.app.util.PasswordLockSecretValue;
import io.xpipe.core.util.InPlaceSecretValue;
import io.xpipe.core.util.ModuleHelper;
import javafx.beans.binding.Bindings;
import javafx.beans.property.*;
import javafx.beans.value.ObservableBooleanValue;
import javafx.beans.value.ObservableDoubleValue;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import lombok.Getter;
import lombok.Value;

View file

@ -44,8 +44,7 @@ public class AppearanceCategory extends AppPrefsCategory {
.nameAndDescription("uiScale")
.addComp(new IntFieldComp(prefs.uiScale).maxWidth(100), prefs.uiScale)
.nameAndDescription("useSystemFont")
.addToggle(prefs.useSystemFont)
)
.addToggle(prefs.useSystemFont))
.addTitle("windowOptions")
.sub(new OptionsBuilder()
.nameAndDescription("windowOpacity")

View file

@ -2,8 +2,8 @@ package io.xpipe.app.prefs;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.ext.PrefsChoiceValue;
import javafx.beans.property.Property;

View file

@ -90,8 +90,7 @@ public class DataStoreEntry extends StorageElement {
boolean expanded,
DataStoreColor color,
String notes,
Order explicitOrder
) {
Order explicitOrder) {
super(directory, uuid, name, lastUsed, lastModified, dirty);
this.categoryUuid = categoryUuid;
this.store = DataStorageParser.storeFromNode(storeNode);
@ -116,8 +115,7 @@ public class DataStoreEntry extends StorageElement {
Instant lastUsed,
Instant lastModified,
DataStore store,
Order explicitOrder
) {
Order explicitOrder) {
super(directory, uuid, name, lastUsed, lastModified, false);
this.categoryUuid = categoryUuid;
this.store = store;
@ -604,7 +602,6 @@ public class DataStoreEntry extends StorageElement {
}
}
@Getter
public enum Order {
@JsonProperty("top")

View file

@ -158,8 +158,8 @@ public class StandardStorage extends DataStorage {
dataStoreCategory.setCategoryUuid(DEFAULT_CATEGORY_UUID);
}
if (dataStoreCategory.getCategoryUuid() != null &&
dataStoreCategory.getCategoryUuid().equals(ALL_CONNECTIONS_CATEGORY_UUID)) {
if (dataStoreCategory.getCategoryUuid() != null
&& dataStoreCategory.getCategoryUuid().equals(ALL_CONNECTIONS_CATEGORY_UUID)) {
dataStoreCategory.setCategoryUuid(DEFAULT_CATEGORY_UUID);
}
});

View file

@ -19,7 +19,10 @@ import java.util.function.UnaryOperator;
public class MarkdownHelper {
public static String toHtml(
String value, UnaryOperator<String> headTransformation, UnaryOperator<String> bodyTransformation, String bodyStyleClass) {
String value,
UnaryOperator<String> headTransformation,
UnaryOperator<String> bodyTransformation,
String bodyStyleClass) {
MutableDataSet options = new MutableDataSet()
.set(
Parser.EXTENSIONS,
@ -47,7 +50,8 @@ public class MarkdownHelper {
var html = renderer.render(document);
var result = bodyTransformation.apply(html);
var headContent = headTransformation.apply("<meta charset=\"utf-8\"/>");
return "<html><head>" + headContent + "</head><body" + (bodyStyleClass != null ? " class=\"" + bodyStyleClass + "\"" : "") + "><article class=\"markdown-body\">" + result
+ "</article></body></html>";
return "<html><head>" + headContent + "</head><body"
+ (bodyStyleClass != null ? " class=\"" + bodyStyleClass + "\"" : "")
+ "><article class=\"markdown-body\">" + result + "</article></body></html>";
}
}

View file

@ -56,14 +56,21 @@ public class SecretManager {
return false;
}
public static SecretValue retrieve(SecretRetrievalStrategy strategy, String prompt, UUID secretId, int sub, boolean interactive) {
public static SecretValue retrieve(
SecretRetrievalStrategy strategy, String prompt, UUID secretId, int sub, boolean interactive) {
if (!strategy.expectsQuery()) {
return null;
}
var uuid = UUID.randomUUID();
var p = expectAskpass(
uuid, secretId, List.of(strategy.query()), SecretQuery.prompt(false), List.of(), CountDown.of(), interactive);
uuid,
secretId,
List.of(strategy.query()),
SecretQuery.prompt(false),
List.of(),
CountDown.of(),
interactive);
p.preAdvance(sub);
var r = p.process(prompt);
completeRequest(uuid);

View file

@ -32,8 +32,7 @@ public class SecretQueryProgress {
@NonNull SecretQuery fallback,
@NonNull List<SecretQueryFilter> filters,
@NonNull CountDown countDown,
boolean interactive
) {
boolean interactive) {
this.requestId = requestId;
this.storeId = storeId;
this.suppliers = new ArrayList<>(suppliers);

View file

@ -60,7 +60,8 @@ public interface SecretRetrievalStrategy {
@Override
public SecretQueryResult query(String prompt) {
return new SecretQueryResult(
value != null ? value.getInternalSecret() : InPlaceSecretValue.of(""), SecretQueryState.NORMAL);
value != null ? value.getInternalSecret() : InPlaceSecretValue.of(""),
SecretQueryState.NORMAL);
}
@Override
@ -180,7 +181,8 @@ public interface SecretRetrievalStrategy {
@Override
public SecretQueryResult query(String prompt) {
try (var cc = new LocalStore().control().command(command).start()) {
return new SecretQueryResult(InPlaceSecretValue.of(cc.readStdoutOrThrow()), SecretQueryState.NORMAL);
return new SecretQueryResult(
InPlaceSecretValue.of(cc.readStdoutOrThrow()), SecretQueryState.NORMAL);
} catch (Exception ex) {
ErrorEvent.fromThrowable("Unable to retrieve password with command " + command, ex)
.handle();

View file

@ -139,7 +139,9 @@ open module io.xpipe.app {
DaemonStatusExchangeImpl,
DaemonStopExchangeImpl,
HandshakeExchangeImpl,
DaemonModeExchangeImpl, FsBlobExchangeImpl, FsReadExchangeImpl,
DaemonModeExchangeImpl,
FsBlobExchangeImpl,
FsReadExchangeImpl,
FsScriptExchangeImpl,
FsWriteExchangeImpl,
AskpassExchangeImpl,

View file

@ -1,7 +1,8 @@
package io.xpipe.beacon;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.core.util.ModuleLayerLoader;
import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;
import java.util.List;
@ -71,8 +72,7 @@ public abstract class BeaconInterface<T> {
public abstract String getPath();
public Object handle(HttpExchange exchange, T body)
throws BeaconClientException, BeaconServerException {
public Object handle(HttpExchange exchange, T body) throws BeaconClientException, BeaconServerException {
throw new UnsupportedOperationException();
}

View file

@ -28,8 +28,11 @@ public class BeaconServer {
}
private static List<String> toProcessCommand(String toExec) {
// Having the trailing space is very important to force cmd to not interpret surrounding spaces and removing them
return OsType.getLocal().equals(OsType.WINDOWS) ? List.of("cmd", "/c", toExec + " ") : List.of("sh", "-c", toExec);
// Having the trailing space is very important to force cmd to not interpret surrounding spaces and removing
// them
return OsType.getLocal().equals(OsType.WINDOWS)
? List.of("cmd", "/c", toExec + " ")
: List.of("sh", "-c", toExec);
}
public static Process tryStartCustom() throws Exception {

View file

@ -1,6 +1,7 @@
package io.xpipe.beacon.api;
import io.xpipe.beacon.BeaconInterface;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

View file

@ -2,6 +2,7 @@ package io.xpipe.beacon.api;
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.store.FilePath;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@ -22,6 +23,7 @@ public class FsReadExchange extends BeaconInterface<FsReadExchange.Request> {
public static class Request {
@NonNull
UUID connection;
@NonNull
FilePath path;
}

View file

@ -2,6 +2,7 @@ package io.xpipe.beacon.api;
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.store.FilePath;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@ -22,6 +23,7 @@ public class FsScriptExchange extends BeaconInterface<FsScriptExchange.Request>
public static class Request {
@NonNull
UUID connection;
@NonNull
UUID blob;
}

View file

@ -2,6 +2,7 @@ package io.xpipe.beacon.api;
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.store.FilePath;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@ -22,8 +23,10 @@ public class FsWriteExchange extends BeaconInterface<FsWriteExchange.Request> {
public static class Request {
@NonNull
UUID connection;
@NonNull
UUID blob;
@NonNull
FilePath path;
}

View file

@ -4,6 +4,7 @@ import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.store.FilePath;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@ -32,10 +33,13 @@ public class ShellStartExchange extends BeaconInterface<ShellStartExchange.Reque
public static class Response {
@NonNull
ShellDialect shellDialect;
@NonNull
OsType osType;
@NonNull
String osName;
@NonNull
FilePath temp;
}

View file

@ -1,9 +1,10 @@
import com.fasterxml.jackson.databind.Module;
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.beacon.BeaconJacksonModule;
import io.xpipe.beacon.api.*;
import io.xpipe.core.util.ModuleLayerLoader;
import com.fasterxml.jackson.databind.Module;
open module io.xpipe.beacon {
exports io.xpipe.beacon;
exports io.xpipe.beacon.test;

View file

@ -1,14 +1,5 @@
package io.xpipe.core.util;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.type.ArrayType;
import io.xpipe.core.dialog.BaseQueryElement;
import io.xpipe.core.dialog.BusyElement;
import io.xpipe.core.dialog.ChoiceElement;
@ -20,6 +11,16 @@ import io.xpipe.core.store.FilePath;
import io.xpipe.core.store.LocalStore;
import io.xpipe.core.store.StorePath;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.type.ArrayType;
import java.io.IOException;
import java.lang.reflect.WildcardType;
import java.nio.charset.Charset;
@ -89,7 +90,8 @@ public class CoreJacksonModule extends SimpleModule {
@Override
public StorePath deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JavaType javaType = JacksonMapper.getDefault().getTypeFactory().constructCollectionLikeType(List.class, String.class);
JavaType javaType =
JacksonMapper.getDefault().getTypeFactory().constructCollectionLikeType(List.class, String.class);
List<String> list = JacksonMapper.getDefault().readValue(p, javaType);
return new StorePath(list);
}

View file

@ -1,7 +1,8 @@
package io.xpipe.ext.base.service;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.core.store.NetworkTunnelStore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;

View file

@ -71,7 +71,8 @@ open module io.xpipe.ext.base {
BrowseStoreAction,
ScanStoreAction;
provides DataStoreProvider with
FixedServiceGroupStoreProvider, CustomServiceGroupStoreProvider,
FixedServiceGroupStoreProvider,
CustomServiceGroupStoreProvider,
CustomServiceStoreProvider,
MappedServiceStoreProvider,
FixedServiceStoreProvider,