Add more terminals plus various small improvements [stage]

This commit is contained in:
crschnick 2023-06-19 16:05:26 +00:00
parent 4689bcc2aa
commit 1aa50d50ca
16 changed files with 245 additions and 23 deletions

View file

@ -60,7 +60,7 @@ dependencies {
implementation 'com.jfoenix:jfoenix:9.0.10' implementation 'com.jfoenix:jfoenix:9.0.10'
implementation 'org.controlsfx:controlsfx:11.1.2' implementation 'org.controlsfx:controlsfx:11.1.2'
implementation 'net.synedra:validatorfx:0.3.1' implementation 'net.synedra:validatorfx:0.3.1'
implementation ('io.github.mkpaz:atlantafx-base:2.0.0') { implementation ('io.github.mkpaz:atlantafx-base:2.0.1') {
exclude group: 'org.openjfx', module: 'javafx-base' exclude group: 'org.openjfx', module: 'javafx-base'
exclude group: 'org.openjfx', module: 'javafx-controls' exclude group: 'org.openjfx', module: 'javafx-controls'
} }

View file

@ -282,12 +282,8 @@ public final class OpenFileSystemModel {
}); });
} }
public void createFileAsync(String name) { public void createLinkAsync(String linkName, String targetFile) {
if (name == null || name.isBlank()) { if (linkName == null || linkName.isBlank() || targetFile == null || targetFile.isBlank()) {
return;
}
if (getCurrentDirectory() == null) {
return; return;
} }
@ -297,6 +293,32 @@ public final class OpenFileSystemModel {
return; return;
} }
if (getCurrentDirectory() == null) {
return;
}
var abs = FileNames.join(getCurrentDirectory().getPath(), linkName);
fileSystem.symbolicLink(abs, targetFile);
refreshSync();
});
});
}
public void createFileAsync(String name) {
if (name == null || name.isBlank()) {
return;
}
ThreadHelper.runFailableAsync(() -> {
BusyProperty.execute(busy, () -> {
if (fileSystem == null) {
return;
}
if (getCurrentDirectory() == null) {
return;
}
var abs = FileNames.join(getCurrentDirectory().getPath(), name); var abs = FileNames.join(getCurrentDirectory().getPath(), name);
fileSystem.touch(abs); fileSystem.touch(abs);
refreshSync(); refreshSync();

View file

@ -1,5 +1,6 @@
package io.xpipe.app.core; package io.xpipe.app.core;
import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.ext.PrefsChoiceValue; import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.fxcomps.impl.FancyTooltipAugment; import io.xpipe.app.fxcomps.impl.FancyTooltipAugment;
import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.ErrorEvent;
@ -131,6 +132,7 @@ public class AppI18n {
for (Class<?> caller : callers) { for (Class<?> caller : callers) {
if (caller.equals(CallingClass.class) if (caller.equals(CallingClass.class)
|| caller.equals(ModuleHelper.class) || caller.equals(ModuleHelper.class)
|| caller.equals(ModalOverlayComp.class)
|| caller.equals(AppI18n.class) || caller.equals(AppI18n.class)
|| caller.equals(FancyTooltipAugment.class) || caller.equals(FancyTooltipAugment.class)
|| caller.equals(PrefsChoiceValue.class) || caller.equals(PrefsChoiceValue.class)

View file

@ -51,6 +51,14 @@ public abstract class Comp<S extends CompStructure<?>> {
return (T) this; return (T) this;
} }
public Comp<S> prefWidth(int width) {
return apply(struc -> struc.get().setPrefWidth(width));
}
public Comp<S> prefHeight(int height) {
return apply(struc -> struc.get().setPrefHeight(height));
}
public Comp<S> hgrow() { public Comp<S> hgrow() {
return apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)); return apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS));
} }

View file

@ -8,6 +8,7 @@ import io.xpipe.app.util.ScriptHelper;
import io.xpipe.app.util.WindowsRegistry; import io.xpipe.app.util.WindowsRegistry;
import io.xpipe.core.impl.FileNames; import io.xpipe.core.impl.FileNames;
import io.xpipe.core.impl.LocalStore; import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType; import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl; import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects; import io.xpipe.core.process.ShellDialects;
@ -21,7 +22,7 @@ import java.util.stream.Stream;
public interface ExternalTerminalType extends PrefsChoiceValue { public interface ExternalTerminalType extends PrefsChoiceValue {
ExternalTerminalType CMD = new SimpleType("app.cmd", "cmd.exe", "cmd.exe") { ExternalTerminalType CMD = new SimpleType("app.cmd", "cmd.exe") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -34,7 +35,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType POWERSHELL_WINDOWS = new SimpleType("app.powershell", "powershell", "PowerShell") { ExternalTerminalType POWERSHELL_WINDOWS = new SimpleType("app.powershell", "powershell") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -47,7 +48,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType PWSH_WINDOWS = new SimpleType("app.pwsh", "pwsh", "PowerShell Core") { ExternalTerminalType PWSH_WINDOWS = new SimpleType("app.pwsh", "pwsh") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -62,7 +63,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType WINDOWS_TERMINAL = new SimpleType("app.windowsTerminal", "wt.exe", "Windows Terminal") { ExternalTerminalType WINDOWS_TERMINAL = new SimpleType("app.windowsTerminal", "wt.exe") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -120,12 +121,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType GNOME_TERMINAL = new SimpleType("app.gnomeTerminal", "gnome-terminal", "Gnome Terminal") { ExternalTerminalType GNOME_TERMINAL = new SimpleType("app.gnomeTerminal", "gnome-terminal") {
@Override @Override
public void launch(String name, String file, boolean elevated) throws Exception { public void launch(String name, String file, boolean elevated) throws Exception {
try (ShellControl pc = LocalStore.getShell()) { try (ShellControl pc = LocalStore.getShell()) {
ApplicationHelper.checkSupport(pc, executable, getDisplayName(), null); ApplicationHelper.checkSupport(pc, executable, toTranslatedString(), null);
var toExecute = executable + " " + toCommand(name, file); var toExecute = executable + " " + toCommand(name, file);
// In order to fix this bug which also affects us: // In order to fix this bug which also affects us:
@ -146,7 +147,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType KONSOLE = new SimpleType("app.konsole", "konsole", "Konsole") { ExternalTerminalType KONSOLE = new SimpleType("app.konsole", "konsole") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -162,7 +163,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType XFCE = new SimpleType("app.xfce", "xfce4-terminal", "Xfce") { ExternalTerminalType XFCE = new SimpleType("app.xfce", "xfce4-terminal") {
@Override @Override
protected String toCommand(String name, String file) { protected String toCommand(String name, String file) {
@ -175,6 +176,97 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
}; };
ExternalTerminalType TERMINATOR = new SimpleType("app.terminator", "terminator") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-e").addQuoted(file).add("-T").addQuoted(name).add("--new-tab").build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType KITTY = new SimpleType("app.kitty", "kitty") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-T").addQuoted(name).addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType TERMINOLOGY = new SimpleType("app.terminology", "terminology") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-T").addQuoted(name).add("-2").add("-e").addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType COOL_RETRO_TERM = new SimpleType("app.coolRetroTerm", "cool-retro-term") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-T").addQuoted(name).add("-e").addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType GUAKE = new SimpleType("app.guake", "guake") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-r").addQuoted(name).add("-e").addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType ALACRITTY = new SimpleType("app.alacritty", "alacritty") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-t").addQuoted(name).add("-e").addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType TILDA = new SimpleType("app.tilda", "tilda") {
@Override
protected String toCommand(String name, String file) {
return CommandBuilder.of().add("-c").addQuoted(file).build();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.LINUX);
}
};
ExternalTerminalType MACOS_TERMINAL = new MacOsTerminalType(); ExternalTerminalType MACOS_TERMINAL = new MacOsTerminalType();
ExternalTerminalType ITERM2 = new ITerm2Type(); ExternalTerminalType ITERM2 = new ITerm2Type();
@ -194,6 +286,13 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
KONSOLE, KONSOLE,
XFCE, XFCE,
GNOME_TERMINAL, GNOME_TERMINAL,
TERMINATOR,
KITTY,
TERMINOLOGY,
COOL_RETRO_TERM,
GUAKE,
ALACRITTY,
TILDA,
ITERM2, ITERM2,
TABBY_MAC_OS, TABBY_MAC_OS,
WARP, WARP,
@ -357,11 +456,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Getter @Getter
abstract class SimpleType extends ExternalApplicationType.PathApplication implements ExternalTerminalType { abstract class SimpleType extends ExternalApplicationType.PathApplication implements ExternalTerminalType {
private final String displayName; public SimpleType(String id, String executable) {
public SimpleType(String id, String executable, String displayName) {
super(id, executable); super(id, executable);
this.displayName = displayName;
} }
@Override @Override
@ -371,7 +467,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
try (ShellControl pc = LocalStore.getShell() try (ShellControl pc = LocalStore.getShell()
.subShell(ShellDialects.POWERSHELL) .subShell(ShellDialects.POWERSHELL)
.start()) { .start()) {
ApplicationHelper.checkSupport(pc, executable, displayName, null); ApplicationHelper.checkSupport(pc, executable, toTranslatedString(), null);
var toExecute = "Start-Process \"" + executable + "\" -Verb RunAs -ArgumentList \"" var toExecute = "Start-Process \"" + executable + "\" -Verb RunAs -ArgumentList \""
+ toCommand(name, file).replaceAll("\"", "`\"") + "\""; + toCommand(name, file).replaceAll("\"", "`\"") + "\"";
pc.executeSimpleCommand(toExecute); pc.executeSimpleCommand(toExecute);
@ -381,7 +477,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
} }
try (ShellControl pc = LocalStore.getShell()) { try (ShellControl pc = LocalStore.getShell()) {
ApplicationHelper.checkSupport(pc, executable, displayName, null); ApplicationHelper.checkSupport(pc, executable, toTranslatedString(), null);
var toExecute = executable + " " + toCommand(name, file); var toExecute = executable + " " + toCommand(name, file);
if (pc.getOsType().equals(OsType.WINDOWS)) { if (pc.getOsType().equals(OsType.WINDOWS)) {

View file

@ -1,5 +1,6 @@
package io.xpipe.app.util; package io.xpipe.app.util;
import atlantafx.base.controls.Spacer;
import io.xpipe.app.core.AppI18n; import io.xpipe.app.core.AppI18n;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.impl.*; import io.xpipe.app.fxcomps.impl.*;
@ -7,6 +8,7 @@ import io.xpipe.core.util.SecretValue;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.geometry.Orientation;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import net.synedra.validatorfx.Check; import net.synedra.validatorfx.Check;
@ -108,6 +110,10 @@ public class OptionsBuilder {
return this; return this;
} }
public OptionsBuilder spacer(double size) {
return addComp(Comp.of(() -> new Spacer(size, Orientation.VERTICAL)));
}
public OptionsBuilder name(String nameKey) { public OptionsBuilder name(String nameKey) {
finishCurrent(); finishCurrent();
name = AppI18n.observable(nameKey); name = AppI18n.observable(nameKey);

View file

@ -17,6 +17,26 @@ public class CommandBuilder {
private final boolean noQuoting; private final boolean noQuoting;
private final StringBuilder builder = new StringBuilder(); private final StringBuilder builder = new StringBuilder();
public CommandBuilder add(String... s) {
for (String s1 : s) {
add(s1);
}
return this;
}
public CommandBuilder addQuoted(String s) {
if (!builder.isEmpty()) {
builder.append(' ');
}
if (noQuoting) {
throw new IllegalArgumentException("No quoting rule conflicts with spaces an argument");
}
builder.append("\"").append(s).append("\"");
return this;
}
public CommandBuilder add(String s) { public CommandBuilder add(String s) {
if (!builder.isEmpty()) { if (!builder.isEmpty()) {
builder.append(' '); builder.append(' ');

View file

@ -147,6 +147,8 @@ public interface ShellDialect {
CommandControl createFileExistsCommand(ShellControl sc, String file); CommandControl createFileExistsCommand(ShellControl sc, String file);
CommandControl symbolicLink(ShellControl sc, String linkFile, String targetFile);
String getFileTouchCommand(String file); String getFileTouchCommand(String file);
String getWhichCommand(String executable); String getWhichCommand(String executable);

View file

@ -134,7 +134,14 @@ public class ConnectionFileSystem implements FileSystem {
public void touch(String file) throws Exception { public void touch(String file) throws Exception {
try (var pc = shellControl try (var pc = shellControl
.command(proc -> proc.getShellDialect().getFileTouchCommand(file)) .command(proc -> proc.getShellDialect().getFileTouchCommand(file))
.complex() .start()) {
pc.discardOrThrow();
}
}
@Override
public void symbolicLink(String linkFile, String targetFile) throws Exception {
try (var pc = shellControl.getShellDialect().symbolicLink(shellControl,linkFile, targetFile)
.start()) { .start()) {
pc.discardOrThrow(); pc.discardOrThrow();
} }

View file

@ -108,6 +108,8 @@ public interface FileSystem extends Closeable, AutoCloseable {
void touch(String file) throws Exception; void touch(String file) throws Exception;
void symbolicLink(String linkFile, String targetFile) throws Exception;
boolean directoryExists(String file) throws Exception; boolean directoryExists(String file) throws Exception;
void directoryAccessible(String file) throws Exception; void directoryAccessible(String file) throws Exception;

8
dist/changelogs/1.2.0.md vendored Normal file
View file

@ -0,0 +1,8 @@
## Changes in 1.2.0
- Introduce new landing page in file browser
- Show commands that are executed to open a shell in connection creation wizard to
- Merge settings and about pages
- Add support for handling symbolic links in file browser
- Add support for many more Linux terminals
- Many small miscellaneous fixes and improvements

View file

@ -8,6 +8,8 @@ import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.browser.icon.BrowserIcons; import io.xpipe.app.browser.icon.BrowserIcons;
import io.xpipe.app.comp.base.ModalOverlayComp; import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.core.process.OsType;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
@ -104,6 +106,45 @@ public class NewItemAction implements BrowserAction, BranchAction {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) { public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserIcons.createDefaultDirectoryIcon().createRegion(); return BrowserIcons.createDefaultDirectoryIcon().createRegion();
} }
},
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Symbolic link";
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.getFileSystem().getShell().orElseThrow().getOsType() != OsType.WINDOWS;
}
@Override
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
var linkName = new SimpleStringProperty();
var target = new SimpleStringProperty();
model.getOverlay()
.setValue(new ModalOverlayComp.OverlayContent(
"base.newLink",
new OptionsBuilder()
.spacer(10)
.name("linkName")
.addString(linkName)
.spacer(10)
.name("targetPath")
.addString(target)
.buildComp()
.prefWidth(400)
.prefHeight(130),
"finish",
() -> {
model.createLinkAsync(linkName.getValue(), target.getValue());
}));
}
@Override
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserIcons.createDefaultFileIcon().createRegion();
}
}); });
} }
} }

View file

@ -25,6 +25,7 @@ open module io.xpipe.ext.base {
requires org.kordamp.ikonli.javafx; requires org.kordamp.ikonli.javafx;
requires com.sun.jna; requires com.sun.jna;
requires com.sun.jna.platform; requires com.sun.jna.platform;
requires atlantafx.base;
provides BrowserAction with provides BrowserAction with
FollowLinkAction, FollowLinkAction,

View file

@ -10,6 +10,9 @@ configuration=Configuration
selectOutput=Select Output selectOutput=Select Output
options=Options options=Options
newFile=New file newFile=New file
newLink=New link
linkName=Link name
targetPath=Target path
newDirectory=New directory newDirectory=New directory
copyShareLink=Copy share link copyShareLink=Copy share link
selectStore=Select Store selectStore=Select Store

View file

@ -46,6 +46,10 @@ dependencies {
compileOnly project(':beacon') compileOnly project(':beacon')
compileOnly project(':app') compileOnly project(':app')
compileOnly 'net.synedra:validatorfx:0.3.1' compileOnly 'net.synedra:validatorfx:0.3.1'
compileOnly ('io.github.mkpaz:atlantafx-base:2.0.1') {
exclude group: 'org.openjfx', module: 'javafx-base'
exclude group: 'org.openjfx', module: 'javafx-controls'
}
if (project != project(':base')) { if (project != project(':base')) {
compileOnly project(':base') compileOnly project(':base')

View file

@ -1 +1 @@
1.1.3 1.2.0