mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Reformat
This commit is contained in:
parent
ea7114178f
commit
147e68efe5
34 changed files with 214 additions and 160 deletions
|
@ -79,12 +79,20 @@ final class BrowserBookmarkComp extends SimpleComp {
|
|||
});
|
||||
};
|
||||
BiConsumer<StoreSection, Comp<CompStructure<Button>>> augment = (s, comp) -> {
|
||||
comp.disable(Bindings.createBooleanBinding(() -> {
|
||||
return busy.get() || !applicable.test(s.getWrapper());
|
||||
}, busy));
|
||||
comp.disable(Bindings.createBooleanBinding(
|
||||
() -> {
|
||||
return busy.get() || !applicable.test(s.getWrapper());
|
||||
},
|
||||
busy));
|
||||
comp.apply(struc -> {
|
||||
open.addListener((observable, oldValue, newValue) -> {
|
||||
struc.get().pseudoClassStateChanged(SELECTED, newValue != null && newValue.getEntry().get().equals(s.getWrapper().getEntry()));
|
||||
struc.get()
|
||||
.pseudoClassStateChanged(
|
||||
SELECTED,
|
||||
newValue != null
|
||||
&& newValue.getEntry()
|
||||
.get()
|
||||
.equals(s.getWrapper().getEntry()));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -355,7 +355,10 @@ final class BrowserFileListComp extends SimpleComp {
|
|||
}
|
||||
|
||||
if (fileList.getFileSystemModel().getFileSystem() != null) {
|
||||
var shell = fileList.getFileSystemModel().getFileSystem().getShell().orElseThrow();
|
||||
var shell = fileList.getFileSystemModel()
|
||||
.getFileSystem()
|
||||
.getShell()
|
||||
.orElseThrow();
|
||||
var hasAttributes = !OsType.WINDOWS.equals(shell.getOsType());
|
||||
if (!hasAttributes) {
|
||||
table.getColumns().remove(modeCol);
|
||||
|
|
|
@ -60,8 +60,7 @@ public final class BrowserFileListModel {
|
|||
var parent = fileSystemModel.getCurrentParentDirectory();
|
||||
var l = Stream.concat(
|
||||
parent != null ? Stream.of(new BrowserEntry(parent, this, true)) : Stream.of(),
|
||||
s.filter(entry -> entry != null)
|
||||
.map(entry -> new BrowserEntry(entry, this, false)))
|
||||
s.filter(entry -> entry != null).map(entry -> new BrowserEntry(entry, this, false)))
|
||||
.toList();
|
||||
all.setValue(l);
|
||||
refreshShown();
|
||||
|
|
|
@ -76,7 +76,9 @@ public class BrowserNavBar extends SimpleComp {
|
|||
// Pseudo classes do not apply if set instantly before shown
|
||||
// If we start a new tab with a directory set, we have to set the pseudo class one pulse later
|
||||
Platform.runLater(() -> {
|
||||
struc.get().pseudoClassStateChanged(INVISIBLE, !val && !struc.get().isFocused());
|
||||
struc.get()
|
||||
.pseudoClassStateChanged(
|
||||
INVISIBLE, !val && !struc.get().isFocused());
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -47,13 +47,9 @@ public class BrowserStatusBarComp extends SimpleComp {
|
|||
if (p == null || p.done()) {
|
||||
return null;
|
||||
} else {
|
||||
var transferred = HumanReadableFormat.byteCount(
|
||||
p.getTransferred(), false);
|
||||
var all = HumanReadableFormat.byteCount(
|
||||
p.getTotal(), true);
|
||||
var name = (p.getName() != null
|
||||
? " @ " + p.getName() + " "
|
||||
: "");
|
||||
var transferred = HumanReadableFormat.byteCount(p.getTransferred(), false);
|
||||
var all = HumanReadableFormat.byteCount(p.getTotal(), true);
|
||||
var name = (p.getName() != null ? " @ " + p.getName() + " " : "");
|
||||
return transferred + " / " + all + name;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -115,7 +115,7 @@ public class StoreCreationComp extends DialogComp {
|
|||
DataStorage.get().getSelectedCategory().getUuid(),
|
||||
name.getValue(),
|
||||
store.getValue());
|
||||
var p = DataStorage.get().getDefaultDisplayParent(testE).orElse(null);
|
||||
var p = DataStorage.get().getDefaultDisplayParent(testE).orElse(null);
|
||||
|
||||
var targetCategory = p != null
|
||||
? p.getCategoryUuid()
|
||||
|
@ -174,7 +174,8 @@ public class StoreCreationComp extends DialogComp {
|
|||
(e, validated) -> {
|
||||
try {
|
||||
DataStorage.get().addStoreEntryIfNotPresent(e);
|
||||
if (validated && e.getProvider().shouldHaveChildren()
|
||||
if (validated
|
||||
&& e.getProvider().shouldHaveChildren()
|
||||
&& AppPrefs.get()
|
||||
.openConnectionSearchWindowOnConnectionCreation()
|
||||
.get()) {
|
||||
|
|
|
@ -54,8 +54,6 @@ public abstract class StoreEntryComp extends SimpleComp {
|
|||
this.content = content;
|
||||
}
|
||||
|
||||
public abstract boolean isFullSize();
|
||||
|
||||
public static StoreEntryComp create(StoreEntryWrapper entry, Comp<?> content, boolean preferLarge) {
|
||||
var forceCondensed = AppPrefs.get() != null
|
||||
&& AppPrefs.get().condenseConnectionDisplay().get();
|
||||
|
@ -79,6 +77,8 @@ public abstract class StoreEntryComp extends SimpleComp {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract boolean isFullSize();
|
||||
|
||||
@Override
|
||||
protected final Region createSimple() {
|
||||
var r = createContent();
|
||||
|
|
|
@ -42,13 +42,14 @@ public class StoreQuickAccessButtonComp extends SimpleComp {
|
|||
|
||||
cm.show(anchor, Side.RIGHT, 0, 0);
|
||||
|
||||
// App.getApp().getStage().getScene().addEventFilter(MouseEvent.MOUSE_MOVED, event -> {
|
||||
// var stages = Stage.getWindows().stream().filter(window -> window instanceof ContextMenu).toList();
|
||||
// var hovered = stages.stream().anyMatch(window -> window.getScene().getRoot().hoverProperty().get());
|
||||
// if (!hovered) {
|
||||
// stages.forEach(window -> window.hide());
|
||||
// }
|
||||
// });
|
||||
// App.getApp().getStage().getScene().addEventFilter(MouseEvent.MOUSE_MOVED, event -> {
|
||||
// var stages = Stage.getWindows().stream().filter(window -> window instanceof ContextMenu).toList();
|
||||
// var hovered = stages.stream().anyMatch(window ->
|
||||
// window.getScene().getRoot().hoverProperty().get());
|
||||
// if (!hovered) {
|
||||
// stages.forEach(window -> window.hide());
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private ContextMenu createMenu() {
|
||||
|
@ -67,11 +68,12 @@ public class StoreQuickAccessButtonComp extends SimpleComp {
|
|||
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().getProvider().getDisplayIconFileName(w.getEntry().getStore());
|
||||
if (c.isEmpty()) {
|
||||
var item = new MenuItem(w.getName().getValue(), PrettyImageHelper.ofFixedSquare(graphic, 16).createRegion());
|
||||
var item = new MenuItem(
|
||||
w.getName().getValue(),
|
||||
PrettyImageHelper.ofFixedSquare(graphic, 16).createRegion());
|
||||
item.setOnAction(event -> {
|
||||
action.accept(w);
|
||||
contextMenu.hide();
|
||||
|
@ -88,7 +90,9 @@ public class StoreQuickAccessButtonComp extends SimpleComp {
|
|||
|
||||
items.add(recurse(contextMenu, sub));
|
||||
}
|
||||
var m = new Menu(w.getName().getValue(), PrettyImageHelper.ofFixedSquare(graphic, 16).createRegion());
|
||||
var m = new Menu(
|
||||
w.getName().getValue(),
|
||||
PrettyImageHelper.ofFixedSquare(graphic, 16).createRegion());
|
||||
m.getItems().setAll(items);
|
||||
m.setOnAction(event -> {
|
||||
if (event.getTarget() == m) {
|
||||
|
|
|
@ -102,7 +102,7 @@ public class StoreSection {
|
|||
var matchesSelector = section.anyMatches(entryFilter);
|
||||
var sameCategory = category == null
|
||||
|| category.getValue() == null
|
||||
|| inCategory(category.getValue(),section.getWrapper());
|
||||
|| inCategory(category.getValue(), section.getWrapper());
|
||||
return showFilter && matchesSelector && sameCategory;
|
||||
},
|
||||
category,
|
||||
|
@ -141,7 +141,7 @@ public class StoreSection {
|
|||
var matchesSelector = section.anyMatches(entryFilter);
|
||||
var sameCategory = category == null
|
||||
|| category.getValue() == null
|
||||
|| inCategory(category.getValue(),section.getWrapper());
|
||||
|| inCategory(category.getValue(), section.getWrapper());
|
||||
// If this entry is already shown as root due to a different category than parent, don't show it
|
||||
// again here
|
||||
var notRoot =
|
||||
|
@ -153,20 +153,13 @@ public class StoreSection {
|
|||
return new StoreSection(e, cached, filtered, depth);
|
||||
}
|
||||
|
||||
public boolean shouldShow(String filter) {
|
||||
return anyMatches(storeEntryWrapper -> storeEntryWrapper.shouldShow(filter));
|
||||
}
|
||||
|
||||
public boolean anyMatches(Predicate<StoreEntryWrapper> c) {
|
||||
return c == null
|
||||
|| c.test(wrapper)
|
||||
|| allChildren.stream().anyMatch(storeEntrySection -> storeEntrySection.anyMatches(c));
|
||||
}
|
||||
|
||||
private static boolean inCategory(StoreCategoryWrapper categoryWrapper, StoreEntryWrapper entryWrapper) {
|
||||
var current = entryWrapper.getCategory().getValue();
|
||||
while (current != null) {
|
||||
if (categoryWrapper.getCategory().getUuid().equals(current.getCategory().getUuid())) {
|
||||
if (categoryWrapper
|
||||
.getCategory()
|
||||
.getUuid()
|
||||
.equals(current.getCategory().getUuid())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -178,4 +171,14 @@ public class StoreSection {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldShow(String filter) {
|
||||
return anyMatches(storeEntryWrapper -> storeEntryWrapper.shouldShow(filter));
|
||||
}
|
||||
|
||||
public boolean anyMatches(Predicate<StoreEntryWrapper> c) {
|
||||
return c == null
|
||||
|| c.test(wrapper)
|
||||
|| allChildren.stream().anyMatch(storeEntrySection -> storeEntrySection.anyMatches(c));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ public class StoreSectionComp extends Comp<CompStructure<VBox>> {
|
|||
w.executeDefaultAction();
|
||||
});
|
||||
};
|
||||
var quickAccessButton = new StoreQuickAccessButtonComp(section, quickAccessAction).vgrow()
|
||||
var quickAccessButton = new StoreQuickAccessButtonComp(section, quickAccessAction)
|
||||
.vgrow()
|
||||
.styleClass("quick-access-button")
|
||||
.apply(struc -> struc.get().setMinWidth(30))
|
||||
.apply(struc -> struc.get().setPrefWidth(30))
|
||||
|
|
|
@ -41,7 +41,8 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
|
|||
|
||||
public StoreSectionMiniComp(
|
||||
StoreSection section,
|
||||
BiConsumer<StoreSection, Comp<CompStructure<Button>>> augment, Consumer<StoreEntryWrapper> action,
|
||||
BiConsumer<StoreSection, Comp<CompStructure<Button>>> augment,
|
||||
Consumer<StoreEntryWrapper> action,
|
||||
boolean condensedStyle) {
|
||||
this.section = section;
|
||||
this.augment = augment;
|
||||
|
@ -112,7 +113,8 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
|
|||
Consumer<StoreEntryWrapper> quickAccessAction = w -> {
|
||||
action.accept(w);
|
||||
};
|
||||
var quickAccessButton = new StoreQuickAccessButtonComp(section, quickAccessAction).vgrow()
|
||||
var quickAccessButton = new StoreQuickAccessButtonComp(section, quickAccessAction)
|
||||
.vgrow()
|
||||
.styleClass("quick-access-button")
|
||||
.maxHeight(100)
|
||||
.disable(quickAccessDisabled);
|
||||
|
|
|
@ -50,7 +50,8 @@ public interface StoreSortMode {
|
|||
@Override
|
||||
public StoreSection representative(StoreSection s) {
|
||||
return Stream.concat(s.getShownChildren().stream().map(this::representative), Stream.of(s))
|
||||
.max(Comparator.comparing(section -> section.getWrapper().getEntry().getLastAccess()))
|
||||
.max(Comparator.comparing(
|
||||
section -> section.getWrapper().getEntry().getLastAccess()))
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,8 @@ public interface StoreSortMode {
|
|||
@Override
|
||||
public StoreSection representative(StoreSection s) {
|
||||
return Stream.concat(s.getShownChildren().stream().map(this::representative), Stream.of(s))
|
||||
.max(Comparator.comparing(section -> section.getWrapper().getEntry().getLastAccess()))
|
||||
.max(Comparator.comparing(
|
||||
section -> section.getWrapper().getEntry().getLastAccess()))
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,12 +80,6 @@ public class AppLogs {
|
|||
hookUpSystemErr();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
if (outFileStream != null) {
|
||||
outFileStream.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldWriteLogs() {
|
||||
if (System.getProperty(WRITE_LOGS_PROP) != null) {
|
||||
return Boolean.parseBoolean(System.getProperty(WRITE_LOGS_PROP));
|
||||
|
@ -192,6 +186,12 @@ public class AppLogs {
|
|||
return DEFAULT_LOG_LEVEL;
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
if (outFileStream != null) {
|
||||
outFileStream.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void close() {
|
||||
if (outFileStream != null) {
|
||||
outFileStream.close();
|
||||
|
|
|
@ -8,8 +8,7 @@ import java.util.concurrent.TimeUnit;
|
|||
public class AppCertutilCheck {
|
||||
|
||||
private static boolean getResult() {
|
||||
var fc = new ProcessBuilder(System.getenv("WINDIR") + "\\System32\\certutil")
|
||||
.redirectErrorStream(true);
|
||||
var fc = new ProcessBuilder(System.getenv("WINDIR") + "\\System32\\certutil").redirectErrorStream(true);
|
||||
try {
|
||||
var proc = fc.start();
|
||||
var out = new String(proc.getInputStream().readAllBytes());
|
||||
|
|
|
@ -11,18 +11,15 @@ public class AppPtbCheck {
|
|||
return;
|
||||
}
|
||||
|
||||
AppWindowHelper.showBlockingAlert(
|
||||
alert -> {
|
||||
alert.setAlertType(Alert.AlertType.INFORMATION);
|
||||
alert.setHeaderText("Notice for the public test build");
|
||||
alert.getDialogPane()
|
||||
.setContent(
|
||||
AppWindowHelper.alertContentText(
|
||||
"You are running a PTB build of XPipe." +
|
||||
" This version is unstable and might contain bugs." +
|
||||
" You should not use it as a daily driver." +
|
||||
" It will also not receive regular updates." +
|
||||
" You will have to install and launch the normal XPipe release for that."));
|
||||
});
|
||||
AppWindowHelper.showBlockingAlert(alert -> {
|
||||
alert.setAlertType(Alert.AlertType.INFORMATION);
|
||||
alert.setHeaderText("Notice for the public test build");
|
||||
alert.getDialogPane()
|
||||
.setContent(AppWindowHelper.alertContentText("You are running a PTB build of XPipe."
|
||||
+ " This version is unstable and might contain bugs."
|
||||
+ " You should not use it as a daily driver."
|
||||
+ " It will also not receive regular updates."
|
||||
+ " You will have to install and launch the normal XPipe release for that."));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ public class AppShellCheck {
|
|||
public static void check() throws Exception {
|
||||
var err = selfTestErrorCheck();
|
||||
|
||||
var canFallback = !ProcessControlProvider.get().getEffectiveLocalDialect().equals(ProcessControlProvider.get().getFallbackDialect());
|
||||
var canFallback = !ProcessControlProvider.get()
|
||||
.getEffectiveLocalDialect()
|
||||
.equals(ProcessControlProvider.get().getFallbackDialect());
|
||||
if (err.isPresent() && canFallback) {
|
||||
var msg = formatMessage(err.get());
|
||||
ErrorEvent.fromThrowable(new IllegalStateException(msg)).handle();
|
||||
|
@ -28,7 +30,9 @@ public class AppShellCheck {
|
|||
}
|
||||
|
||||
private static String modifyOutput(String output) {
|
||||
if (OsType.getLocal().equals(OsType.WINDOWS) && output.contains("is not recognized as an internal or external command") && output.contains("exec-")) {
|
||||
if (OsType.getLocal().equals(OsType.WINDOWS)
|
||||
&& output.contains("is not recognized as an internal or external command")
|
||||
&& output.contains("exec-")) {
|
||||
return "Unable to create temporary script files";
|
||||
}
|
||||
|
||||
|
@ -36,9 +40,12 @@ public class AppShellCheck {
|
|||
}
|
||||
|
||||
private static String formatMessage(String output) {
|
||||
var fallback = !ProcessControlProvider.get().getEffectiveLocalDialect().equals(ProcessControlProvider.get().getFallbackDialect()) ? "XPipe will now attempt to fall back to another shell." : "";
|
||||
return
|
||||
"""
|
||||
var fallback = !ProcessControlProvider.get()
|
||||
.getEffectiveLocalDialect()
|
||||
.equals(ProcessControlProvider.get().getFallbackDialect())
|
||||
? "XPipe will now attempt to fall back to another shell."
|
||||
: "";
|
||||
return """
|
||||
Shell self-test failed for %s:
|
||||
%s
|
||||
|
||||
|
@ -51,11 +58,10 @@ public class AppShellCheck {
|
|||
|
||||
%s
|
||||
"""
|
||||
.formatted(
|
||||
ProcessControlProvider.get()
|
||||
.getEffectiveLocalDialect()
|
||||
.getDisplayName(),
|
||||
modifyOutput(output), fallback);
|
||||
.formatted(
|
||||
ProcessControlProvider.get().getEffectiveLocalDialect().getDisplayName(),
|
||||
modifyOutput(output),
|
||||
fallback);
|
||||
}
|
||||
|
||||
private static void enableFallback() throws Exception {
|
||||
|
|
|
@ -186,16 +186,23 @@ public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
|
|||
button.apply(struc -> {
|
||||
struc.get().setMaxWidth(2000);
|
||||
struc.get().setAlignment(Pos.CENTER_LEFT);
|
||||
Comp<?> graphic = PrettyImageHelper.ofSvg(Bindings.createStringBinding(() -> {
|
||||
if (selected.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
Comp<?> graphic = PrettyImageHelper.ofSvg(
|
||||
Bindings.createStringBinding(
|
||||
() -> {
|
||||
if (selected.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return selected.getValue().get().getProvider().getDisplayIconFileName(selected.getValue().getStore());
|
||||
}, selected), 16, 16);
|
||||
struc.get()
|
||||
.setGraphic(graphic
|
||||
.createRegion());
|
||||
return selected.getValue()
|
||||
.get()
|
||||
.getProvider()
|
||||
.getDisplayIconFileName(
|
||||
selected.getValue().getStore());
|
||||
},
|
||||
selected),
|
||||
16,
|
||||
16);
|
||||
struc.get().setGraphic(graphic.createRegion());
|
||||
struc.get().setOnAction(event -> {
|
||||
getPopover().show(struc.get());
|
||||
event.consume();
|
||||
|
|
|
@ -8,9 +8,6 @@ import javafx.beans.property.SimpleStringProperty;
|
|||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.util.Subscription;
|
||||
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
public class LabelComp extends Comp<CompStructure<Label>> {
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ public class ErrorHandlerComp extends SimpleComp {
|
|||
|
||||
// Unhandled platform exceptions usually means that we will have trouble displaying another window
|
||||
// Let's just hope that this is not the case
|
||||
// if (event.isUnhandled() && Platform.isFxApplicationThread()) {
|
||||
// ErrorAction.ignore().handle(event);
|
||||
// return;
|
||||
// }
|
||||
// if (event.isUnhandled() && Platform.isFxApplicationThread()) {
|
||||
// ErrorAction.ignore().handle(event);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
showAndWaitWithPlatformThread(event, forceWait);
|
||||
|
|
|
@ -50,15 +50,15 @@ public class EventHandlerImpl extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleOnShutdown(ErrorEvent ee) {
|
||||
ErrorAction.ignore().handle(ee);
|
||||
handle(fromErrorEvent(ee));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(ErrorEvent ee) {
|
||||
if (AppLogs.get() != null && AppLogs.get().getSessionLogsDirectory() != null) {
|
||||
ee.addAttachment(AppLogs.get().getSessionLogsDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleOnShutdown(ErrorEvent ee) {
|
||||
ErrorAction.ignore().handle(ee);
|
||||
handle(fromErrorEvent(ee));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,22 +107,29 @@ public class AppPrefs {
|
|||
bindDeveloperTrue(developerDisableGuiRestrictions);
|
||||
private final ObjectProperty<SupportedLocale> language =
|
||||
map(new SimpleObjectProperty<>(SupportedLocale.ENGLISH), "language", SupportedLocale.class);
|
||||
|
||||
@Getter
|
||||
private final Property<InPlaceSecretValue> lockPassword = new SimpleObjectProperty<>();
|
||||
|
||||
@Getter
|
||||
private final StringProperty lockCrypt =
|
||||
mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class);
|
||||
|
||||
private final IntegerProperty editorReloadTimeout =
|
||||
map(new SimpleIntegerProperty(1000), "editorReloadTimeout", Integer.class);
|
||||
private final BooleanProperty confirmDeletions =
|
||||
map(new SimpleBooleanProperty(true), "confirmDeletions", Boolean.class);
|
||||
|
||||
@Getter
|
||||
private final List<AppPrefsCategory> categories;
|
||||
|
||||
private final AppPrefsStorageHandler globalStorageHandler = new AppPrefsStorageHandler(
|
||||
AppProperties.get().getDataDir().resolve("settings").resolve("preferences.json"));
|
||||
private final Map<Mapping<?>, Comp<?>> customEntries = new LinkedHashMap<>();
|
||||
|
||||
@Getter
|
||||
private final Property<AppPrefsCategory> selectedCategory;
|
||||
|
||||
private final PrefsHandler extensionHandler = new PrefsHandlerImpl();
|
||||
private AppPrefsStorageHandler vaultStorageHandler;
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ public class AppearanceCategory extends AppPrefsCategory {
|
|||
.addTitle("uiOptions")
|
||||
.sub(new OptionsBuilder()
|
||||
.nameAndDescription("theme")
|
||||
.addComp(ChoiceComp.ofTranslatable(prefs.theme, AppTheme.Theme.ALL, false).styleClass("theme-switcher"), prefs.theme)
|
||||
.addComp(
|
||||
ChoiceComp.ofTranslatable(prefs.theme, AppTheme.Theme.ALL, false)
|
||||
.styleClass("theme-switcher"),
|
||||
prefs.theme)
|
||||
.nameAndDescription("performanceMode")
|
||||
.addToggle(prefs.performanceMode)
|
||||
.nameAndDescription("uiScale")
|
||||
|
|
|
@ -65,10 +65,17 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
.addFile(configuration.getScriptFile());
|
||||
}
|
||||
|
||||
return CommandBuilder.of().add("-ExecutionPolicy", "Bypass").add("-EncodedCommand").add(sc -> {
|
||||
var base64 = Base64.getEncoder().encodeToString(configuration.getDialectLaunchCommand().buildCommandBase(sc).getBytes(StandardCharsets.UTF_16LE));
|
||||
return "\"" + base64 + "\"";
|
||||
});
|
||||
return CommandBuilder.of()
|
||||
.add("-ExecutionPolicy", "Bypass")
|
||||
.add("-EncodedCommand")
|
||||
.add(sc -> {
|
||||
var base64 = Base64.getEncoder()
|
||||
.encodeToString(configuration
|
||||
.getDialectLaunchCommand()
|
||||
.buildCommandBase(sc)
|
||||
.getBytes(StandardCharsets.UTF_16LE));
|
||||
return "\"" + base64 + "\"";
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -86,12 +93,16 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
@Override
|
||||
protected CommandBuilder toCommand(LaunchConfiguration configuration) {
|
||||
return CommandBuilder.of().add("-ExecutionPolicy", "Bypass").add("-EncodedCommand").add(sc -> {
|
||||
// Fix for https://github.com/PowerShell/PowerShell/issues/18530#issuecomment-1325691850
|
||||
var c = "$env:PSModulePath=\"\";" + configuration.getDialectLaunchCommand().buildCommandBase(sc);
|
||||
var base64 = Base64.getEncoder().encodeToString(c.getBytes(StandardCharsets.UTF_16LE));
|
||||
return "\"" + base64 + "\"";
|
||||
});
|
||||
return CommandBuilder.of()
|
||||
.add("-ExecutionPolicy", "Bypass")
|
||||
.add("-EncodedCommand")
|
||||
.add(sc -> {
|
||||
// Fix for https://github.com/PowerShell/PowerShell/issues/18530#issuecomment-1325691850
|
||||
var c = "$env:PSModulePath=\"\";"
|
||||
+ configuration.getDialectLaunchCommand().buildCommandBase(sc);
|
||||
var base64 = Base64.getEncoder().encodeToString(c.getBytes(StandardCharsets.UTF_16LE));
|
||||
return "\"" + base64 + "\"";
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -503,7 +514,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
};
|
||||
ExternalTerminalType WARP = new MacOsType("app.warp", "Warp") {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supportsTabs() {
|
||||
return true;
|
||||
|
@ -678,7 +689,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
static ExternalTerminalType determineDefault(ExternalTerminalType existing) {
|
||||
// Check for incompatibility with fallback shell
|
||||
if (ExternalTerminalType.CMD.equals(existing) && !ProcessControlProvider.get().getEffectiveLocalDialect().equals(ShellDialects.CMD)) {
|
||||
if (ExternalTerminalType.CMD.equals(existing)
|
||||
&& !ProcessControlProvider.get().getEffectiveLocalDialect().equals(ShellDialects.CMD)) {
|
||||
return ExternalTerminalType.POWERSHELL;
|
||||
}
|
||||
|
||||
|
@ -817,5 +829,4 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
protected abstract CommandBuilder toCommand(LaunchConfiguration configuration) throws Exception;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,43 +10,42 @@ import java.nio.file.Path;
|
|||
|
||||
public class WindowsTerminalType {
|
||||
|
||||
public static final ExternalTerminalType WINDOWS_TERMINAL =
|
||||
new ExternalTerminalType.SimplePathType("app.windowsTerminal", "wt.exe") {
|
||||
|
||||
public static final ExternalTerminalType WINDOWS_TERMINAL = new ExternalTerminalType.SimplePathType("app.windowsTerminal", "wt.exe") {
|
||||
@Override
|
||||
protected CommandBuilder toCommand(LaunchConfiguration configuration) throws Exception {
|
||||
return WindowsTerminalType.toCommand(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandBuilder toCommand(LaunchConfiguration configuration) throws Exception {
|
||||
return WindowsTerminalType.toCommand(configuration);
|
||||
}
|
||||
@Override
|
||||
public boolean supportsTabs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTabs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsColoredTitle() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean supportsColoredTitle() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static final ExternalTerminalType WINDOWS_TERMINAL_PREVIEW = new ExternalTerminalType() {
|
||||
|
||||
@Override
|
||||
public boolean supportsColoredTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTabs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsColoredTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(ExternalTerminalType.LaunchConfiguration configuration) throws Exception {
|
||||
LocalShell.getShell()
|
||||
.executeSimpleCommand(CommandBuilder.of()
|
||||
.addFile(getPath().toString())
|
||||
.add(toCommand(configuration)));
|
||||
.executeSimpleCommand(
|
||||
CommandBuilder.of().addFile(getPath().toString()).add(toCommand(configuration)));
|
||||
}
|
||||
|
||||
private Path getPath() {
|
||||
|
@ -72,9 +71,11 @@ public class WindowsTerminalType {
|
|||
// So just remove that slash
|
||||
var fixedName = FileNames.removeTrailingSlash(configuration.getColoredTitle());
|
||||
|
||||
var toExec = !ShellDialects.isPowershell(LocalShell.getShell()) ?
|
||||
CommandBuilder.of().addFile(configuration.getScriptFile()) :
|
||||
CommandBuilder.of().add("powershell", "-ExecutionPolicy", "Bypass", "-File").addQuoted(configuration.getScriptFile());
|
||||
var toExec = !ShellDialects.isPowershell(LocalShell.getShell())
|
||||
? CommandBuilder.of().addFile(configuration.getScriptFile())
|
||||
: CommandBuilder.of()
|
||||
.add("powershell", "-ExecutionPolicy", "Bypass", "-File")
|
||||
.addQuoted(configuration.getScriptFile());
|
||||
var cmd = CommandBuilder.of().add("-w", "1", "nt");
|
||||
|
||||
if (configuration.getColor() != null) {
|
||||
|
|
|
@ -41,7 +41,8 @@ public class ApplicationHelper {
|
|||
var script = ScriptHelper.createExecScript(pc, command);
|
||||
return String.format(
|
||||
"Start-Process -FilePath %s -ArgumentList \"-NoProfile\", \"-File\", %s",
|
||||
pc.getShellDialect().getExecutableName(), pc.getShellDialect().fileArgument(script));
|
||||
pc.getShellDialect().getExecutableName(),
|
||||
pc.getShellDialect().fileArgument(script));
|
||||
}
|
||||
|
||||
if (pc.getOsType().equals(OsType.WINDOWS)) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.xpipe.app.util;
|
||||
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.core.util.NewLine;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
import io.xpipe.core.dialog.Dialog;
|
||||
import io.xpipe.core.dialog.QueryConverter;
|
||||
import io.xpipe.core.store.*;
|
||||
import io.xpipe.core.util.NewLine;
|
||||
import io.xpipe.core.util.SecretValue;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
import lombok.Value;
|
||||
|
||||
public class DialogHelper {
|
||||
|
|
|
@ -73,7 +73,8 @@ public enum PlatformState {
|
|||
// The headless check is not needed though but still done
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
||||
|
||||
// Catch more than just the headless exception in case the graphics environment initialization completely fails
|
||||
// Catch more than just the headless exception in case the graphics environment initialization completely
|
||||
// fails
|
||||
} catch (Throwable t) {
|
||||
TrackEvent.warn(t.getMessage());
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
|
|
|
@ -41,7 +41,8 @@ public class ShellTemp {
|
|||
base = FileNames.join("/tmp", "xpipe");
|
||||
// We have to make sure that also other users can create files here
|
||||
// This command should work in all shells on unix systems
|
||||
proc.command("chmod 777 " + proc.getShellDialect().fileArgument(base)).executeAndCheck();
|
||||
proc.command("chmod 777 " + proc.getShellDialect().fileArgument(base))
|
||||
.executeAndCheck();
|
||||
// Use user-specific directories on anything else than macOS as that one already has that
|
||||
if (!proc.getOsType().equals(OsType.MACOS)) {
|
||||
var user = proc.getShellDialect().printUsernameCommand(proc).readStdoutOrThrow();
|
||||
|
|
|
@ -3,9 +3,9 @@ package io.xpipe.app.util;
|
|||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.terminal.ExternalTerminalType;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.terminal.ExternalTerminalType;
|
||||
import io.xpipe.core.process.ProcessControl;
|
||||
import io.xpipe.core.process.ProcessControlProvider;
|
||||
import io.xpipe.core.process.ShellControl;
|
||||
|
|
|
@ -27,7 +27,7 @@ public class TerminalLauncherManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!sc.getShellDialect().directoryExists(sc,directory).executeAndCheck()) {
|
||||
if (!sc.getShellDialect().directoryExists(sc, directory).executeAndCheck()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@ public class TerminalLauncherManager {
|
|||
};
|
||||
|
||||
try {
|
||||
var file = ScriptHelper.createLocalExecScript(
|
||||
processControl.prepareTerminalOpen(config, workingDirectory));
|
||||
var file = ScriptHelper.createLocalExecScript(processControl.prepareTerminalOpen(config, workingDirectory));
|
||||
entry.setResult(new ResultSuccess(Path.of(file)));
|
||||
} catch (Exception e) {
|
||||
entry.setResult(new ResultFailure(e));
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package io.xpipe.core.dialog;
|
||||
|
||||
import io.xpipe.core.util.NewLine;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
import io.xpipe.core.util.SecretValue;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.xpipe.core.util.NewLine;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
import io.xpipe.core.store.FileSystem;
|
||||
import io.xpipe.core.util.NewLine;
|
||||
import io.xpipe.core.util.SecretValue;
|
||||
import io.xpipe.core.util.StreamCharset;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
|
|
@ -10,10 +10,14 @@ public interface ShellDialectAskpass {
|
|||
String prepareFixedContent(ShellControl sc, String fileName, List<String> s) throws Exception;
|
||||
|
||||
String elevateDumbCommand(
|
||||
ShellControl shellControl, UUID requestId, ElevationHandler handler, CountDown countDown, String message, CommandConfiguration command
|
||||
)
|
||||
ShellControl shellControl,
|
||||
UUID requestId,
|
||||
ElevationHandler handler,
|
||||
CountDown countDown,
|
||||
String message,
|
||||
CommandConfiguration command)
|
||||
throws Exception;
|
||||
|
||||
String elevateTerminalCommandWithPreparedAskpass(ShellControl shellControl, ElevationHandler handler, String command, String prefix)
|
||||
throws Exception;
|
||||
String elevateTerminalCommandWithPreparedAskpass(
|
||||
ShellControl shellControl, ElevationHandler handler, String command, String prefix) throws Exception;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,8 @@ public class RunAction extends MultiExecuteAction {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (ShellDialects.isPowershell(shell.get()) && Stream.of("ps1")
|
||||
.anyMatch(s -> e.getPath().endsWith(s))) {
|
||||
if (ShellDialects.isPowershell(shell.get())
|
||||
&& Stream.of("ps1").anyMatch(s -> e.getPath().endsWith(s))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue