Merge branch icons into master [release]

This commit is contained in:
crschnick 2024-10-01 10:29:31 +00:00
parent 19b341d848
commit dbea577662
5428 changed files with 52759 additions and 1861 deletions

View file

@ -25,15 +25,15 @@ components from it when it is run in a development environment.
Note that in case the current master branch is ahead of the latest release, it might happen that there are some incompatibilities when loading data from your local XPipe installation.
You should therefore always check out the matching version tag for your local repository and local XPipe installation.
You can find the available version tags at https://github.com/xpipe-io/xpipe/tags.
So for example if you currently have XPipe `10.0` installed, you should run `git reset --hard 10.0` first to properly compile against it.
So for example if you currently have XPipe `11.3` installed, you should run `git reset --hard 11.3` first to properly compile against it.
You need to have JDK for Java 21 installed to compile the project.
If you are on Linux or macOS, you can easily accomplish that by running
```bash
curl -s "https://get.sdkman.io" | bash
. "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21.0.1-graalce
sdk default java 21.0.1-graalce
sdk install java 22.0.2-graalce
sdk default java 22.0.2-graalce
```
.
On Windows, you have to manually install a JDK, e.g. from [Adoptium](https://adoptium.net/temurin/releases/?version=21).
@ -74,7 +74,7 @@ Especially when starting out, it might be a good idea to start with easy tasks f
### Interacting via the HTTP API
You can create clients they communicate with the XPipe daemon via its HTTP API.
You can create clients that communicate with the XPipe daemon via its HTTP API.
To get started, see the [OpenAPI spec](/openapi.yaml).
### Implementing support for a new editor
@ -98,9 +98,13 @@ All actions that you can perform for certain connections in the connection overv
You can add custom script definitions [here](https://github.com/xpipe-io/xpipe/tree/master/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java) and [here](https://github.com/xpipe-io/xpipe/tree/master/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts).
### Adding more system icons for system autodetection
You can register new system types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/java/io/xpipe/app/resources/SystemIcons.java) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/img/system).
### Adding more file icons for specific types
You can register file types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/resources/io/xpipe/app/resources/file_list.txt) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/browser_icons).
You can register file types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/resources/io/xpipe/app/resources/file_list.txt) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/img/browser).
The existing file list and icons are taken from the [vscode-icons](https://github.com/vscode-icons/vscode-icons) project. Due to limitations in the file definition list compatibility, some file types might not be listed by their proper extension and are therefore not being applied correctly even though the images and definitions exist already.
@ -108,6 +112,6 @@ The existing file list and icons are taken from the [vscode-icons](https://githu
if you want to work on something that was not listed here, you can still do so of course. You can reach out on the [Discord server](https://discord.gg/8y89vS8cRb) to discuss any development plans and get you started.
### Translations
### Adding translations
See the [translation guide](/lang) for details.

View file

@ -17,8 +17,10 @@ It currently supports:
- [Docker](https://www.docker.com/), [Podman](https://podman.io/), and [LXD](https://linuxcontainers.org/lxd/introduction/) container instances located on any host
- [Windows Subsystem for Linux](https://ubuntu.com/wsl), [Cygwin](https://www.cygwin.com/), and [MSYS2](https://www.msys2.org/) instances
- [Proxmox PVE](https://www.proxmox.com/en/proxmox-virtual-environment/overview) virtual machines and containers
- [Hyper-V](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/) and [VMware Player/Workstation/Fusion](https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion) virtual machines
- [Kubernetes](https://kubernetes.io/) clusters, pods, and containers
- [Powershell Remote Sessions](https://learn.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.3)
- Built-in VNC connections and RDP launchers
- Any other custom remote connection methods that work through the command-line
## Connection hub
@ -50,6 +52,8 @@ It currently supports:
- Works with all command shells such as bash, zsh, cmd, PowerShell, and more, locally and remote
- Connects to a system while the terminal is still starting up, allowing for faster connections than otherwise possible
![Terminal](https://github.com/xpipe-io/.github/raw/main/img/terminal_shadow.png)
<br>
<p align="center">
<img src="https://github.com/xpipe-io/.github/raw/main/img/terminal.gif" alt="Terminal launcher"/>

View file

@ -52,10 +52,10 @@ dependencies {
api files("$rootDir/gradle/gradle_scripts/vernacular-1.16.jar")
api 'org.bouncycastle:bcprov-jdk18on:1.78.1'
api 'info.picocli:picocli:4.7.6'
api ('org.kohsuke:github-api:1.324') {
api ('org.kohsuke:github-api:1.326') {
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
api 'org.apache.commons:commons-lang3:3.16.0'
api 'org.apache.commons:commons-lang3:3.17.0'
api 'io.sentry:sentry:7.14.0'
api 'commons-io:commons-io:2.16.1'
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.17.2"

View file

@ -1,8 +1,8 @@
package io.xpipe.app.beacon;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.util.MarkdownHelper;
import io.xpipe.beacon.BeaconConfig;
import io.xpipe.beacon.BeaconInterface;

View file

@ -39,7 +39,8 @@ public class BeaconRequestHandler<T> implements HttpHandler {
}
}
if (beaconInterface.requiresEnabledApi() && !AppPrefs.get().enableHttpApi().get()) {
if (beaconInterface.requiresEnabledApi()
&& !AppPrefs.get().enableHttpApi().get()) {
var ex = new BeaconServerException("HTTP API is not enabled in the settings menu");
writeError(exchange, ex, 403);
return;

View file

@ -15,9 +15,9 @@ public class ConnectionRefreshExchangeImpl extends ConnectionRefreshExchange {
.getStoreEntryIfPresent(msg.getConnection())
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection()));
if (e.getStore() instanceof FixedHierarchyStore) {
DataStorage.get().refreshChildren(e, true);
DataStorage.get().refreshChildren(e, null, true);
} else {
e.validateOrThrow();
e.validateOrThrowAndClose(null);
}
return Response.builder().build();
}

View file

@ -43,7 +43,6 @@ public class FsReadExchangeImpl extends FsReadExchange {
var out = exchange.getResponseBody()) {
fileIn.transferTo(out);
}
return Response.builder().build();
} else {
byte[] bytes;
try (var in = fs.openInput(msg.getPath().toString())) {
@ -55,7 +54,7 @@ public class FsReadExchangeImpl extends FsReadExchange {
try (var out = exchange.getResponseBody()) {
out.write(bytes);
}
}
return Response.builder().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.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 {

View file

@ -1,11 +1,12 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.api.SshLaunchExchange;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellDialects;
import com.sun.net.httpserver.HttpExchange;
import java.util.List;
public class SshLaunchExchangeImpl extends SshLaunchExchange {
@ -27,7 +28,7 @@ public class SshLaunchExchangeImpl extends SshLaunchExchange {
// There are sometimes multiple requests by a terminal client (e.g. Termius)
// This might fail sometimes, but it is expected
var r = TerminalLauncherManager.waitForNextLaunch();
var r = TerminalLauncherManager.sshLaunchExchange();
var c = ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getOpenScriptCommand(r.toString())

View file

@ -9,7 +9,7 @@ import com.sun.net.httpserver.HttpExchange;
public class TerminalLaunchExchangeImpl extends TerminalLaunchExchange {
@Override
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException {
var r = TerminalLauncherManager.performLaunch(msg.getRequest());
var r = TerminalLauncherManager.launchExchange(msg.getRequest());
return Response.builder().targetFile(r).build();
}

View file

@ -10,7 +10,7 @@ import com.sun.net.httpserver.HttpExchange;
public class TerminalWaitExchangeImpl extends TerminalWaitExchange {
@Override
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException, BeaconServerException {
TerminalLauncherManager.waitForCompletion(msg.getRequest());
TerminalLauncherManager.waitExchange(msg.getRequest());
return Response.builder().build();
}

View file

@ -3,9 +3,9 @@ package io.xpipe.app.browser;
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.browser.file.BrowserFileTransferMode;
import io.xpipe.app.browser.file.LocalFileSystem;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.util.FailableRunnable;

View file

@ -1,20 +1,76 @@
package io.xpipe.app.browser;
import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.FileBridge;
import io.xpipe.app.util.FileOpener;
import io.xpipe.core.process.ElevationFunction;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ConnectionFileSystem;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileInfo;
import io.xpipe.core.store.FileNames;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;
public class BrowserFileOpener {
private static OutputStream openFileOutput(OpenFileSystemModel model, FileEntry file, long totalBytes)
throws Exception {
var fileSystem = model.getFileSystem();
if (model.isClosed() || fileSystem.getShell().isEmpty()) {
return OutputStream.nullOutputStream();
}
var sc = fileSystem.getShell().get();
if (sc.getOsType() == OsType.WINDOWS) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}
var info = (FileInfo.Unix) file.getInfo();
var zero = Integer.valueOf(0);
var otherWrite = info.getPermissions().charAt(7) == 'w';
var requiresRoot = zero.equals(info.getUid()) && zero.equals(info.getGid()) && !otherWrite;
if (!requiresRoot || model.getCache().isRoot()) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}
var elevate = AppWindowHelper.showConfirmationAlert(
"app.fileWriteSudoTitle", "app.fileWriteSudoHeader", "app.fileWriteSudoContent");
if (!elevate) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}
var rootSc = sc.identicalSubShell()
.elevated(ElevationFunction.elevated("sudo"))
.start();
var rootFs = new ConnectionFileSystem(rootSc);
try {
return new FilterOutputStream(rootFs.openOutput(file.getPath(), totalBytes)) {
@Override
public void close() throws IOException {
super.close();
rootFs.close();
}
};
} catch (Exception ex) {
rootFs.close();
throw ex;
}
}
private static int calculateKey(FileEntry entry) {
return Objects.hash(entry.getPath(), entry.getFileSystem(), entry.getKind(), entry.getInfo());
}
public static void openWithAnyApplication(OpenFileSystemModel model, FileEntry entry) {
var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
@ -35,7 +91,7 @@ public class BrowserFileOpener {
public static void openInDefaultApplication(OpenFileSystemModel model, FileEntry entry) {
var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
@ -61,7 +117,7 @@ public class BrowserFileOpener {
}
var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
@ -71,11 +127,7 @@ public class BrowserFileOpener {
return entry.getFileSystem().openInput(file);
},
(size) -> {
if (model.isClosed()) {
return OutputStream.nullOutputStream();
}
return entry.getFileSystem().openOutput(file, size);
return openFileOutput(model, entry, size);
},
FileOpener::openInTextEditor);
}

View file

@ -84,7 +84,7 @@ public class BrowserNavBar extends Comp<BrowserNavBar.Structure> {
var graphic = Bindings.createStringBinding(
() -> {
return model.getCurrentDirectory() != null
? FileIconManager.getFileIcon(model.getCurrentDirectory(), false)
? FileIconManager.getFileIcon(model.getCurrentDirectory())
: null;
},
model.getCurrentPath());

View file

@ -55,7 +55,7 @@ public class BrowserStatusBarComp extends SimpleComp {
private Comp<?> createProgressEstimateStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
var expected = p.expectedTimeRemaining();
@ -74,7 +74,7 @@ public class BrowserStatusBarComp extends SimpleComp {
private Comp<?> createProgressStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
var transferred = HumanReadableFormat.progressByteCount(p.getTransferred());
@ -91,7 +91,7 @@ public class BrowserStatusBarComp extends SimpleComp {
private Comp<?> createProgressNameStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
return p.getName();

View file

@ -10,12 +10,14 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.ShellTemp;
import io.xpipe.app.util.ThreadHelper;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import lombok.Value;
import org.apache.commons.io.FileUtils;
@ -133,6 +135,12 @@ public class BrowserTransferModel {
BrowserFileTransferMode.COPY,
false,
progress -> {
// Don't update item progress to keep it as finished
if (progress == null) {
item.getOpenFileSystemModel().getProgress().setValue(null);
return;
}
synchronized (item.getProgress()) {
item.getProgress().setValue(progress);
}
@ -170,7 +178,7 @@ public class BrowserTransferModel {
if (Files.isDirectory(file)) {
FileUtils.moveDirectory(file.toFile(), target.toFile());
} else {
FileUtils.moveFile(file.toFile(), target.toFile(), StandardCopyOption.REPLACE_EXISTING);
Files.move(file, target, StandardCopyOption.REPLACE_EXISTING);
}
}
DesktopHelper.browseFileInDirectory(downloads.resolve(files.getFirst().getFileName()));

View file

@ -14,14 +14,6 @@ public class BrowserTransferProgress {
long total;
Instant start;
public static BrowserTransferProgress empty() {
return new BrowserTransferProgress(null, 0, 0, Instant.now());
}
static BrowserTransferProgress empty(String name, long size) {
return new BrowserTransferProgress(name, 0, size, Instant.now());
}
public static BrowserTransferProgress finished(String name, long size) {
return new BrowserTransferProgress(name, size, size, Instant.now());
}

View file

@ -52,7 +52,7 @@ public class BrowserWelcomeComp extends SimpleComp {
var vbox = new VBox(welcome, new Spacer(4, Orientation.VERTICAL));
vbox.setAlignment(Pos.CENTER_LEFT);
var img = new PrettySvgComp(new SimpleStringProperty("Hips.svg"), 50, 75)
var img = new PrettySvgComp(new SimpleStringProperty("graphics/Hips.svg"), 50, 75)
.padding(new Insets(5, 0, 0, 0))
.createRegion();
@ -145,8 +145,7 @@ public class BrowserWelcomeComp extends SimpleComp {
private Comp<?> entryButton(BrowserSavedState.Entry e, BooleanProperty disable) {
var entry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
var graphic =
entry.get().getProvider().getDisplayIconFileName(entry.get().getStore());
var graphic = entry.get().getEffectiveIconFile();
var view = PrettyImageHelper.ofFixedSize(graphic, 30, 24);
return new ButtonComp(
new SimpleStringProperty(DataStorage.get().getStoreEntryDisplayName(entry.get())),

View file

@ -2,6 +2,7 @@ package io.xpipe.app.browser.file;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FilePath;
@ -62,7 +63,8 @@ public class BrowserAlerts {
}
public static boolean showDeleteAlert(List<FileEntry> source) {
if (source.stream().noneMatch(entry -> entry.getKind() == FileKind.DIRECTORY)) {
if (!AppPrefs.get().confirmDeletions().get()
&& source.stream().noneMatch(entry -> entry.getKind() == FileKind.DIRECTORY)) {
return true;
}

View file

@ -65,11 +65,11 @@ public class BrowserEntry {
if (fileType != null) {
return fileType.getIcon();
} else if (directoryType != null) {
return directoryType.getIcon(rawFileEntry, false);
return directoryType.getIcon(rawFileEntry);
} else {
return rawFileEntry != null && rawFileEntry.resolved().getKind() == FileKind.DIRECTORY
? "default_folder.svg"
: "default_file.svg";
? "browser/default_folder.svg"
: "browser/default_file.svg";
}
}

View file

@ -248,7 +248,6 @@ public final class BrowserFileListComp extends SimpleComp {
if (inCooldown) {
lastType.set(Instant.now());
event.consume();
return;
} else {
lastType.set(null);
typedSelection.set("");
@ -256,8 +255,8 @@ public final class BrowserFileListComp extends SimpleComp {
if (!recursive) {
updateTypedSelection(table, lastType, event, true);
}
return;
}
return;
}
lastType.set(Instant.now());
@ -631,6 +630,10 @@ public final class BrowserFileListComp extends SimpleComp {
() -> getTableRow().getItem(), fileList.getFileSystemModel())
.hide(Bindings.createBooleanBinding(
() -> {
if (getTableRow() == null) {
return true;
}
var item = getTableRow().getItem();
var notDir = item.getRawFileEntry().resolved().getKind() != FileKind.DIRECTORY;
var isParentLink = item.getRawFileEntry()

View file

@ -102,7 +102,7 @@ public class BrowserFileTransferOperation {
public void execute() throws Exception {
if (files.isEmpty()) {
updateProgress(BrowserTransferProgress.empty());
updateProgress(null);
return;
}
@ -115,6 +115,7 @@ public class BrowserFileTransferOperation {
}
}
try {
for (var file : files) {
if (same) {
handleSingleOnSameFileSystem(file);
@ -128,6 +129,9 @@ public class BrowserFileTransferOperation {
deleteSingle(file);
}
}
} finally {
updateProgress(null);
}
}
private void handleSingleOnSameFileSystem(FileEntry source) throws Exception {

View file

@ -142,8 +142,7 @@ public class BrowserQuickAccessContextMenu extends ContextMenu {
this.menu = new Menu(
// Use original name, not the link target
browserEntry.getRawFileEntry().getName(),
PrettyImageHelper.ofFixedRasterized(
FileIconManager.getFileIcon(browserEntry.getRawFileEntry(), false), 24, 24)
PrettyImageHelper.ofFixedSize(FileIconManager.getFileIcon(browserEntry.getRawFileEntry()), 24, 24)
.createRegion());
createMenu();
addInputListeners();

View file

@ -1,9 +1,9 @@
package io.xpipe.app.browser.file;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
import io.xpipe.app.ext.LocalStore;
import java.nio.file.Files;
import java.nio.file.Path;
@ -19,6 +19,13 @@ public class LocalFileSystem {
}
}
public static void reset() throws Exception {
if (localFileSystem != null) {
localFileSystem.close();
localFileSystem = null;
}
}
public static FileEntry getLocalFileEntry(Path file) throws Exception {
if (localFileSystem == null) {
throw new IllegalStateException();

View file

@ -60,7 +60,8 @@ public class OpenFileSystemCache extends ShellControlCache {
var split = s.split(":");
try {
users.putIfAbsent(Integer.parseInt(split[2]), split[0]);
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
});
if (users.isEmpty()) {
@ -81,7 +82,8 @@ public class OpenFileSystemCache extends ShellControlCache {
var split = s.split(":");
try {
groups.putIfAbsent(Integer.parseInt(split[2]), split[0]);
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
});
if (groups.isEmpty()) {

View file

@ -11,6 +11,7 @@ import io.xpipe.app.browser.file.FileSystemHelper;
import io.xpipe.app.browser.session.BrowserAbstractSessionModel;
import io.xpipe.app.browser.session.BrowserSessionTab;
import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStorage;
@ -18,7 +19,7 @@ import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.process.ShellOpenFunction;
@ -47,8 +48,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
private final OpenFileSystemHistory history = new OpenFileSystemHistory();
private final Property<ModalOverlayComp.OverlayContent> overlay = new SimpleObjectProperty<>();
private final BooleanProperty inOverview = new SimpleBooleanProperty();
private final Property<BrowserTransferProgress> progress =
new SimpleObjectProperty<>(BrowserTransferProgress.empty());
private final Property<BrowserTransferProgress> progress = new SimpleObjectProperty<>();
private FileSystem fileSystem;
private OpenFileSystemSavedState savedState;
private OpenFileSystemCache cache;
@ -73,10 +73,13 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
@Override
public boolean canImmediatelyClose() {
return !progress.getValue().done()
|| (fileSystem != null
&& fileSystem.getShell().isPresent()
&& fileSystem.getShell().get().getLock().isLocked());
if (fileSystem == null
|| fileSystem.getShell().isEmpty()
|| !fileSystem.getShell().get().getLock().isLocked()) {
return true;
}
return progress.getValue() == null || progress.getValue().done();
}
@Override
@ -252,7 +255,11 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
entry.getEntry(),
name,
directory,
fileSystem.getShell().get().singularSubShell(ShellOpenFunction.of(adjustedPath)));
fileSystem
.getShell()
.get()
.singularSubShell(
ShellOpenFunction.of(CommandBuilder.ofString(adjustedPath), false)));
} else {
TerminalLauncher.open(
entry.getEntry(),
@ -453,7 +460,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
return fileSystem == null;
}
public void initWithGivenDirectory(String dir) throws Exception {
public void initWithGivenDirectory(String dir) {
cdSync(dir);
}

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.icon;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileNames;
@ -42,8 +42,8 @@ public abstract class BrowserIconDirectoryType {
}
@Override
public String getIcon(FileEntry entry, boolean open) {
return open ? "default_root_folder_opened.svg" : "default_root_folder.svg";
public String getIcon(FileEntry entry) {
return "browser/default_root_folder.svg";
}
});
@ -60,17 +60,10 @@ public abstract class BrowserIconDirectoryType {
})
.collect(Collectors.toSet());
var closedIcon = split[2].trim();
var openIcon = split[3].trim();
var closedIcon = "browser/" + split[2].trim();
var lightClosedIcon = split.length > 4 ? "browser/" + split[4].trim() : closedIcon;
var lightClosedIcon = split.length > 4 ? split[4].trim() : closedIcon;
var lightOpenIcon = split.length > 4 ? split[5].trim() : openIcon;
ALL.add(new Simple(
id,
new IconVariant(lightClosedIcon, closedIcon),
new IconVariant(lightOpenIcon, openIcon),
filter));
ALL.add(new Simple(id, new IconVariant(lightClosedIcon, closedIcon), filter));
}
}
});
@ -84,7 +77,7 @@ public abstract class BrowserIconDirectoryType {
public abstract boolean matches(FileEntry entry);
public abstract String getIcon(FileEntry entry, boolean open);
public abstract String getIcon(FileEntry entry);
public static class Simple extends BrowserIconDirectoryType {
@ -92,13 +85,11 @@ public abstract class BrowserIconDirectoryType {
private final String id;
private final IconVariant closed;
private final IconVariant open;
private final Set<String> names;
public Simple(String id, IconVariant closed, IconVariant open, Set<String> names) {
public Simple(String id, IconVariant closed, Set<String> names) {
this.id = id;
this.closed = closed;
this.open = open;
this.names = names;
}
@ -113,8 +104,8 @@ public abstract class BrowserIconDirectoryType {
}
@Override
public String getIcon(FileEntry entry, boolean open) {
return open ? this.open.getIcon() : this.closed.getIcon();
public String getIcon(FileEntry entry) {
return this.closed.getIcon();
}
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.icon;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileNames;
@ -47,8 +47,8 @@ public abstract class BrowserIconFileType {
return "." + r;
})
.collect(Collectors.toSet());
var darkIcon = split[2].trim();
var lightIcon = split.length > 3 ? split[3].trim() : darkIcon;
var darkIcon = "browser/" + split[2].trim();
var lightIcon = (split.length > 3 ? "browser/" + split[3].trim() : darkIcon);
ALL.add(new BrowserIconFileType.Simple(id, lightIcon, darkIcon, filter));
}
}

View file

@ -7,11 +7,11 @@ import io.xpipe.core.store.FileEntry;
public class BrowserIcons {
public static Comp<?> createDefaultFileIcon() {
return PrettyImageHelper.ofFixedSizeSquare("default_file.svg", 24);
return PrettyImageHelper.ofFixedSizeSquare("browser/default_file.svg", 24);
}
public static Comp<?> createDefaultDirectoryIcon() {
return PrettyImageHelper.ofFixedSizeSquare("default_folder.svg", 24);
return PrettyImageHelper.ofFixedSizeSquare("browser/default_folder.svg", 24);
}
public static Comp<?> createIcon(BrowserIconFileType type) {
@ -19,6 +19,6 @@ public class BrowserIcons {
}
public static Comp<?> createIcon(FileEntry entry) {
return PrettyImageHelper.ofFixedSizeSquare(FileIconManager.getFileIcon(entry, false), 24);
return PrettyImageHelper.ofFixedSizeSquare(FileIconManager.getFileIcon(entry), 24);
}
}

View file

@ -1,7 +1,5 @@
package io.xpipe.app.browser.icon;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.core.AppResources;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
@ -13,12 +11,11 @@ public class FileIconManager {
if (!loaded) {
BrowserIconFileType.loadDefinitions();
BrowserIconDirectoryType.loadDefinitions();
AppImages.loadDirectory(AppResources.XPIPE_MODULE, "browser_icons", true, false);
loaded = true;
}
}
public static synchronized String getFileIcon(FileEntry entry, boolean open) {
public static synchronized String getFileIcon(FileEntry entry) {
if (entry == null) {
return null;
}
@ -33,13 +30,11 @@ public class FileIconManager {
} else {
for (var f : BrowserIconDirectoryType.getAll()) {
if (f.matches(r)) {
return f.getIcon(r, open);
return f.getIcon(r);
}
}
}
return r.getKind() == FileKind.DIRECTORY
? (open ? "default_folder_opened.svg" : "default_folder.svg")
: "default_file.svg";
return "browser/" + (r.getKind() == FileKind.DIRECTORY ? "default_folder.svg" : "default_file.svg");
}
}

View file

@ -9,11 +9,8 @@ import io.xpipe.app.comp.base.DialogComp;
import io.xpipe.app.comp.base.SideSplitPaneComp;
import io.xpipe.app.comp.store.StoreEntryWrapper;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.StackComp;
import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.fxcomps.util.BindingsHelper;
@ -30,7 +27,6 @@ import javafx.geometry.Pos;
import javafx.scene.control.TextField;
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;
@ -40,7 +36,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class BrowserChooserComp extends SimpleComp {
public class BrowserChooserComp extends DialogComp {
private final BrowserFileChooserModel model;
@ -52,24 +48,16 @@ public class BrowserChooserComp extends SimpleComp {
Supplier<DataStoreEntryRef<? extends FileSystemStore>> store, Consumer<FileReference> file, boolean save) {
PlatformThread.runLaterIfNeeded(() -> {
var model = new BrowserFileChooserModel(OpenFileSystemModel.SelectionMode.SINGLE_FILE);
var comp = new BrowserChooserComp(model)
.apply(struc -> struc.get().setPrefSize(1200, 700))
.apply(struc -> AppFont.normal(struc.get()));
var window = AppWindowHelper.sideWindow(
AppI18n.get(save ? "saveFileTitle" : "openFileTitle"),
stage -> {
DialogComp.showWindow(save ? "saveFileTitle" : "openFileTitle", stage -> {
var comp = new BrowserChooserComp(model);
comp.apply(struc -> struc.get().setPrefSize(1200, 700))
.apply(struc -> AppFont.normal(struc.get()))
.styleClass("browser")
.styleClass("chooser");
return comp;
},
false,
null);
});
model.setOnFinish(fileStores -> {
file.accept(fileStores.size() > 0 ? fileStores.getFirst() : null);
window.close();
});
window.show();
window.setOnHidden(event -> {
model.finishWithoutChoice();
event.consume();
});
ThreadHelper.runAsync(() -> {
model.openFileSystemAsync(store.get(), null, null);
@ -78,7 +66,27 @@ public class BrowserChooserComp extends SimpleComp {
}
@Override
protected Region createSimple() {
protected String finishKey() {
return "select";
}
@Override
protected Comp<?> pane(Comp<?> content) {
return content;
}
@Override
protected void finish() {
model.finishChooser();
}
@Override
protected void discard() {
model.finishWithoutChoice();
}
@Override
public Comp<?> content() {
Predicate<StoreEntryWrapper> applicable = storeEntryWrapper -> {
return (storeEntryWrapper.getEntry().getStore() instanceof ShellStore)
&& storeEntryWrapper.getEntry().getValidity().isUsable();
@ -96,7 +104,7 @@ public class BrowserChooserComp extends SimpleComp {
return;
}
if (entry.getStore() instanceof ShellStore fileSystem) {
if (entry.getStore() instanceof ShellStore) {
model.openFileSystemAsync(entry.ref(), null, busy);
}
});
@ -144,26 +152,6 @@ public class BrowserChooserComp extends SimpleComp {
struc.getLeft().setMinWidth(200);
struc.getLeft().setMaxWidth(500);
});
var dialogPane = new DialogComp() {
@Override
protected String finishKey() {
return "select";
}
@Override
protected Comp<?> pane(Comp<?> content) {
return content;
}
@Override
protected void finish() {
model.finishChooser();
}
@Override
public Comp<?> content() {
return splitPane;
}
@ -193,11 +181,4 @@ public class BrowserChooserComp extends SimpleComp {
return bottomBar;
});
}
};
var r = dialogPane.createRegion();
r.getStyleClass().add("browser");
r.getStyleClass().add("chooser");
return r;
}
}

View file

@ -51,11 +51,12 @@ public class BrowserSessionModel extends BrowserAbstractSessionModel<BrowserSess
for (var o : new ArrayList<>(sessionEntries)) {
// Don't close busy connections gracefully
// as we otherwise might lock up
if (o.canImmediatelyClose()) {
if (!o.canImmediatelyClose()) {
continue;
}
closeSync(o);
// Prevent blocking of shutdown
closeAsync(o);
}
BrowserSavedStateImpl.get().save();
}

View file

@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.impl.TooltipAugment;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.ContextMenuHelper;
@ -238,7 +239,6 @@ public class BrowserSessionTabsComp extends SimpleComp {
% tabs.getTabs().size();
tabs.getSelectionModel().select(previous);
keyEvent.consume();
return;
}
});
@ -329,12 +329,14 @@ public class BrowserSessionTabsComp extends SimpleComp {
ring.setMaxSize(16, 16);
ring.progressProperty()
.bind(Bindings.createDoubleBinding(
() -> model.getBusy().get() ? -1d : 0, PlatformThread.sync(model.getBusy())));
() -> model.getBusy().get()
&& !AppPrefs.get().performanceMode().get()
? -1d
: 0,
PlatformThread.sync(model.getBusy()),
AppPrefs.get().performanceMode()));
var image = model.getEntry()
.get()
.getProvider()
.getDisplayIconFileName(model.getEntry().getStore());
var image = model.getEntry().get().getEffectiveIconFile();
var logo = PrettyImageHelper.ofFixedSizeSquare(image, 16).createRegion();
tab.graphicProperty()

View file

@ -64,7 +64,6 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
if (shortcut != null && shortcut.match(event)) {
((ButtonBase) ((Parent) node).getChildrenUnmodifiable().get(1)).fire();
event.consume();
return;
}
});
});

View file

@ -20,22 +20,30 @@ import javafx.stage.Stage;
import atlantafx.base.theme.Styles;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
public abstract class DialogComp extends Comp<CompStructure<Region>> {
public static void showWindow(String titleKey, Function<Stage, DialogComp> f) {
var loading = new SimpleBooleanProperty();
var dialog = new AtomicReference<DialogComp>();
Platform.runLater(() -> {
var stage = AppWindowHelper.sideWindow(
AppI18n.get(titleKey),
window -> {
var c = f.apply(window);
dialog.set(c);
loading.bind(c.busy());
return c;
},
false,
loading);
stage.setOnCloseRequest(event -> {
if (dialog.get() != null) {
dialog.get().discard();
}
});
stage.show();
});
}
@ -60,12 +68,16 @@ public abstract class DialogComp extends Comp<CompStructure<Region>> {
.addAll(customButtons().stream()
.map(buttonComp -> buttonComp.createRegion())
.toList());
var nextButton = new ButtonComp(AppI18n.observable(finishKey()), null, this::finish)
var nextButton = finishButton();
buttons.getChildren().add(nextButton.createRegion());
return buttons;
}
protected Comp<?> finishButton() {
return new ButtonComp(AppI18n.observable(finishKey()), null, this::finish)
.apply(struc -> struc.get().setDefaultButton(true))
.styleClass(Styles.ACCENT)
.styleClass("next");
buttons.getChildren().add(nextButton.createRegion());
return buttons;
}
protected String finishKey() {
@ -93,6 +105,8 @@ public abstract class DialogComp extends Comp<CompStructure<Region>> {
protected abstract void finish();
protected abstract void discard();
public abstract Comp<?> content();
protected Comp<?> pane(Comp<?> content) {

View file

@ -26,6 +26,8 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
private static final PseudoClass ODD = PseudoClass.getPseudoClass("odd");
private static final PseudoClass EVEN = PseudoClass.getPseudoClass("even");
private static final PseudoClass FIRST = PseudoClass.getPseudoClass("first");
private static final PseudoClass LAST = PseudoClass.getPseudoClass("last");
private final ObservableList<T> shown;
private final ObservableList<T> all;
@ -114,9 +116,10 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
for (int i = 0; i < newShown.size(); i++) {
var r = newShown.get(i);
r.pseudoClassStateChanged(ODD, false);
r.pseudoClassStateChanged(EVEN, false);
r.pseudoClassStateChanged(i % 2 == 0 ? EVEN : ODD, true);
r.pseudoClassStateChanged(ODD, i % 2 != 0);
r.pseudoClassStateChanged(EVEN, i % 2 == 0);
r.pseudoClassStateChanged(FIRST, i == 0);
r.pseudoClassStateChanged(LAST, i == newShown.size() - 1);
}
var d = new DerivedObservableList<>(listView.getChildren(), true);

View file

@ -1,13 +1,13 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.MarkdownHelper;
import io.xpipe.app.util.ShellTemp;

View file

@ -1,11 +1,11 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.comp.store.StoreEntryWrapper;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.PrettyImageComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.impl.StackComp;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.process.OsNameState;
import io.xpipe.core.store.FileNames;
@ -22,8 +22,7 @@ import java.util.Map;
public class OsLogoComp extends SimpleComp {
private static final Map<String, String> ICONS = new HashMap<>();
private static final String LINUX_DEFAULT = "linux-24.png";
private static final String LINUX_DEFAULT_SVG = "linux.svg";
private static final String LINUX_DEFAULT_24 = "linux-24.png";
private final StoreEntryWrapper wrapper;
private final ObservableValue<SystemStateComp.State> state;
@ -54,8 +53,9 @@ public class OsLogoComp extends SimpleComp {
wrapper.getPersistentState(),
state);
var hide = BindingsHelper.map(img, s -> s != null);
return new StackComp(
List.of(new SystemStateComp(state).hide(hide), new PrettyImageComp(img, 24, 24).visible(hide)))
return new StackComp(List.of(
new SystemStateComp(state).hide(hide),
PrettyImageHelper.ofFixedSize(img, 24, 24).visible(hide)))
.createRegion();
}
@ -67,11 +67,12 @@ public class OsLogoComp extends SimpleComp {
if (ICONS.isEmpty()) {
AppResources.with(AppResources.XPIPE_MODULE, "img/os", file -> {
try (var list = Files.list(file)) {
list.filter(path -> path.toString().endsWith(".svg")
&& !path.toString().endsWith(LINUX_DEFAULT_SVG))
list.filter(path -> path.toString().endsWith(".png")
&& !path.toString().endsWith(LINUX_DEFAULT_24)
&& !path.toString().endsWith("-40.png"))
.map(path -> FileNames.getFileName(path.toString()))
.forEach(path -> {
var base = FileNames.getBaseName(path).replace("-dark", "") + "-24.png";
var base = path.replace("-dark", "").replace("-24.png", ".svg");
ICONS.put(FileNames.getBaseName(base).split("-")[0], "os/" + base);
});
}
@ -82,6 +83,6 @@ public class OsLogoComp extends SimpleComp {
.filter(e -> name.toLowerCase().contains(e.getKey()))
.findAny()
.map(e -> e.getValue())
.orElse("os/" + LINUX_DEFAULT);
.orElse("os/linux.svg");
}
}

View file

@ -20,6 +20,7 @@ import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.*;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.ValidationContext;
import io.xpipe.core.util.ValidationException;
import javafx.application.Platform;
@ -42,14 +43,13 @@ import net.synedra.validatorfx.GraphicDecorationStackPane;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class StoreCreationComp extends DialogComp {
Stage window;
BiConsumer<DataStoreEntry, Boolean> consumer;
CreationConsumer consumer;
Property<DataStoreProvider> provider;
ObjectProperty<DataStore> store;
Predicate<DataStoreProvider> filter;
@ -67,7 +67,7 @@ public class StoreCreationComp extends DialogComp {
public StoreCreationComp(
Stage window,
BiConsumer<DataStoreEntry, Boolean> consumer,
CreationConsumer consumer,
Property<DataStoreProvider> provider,
ObjectProperty<DataStore> store,
Predicate<DataStoreProvider> filter,
@ -165,8 +165,11 @@ public class StoreCreationComp extends DialogComp {
e.getProvider(),
e.getStore(),
v -> true,
(newE, validated) -> {
(newE, context, validated) -> {
ThreadHelper.runAsync(() -> {
if (context != null) {
context.close();
}
if (!DataStorage.get().getStoreEntries().contains(e)) {
DataStorage.get().addStoreEntryIfNotPresent(newE);
} else {
@ -193,15 +196,16 @@ public class StoreCreationComp extends DialogComp {
base != null ? DataStoreProviders.byStore(base) : null,
base,
dataStoreProvider -> category.equals(dataStoreProvider.getCreationCategory()),
(e, validated) -> {
(e, context, validated) -> {
try {
DataStorage.get().addStoreEntryIfNotPresent(e);
if (validated
if (context != null
&& validated
&& e.getProvider().shouldShowScan()
&& AppPrefs.get()
.openConnectionSearchWindowOnConnectionCreation()
.get()) {
ScanAlert.showAsync(e);
ScanAlert.showAsync(e, context);
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
@ -211,12 +215,17 @@ public class StoreCreationComp extends DialogComp {
null);
}
public interface CreationConsumer {
void consume(DataStoreEntry entry, ValidationContext<?> validationContext, boolean validated);
}
private static void show(
String initialName,
DataStoreProvider provider,
DataStore s,
Predicate<DataStoreProvider> filter,
BiConsumer<DataStoreEntry, Boolean> con,
CreationConsumer con,
boolean staticDisplay,
DataStoreEntry existingEntry) {
var prop = new SimpleObjectProperty<>(provider);
@ -247,7 +256,7 @@ public class StoreCreationComp extends DialogComp {
return List.of(
new ButtonComp(AppI18n.observable("skip"), null, () -> {
if (showInvalidConfirmAlert()) {
commit(false);
commit(null, false);
} else {
finish();
}
@ -275,6 +284,9 @@ public class StoreCreationComp extends DialogComp {
return busy;
}
@Override
protected void discard() {}
@Override
protected void finish() {
if (finished.get()) {
@ -287,7 +299,7 @@ public class StoreCreationComp extends DialogComp {
// We didn't change anything
if (existingEntry != null && existingEntry.getStore().equals(store.getValue())) {
commit(false);
commit(null, false);
return;
}
@ -315,10 +327,10 @@ public class StoreCreationComp extends DialogComp {
return;
}
try (var b = new BooleanScope(busy).start()) {
try (var ignored = new BooleanScope(busy).start()) {
DataStorage.get().addStoreEntryInProgress(entry.getValue());
entry.getValue().validateOrThrow();
commit(true);
var context = entry.getValue().validateAndKeepOpenOrThrowAndClose(null);
commit(context, true);
} catch (Throwable ex) {
if (ex instanceof ValidationException) {
ErrorEvent.expected(ex);
@ -403,14 +415,14 @@ public class StoreCreationComp extends DialogComp {
.createRegion();
}
private void commit(boolean validated) {
private void commit(ValidationContext<?> validationContext, boolean validated) {
if (finished.get()) {
return;
}
finished.setValue(true);
if (entry.getValue() != null) {
consumer.accept(entry.getValue(), validated);
consumer.consume(entry.getValue(), validationContext, validated);
}
PlatformThread.runLaterIfNeeded(() -> {

View file

@ -22,7 +22,7 @@ public class StoreCreationMenu {
automatically.setGraphic(new FontIcon("mdi2e-eye-plus-outline"));
automatically.textProperty().bind(AppI18n.observable("addAutomatically"));
automatically.setOnAction(event -> {
ScanAlert.showAsync(null);
ScanAlert.showAsync(null, null);
event.consume();
});
menu.getItems().add(automatically);
@ -32,17 +32,21 @@ public class StoreCreationMenu {
menu.getItems().add(category("addDesktop", "mdi2c-camera-plus", DataStoreCreationCategory.DESKTOP, null));
menu.getItems().add(category("addShell", "mdi2t-text-box-multiple", DataStoreCreationCategory.SHELL, "shellEnvironment"));
menu.getItems()
.add(category(
"addShell", "mdi2t-text-box-multiple", DataStoreCreationCategory.SHELL, "shellEnvironment"));
menu.getItems()
.add(category("addScript", "mdi2s-script-text-outline", DataStoreCreationCategory.SCRIPT, "script"));
menu.getItems()
.add(category("addTunnel", "mdi2v-vector-polyline-plus", DataStoreCreationCategory.TUNNEL, "customService"));
.add(category(
"addTunnel", "mdi2v-vector-polyline-plus", DataStoreCreationCategory.TUNNEL, "customService"));
menu.getItems().add(category("addSerial", "mdi2s-serial-port", DataStoreCreationCategory.SERIAL, "serial"));
// menu.getItems().add(category("addDatabase", "mdi2d-database-plus", DataStoreCreationCategory.DATABASE, null));
// menu.getItems().add(category("addDatabase", "mdi2d-database-plus", DataStoreCreationCategory.DATABASE,
// null));
}
private static MenuItem category(
@ -85,8 +89,7 @@ public class StoreCreationMenu {
.sorted(Comparator.comparingInt(dataStoreProvider -> dataStoreProvider.getOrderPriority()))
.toList();
int lastOrder = providers.getFirst().getOrderPriority();
for (int i = 0; i < providers.size(); i++) {
var dataStoreProvider = providers.get(i);
for (io.xpipe.app.ext.DataStoreProvider dataStoreProvider : providers) {
if (dataStoreProvider.getOrderPriority() != lastOrder) {
menu.getItems().add(new SeparatorMenuItem());
lastOrder = dataStoreProvider.getOrderPriority();

View file

@ -10,12 +10,12 @@ import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.impl.IconButtonComp;
import io.xpipe.app.fxcomps.impl.LabelComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.impl.TooltipAugment;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.DerivedObservableList;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.storage.DataColor;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
@ -33,7 +33,6 @@ import javafx.scene.control.*;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import atlantafx.base.layout.InputGroup;
import atlantafx.base.theme.Styles;
@ -192,26 +191,7 @@ public abstract class StoreEntryComp extends SimpleComp {
}
protected Node createIcon(int w, int h) {
var img = getWrapper().disabledProperty().get()
? "disabled_icon.png"
: getWrapper()
.getEntry()
.getProvider()
.getDisplayIconFileName(getWrapper().getEntry().getStore());
var imageComp = PrettyImageHelper.ofFixedSize(img, w, h);
var storeIcon = imageComp.createRegion();
if (getWrapper().getValidity().getValue().isUsable()) {
new TooltipAugment<>(getWrapper().getEntry().getProvider().displayName(), null).augment(storeIcon);
}
var stack = new StackPane(storeIcon);
stack.setMinHeight(w + 7);
stack.setMinWidth(w + 7);
stack.setMaxHeight(w + 7);
stack.setMaxWidth(w + 7);
stack.getStyleClass().add("icon");
stack.setAlignment(Pos.CENTER);
return stack;
return new StoreIconComp(getWrapper(), w, h).createRegion();
}
protected Region createButtonBar() {
@ -265,7 +245,9 @@ public abstract class StoreEntryComp extends SimpleComp {
button.apply(new ContextMenuAugment<>(
mouseEvent -> mouseEvent.getButton() == MouseButton.PRIMARY, keyEvent -> false, () -> {
var cm = ContextMenuHelper.create();
branch.getChildren(getWrapper().getEntry().ref()).forEach(childProvider -> {
branch.getChildren(getWrapper().getEntry().ref()).stream()
.filter(actionProvider -> getWrapper().showActionProvider(actionProvider))
.forEach(childProvider -> {
var menu = buildMenuItemForAction(childProvider);
if (menu != null) {
cm.getItems().add(menu);
@ -341,14 +323,16 @@ public abstract class StoreEntryComp extends SimpleComp {
if (DataStorage.get().isRootEntry(getWrapper().getEntry())) {
var color = new Menu(AppI18n.get("color"), new FontIcon("mdi2f-format-color-fill"));
var none = new MenuItem("None");
var none = new MenuItem();
none.textProperty().bind(AppI18n.observable("none"));
none.setOnAction(event -> {
getWrapper().getEntry().setColor(null);
event.consume();
});
color.getItems().add(none);
Arrays.stream(DataColor.values()).forEach(dataStoreColor -> {
MenuItem m = new MenuItem(DataStoreFormatter.capitalize(dataStoreColor.getId()));
MenuItem m = new MenuItem();
m.textProperty().bind(AppI18n.observable(dataStoreColor.getId()));
m.setOnAction(event -> {
getWrapper().getEntry().setColor(dataStoreColor);
event.consume();
@ -463,6 +447,7 @@ public abstract class StoreEntryComp extends SimpleComp {
if (branch != null) {
var items = branch.getChildren(getWrapper().getEntry().ref()).stream()
.filter(actionProvider -> getWrapper().showActionProvider(actionProvider))
.map(c -> buildMenuItemForAction(c))
.toList();
menu.getItems().addAll(items);
@ -475,6 +460,7 @@ public abstract class StoreEntryComp extends SimpleComp {
getWrapper()
.runAction(leaf.createAction(getWrapper().getEntry().ref()), leaf.showBusy());
});
event.consume();
});
menu.getItems().add(run);
@ -493,6 +479,7 @@ public abstract class StoreEntryComp extends SimpleComp {
.getName(getWrapper().getEntry().ref())
.getValue() + ")");
});
event.consume();
});
menu.getItems().add(sc);
@ -504,6 +491,7 @@ public abstract class StoreEntryComp extends SimpleComp {
AppActionLinkDetector.setLastDetectedAction(url);
ClipboardHelper.copyUrl(url);
});
event.consume();
});
menu.getItems().add(l);
}
@ -518,10 +506,13 @@ public abstract class StoreEntryComp extends SimpleComp {
return;
}
event.consume();
ThreadHelper.runFailableAsync(() -> {
getWrapper().runAction(leaf.createAction(getWrapper().getEntry().ref()), leaf.showBusy());
});
event.consume();
if (event.getTarget() instanceof Menu m) {
m.getParentPopup().hide();
}
});
return item;

View file

@ -2,6 +2,7 @@ package io.xpipe.app.comp.store;
import io.xpipe.app.comp.base.ListBoxViewComp;
import io.xpipe.app.comp.base.MultiContentComp;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
@ -34,6 +35,12 @@ public class StoreEntryListComp extends SimpleComp {
struc.get().setVvalue(0);
});
});
content.apply(struc -> {
// Reset scroll
AppLayoutModel.get().getSelected().addListener((observable, oldValue, newValue) -> {
struc.get().setVvalue(0);
});
});
return content.styleClass("store-list-comp");
}
@ -44,7 +51,8 @@ public class StoreEntryListComp extends SimpleComp {
() -> {
var allCat = StoreViewState.get().getAllConnectionsCategory();
var connections = StoreViewState.get().getAllEntries().getList().stream()
.filter(wrapper -> allCat.equals(wrapper.getCategory().getValue().getRoot()))
.filter(wrapper -> allCat.equals(
wrapper.getCategory().getValue().getRoot()))
.toList();
return initialCount == connections.size()
&& StoreViewState.get()

View file

@ -8,6 +8,7 @@ import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.FilterComp;
import io.xpipe.app.fxcomps.impl.IconButtonComp;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
@ -72,8 +73,13 @@ public class StoreEntryListOverviewComp extends SimpleComp {
// But it is good enough.
var showProvider = true;
try {
showProvider = storeEntryWrapper.getEntry().getProvider().shouldShow(storeEntryWrapper);
} catch (Exception ignored) {}
showProvider = storeEntryWrapper.getEntry().getProvider() == null
|| storeEntryWrapper
.getEntry()
.getProvider()
.shouldShow(storeEntryWrapper);
} catch (Exception ignored) {
}
return inRootCategory && showProvider;
},
StoreViewState.get().getActiveCategory());
@ -143,15 +149,15 @@ public class StoreEntryListOverviewComp extends SimpleComp {
}
private Comp<?> createAlphabeticalSortButton() {
var icon = Bindings.createStringBinding(
var icon = Bindings.createObjectBinding(
() -> {
if (sortMode.getValue() == StoreSortMode.ALPHABETICAL_ASC) {
return "mdi2s-sort-alphabetical-descending";
return new LabelGraphic.IconGraphic("mdi2s-sort-alphabetical-descending");
}
if (sortMode.getValue() == StoreSortMode.ALPHABETICAL_DESC) {
return "mdi2s-sort-alphabetical-ascending";
return new LabelGraphic.IconGraphic("mdi2s-sort-alphabetical-ascending");
}
return "mdi2s-sort-alphabetical-descending";
return new LabelGraphic.IconGraphic("mdi2s-sort-alphabetical-descending");
},
sortMode);
var alphabetical = new IconButtonComp(icon, () -> {
@ -184,15 +190,15 @@ public class StoreEntryListOverviewComp extends SimpleComp {
}
private Comp<?> createDateSortButton() {
var icon = Bindings.createStringBinding(
var icon = Bindings.createObjectBinding(
() -> {
if (sortMode.getValue() == StoreSortMode.DATE_ASC) {
return "mdi2s-sort-clock-ascending-outline";
return new LabelGraphic.IconGraphic("mdi2s-sort-clock-ascending-outline");
}
if (sortMode.getValue() == StoreSortMode.DATE_DESC) {
return "mdi2s-sort-clock-descending-outline";
return new LabelGraphic.IconGraphic("mdi2s-sort-clock-descending-outline");
}
return "mdi2s-sort-clock-ascending-outline";
return new LabelGraphic.IconGraphic("mdi2s-sort-clock-ascending-outline");
},
sortMode);
var date = new IconButtonComp(icon, () -> {

View file

@ -17,7 +17,9 @@ import lombok.Getter;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@Getter
public class StoreEntryWrapper {
@ -40,6 +42,8 @@ public class StoreEntryWrapper {
private final Property<StoreCategoryWrapper> category = new SimpleObjectProperty<>();
private final Property<String> summary = new SimpleObjectProperty<>();
private final Property<StoreNotes> notes;
private final Property<String> customIcon = new SimpleObjectProperty<>();
private final Property<String> iconFile = new SimpleObjectProperty<>();
public StoreEntryWrapper(DataStoreEntry entry) {
this.entry = entry;
@ -137,6 +141,8 @@ public class StoreEntryWrapper {
}
color.setValue(entry.getColor());
notes.setValue(new StoreNotes(entry.getNotes(), entry.getNotes()));
customIcon.setValue(entry.getIcon());
iconFile.setValue(entry.getEffectiveIconFile());
busy.setValue(entry.getBusyCounter().get() != 0);
deletable.setValue(entry.getConfiguration().isDeletable()
@ -191,7 +197,7 @@ public class StoreEntryWrapper {
}
}
private boolean showActionProvider(ActionProvider p) {
public boolean showActionProvider(ActionProvider p) {
var leaf = p.getLeafDataStoreCallSite();
if (leaf != null) {
return (entry.getValidity().isUsable() || (!leaf.requiresValidStore() && entry.getProvider() != null))
@ -214,7 +220,7 @@ public class StoreEntryWrapper {
}
public void refreshChildren() {
var hasChildren = DataStorage.get().refreshChildren(entry);
var hasChildren = DataStorage.get().refreshChildren(entry, null);
PlatformThread.runLaterIfNeeded(() -> {
expanded.set(hasChildren);
});

View file

@ -0,0 +1,145 @@
package io.xpipe.app.comp.store;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.resources.SystemIcon;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.*;
import javafx.scene.input.MouseButton;
import javafx.scene.layout.Region;
import atlantafx.base.theme.Tweaks;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import static atlantafx.base.theme.Styles.TEXT_SMALL;
public class StoreIconChoiceComp extends SimpleComp {
private final Property<SystemIcon> selected;
private final List<SystemIcon> icons;
private final int columns;
private final SimpleStringProperty filter;
private final Runnable doubleClick;
public StoreIconChoiceComp(
Property<SystemIcon> selected,
List<SystemIcon> icons,
int columns,
SimpleStringProperty filter,
Runnable doubleClick) {
this.selected = selected;
this.icons = icons;
this.columns = columns;
this.filter = filter;
this.doubleClick = doubleClick;
}
@Override
protected Region createSimple() {
var table = new TableView<List<SystemIcon>>();
initTable(table);
updateData(table, null);
filter.addListener((observable, oldValue, newValue) -> updateData(table, newValue));
return table;
}
private void initTable(TableView<List<SystemIcon>> table) {
for (int i = 0; i < columns; i++) {
var col = new TableColumn<List<SystemIcon>, SystemIcon>("col" + i);
final int colIndex = i;
col.setCellValueFactory(cb -> {
var row = cb.getValue();
var item = row.size() > colIndex ? row.get(colIndex) : null;
return new SimpleObjectProperty<>(item);
});
col.setCellFactory(cb -> new IconCell());
col.getStyleClass().add(Tweaks.ALIGN_CENTER);
table.getColumns().add(col);
}
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS);
table.getSelectionModel().setCellSelectionEnabled(true);
table.getStyleClass().add("icon-browser");
table.setPlaceholder(new Region());
}
private void updateData(TableView<List<SystemIcon>> table, String filterString) {
var displayedIcons = filterString == null || filterString.isBlank() || filterString.length() < 2
? icons
: icons.stream()
.filter(icon -> containsString(icon.getDisplayName(), filterString))
.toList();
var data = partitionList(displayedIcons, columns);
table.getItems().setAll(data);
}
private <T> Collection<List<T>> partitionList(List<T> list, int size) {
List<List<T>> partitions = new ArrayList<>();
if (list.size() == 0) {
return partitions;
}
int length = list.size();
int numOfPartitions = length / size + ((length % size == 0) ? 0 : 1);
for (int i = 0; i < numOfPartitions; i++) {
int from = i * size;
int to = Math.min((i * size + size), length);
partitions.add(list.subList(from, to));
}
return partitions;
}
private boolean containsString(String s1, String s2) {
return s1.toLowerCase(Locale.ROOT).contains(s2.toLowerCase(Locale.ROOT));
}
public class IconCell extends TableCell<List<SystemIcon>, SystemIcon> {
private final Label root = new Label();
private final StringProperty image = new SimpleStringProperty();
public IconCell() {
super();
root.setContentDisplay(ContentDisplay.TOP);
Region imageView = PrettyImageHelper.ofFixedSize(image, 40, 40).createRegion();
root.setGraphic(imageView);
root.setGraphicTextGap(10);
root.getStyleClass().addAll("icon-label", TEXT_SMALL);
setOnMouseClicked(event -> {
if (event.getButton() == MouseButton.PRIMARY) {
selected.setValue(getItem());
}
if (event.getClickCount() > 1) {
doubleClick.run();
}
});
}
@Override
protected void updateItem(SystemIcon icon, boolean empty) {
super.updateItem(icon, empty);
if (icon == null) {
setGraphic(null);
return;
}
root.setText(icon.getDisplayName());
image.set("app:system/" + icon.getIconName() + ".svg");
setGraphic(root);
}
}
}

View file

@ -0,0 +1,99 @@
package io.xpipe.app.comp.store;
import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.comp.base.DialogComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.FilterComp;
import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.resources.SystemIcon;
import io.xpipe.app.resources.SystemIcons;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.Hyperlinks;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.layout.Region;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
public class StoreIconChoiceDialogComp extends SimpleComp {
public static void show(DataStoreEntry entry) {
var window = AppWindowHelper.sideWindow(
AppI18n.get("chooseCustomIcon"), stage -> new StoreIconChoiceDialogComp(entry, stage), false, null);
window.initModality(Modality.APPLICATION_MODAL);
window.show();
}
private final ObjectProperty<SystemIcon> selected = new SimpleObjectProperty<>();
private final DataStoreEntry entry;
private final Stage dialogStage;
public StoreIconChoiceDialogComp(DataStoreEntry entry, Stage dialogStage) {
this.entry = entry;
this.dialogStage = dialogStage;
}
@Override
protected Region createSimple() {
var filterText = new SimpleStringProperty();
var filter = new FilterComp(filterText).apply(struc -> {
dialogStage.setOnShowing(event -> {
struc.get().requestFocus();
event.consume();
});
});
var github = new ButtonComp(null, new FontIcon("mdi2g-github"), () -> {
Hyperlinks.open(Hyperlinks.SELFHST_ICONS);
})
.grow(false, true);
var dialog = new DialogComp() {
@Override
protected void finish() {
entry.setIcon(selected.get() != null ? selected.getValue().getIconName() : null, true);
dialogStage.close();
}
@Override
protected void discard() {}
@Override
public Comp<?> content() {
return new StoreIconChoiceComp(selected, SystemIcons.getSystemIcons(), 5, filterText, () -> {
finish();
});
}
@Override
protected Comp<?> pane(Comp<?> content) {
return content;
}
@Override
public Comp<?> bottom() {
var clear = new ButtonComp(AppI18n.observable("clear"), () -> {
selected.setValue(null);
finish();
})
.grow(false, true);
return new HorizontalComp(List.of(github, filter.hgrow(), clear)).spacing(10);
}
@Override
protected Comp<?> finishButton() {
return super.finishButton().disable(selected.isNull());
}
};
dialog.prefWidth(600);
dialog.prefHeight(600);
return dialog.createRegion();
}
}

View file

@ -0,0 +1,64 @@
package io.xpipe.app.comp.store;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.impl.TooltipAugment;
import javafx.beans.binding.Bindings;
import javafx.geometry.Pos;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import lombok.AllArgsConstructor;
import org.kordamp.ikonli.javafx.FontIcon;
@AllArgsConstructor
public class StoreIconComp extends SimpleComp {
private final StoreEntryWrapper wrapper;
private final int w;
private final int h;
@Override
protected Region createSimple() {
var imageComp = PrettyImageHelper.ofFixedSize(wrapper.getIconFile(), w, h);
var storeIcon = imageComp.createRegion();
if (wrapper.getValidity().getValue().isUsable()) {
new TooltipAugment<>(wrapper.getEntry().getProvider().displayName(), null).augment(storeIcon);
}
var background = new Region();
background.getStyleClass().add("background");
var dots = new FontIcon("mdi2d-dots-horizontal");
dots.setIconSize((int) (h * 1.3));
var stack = new StackPane(background, storeIcon, dots);
stack.setMinHeight(w + 7);
stack.setMinWidth(w + 7);
stack.setMaxHeight(w + 7);
stack.setMaxWidth(w + 7);
stack.getStyleClass().add("icon");
stack.setAlignment(Pos.CENTER);
dots.visibleProperty().bind(stack.hoverProperty());
storeIcon
.opacityProperty()
.bind(Bindings.createDoubleBinding(
() -> {
return stack.isHover() ? 0.5 : 1.0;
},
stack.hoverProperty()));
stack.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
if (event.getButton() == MouseButton.PRIMARY) {
StoreIconChoiceDialogComp.show(wrapper.getEntry());
event.consume();
}
});
return stack;
}
}

View file

@ -39,12 +39,12 @@ public class StoreIntroComp extends SimpleComp {
var scanButton = new Button(null, new FontIcon("mdi2m-magnify"));
scanButton.textProperty().bind(AppI18n.observable("detectConnections"));
scanButton.setOnAction(event -> ScanAlert.showAsync(DataStorage.get().local()));
scanButton.setOnAction(event -> ScanAlert.showAsync(DataStorage.get().local(), null));
scanButton.setDefaultButton(true);
var scanPane = new StackPane(scanButton);
scanPane.setAlignment(Pos.CENTER);
var img = new PrettySvgComp(new SimpleStringProperty("Wave.svg"), 80, 150).createRegion();
var img = new PrettySvgComp(new SimpleStringProperty("graphics/Wave.svg"), 80, 150).createRegion();
var text = new VBox(title, introDesc);
text.setSpacing(5);
text.setAlignment(Pos.CENTER_LEFT);

View file

@ -96,6 +96,9 @@ public class StoreNotesComp extends Comp<StoreNotesComp.Structure> {
ref.get().hide();
}
@Override
protected void discard() {}
@Override
protected String finishKey() {
return "apply";

View file

@ -41,8 +41,7 @@ public class StoreQuickAccessButtonComp extends Comp<CompStructure<Button>> {
private MenuItem recurse(ContextMenu contextMenu, StoreSection section) {
var c = section.getShownChildren();
var w = section.getWrapper();
var graphic =
w.getEntry().getProvider().getDisplayIconFileName(w.getEntry().getStore());
var graphic = w.getEntry().getEffectiveIconFile();
if (c.getList().isEmpty()) {
var item = ContextMenuHelper.item(
new LabelGraphic.ImageGraphic(graphic, 16), w.getName().getValue());

View file

@ -176,7 +176,8 @@ public class StoreSection {
var showProvider = true;
try {
showProvider = other.getEntry().getProvider().shouldShow(other);
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
return showProvider;
},
e.getPersistentState(),

View file

@ -7,6 +7,7 @@ import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.fxcomps.impl.IconButtonComp;
import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.storage.DataColor;
import io.xpipe.app.util.ThreadHelper;
@ -68,11 +69,15 @@ public class StoreSectionComp extends Comp<CompStructure<VBox>> {
private Comp<CompStructure<Button>> createExpandButton() {
var expandButton = new IconButtonComp(
Bindings.createStringBinding(
() -> section.getWrapper().getExpanded().get()
&& section.getShownChildren().getList().size() > 0
Bindings.createObjectBinding(
() -> new LabelGraphic.IconGraphic(
section.getWrapper().getExpanded().get()
&& section.getShownChildren()
.getList()
.size()
> 0
? "mdal-keyboard_arrow_down"
: "mdal-keyboard_arrow_right",
: "mdal-keyboard_arrow_right"),
section.getWrapper().getExpanded(),
section.getShownChildren().getList()),
() -> {

View file

@ -8,6 +8,7 @@ import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.fxcomps.impl.IconButtonComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.storage.DataColor;
import javafx.beans.binding.Bindings;
@ -52,15 +53,9 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
if (section.getWrapper() != null) {
var root = new ButtonComp(section.getWrapper().nameProperty(), () -> {})
.apply(struc -> {
var provider = section.getWrapper().getEntry().getProvider();
struc.get()
.setGraphic(PrettyImageHelper.ofFixedSizeSquare(
provider != null
? provider.getDisplayIconFileName(section.getWrapper()
.getEntry()
.getStore())
: null,
16)
.setGraphic(PrettyImageHelper.ofFixedSize(
section.getWrapper().getIconFile(), 16, 16)
.createRegion());
})
.apply(struc -> {
@ -81,8 +76,9 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
new SimpleBooleanProperty(section.getWrapper().getExpanded().get()
&& section.getShownChildren().getList().size() > 0);
var button = new IconButtonComp(
Bindings.createStringBinding(
() -> expanded.get() ? "mdal-keyboard_arrow_down" : "mdal-keyboard_arrow_right",
Bindings.createObjectBinding(
() -> new LabelGraphic.IconGraphic(
expanded.get() ? "mdal-keyboard_arrow_down" : "mdal-keyboard_arrow_right"),
expanded),
() -> {
expanded.set(!expanded.get());

View file

@ -98,9 +98,10 @@ public class StoreViewState {
private void initFilterJump() {
var all = getAllConnectionsCategory();
filter.addListener((observable, oldValue, newValue) -> {
var matchingCats = categories.getList().stream().filter(storeCategoryWrapper -> storeCategoryWrapper.getRoot().equals(all))
.filter(storeCategoryWrapper -> storeCategoryWrapper.getDirectContainedEntries()
.stream()
var matchingCats = categories.getList().stream()
.filter(storeCategoryWrapper ->
storeCategoryWrapper.getRoot().equals(all))
.filter(storeCategoryWrapper -> storeCategoryWrapper.getDirectContainedEntries().stream()
.anyMatch(wrapper -> wrapper.matchesFilter(newValue)))
.toList();
if (matchingCats.size() == 1) {

View file

@ -10,6 +10,8 @@ import io.xpipe.app.util.LicenseProvider;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ObservableDoubleValue;
import javafx.stage.Stage;
import lombok.Getter;
@ -63,4 +65,12 @@ public class App extends Application {
stage.requestFocus();
});
}
public ObservableDoubleValue displayScale() {
if (getStage() == null) {
return new SimpleDoubleProperty(1.0);
}
return getStage().outputScaleXProperty();
}
}

View file

@ -9,10 +9,10 @@ import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.desktop.*;
import java.util.List;
import javax.imageio.ImageIO;
public class AppDesktopIntegration {
@ -36,7 +36,8 @@ public class AppDesktopIntegration {
ThreadHelper.sleep(1000);
OperationMode.close();
});
}}
}
}
});
}

View file

@ -1,10 +1,11 @@
package io.xpipe.app.core;
import io.xpipe.app.ext.ExtensionException;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.process.OsType;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.util.ModuleHelper;
import io.xpipe.core.util.ModuleLayerLoader;
import io.xpipe.core.util.XPipeInstallation;
@ -55,8 +56,8 @@ public class AppExtensionManager {
ErrorEvent.fromThrowable(t).handle();
});
} catch (Throwable t) {
throw new ExtensionException(
"Service provider initialization failed. Is the installation data corrupt?", t);
throw ExtensionException.corrupt(
"Service provider initialization failed", t);
}
}
}
@ -72,7 +73,7 @@ public class AppExtensionManager {
private void loadBaseExtension() {
var baseModule = findAndParseExtension("base", ModuleLayer.boot());
if (baseModule.isEmpty()) {
throw new ExtensionException("Missing base module. Is the installation data corrupt?");
throw ExtensionException.corrupt("Missing base module");
}
baseLayer = baseModule.get().getModule().getLayer();
@ -205,8 +206,8 @@ public class AppExtensionManager {
var ext = getExtensionFromDir(layer, dir);
if (ext.isEmpty()) {
if (AppProperties.get().isFullVersion()) {
throw new ExtensionException(
"Unable to load extension from directory " + dir + ". Is the installation corrupted?");
throw ExtensionException.corrupt(
"Unable to load extension from directory " + dir);
}
} else {
if (loadedExtensions.stream()

View file

@ -1,6 +1,7 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.process.OsType;
import javafx.scene.Node;

View file

@ -4,6 +4,7 @@ import io.xpipe.app.comp.base.MarkdownComp;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.resources.AppResources;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Insets;

View file

@ -1,144 +0,0 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
import org.apache.commons.io.FilenameUtils;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.Map;
public class AppImages {
public static final Image DEFAULT_IMAGE = new WritableImage(1, 1);
private static final Map<String, Image> images = new HashMap<>();
private static final Map<String, String> svgImages = new HashMap<>();
public static void init() {
if (images.size() > 0 || svgImages.size() > 0) {
return;
}
TrackEvent.info("Loading images ...");
for (var module : AppExtensionManager.getInstance().getContentModules()) {
loadDirectory(module.getName(), "img", true, true);
}
}
public static void loadDirectory(String module, String dir, boolean loadImages, boolean loadSvgs) {
AppResources.with(module, dir, basePath -> {
if (!Files.exists(basePath)) {
return;
}
var simpleName = FilenameUtils.getExtension(module);
String defaultPrefix = simpleName + ":";
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
var relativeFileName = FilenameUtils.separatorsToUnix(
basePath.relativize(file).toString());
try {
if (FilenameUtils.getExtension(file.toString()).equals("svg") && loadSvgs) {
var s = Files.readString(file);
svgImages.put(defaultPrefix + relativeFileName, s);
} else if (loadImages) {
images.put(defaultPrefix + relativeFileName, loadImage(file));
}
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
}
return FileVisitResult.CONTINUE;
}
});
});
}
public static String svgImage(String file) {
if (file == null) {
return "";
}
var key = file.contains(":") ? file : "app:" + file;
if (svgImages.containsKey(key)) {
return svgImages.get(key);
}
TrackEvent.warn("Svg image " + key + " not found");
return "";
}
public static boolean hasNormalImage(String file) {
if (file == null) {
return false;
}
var key = file.contains(":") ? file : "app:" + file;
return images.containsKey(key);
}
public static boolean hasSvgImage(String file) {
if (file == null) {
return false;
}
var key = file.contains(":") ? file : "app:" + file;
return svgImages.containsKey(key);
}
public static Image image(String file) {
if (file == null) {
return DEFAULT_IMAGE;
}
var key = file.contains(":") ? file : "app:" + file;
if (images.containsKey(key)) {
return images.get(key);
}
TrackEvent.warn("Normal image " + key + " not found");
return DEFAULT_IMAGE;
}
public static BufferedImage toAwtImage(Image fxImage) {
BufferedImage img =
new BufferedImage((int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < fxImage.getWidth(); x++) {
for (int y = 0; y < fxImage.getHeight(); y++) {
int rgb = fxImage.getPixelReader().getArgb(x, y);
img.setRGB(x, y, rgb);
}
}
return img;
}
public static Image loadImage(Path p) {
if (p == null) {
return DEFAULT_IMAGE;
}
if (!Files.isRegularFile(p)) {
TrackEvent.error("Image file " + p + " not found.");
return DEFAULT_IMAGE;
}
try (var in = Files.newInputStream(p)) {
return new Image(in, -1, -1, true, true);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
return DEFAULT_IMAGE;
}
}
}

View file

@ -5,12 +5,14 @@ import io.xpipe.app.browser.session.BrowserSessionComp;
import io.xpipe.app.browser.session.BrowserSessionModel;
import io.xpipe.app.comp.store.StoreLayoutComp;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.prefs.AppPrefsComp;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.LicenseProvider;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
@ -21,6 +23,7 @@ import lombok.Data;
import lombok.Getter;
import lombok.extern.jackson.Jacksonized;
import java.time.*;
import java.util.ArrayList;
import java.util.List;
@ -75,47 +78,71 @@ public class AppLayoutModel {
var l = new ArrayList<>(List.of(
new Entry(
AppI18n.observable("browser"),
"mdi2f-file-cabinet",
new LabelGraphic.IconGraphic("mdi2f-file-cabinet"),
new BrowserSessionComp(BrowserSessionModel.DEFAULT),
null,
new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)),
new Entry(
AppI18n.observable("connections"),
"mdi2c-connection",
new LabelGraphic.IconGraphic("mdi2c-connection"),
new StoreLayoutComp(),
null,
new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN)),
new Entry(
AppI18n.observable("settings"),
"mdsmz-miscellaneous_services",
new LabelGraphic.IconGraphic("mdsmz-miscellaneous_services"),
new AppPrefsComp(),
null,
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.SHORTCUT_DOWN)),
new Entry(
AppI18n.observable("explorePlans"),
"mdi2p-professional-hexagon",
new LabelGraphic.IconGraphic("mdi2p-professional-hexagon"),
LicenseProvider.get().overviewPage(),
null,
null),
new Entry(
AppI18n.observable("visitGithubRepository"),
"mdi2g-github",
new LabelGraphic.IconGraphic("mdi2g-github"),
null,
() -> Hyperlinks.open(Hyperlinks.GITHUB),
null),
new Entry(
AppI18n.observable("discord"),
"mdi2d-discord",
new LabelGraphic.IconGraphic("mdi2d-discord"),
null,
() -> Hyperlinks.open(Hyperlinks.DISCORD),
null),
new Entry(
AppI18n.observable("api"),
"mdi2c-code-json",
new LabelGraphic.IconGraphic("mdi2c-code-json"),
null,
() -> Hyperlinks.open(
"http://localhost:" + AppBeaconServer.get().getPort()),
null)));
null)
// new Entry(
// AppI18n.observable("webtop"),
// "mdi2d-desktop-mac",
// null,
// () -> Hyperlinks.open(Hyperlinks.GITHUB_WEBTOP),
// null)
));
var now = Instant.now();
var zone = ZoneId.of(ZoneId.SHORT_IDS.get("PST"));
var phStart = ZonedDateTime.of(2024, 10, 22, 0, 1, 0, 0, zone).toInstant();
var clicked = AppCache.get("phClicked",Boolean.class,() -> false);
var phShow = now.isAfter(phStart) && !clicked;
if (phShow) {
l.add(new Entry(
new SimpleStringProperty("Product Hunt"),
new LabelGraphic.ImageGraphic("app:producthunt-color.png", 24),
null,
() -> {
AppCache.update("phClicked", true);
Hyperlinks.open(Hyperlinks.PRODUCT_HUNT);
},
null));
}
return l;
}
@ -129,5 +156,9 @@ public class AppLayoutModel {
}
public record Entry(
ObservableValue<String> name, String icon, Comp<?> comp, Runnable action, KeyCombination combination) {}
ObservableValue<String> name,
LabelGraphic icon,
Comp<?> comp,
Runnable action,
KeyCombination combination) {}
}

View file

@ -1,132 +0,0 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.util.FailableConsumer;
import io.xpipe.modulefs.ModuleFileSystem;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URI;
import java.net.URL;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
public class AppResources {
public static final String XPIPE_MODULE = "io.xpipe.app";
private static final Map<String, ModuleFileSystem> fileSystems = new ConcurrentHashMap<>();
public static void reset() {
fileSystems.forEach((s, moduleFileSystem) -> {
try {
moduleFileSystem.close();
} catch (IOException ignored) {
// Usually when updating, a SIGTERM is sent to this application.
// However, it takes a while to shut down but the installer is deleting files meanwhile.
// It can happen that the jar it does not exist anymore
}
});
fileSystems.clear();
}
private static ModuleFileSystem openFileSystemIfNeeded(String module) throws IOException {
var layer = AppExtensionManager.getInstance() != null
? AppExtensionManager.getInstance().getExtendedLayer()
: null;
// Only cache file systems with extended layer
if (layer != null && fileSystems.containsKey(module)) {
return fileSystems.get(module);
}
if (layer == null) {
layer = ModuleLayer.boot();
}
var fs = (ModuleFileSystem) FileSystems.newFileSystem(URI.create("module:/" + module), Map.of("layer", layer));
if (AppExtensionManager.getInstance() != null) {
fileSystems.put(module, fs);
}
return fs;
}
public static Optional<URL> getResourceURL(String module, String file) {
try {
var fs = openFileSystemIfNeeded(module);
var f = fs.getPath(module.replace('.', '/') + "/resources/" + file);
var url = f.getWrappedPath().toUri().toURL();
return Optional.of(url);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
return Optional.empty();
}
}
public static void with(String module, String file, FailableConsumer<Path, IOException> con) {
if (AppProperties.get() != null
&& !AppProperties.get().isImage()
&& AppProperties.get().isDeveloperMode()) {
// Check if resource was found. If we use external processed resources, we can't use local dev resources
if (withLocalDevResource(module, file, con)) {
return;
}
}
withResource(module, file, con);
}
public static void withResourceInLayer(
String module, String file, ModuleLayer layer, FailableConsumer<Path, IOException> con) {
try (var fs = FileSystems.newFileSystem(URI.create("module:/" + module), Map.of("layer", layer))) {
var f = fs.getPath(module.replace('.', '/') + "/resources/" + file);
con.accept(f);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
}
}
private static void withResource(String module, String file, FailableConsumer<Path, IOException> con) {
var path = module.startsWith("io.xpipe") ? module.replace('.', '/') + "/resources/" + file : file;
try {
var fs = openFileSystemIfNeeded(module);
var f = fs.getPath(path);
con.accept(f);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
}
}
private static boolean withLocalDevResource(String module, String file, FailableConsumer<Path, IOException> con) {
try {
var fs = openFileSystemIfNeeded(module);
var url = fs.getPath("").getWrappedPath().toUri().toURL();
if (!url.getProtocol().equals("jar")) {
return false;
}
JarURLConnection connection = (JarURLConnection) url.openConnection();
URL fileUrl = connection.getJarFileURL();
var jarFile = Path.of(fileUrl.toURI());
var resDir = jarFile.getParent()
.getParent()
.getParent()
.resolve("src")
.resolve("main")
.resolve("resources");
var f = resDir.resolve(module.replace('.', '/') + "/resources/" + file);
if (!Files.exists(f)) {
return false;
}
con.accept(f);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
}
return true;
}
}

View file

@ -3,6 +3,7 @@ package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppResources;
import javafx.scene.Scene;

View file

@ -6,6 +6,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.process.OsType;
import javafx.animation.Interpolator;

View file

@ -2,6 +2,8 @@ package io.xpipe.app.core;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.resources.AppImages;
import io.xpipe.app.resources.AppResources;
import io.xpipe.core.process.OsType;
import java.awt.*;

View file

@ -1,9 +1,13 @@
package io.xpipe.app.core.check;
import io.xpipe.app.comp.base.MarkdownComp;
import io.xpipe.app.core.*;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppState;
import io.xpipe.app.core.AppStyle;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.WindowsRegistry;
import io.xpipe.core.process.OsType;
@ -42,7 +46,6 @@ public class AppAvCheck {
PlatformState.initPlatformOrThrow();
AppStyle.init();
AppImages.init();
var a = AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("antivirusNoticeTitle"));

View file

@ -8,7 +8,9 @@ import java.util.concurrent.TimeUnit;
public class AppBundledToolsCheck {
private static boolean getResult() {
var fc = new ProcessBuilder("where", "ssh").redirectErrorStream(true).redirectOutput(ProcessBuilder.Redirect.DISCARD);
var fc = new ProcessBuilder("where", "ssh")
.redirectErrorStream(true)
.redirectOutput(ProcessBuilder.Redirect.DISCARD);
try {
var proc = fc.start();
proc.waitFor(2, TimeUnit.SECONDS);

View file

@ -0,0 +1,22 @@
package io.xpipe.app.core.check;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.PlatformState;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
public class AppGpuCheck {
public static void check() {
if (PlatformState.getCurrent() != PlatformState.RUNNING) {
return;
}
if (Platform.isSupported(ConditionalFeature.SCENE3D)) {
return;
}
AppPrefs.get().performanceMode.setValue(true);
}
}

View file

@ -0,0 +1,28 @@
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.issue.ErrorEvent;
public class AppJavaOptionsCheck {
public static void check() {
if (AppCache.get("javaOptionsWarningShown", Boolean.class,() -> false)) {
return;
}
var env = System.getenv("_JAVA_OPTIONS");
if (env == null) {
return;
}
ErrorEvent.fromMessage(
"You have configured the global environment variable _JAVA_OPTIONS=%s on your system."
.formatted(env)
+ " This will forcefully apply all custom JVM options to XPipe and can cause a variety of different issues."
+ " Please remove this global environment variable and use local configuration instead for your other JVM programs.")
.noDefaultActions()
.expected()
.handle();
AppCache.update("javaOptionsWarningShown", true);
}
}

View file

@ -26,7 +26,10 @@ public class AppRosettaCheck {
if (ret.get().equals("1")) {
ErrorEvent.fromMessage("You are running the Intel version of XPipe on an Apple Silicon system."
+ " There is a native build available that comes with much better performance."
+ " Please install that one instead.");
+ " Please install that one instead.")
.noDefaultActions()
.expected()
.handle();
}
}
}

View file

@ -1,9 +1,9 @@
package io.xpipe.app.core.check;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.LocalShell;
import io.xpipe.core.process.OsType;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ProcessOutputException;
import lombok.Value;

View file

@ -8,8 +8,11 @@ import io.xpipe.app.core.*;
import io.xpipe.app.core.check.*;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.resources.SystemIcons;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStorageSyncHandler;
import io.xpipe.app.update.XPipeDistributionType;
@ -44,6 +47,7 @@ public class BaseMode extends OperationMode {
AppCertutilCheck.check();
AppBundledToolsCheck.check();
AppAvCheck.check();
AppJavaOptionsCheck.check();
AppSid.init();
LocalShell.init();
AppShellCheck.check();
@ -56,6 +60,7 @@ public class BaseMode extends OperationMode {
DataStorageSyncHandler.getInstance().retrieveSyncedData();
AppPrefs.initSharedRemote();
UnlockAlert.showIfNeeded();
SystemIcons.init();
DataStorage.init();
DataStoreProviders.init();
AppFileWatcher.init();
@ -70,7 +75,7 @@ public class BaseMode extends OperationMode {
public void onSwitchFrom() {}
@Override
public void finalTeardown() {
public void finalTeardown() throws Exception {
TrackEvent.info("Background mode shutdown started");
BrowserSessionModel.DEFAULT.reset();
SshLocalBridge.reset();
@ -78,12 +83,14 @@ public class BaseMode extends OperationMode {
DataStoreProviders.reset();
DataStorage.reset();
AppPrefs.reset();
DataStorageSyncHandler.getInstance().reset();
LocalShell.reset();
ProcessControlProvider.get().reset();
AppResources.reset();
AppExtensionManager.reset();
AppDataLock.unlock();
BlobManager.reset();
FileBridge.reset();
// Shut down server last to keep a non-daemon thread running
AppBeaconServer.reset();
TrackEvent.info("Background mode shutdown finished");
}

View file

@ -4,6 +4,7 @@ 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.AppLayoutModel;
import io.xpipe.app.core.check.AppPtbCheck;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.fxcomps.util.PlatformThread;
@ -39,6 +40,7 @@ public class GuiMode extends PlatformMode {
AppGreetings.showIfNeeded();
AppPtbCheck.check();
NativeBridge.init();
AppLayoutModel.init();
TrackEvent.info("Waiting for window setup completion ...");
PlatformThread.runLaterIfNeededBlocking(() -> {
@ -63,4 +65,10 @@ public class GuiMode extends PlatformMode {
UpdateChangelogAlert.showIfNeeded();
}
@Override
public void finalTeardown() throws Throwable {
LocalFileSystem.reset();
super.finalTeardown();
}
}

View file

@ -225,6 +225,8 @@ public abstract class OperationMode {
CURRENT.finalTeardown();
}
CURRENT = null;
// Restart local shell
LocalShell.init();
r.run();
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).handle();
@ -293,6 +295,8 @@ public abstract class OperationMode {
inShutdown = true;
OperationMode.inShutdownHook = inShutdownHook;
// Keep a non-daemon thread running
var thread = ThreadHelper.createPlatformThread("shutdown", false, () -> {
try {
if (CURRENT != null) {
CURRENT.finalTeardown();
@ -304,6 +308,14 @@ public abstract class OperationMode {
}
OperationMode.halt(hasError ? 1 : 0);
});
thread.start();
try {
thread.join();
} catch (InterruptedException ignored) {
OperationMode.halt(1);
}
}
// public static synchronized void reload() {

View file

@ -3,8 +3,10 @@ package io.xpipe.app.core.mode;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppFontLoadingCheck;
import io.xpipe.app.core.check.AppGpuCheck;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppImages;
import io.xpipe.app.update.UpdateAvailableAlert;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.ThreadHelper;
@ -29,11 +31,14 @@ public abstract class PlatformMode extends OperationMode {
PlatformState.initPlatformOrThrow();
// Check if we can load system fonts or fail
AppFontLoadingCheck.check();
// Can be loaded async
var imageThread = ThreadHelper.runFailableAsync(() -> {
AppImages.init();
});
AppGpuCheck.check();
AppFont.init();
AppTheme.init();
AppStyle.init();
AppImages.init();
AppLayoutModel.init();
TrackEvent.info("Finished essential component initialization before platform");
TrackEvent.info("Launching application ...");
@ -56,6 +61,7 @@ public abstract class PlatformMode extends OperationMode {
}
StoreViewState.init();
imageThread.join();
}
@Override

View file

@ -1,7 +1,6 @@
package io.xpipe.app.core.window;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppTheme;
import io.xpipe.app.core.mode.OperationMode;
@ -10,8 +9,10 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.CloseBehaviourAlert;
import io.xpipe.app.resources.AppImages;
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;
@ -24,17 +25,18 @@ import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
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

@ -5,6 +5,8 @@ import io.xpipe.app.core.*;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppImages;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.util.InputHelper;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;

View file

@ -1,11 +1,13 @@
package io.xpipe.app.core.window;
import com.sun.jna.NativeLong;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.NativeBridge;
import io.xpipe.core.util.ModuleHelper;
import javafx.stage.Window;
import com.sun.jna.NativeLong;
import lombok.Getter;
import lombok.SneakyThrows;

View file

@ -0,0 +1,6 @@
package io.xpipe.app.ext;
public interface ContainerImageStore {
String getImageName();
}

View file

@ -7,9 +7,9 @@ import io.xpipe.app.comp.store.StoreEntryWrapper;
import io.xpipe.app.comp.store.StoreSection;
import io.xpipe.app.comp.store.StoreSectionComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.resources.AppImages;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.util.JacksonizedValue;
@ -57,12 +57,12 @@ public interface DataStoreProvider {
default void validate() {
for (Class<?> storeClass : getStoreClasses()) {
if (!JacksonizedValue.class.isAssignableFrom(storeClass)) {
throw new ExtensionException(
throw ExtensionException.corrupt(
String.format("Store class %s is not a Jacksonized value", storeClass.getSimpleName()));
}
if (getUsageCategory() == null) {
throw new ExtensionException("Provider %s does not have the usage category".formatted(getId()));
throw ExtensionException.corrupt("Provider %s does not have the usage category".formatted(getId()));
}
}
}

View file

@ -1,14 +1,16 @@
package io.xpipe.app.ext;
import io.xpipe.core.util.XPipeInstallation;
public class ExtensionException extends RuntimeException {
public ExtensionException() {}
public ExtensionException(String message) {
private ExtensionException(String message) {
super(message);
}
public ExtensionException(String message, Throwable cause) {
private ExtensionException(String message, Throwable cause) {
super(message, cause);
}
@ -20,7 +22,18 @@ public class ExtensionException extends RuntimeException {
super(message, cause, enableSuppression, writableStackTrace);
}
public static ExtensionException corrupt(String message, Throwable cause) {
try {
var loc = XPipeInstallation.getCurrentInstallationBasePath();
var full = message + ".\n\n" + "Please check whether the XPipe installation data at " + loc + " is corrupted.";
return new ExtensionException(full, cause);
} catch (Throwable t) {
var full = message + ".\n\n" + "Please check whether the XPipe installation data is corrupted.";
return new ExtensionException(full, cause);
}
}
public static ExtensionException corrupt(String message) {
return new ExtensionException(message + ". Is the installation data corrupt?");
return corrupt(message, null);
}
}

View file

@ -20,7 +20,7 @@ public class LocalStore extends JacksonizedValue
}
@Override
public ShellControl control() {
public ShellControl parentControl() {
var pc = ProcessControlProvider.get().createLocalProcessControl(true);
pc.withSourceStore(this);
pc.withShellStateInit(this);
@ -28,6 +28,11 @@ public class LocalStore extends JacksonizedValue
return pc;
}
@Override
public ShellControl control(ShellControl parent) {
return parent;
}
@Override
public DataStore getNetworkParent() {
return null;

View file

@ -3,6 +3,7 @@ package io.xpipe.app.ext;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.process.*;
import io.xpipe.core.store.DataStore;
import lombok.NonNull;
import java.util.ServiceLoader;
@ -22,6 +23,8 @@ public abstract class ProcessControlProvider {
return INSTANCE;
}
public abstract void reset();
public abstract ShellControl withDefaultScripts(ShellControl pc);
public abstract ShellControl sub(

View file

@ -31,11 +31,11 @@ public abstract class ScanProvider {
String nameKey;
boolean disabled;
boolean defaultSelected;
FailableRunnable<Exception> scanner;
FailableRunnable<Throwable> scanner;
String licenseFeatureId;
public ScanOperation(
String nameKey, boolean disabled, boolean defaultSelected, FailableRunnable<Exception> scanner) {
String nameKey, boolean disabled, boolean defaultSelected, FailableRunnable<Throwable> scanner) {
this.nameKey = nameKey;
this.disabled = disabled;
this.defaultSelected = defaultSelected;

View file

@ -4,6 +4,7 @@ import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.comp.store.*;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.storage.DataStorage;
@ -11,7 +12,6 @@ import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
import io.xpipe.core.store.DataStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.binding.Bindings;
@ -200,18 +200,10 @@ public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
button.apply(struc -> {
struc.get().setMaxWidth(2000);
struc.get().setAlignment(Pos.CENTER_LEFT);
Comp<?> graphic = new PrettySvgComp(
Comp<?> graphic = PrettyImageHelper.ofFixedSize(
Bindings.createStringBinding(
() -> {
if (selected.getValue() == null) {
return null;
}
return selected.getValue()
.get()
.getProvider()
.getDisplayIconFileName(
selected.getValue().getStore());
return selected.getValue().get().getEffectiveIconFile();
},
selected),
16,

View file

@ -46,7 +46,7 @@ public class DataStoreListChoiceComp<T extends DataStore> extends SimpleComp {
var label = new LabelComp(t.get().getName()).apply(struc -> struc.get()
.setGraphic(PrettyImageHelper.ofFixedSizeSquare(
t.get().getProvider().getDisplayIconFileName(t.getStore()), 16)
t.get().getEffectiveIconFile(), 16)
.createRegion()));
var delete = new IconButtonComp("mdal-delete_outline", () -> {
selectedList.remove(t);

View file

@ -3,6 +3,7 @@ package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.fxcomps.util.PlatformThread;
import javafx.beans.property.SimpleObjectProperty;
@ -16,23 +17,31 @@ import org.kordamp.ikonli.javafx.FontIcon;
public class IconButtonComp extends Comp<CompStructure<Button>> {
private final ObservableValue<String> icon;
private final ObservableValue<? extends LabelGraphic> icon;
private final Runnable listener;
public IconButtonComp(String defaultVal) {
this(new SimpleObjectProperty<>(new LabelGraphic.IconGraphic(defaultVal)), null);
}
public IconButtonComp(String defaultVal, Runnable listener) {
this(new SimpleObjectProperty<>(new LabelGraphic.IconGraphic(defaultVal)), listener);
}
public IconButtonComp(LabelGraphic defaultVal) {
this(new SimpleObjectProperty<>(defaultVal), null);
}
public IconButtonComp(ObservableValue<String> icon) {
public IconButtonComp(ObservableValue<? extends LabelGraphic> icon) {
this.icon = icon;
this.listener = null;
}
public IconButtonComp(String defaultVal, Runnable listener) {
public IconButtonComp(LabelGraphic defaultVal, Runnable listener) {
this(new SimpleObjectProperty<>(defaultVal), listener);
}
public IconButtonComp(ObservableValue<String> icon, Runnable listener) {
public IconButtonComp(ObservableValue<? extends LabelGraphic> icon, Runnable listener) {
this.icon = PlatformThread.sync(icon);
this.listener = listener;
}
@ -41,18 +50,17 @@ public class IconButtonComp extends Comp<CompStructure<Button>> {
public CompStructure<Button> createBase() {
var button = new Button();
button.getStyleClass().add(Styles.FLAT);
var fi = new FontIcon(icon.getValue());
fi.setFocusTraversable(false);
icon.addListener((c, o, n) -> {
fi.setIconLiteral(n);
icon.subscribe(labelGraphic -> {
button.setGraphic(labelGraphic.createGraphicNode());
if (button.getGraphic() instanceof FontIcon fi) {
fi.setIconSize((int) new Size(button.getFont().getSize(), SizeUnits.PT).pixels());
}
});
fi.setIconSize((int) new Size(fi.getFont().getSize(), SizeUnits.PT).pixels());
button.fontProperty().addListener((c, o, n) -> {
button.fontProperty().subscribe((n) -> {
if (button.getGraphic() instanceof FontIcon fi) {
fi.setIconSize((int) new Size(n.getSize(), SizeUnits.PT).pixels());
}
});
// fi.iconColorProperty().bind(button.textFillProperty());
button.setGraphic(fi);
if (listener != null) {
button.setOnAction(e -> {
listener.run();

View file

@ -1,10 +1,10 @@
package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppImages;
import io.xpipe.core.store.FileNames;
import javafx.beans.binding.Bindings;

View file

@ -1,55 +1,70 @@
package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.core.App;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.resources.AppImages;
import io.xpipe.core.store.FileNames;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import java.util.List;
import java.util.Optional;
public class PrettyImageHelper {
private static Optional<String> rasterizedImageIfExists(String img, int width, int height) {
private static Optional<String> rasterizedImageIfExists(String img, int height) {
if (img != null && img.endsWith(".svg")) {
var base = FileNames.getBaseName(img);
var renderedName = base + "-" + height + ".png";
if (AppImages.hasNormalImage(base + "-" + height + ".png")) {
if (AppImages.hasNormalImage(renderedName)) {
return Optional.of(renderedName);
}
}
if (img != null && img.endsWith(".png")) {
if (AppImages.hasNormalImage(img)) {
return Optional.of(img);
}
}
return Optional.empty();
}
private static ObservableValue<String> rasterizedImageIfExistsScaled(String img, int height) {
return Bindings.createStringBinding(
() -> {
if (img == null) {
return null;
}
if (!img.endsWith(".svg")) {
return rasterizedImageIfExists(img, height).orElse(null);
}
var sizes = List.of(16, 24, 40, 80);
var mult = Math.round(App.getApp().displayScale().get() * height);
var base = FileNames.getBaseName(img);
var available = sizes.stream()
.filter(integer -> AppImages.hasNormalImage(base + "-" + integer + ".png"))
.toList();
var closest = available.stream()
.filter(integer -> integer >= mult)
.findFirst()
.orElse(available.size() > 0 ? available.getLast() : 0);
return rasterizedImageIfExists(img, closest).orElse(null);
},
App.getApp().displayScale());
}
public static Comp<?> ofFixedSizeSquare(String img, int size) {
return ofFixedSize(img, size, size);
}
public static Comp<?> ofFixedRasterized(String img, int w, int h) {
if (img == null) {
return new PrettyImageComp(new SimpleStringProperty(null), w, h);
}
var rasterized = rasterizedImageIfExists(img, w, h);
return new PrettyImageComp(new SimpleStringProperty(rasterized.orElse(null)), w, h);
}
public static Comp<?> ofFixedSize(String img, int w, int h) {
if (img == null) {
return new PrettyImageComp(new SimpleStringProperty(null), w, h);
}
var rasterized = rasterizedImageIfExists(img, w, h);
if (rasterized.isPresent()) {
return new PrettyImageComp(new SimpleStringProperty(rasterized.get()), w, h);
} else {
return img.endsWith(".svg")
? new PrettySvgComp(new SimpleStringProperty(img), w, h)
: new PrettyImageComp(new SimpleStringProperty(img), w, h);
}
return ofFixedSize(new SimpleStringProperty(img), w, h);
}
public static Comp<?> ofFixedSize(ObservableValue<String> img, int w, int h) {
@ -57,8 +72,8 @@ public class PrettyImageHelper {
return new PrettyImageComp(new SimpleStringProperty(null), w, h);
}
var binding = BindingsHelper.map(img, s -> {
return rasterizedImageIfExists(s, w, h).orElse(s);
var binding = BindingsHelper.flatMap(img, s -> {
return rasterizedImageIfExistsScaled(s, h);
});
return new PrettyImageComp(binding, w, h);
}

View file

@ -1,9 +1,9 @@
package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppImages;
import io.xpipe.core.store.FileNames;
import javafx.beans.binding.Bindings;

View file

@ -12,11 +12,11 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
import io.xpipe.app.fxcomps.util.DerivedObservableList;
import io.xpipe.app.fxcomps.util.LabelGraphic;
import io.xpipe.app.storage.DataColor;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreCategory;
import io.xpipe.app.util.ContextMenuHelper;
import io.xpipe.app.util.DataStoreFormatter;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleBooleanProperty;
@ -57,11 +57,11 @@ public class StoreCategoryComp extends SimpleComp {
.createRegion();
var showing = new SimpleBooleanProperty();
var expandIcon = Bindings.createStringBinding(
var expandIcon = Bindings.createObjectBinding(
() -> {
var exp = category.getExpanded().get()
&& category.getChildren().size() > 0;
return exp ? "mdal-keyboard_arrow_down" : "mdal-keyboard_arrow_right";
return new LabelGraphic.IconGraphic(exp ? "mdal-keyboard_arrow_down" : "mdal-keyboard_arrow_right");
},
category.getExpanded(),
category.getChildren());
@ -78,18 +78,18 @@ public class StoreCategoryComp extends SimpleComp {
.tooltipKey("expand", new KeyCodeCombination(KeyCode.SPACE));
var hover = new SimpleBooleanProperty();
var statusIcon = Bindings.createStringBinding(
var statusIcon = Bindings.createObjectBinding(
() -> {
if (hover.get()) {
return "mdomz-settings";
return new LabelGraphic.IconGraphic("mdomz-settings");
}
if (!DataStorage.get().supportsSharing()
|| !category.getCategory().canShare()) {
return "mdi2g-git";
return new LabelGraphic.IconGraphic("mdi2g-git");
}
return category.getSync().getValue() ? "mdi2g-git" : "mdi2c-cancel";
return new LabelGraphic.IconGraphic(category.getSync().getValue() ? "mdi2g-git" : "mdi2c-cancel");
},
category.getSync(),
hover);
@ -196,14 +196,16 @@ public class StoreCategoryComp extends SimpleComp {
contextMenu.getItems().add(new SeparatorMenuItem());
var color = new Menu(AppI18n.get("color"), new FontIcon("mdi2f-format-color-fill"));
var none = new MenuItem("None");
var none = new MenuItem();
none.textProperty().bind(AppI18n.observable("none"));
none.setOnAction(event -> {
category.getCategory().setColor(null);
event.consume();
});
color.getItems().add(none);
Arrays.stream(DataColor.values()).forEach(dataStoreColor -> {
MenuItem m = new MenuItem(DataStoreFormatter.capitalize(dataStoreColor.getId()));
MenuItem m = new MenuItem();
m.textProperty().bind(AppI18n.observable(dataStoreColor.getId()));
m.setOnAction(event -> {
category.getCategory().setColor(dataStoreColor);
event.consume();

View file

@ -5,6 +5,26 @@ import io.xpipe.app.util.Hyperlinks;
public interface ErrorAction {
static ErrorAction openDocumentation(String link) {
return new ErrorAction() {
@Override
public String getName() {
return AppI18n.get("openDocumentation");
}
@Override
public String getDescription() {
return AppI18n.get("openDocumentationDescription");
}
@Override
public boolean handle(ErrorEvent event) {
Hyperlinks.open(link);
return false;
}
};
}
static ErrorAction reportOnGithub() {
return new ErrorAction() {
@Override

View file

@ -254,14 +254,19 @@ public class ErrorHandlerComp extends SimpleComp {
actionBox.getChildren().add(ac);
}
if (!event.isDisableDefaultActions() || event.getCustomActions().isEmpty()) {
if (!event.isDisableDefaultActions()) {
for (var action :
List.of(ErrorAction.automaticallyReport(), ErrorAction.reportOnGithub(), ErrorAction.ignore())) {
var ac = createActionComp(action);
actionBox.getChildren().add(ac);
}
actionBox.getChildren().get(1).getStyleClass().addAll(BUTTON_OUTLINED, ACCENT);
} else if (event.getCustomActions().isEmpty()) {
for (var action : List.of(ErrorAction.ignore())) {
var ac = createActionComp(action);
actionBox.getChildren().add(ac);
}
}
actionBox.getChildren().get(1).getStyleClass().addAll(BUTTON_OUTLINED, ACCENT);
content.getChildren().addAll(actionBox);
content.getStyleClass().add("top");

View file

@ -8,6 +8,7 @@ import io.xpipe.app.core.*;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.resources.AppResources;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;

View file

@ -112,17 +112,21 @@ public class LauncherCommand implements Callable<Integer> {
}
try {
client.get().performRequest(DaemonFocusExchange.Request.builder()
client.get()
.performRequest(DaemonFocusExchange.Request.builder()
.mode(getEffectiveMode())
.build());
if (!inputs.isEmpty()) {
client.get().performRequest(DaemonOpenExchange.Request.builder()
client.get()
.performRequest(DaemonOpenExchange.Request.builder()
.arguments(inputs)
.build());
}
} catch (Exception ex) {
// Wait until shutdown has completed
if (ex.getMessage() != null && ex.getMessage().contains("Daemon is currently in shutdown") && attemptCounter < 10) {
if (ex.getMessage() != null
&& ex.getMessage().contains("Daemon is currently in shutdown")
&& attemptCounter < 10) {
ThreadHelper.sleep(1000);
checkStart(++attemptCounter);
return;

View file

@ -115,7 +115,7 @@ public class AboutCategory extends AppPrefsCategory {
AppI18n.observable("xPipeClient"),
new SimpleStringProperty("Version " + AppProperties.get().getVersion() + " ("
+ AppProperties.get().getArch() + ")"),
"logo.png");
"logo/logo.png");
});
if (OsType.getLocal() != OsType.MACOS) {

View file

@ -1,9 +1,6 @@
package io.xpipe.app.prefs;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppTheme;
import io.xpipe.app.core.*;
import io.xpipe.app.ext.PrefsHandler;
import io.xpipe.app.ext.PrefsProvider;
import io.xpipe.app.fxcomps.Comp;
@ -11,6 +8,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.PasswordLockSecretValue;
import io.xpipe.core.util.InPlaceSecretValue;
import io.xpipe.core.util.ModuleHelper;
@ -38,14 +36,17 @@ public class AppPrefs {
private static AppPrefs INSTANCE;
private final List<Mapping<?>> mapping = new ArrayList<>();
final BooleanProperty dontAllowTerminalRestart =
mapVaultSpecific(new SimpleBooleanProperty(false), "dontAllowTerminalRestart", Boolean.class);
final BooleanProperty enableHttpApi =
mapVaultSpecific(new SimpleBooleanProperty(false), "enableHttpApi", Boolean.class);
final BooleanProperty dontAutomaticallyStartVmSshServer =
mapVaultSpecific(new SimpleBooleanProperty(false), "dontAutomaticallyStartVmSshServer", Boolean.class);
final BooleanProperty dontAcceptNewHostKeys =
mapVaultSpecific(new SimpleBooleanProperty(false), "dontAcceptNewHostKeys", Boolean.class);
final BooleanProperty performanceMode = map(new SimpleBooleanProperty(false), "performanceMode", Boolean.class);
public final BooleanProperty useBundledTools = map(new SimpleBooleanProperty(false), "useBundledTools", Boolean.class);
public final BooleanProperty performanceMode = map(new SimpleBooleanProperty(), "performanceMode", Boolean.class);
public final BooleanProperty useBundledTools =
map(new SimpleBooleanProperty(false), "useBundledTools", Boolean.class);
public final ObjectProperty<AppTheme.Theme> theme =
map(new SimpleObjectProperty<>(), "theme", AppTheme.Theme.class);
final BooleanProperty useSystemFont = map(new SimpleBooleanProperty(true), "useSystemFont", Boolean.class);
@ -75,6 +76,8 @@ public class AppPrefs {
mapVaultSpecific(new SimpleBooleanProperty(false), "dontCachePasswords", Boolean.class);
public final BooleanProperty denyTempScriptCreation =
mapVaultSpecific(new SimpleBooleanProperty(false), "denyTempScriptCreation", Boolean.class);
final Property<ExternalPasswordManager> passwordManager =
mapVaultSpecific(new SimpleObjectProperty<>(), "passwordManager", ExternalPasswordManager.class);
final StringProperty passwordManagerCommand =
map(new SimpleStringProperty(""), "passwordManagerCommand", String.class);
final ObjectProperty<StartupBehaviour> startupBehaviour =
@ -104,6 +107,8 @@ public class AppPrefs {
map(new SimpleBooleanProperty(true), "openConnectionSearchWindowOnConnectionCreation", Boolean.class);
final ObjectProperty<Path> storageDirectory =
map(new SimpleObjectProperty<>(DEFAULT_STORAGE_DIR), "storageDirectory", Path.class);
final BooleanProperty confirmAllDeletions =
map(new SimpleBooleanProperty(false), "confirmAllDeletions", Boolean.class);
final BooleanProperty developerMode = map(new SimpleBooleanProperty(false), "developerMode", Boolean.class);
final BooleanProperty developerDisableUpdateVersionCheck =
map(new SimpleBooleanProperty(false), "developerDisableUpdateVersionCheck", Boolean.class);
@ -150,6 +155,10 @@ public class AppPrefs {
return enableHttpApi;
}
public ObservableBooleanValue dontAllowTerminalRestart() {
return dontAllowTerminalRestart;
}
private final IntegerProperty editorReloadTimeout =
map(new SimpleIntegerProperty(1000), "editorReloadTimeout", Integer.class);
private final BooleanProperty confirmDeletions =
@ -253,6 +262,10 @@ public class AppPrefs {
developerMode());
}
public ObservableValue<ExternalPasswordManager> externalPasswordManager() {
return passwordManager;
}
public ObservableValue<SupportedLocale> language() {
return language;
}
@ -476,6 +489,9 @@ public class AppPrefs {
if (rdpClientType.get() == null) {
rdpClientType.setValue(ExternalRdpClientType.determineDefault());
}
if (AppState.get().isInitialLaunch()) {
performanceMode.setValue(XPipeDistributionType.get() == XPipeDistributionType.WEBTOP);
}
}
public Comp<?> getCustomComp(String id) {

View file

@ -75,7 +75,7 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
public boolean isAvailable() {
try (ShellControl pc = LocalShell.getShell()) {
return pc.executeSimpleBooleanCommand(pc.getShellDialect().getWhichCommand(executable));
return CommandSupport.findProgram(pc, executable).isPresent();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
return false;
@ -115,14 +115,9 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
protected Optional<Path> determineFromPath() {
// Try to locate if it is in the Path
try (var sc = LocalShell.getShell().start()) {
var out = sc.command(CommandBuilder.ofFunction(
var1 -> var1.getShellDialect().getWhichCommand(executable)))
.readStdoutIfPossible();
var out = CommandSupport.findProgram(sc, executable);
if (out.isPresent()) {
var first = out.get().lines().findFirst();
if (first.isPresent()) {
return first.map(String::trim).map(Path::of);
}
return out.map(Path::of);
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().handle();

View file

@ -79,7 +79,10 @@ public interface ExternalEditorType extends PrefsChoiceValue {
LinuxPathType VSCODE_LINUX = new LinuxPathType("app.vscode", "code") {
@Override
public void launch(Path file) throws Exception {
var builder = CommandBuilder.of().fixedEnvrironment("DONT_PROMPT_WSL_INSTALL", "No_Prompt_please").addFile(executable).addFile(file.toString());
var builder = CommandBuilder.of()
.fixedEnvrironment("DONT_PROMPT_WSL_INSTALL", "No_Prompt_please")
.addFile(executable)
.addFile(file.toString());
ExternalApplicationHelper.startAsync(builder);
}
};

View file

@ -1,6 +1,9 @@
package io.xpipe.app.prefs;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.LocalShell;
import io.xpipe.core.process.OsType;
import java.util.List;
@ -8,74 +11,123 @@ import java.util.stream.Stream;
public interface ExternalPasswordManager extends PrefsChoiceValue {
String getTemplate();
String retrievePassword(String key);
ExternalPasswordManager COMMAND = new ExternalPasswordManager() {
ExternalPasswordManager BITWARDEN = new ExternalPasswordManager() {
@Override
public String getTemplate() {
return "bw get password $KEY --nointeraction --raw";
public String retrievePassword(String key) {
var cmd = AppPrefs.get().passwordManagerString(key);
if (cmd == null) {
return null;
}
try (var cc = ProcessControlProvider.get().createLocalProcessControl(true).command(cmd).start()) {
var out = cc.readStdoutOrThrow();
// Dashlane fixes
var rawCmd = AppPrefs.get().passwordManagerCommand.get();
if (rawCmd.contains("dcli")) {
out = out.lines().findFirst().map(s -> s.trim().replaceAll("\\s+$", "")).orElse(null);
}
return out;
} catch (Exception ex) {
ErrorEvent.fromThrowable("Unable to retrieve password with command " + cmd, ex)
.expected()
.handle();
return null;
}
}
@Override
public String getId() {
return "bitwarden";
return "command";
}
};
ExternalPasswordManager ONEPASSWORD = new ExternalPasswordManager() {
ExternalPasswordManager WINDOWS_CREDENTIAL_MANAGER = new ExternalPasswordManager() {
private boolean loaded = false;
@Override
public String getTemplate() {
return "op read $KEY --force";
public synchronized String retrievePassword(String key) {
try {
if (!loaded) {
loaded = true;
var cmd =
"""
$code = @"
using System.Text;
using System;
using System.Runtime.InteropServices;
namespace CredManager {
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CredentialMem
{
public int flags;
public int type;
public string targetName;
public string comment;
public System.Runtime.InteropServices.ComTypes.FILETIME lastWritten;
public int credentialBlobSize;
public IntPtr credentialBlob;
public int persist;
public int attributeCount;
public IntPtr credAttribute;
public string targetAlias;
public string userName;
}
public class Credential {
[DllImport("advapi32.dll", EntryPoint = "CredReadW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool CredRead(string target, int type, int reservedFlag, out IntPtr credentialPtr);
public static string GetUserPassword(string target)
{
CredentialMem credMem;
IntPtr credPtr;
if (CredRead(target, 1, 0, out credPtr))
{
credMem = Marshal.PtrToStructure<CredentialMem>(credPtr);
byte[] passwordBytes = new byte[credMem.credentialBlobSize];
Marshal.Copy(credMem.credentialBlob, passwordBytes, 0, credMem.credentialBlobSize);
return Encoding.Unicode.GetString(passwordBytes);
} else {
throw new Exception("No credentials found for target: " + target);
}
}
}
}
"@
Add-Type -TypeDefinition $code -Language CSharp
""";
LocalShell.getLocalPowershell().command(cmd).execute();
}
return LocalShell.getLocalPowershell()
.command("[CredManager.Credential]::GetUserPassword(\"" + key.replaceAll("\"", "`\"") + "\")")
.readStdoutOrThrow();
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().handle();
return null;
}
}
@Override
public String getId() {
return "1password";
}
};
ExternalPasswordManager DASHLANE = new ExternalPasswordManager() {
@Override
public String getTemplate() {
return "dcli password --output console $KEY";
}
@Override
public String getId() {
return "dashlane";
}
};
ExternalPasswordManager LASTPASS = new ExternalPasswordManager() {
@Override
public String getTemplate() {
return "lpass show --password $KEY";
}
@Override
public String getId() {
return "lastpass";
}
};
ExternalPasswordManager MACOS_KEYCHAIN = new ExternalPasswordManager() {
@Override
public String getTemplate() {
return "security find-generic-password -w -l $KEY";
}
@Override
public String getId() {
return "macosKeychain";
return "windowsCredentialManager";
}
@Override
public boolean isSelectable() {
return OsType.getLocal() == OsType.MACOS;
return OsType.getLocal() == OsType.WINDOWS;
}
};
List<ExternalPasswordManager> ALL = Stream.of(ONEPASSWORD, BITWARDEN, DASHLANE, LASTPASS, MACOS_KEYCHAIN)
List<ExternalPasswordManager> ALL = Stream.of(COMMAND, WINDOWS_CREDENTIAL_MANAGER)
.filter(externalPasswordManager -> externalPasswordManager.isSelectable())
.toList();
}

Some files were not shown because too many files have changed in this diff Show more