mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Dock rework
This commit is contained in:
parent
19b341d848
commit
c32f1fbaf7
5433 changed files with 53130 additions and 1874 deletions
|
@ -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.
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
return Response.builder().build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import io.xpipe.app.util.TerminalLauncherManager;
|
||||
import io.xpipe.app.util.TerminalView;
|
||||
import io.xpipe.beacon.BeaconClientException;
|
||||
import io.xpipe.beacon.BeaconServerException;
|
||||
import io.xpipe.beacon.api.TerminalWaitExchange;
|
||||
|
@ -10,7 +11,8 @@ 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());
|
||||
TerminalView.get().open(msg.getPid());
|
||||
return Response.builder().build();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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())),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,9 +194,9 @@ public final class BrowserFileListComp extends SimpleComp {
|
|||
? unix.getGroup()
|
||||
: m.getCache().getGroups().getOrDefault(unix.getGid(), "?");
|
||||
var uid = String.valueOf(
|
||||
unix.getUid() != null ? unix.getUid() : m.getCache().getUidForUser(user));
|
||||
unix.getUid() != null ? unix.getUid() : m.getCache().getUidForUser(user));
|
||||
var gid = String.valueOf(
|
||||
unix.getGid() != null ? unix.getGid() : m.getCache().getGidForGroup(group));
|
||||
unix.getGid() != null ? unix.getGid() : m.getCache().getGidForGroup(group));
|
||||
if (uid.equals(gid) && user.equals(group)) {
|
||||
return user + " [" + uid + "]";
|
||||
}
|
||||
|
@ -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()
|
||||
|
|
|
@ -102,7 +102,7 @@ public class BrowserFileTransferOperation {
|
|||
|
||||
public void execute() throws Exception {
|
||||
if (files.isEmpty()) {
|
||||
updateProgress(BrowserTransferProgress.empty());
|
||||
updateProgress(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,18 +115,22 @@ public class BrowserFileTransferOperation {
|
|||
}
|
||||
}
|
||||
|
||||
for (var file : files) {
|
||||
if (same) {
|
||||
handleSingleOnSameFileSystem(file);
|
||||
} else {
|
||||
handleSingleAcrossFileSystems(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!same && doesMove) {
|
||||
try {
|
||||
for (var file : files) {
|
||||
deleteSingle(file);
|
||||
if (same) {
|
||||
handleSingleOnSameFileSystem(file);
|
||||
} else {
|
||||
handleSingleAcrossFileSystems(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!same && doesMove) {
|
||||
for (var file : files) {
|
||||
deleteSingle(file);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
updateProgress(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 -> {
|
||||
return comp;
|
||||
},
|
||||
false,
|
||||
null);
|
||||
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;
|
||||
});
|
||||
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,60 +152,33 @@ public class BrowserChooserComp extends SimpleComp {
|
|||
struc.getLeft().setMinWidth(200);
|
||||
struc.getLeft().setMaxWidth(500);
|
||||
});
|
||||
return splitPane;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comp<?> bottom() {
|
||||
return Comp.of(() -> {
|
||||
var selected = new HBox();
|
||||
selected.setAlignment(Pos.CENTER_LEFT);
|
||||
model.getFileSelection().addListener((ListChangeListener<? super BrowserEntry>) c -> {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
selected.getChildren()
|
||||
.setAll(c.getList().stream()
|
||||
.map(s -> {
|
||||
var field = new TextField(
|
||||
s.getRawFileEntry().getPath());
|
||||
field.setEditable(false);
|
||||
field.getStyleClass().add("chooser-selection");
|
||||
HBox.setHgrow(field, Priority.ALWAYS);
|
||||
return field;
|
||||
})
|
||||
.toList());
|
||||
});
|
||||
});
|
||||
var bottomBar = new HBox(selected);
|
||||
HBox.setHgrow(selected, Priority.ALWAYS);
|
||||
bottomBar.setAlignment(Pos.CENTER);
|
||||
return bottomBar;
|
||||
@Override
|
||||
public Comp<?> bottom() {
|
||||
return Comp.of(() -> {
|
||||
var selected = new HBox();
|
||||
selected.setAlignment(Pos.CENTER_LEFT);
|
||||
model.getFileSelection().addListener((ListChangeListener<? super BrowserEntry>) c -> {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
selected.getChildren()
|
||||
.setAll(c.getList().stream()
|
||||
.map(s -> {
|
||||
var field = new TextField(
|
||||
s.getRawFileEntry().getPath());
|
||||
field.setEditable(false);
|
||||
field.getStyleClass().add("chooser-selection");
|
||||
HBox.setHgrow(field, Priority.ALWAYS);
|
||||
return field;
|
||||
})
|
||||
.toList());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var r = dialogPane.createRegion();
|
||||
r.getStyleClass().add("browser");
|
||||
r.getStyleClass().add("chooser");
|
||||
return r;
|
||||
});
|
||||
var bottomBar = new HBox(selected);
|
||||
HBox.setHgrow(selected, Priority.ALWAYS);
|
||||
bottomBar.setAlignment(Pos.CENTER);
|
||||
return bottomBar;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.xpipe.app.fxcomps.SimpleCompStructure;
|
|||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
|
||||
import io.xpipe.app.util.TerminalView;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.Parent;
|
||||
|
@ -49,14 +50,16 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
|
|||
var sidebarR = sidebar.createRegion();
|
||||
pane.setRight(sidebarR);
|
||||
model.getSelected().addListener((c, o, n) -> {
|
||||
if (o != null && o.equals(model.getEntries().get(2))) {
|
||||
if (o != null && o.equals(model.getEntries().get(3))) {
|
||||
AppPrefs.get().save();
|
||||
DataStorage.get().saveAsync();
|
||||
}
|
||||
|
||||
if (o != null && o.equals(model.getEntries().get(1))) {
|
||||
if (o != null && o.equals(model.getEntries().get(0))) {
|
||||
StoreViewState.get().updateDisplay();
|
||||
}
|
||||
|
||||
TerminalView.get().toggleView(model.getEntries().get(2).equals(n));
|
||||
});
|
||||
pane.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
|
||||
sidebarR.getChildrenUnmodifiable().forEach(node -> {
|
||||
|
@ -64,7 +67,6 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
|
|||
if (shortcut != null && shortcut.match(event)) {
|
||||
((ButtonBase) ((Parent) node).getChildrenUnmodifiable().get(1)).fire();
|
||||
event.consume();
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package io.xpipe.app.comp.base;
|
||||
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.core.window.AppMainWindow;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import io.xpipe.app.util.TerminalView;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.WindowEvent;
|
||||
|
||||
public class TerminalViewDockComp extends SimpleComp {
|
||||
|
||||
@Override
|
||||
protected Region createSimple() {
|
||||
var label = new Label();
|
||||
label.textProperty().bind(AppI18n.observable("clickToDock"));
|
||||
var stack = new StackPane(label);
|
||||
stack.setAlignment(Pos.CENTER);
|
||||
stack.setCursor(Cursor.HAND);
|
||||
stack.boundsInParentProperty().addListener((observable, oldValue, newValue) -> {
|
||||
update(stack);
|
||||
});
|
||||
var s = AppMainWindow.getInstance().getStage();
|
||||
s.xProperty().addListener((observable, oldValue, newValue) -> {
|
||||
update(stack);
|
||||
});
|
||||
s.yProperty().addListener((observable, oldValue, newValue) -> {
|
||||
update(stack);
|
||||
});
|
||||
s.widthProperty().addListener((observable, oldValue, newValue) -> {
|
||||
update(stack);
|
||||
});
|
||||
s.heightProperty().addListener((observable, oldValue, newValue) -> {
|
||||
update(stack);
|
||||
});
|
||||
s.iconifiedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
TerminalView.get().onMinimize();
|
||||
} else {
|
||||
TerminalView.get().onFocusGain();
|
||||
}
|
||||
});
|
||||
s.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
TerminalView.get().onFocusGain();
|
||||
} else {
|
||||
TerminalView.get().onFocusLost();
|
||||
}
|
||||
});
|
||||
s.addEventFilter(WindowEvent.WINDOW_HIDDEN,event -> {
|
||||
TerminalView.get().onClose();
|
||||
});
|
||||
stack.setOnMouseClicked(event -> {
|
||||
TerminalView.get().clickView();
|
||||
event.consume();
|
||||
});
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void update(Region region) {
|
||||
var bounds = region.localToScreen(region.getBoundsInLocal());
|
||||
TerminalView.get().resizeView((int) bounds.getMinX(), (int) bounds.getMinY(),(int) bounds.getWidth(), (int) bounds.getHeight());
|
||||
}
|
||||
}
|
|
@ -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(() -> {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,12 +245,14 @@ 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 -> {
|
||||
var menu = buildMenuItemForAction(childProvider);
|
||||
if (menu != null) {
|
||||
cm.getItems().add(menu);
|
||||
}
|
||||
});
|
||||
branch.getChildren(getWrapper().getEntry().ref()).stream()
|
||||
.filter(actionProvider -> getWrapper().showActionProvider(actionProvider))
|
||||
.forEach(childProvider -> {
|
||||
var menu = buildMenuItemForAction(childProvider);
|
||||
if (menu != null) {
|
||||
cm.getItems().add(menu);
|
||||
}
|
||||
});
|
||||
return cm;
|
||||
}));
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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, () -> {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
64
app/src/main/java/io/xpipe/app/comp/store/StoreIconComp.java
Normal file
64
app/src/main/java/io/xpipe/app/comp/store/StoreIconComp.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -96,6 +96,9 @@ public class StoreNotesComp extends Comp<StoreNotesComp.Structure> {
|
|||
ref.get().hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void discard() {}
|
||||
|
||||
@Override
|
||||
protected String finishKey() {
|
||||
return "apply";
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
? "mdal-keyboard_arrow_down"
|
||||
: "mdal-keyboard_arrow_right",
|
||||
Bindings.createObjectBinding(
|
||||
() -> new LabelGraphic.IconGraphic(
|
||||
section.getWrapper().getExpanded().get()
|
||||
&& section.getShownChildren()
|
||||
.getList()
|
||||
.size()
|
||||
> 0
|
||||
? "mdal-keyboard_arrow_down"
|
||||
: "mdal-keyboard_arrow_right"),
|
||||
section.getWrapper().getExpanded(),
|
||||
section.getShownChildren().getList()),
|
||||
() -> {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -98,10 +98,11 @@ 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()
|
||||
.anyMatch(wrapper -> wrapper.matchesFilter(newValue)))
|
||||
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) {
|
||||
activeCategory.setValue(matchingCats.getFirst());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,14 +3,17 @@ package io.xpipe.app.core;
|
|||
import io.xpipe.app.beacon.AppBeaconServer;
|
||||
import io.xpipe.app.browser.session.BrowserSessionComp;
|
||||
import io.xpipe.app.browser.session.BrowserSessionModel;
|
||||
import io.xpipe.app.comp.base.TerminalViewDockComp;
|
||||
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 +24,7 @@ import lombok.Data;
|
|||
import lombok.Getter;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.time.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -38,7 +42,7 @@ public class AppLayoutModel {
|
|||
public AppLayoutModel(SavedState savedState) {
|
||||
this.savedState = savedState;
|
||||
this.entries = createEntryList();
|
||||
this.selected = new SimpleObjectProperty<>(entries.get(1));
|
||||
this.selected = new SimpleObjectProperty<>(entries.get(0));
|
||||
}
|
||||
|
||||
public static AppLayoutModel get() {
|
||||
|
@ -56,66 +60,100 @@ public class AppLayoutModel {
|
|||
}
|
||||
|
||||
public void selectBrowser() {
|
||||
selected.setValue(entries.getFirst());
|
||||
selected.setValue(entries.get(1));
|
||||
}
|
||||
|
||||
public void selectSettings() {
|
||||
public void selectTerminal() {
|
||||
selected.setValue(entries.get(2));
|
||||
}
|
||||
|
||||
public void selectLicense() {
|
||||
public void selectSettings() {
|
||||
selected.setValue(entries.get(3));
|
||||
}
|
||||
|
||||
public void selectLicense() {
|
||||
selected.setValue(entries.get(4));
|
||||
}
|
||||
|
||||
public void selectConnections() {
|
||||
selected.setValue(entries.get(1));
|
||||
selected.setValue(entries.get(0));
|
||||
}
|
||||
|
||||
private List<Entry> createEntryList() {
|
||||
var l = new ArrayList<>(List.of(
|
||||
new Entry(
|
||||
AppI18n.observable("browser"),
|
||||
"mdi2f-file-cabinet",
|
||||
new BrowserSessionComp(BrowserSessionModel.DEFAULT),
|
||||
AppI18n.observable("connections"),
|
||||
new LabelGraphic.IconGraphic("mdi2c-connection"),
|
||||
new StoreLayoutComp(),
|
||||
null,
|
||||
new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)),
|
||||
new Entry(
|
||||
AppI18n.observable("connections"),
|
||||
"mdi2c-connection",
|
||||
new StoreLayoutComp(),
|
||||
AppI18n.observable("browser"),
|
||||
new LabelGraphic.IconGraphic("mdi2f-file-cabinet"),
|
||||
new BrowserSessionComp(BrowserSessionModel.DEFAULT),
|
||||
null,
|
||||
new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN)),
|
||||
new Entry(
|
||||
AppI18n.observable("terminal"),
|
||||
new LabelGraphic.IconGraphic("mdi2m-monitor-screenshot"),
|
||||
new TerminalViewDockComp(),
|
||||
null,
|
||||
new KeyCodeCombination(KeyCode.DIGIT3, 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 +167,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) {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
22
app/src/main/java/io/xpipe/app/core/check/AppGpuCheck.java
Normal file
22
app/src/main/java/io/xpipe/app/core/check/AppGpuCheck.java
Normal 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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -25,8 +25,11 @@ 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.");
|
||||
+ " There is a native build available that comes with much better performance."
|
||||
+ " Please install that one instead.")
|
||||
.noDefaultActions()
|
||||
.expected()
|
||||
.handle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,12 +60,14 @@ public class BaseMode extends OperationMode {
|
|||
DataStorageSyncHandler.getInstance().retrieveSyncedData();
|
||||
AppPrefs.initSharedRemote();
|
||||
UnlockAlert.showIfNeeded();
|
||||
SystemIcons.init();
|
||||
DataStorage.init();
|
||||
DataStoreProviders.init();
|
||||
AppFileWatcher.init();
|
||||
FileBridge.init();
|
||||
BlobManager.init();
|
||||
ActionProvider.initProviders();
|
||||
TerminalView.init();
|
||||
TrackEvent.info("Finished base components initialization");
|
||||
initialized = true;
|
||||
}
|
||||
|
@ -70,7 +76,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 +84,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");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,17 +295,27 @@ public abstract class OperationMode {
|
|||
|
||||
inShutdown = true;
|
||||
OperationMode.inShutdownHook = inShutdownHook;
|
||||
try {
|
||||
if (CURRENT != null) {
|
||||
CURRENT.finalTeardown();
|
||||
// Keep a non-daemon thread running
|
||||
var thread = ThreadHelper.createPlatformThread("shutdown", false, () -> {
|
||||
try {
|
||||
if (CURRENT != null) {
|
||||
CURRENT.finalTeardown();
|
||||
}
|
||||
CURRENT = null;
|
||||
} catch (Throwable t) {
|
||||
ErrorEvent.fromThrowable(t).term().handle();
|
||||
OperationMode.halt(1);
|
||||
}
|
||||
CURRENT = null;
|
||||
} catch (Throwable t) {
|
||||
ErrorEvent.fromThrowable(t).term().handle();
|
||||
|
||||
OperationMode.halt(hasError ? 1 : 0);
|
||||
});
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException ignored) {
|
||||
OperationMode.halt(1);
|
||||
}
|
||||
|
||||
OperationMode.halt(hasError ? 1 : 0);
|
||||
}
|
||||
|
||||
// public static synchronized void reload() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
@ -262,6 +264,9 @@ public class AppMainWindow {
|
|||
|
||||
public void show() {
|
||||
stage.show();
|
||||
if (OsType.getLocal() == OsType.WINDOWS) {
|
||||
NativeWinWindowControl.MAIN_WINDOW = new NativeWinWindowControl(stage);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupContent(Comp<?> content) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.xpipe.app.core.window;
|
||||
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import io.xpipe.app.util.Rect;
|
||||
import javafx.stage.Window;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
|
@ -13,10 +15,29 @@ import lombok.Getter;
|
|||
import lombok.SneakyThrows;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@Getter
|
||||
public class NativeWinWindowControl {
|
||||
|
||||
public static Optional<NativeWinWindowControl> byPid(long pid) {
|
||||
var ref = new AtomicReference<NativeWinWindowControl>();
|
||||
User32.INSTANCE.EnumWindows((hWnd, data) -> {
|
||||
var wpid = new IntByReference();
|
||||
User32.INSTANCE.GetWindowThreadProcessId(hWnd, wpid);
|
||||
if (wpid.getValue() == pid) {
|
||||
ref.set(new NativeWinWindowControl(hWnd));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}, null);
|
||||
return Optional.ofNullable(ref.get());
|
||||
}
|
||||
|
||||
public static NativeWinWindowControl MAIN_WINDOW;
|
||||
|
||||
private final WinDef.HWND windowHandle;
|
||||
|
||||
@SneakyThrows
|
||||
|
@ -38,8 +59,28 @@ public class NativeWinWindowControl {
|
|||
this.windowHandle = windowHandle;
|
||||
}
|
||||
|
||||
public void move(int x, int y, int w, int h) {
|
||||
User32.INSTANCE.SetWindowPos(windowHandle, new WinDef.HWND(), x, y, w, h, 0);
|
||||
public void alwaysInFront() {
|
||||
orderRelative(new WinDef.HWND(new Pointer( 0xFFFFFFFFFFFFFFFFL)));
|
||||
}
|
||||
|
||||
public void orderRelative(WinDef.HWND predecessor) {
|
||||
User32.INSTANCE.SetWindowPos(windowHandle, predecessor, 0, 0, 0, 0, User32.SWP_NOACTIVATE | User32.SWP_NOMOVE | User32.SWP_NOSIZE);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
User32.INSTANCE.ShowWindow(windowHandle,User32.SW_RESTORE);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
User32.INSTANCE.CloseWindow(windowHandle);
|
||||
}
|
||||
|
||||
public void minimize() {
|
||||
User32.INSTANCE.ShowWindow(windowHandle,User32.SW_MINIMIZE);
|
||||
}
|
||||
|
||||
public void move(Rect bounds) {
|
||||
User32.INSTANCE.SetWindowPos(windowHandle, null, bounds.getX(), bounds.getY(), bounds.getW(), bounds.getH(), User32.SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
public boolean setWindowAttribute(int attribute, boolean attributeValue) {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package io.xpipe.app.ext;
|
||||
|
||||
public interface ContainerImageStore {
|
||||
|
||||
String getImageName();
|
||||
}
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) -> {
|
||||
fi.setIconSize((int) new Size(n.getSize(), SizeUnits.PT).pixels());
|
||||
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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -112,17 +112,21 @@ public class LauncherCommand implements Callable<Integer> {
|
|||
}
|
||||
|
||||
try {
|
||||
client.get().performRequest(DaemonFocusExchange.Request.builder()
|
||||
.mode(getEffectiveMode())
|
||||
.build());
|
||||
client.get()
|
||||
.performRequest(DaemonFocusExchange.Request.builder()
|
||||
.mode(getEffectiveMode())
|
||||
.build());
|
||||
if (!inputs.isEmpty()) {
|
||||
client.get().performRequest(DaemonOpenExchange.Request.builder()
|
||||
.arguments(inputs)
|
||||
.build());
|
||||
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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue