From ecdf5119b07ed6fa511aced257ef349b84032d22 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 20 Nov 2024 09:22:20 +0000 Subject: [PATCH] Reformat --- .../app/browser/BrowserFullSessionModel.java | 9 ++++++--- .../browser/file/BrowserFileSystemTabComp.java | 18 +++++++++++------- .../file/BrowserFileSystemTabModel.java | 3 ++- .../file/BrowserTerminalDockTabModel.java | 6 ++++-- .../xpipe/app/comp/base/SideMenuBarComp.java | 11 +++++++++-- .../app/comp/store/StandardStoreEntryComp.java | 5 ++++- .../xpipe/app/comp/store/StoreEntryComp.java | 3 --- .../app/comp/store/StoreEntryWrapper.java | 3 ++- .../core/check/AppHomebrewCoreutilsCheck.java | 7 ++++--- .../app/core/check/AppUserDirectoryCheck.java | 1 - .../io/xpipe/app/core/mode/OperationMode.java | 1 - .../main/java/io/xpipe/app/prefs/AppPrefs.java | 14 ++++++-------- .../xpipe/app/prefs/FileBrowserCategory.java | 3 +-- .../app/terminal/WindowsTerminalType.java | 3 +-- .../java/io/xpipe/app/update/AppInstaller.java | 17 +++++++++++------ .../io/xpipe/core/util/XPipeInstallation.java | 2 +- .../xpipe/ext/base/browser/DownloadAction.java | 5 ++--- 17 files changed, 64 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java index bb79c4331..795b6e2fc 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java @@ -36,9 +36,10 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel { - DEFAULT.openSync(tab,null); + DEFAULT.openSync(tab, null); DEFAULT.pinTab(tab); }); } @@ -134,7 +135,9 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel browserSessionTab != tab).toList(); + var previousOthers = previousTabs.stream() + .filter(browserSessionTab -> browserSessionTab != tab) + .toList(); if (previousOthers.size() > 0) { var prev = previousOthers.getLast(); getSelectedEntry().setValue(prev); diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java index 427efbddb..571036563 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java @@ -9,8 +9,8 @@ import io.xpipe.app.comp.augment.ContextMenuAugment; import io.xpipe.app.comp.base.*; import io.xpipe.app.core.AppFont; import io.xpipe.app.util.InputHelper; - import io.xpipe.app.util.PlatformThread; + import javafx.beans.binding.Bindings; import javafx.geometry.Pos; import javafx.scene.control.Button; @@ -99,13 +99,17 @@ public class BrowserFileSystemTabComp extends SimpleComp { if (model.getBrowserModel() instanceof BrowserFullSessionModel fullSessionModel) { var pinButton = new Button(); - pinButton.graphicProperty().bind(PlatformThread.sync(Bindings.createObjectBinding(() -> { - if (fullSessionModel.getGlobalPinnedTab().getValue() != model) { - return new FontIcon("mdi2p-pin"); - } + pinButton + .graphicProperty() + .bind(PlatformThread.sync(Bindings.createObjectBinding( + () -> { + if (fullSessionModel.getGlobalPinnedTab().getValue() != model) { + return new FontIcon("mdi2p-pin"); + } - return new FontIcon("mdi2p-pin-off"); - }, fullSessionModel.getGlobalPinnedTab()))); + return new FontIcon("mdi2p-pin-off"); + }, + fullSessionModel.getGlobalPinnedTab()))); pinButton.setOnAction(e -> { if (fullSessionModel.getGlobalPinnedTab().getValue() != model) { fullSessionModel.pinTab(model); diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java index 75aa2d88b..e85de5731 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java @@ -114,7 +114,8 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab shellSession.getTerminal().equals(session.getTerminal())).count(); + var others = sessions.stream() + .filter(shellSession -> shellSession.getTerminal().equals(session.getTerminal())) + .count(); if (others == 0) { session.getTerminal().controllable().ifPresent(controllableTerminalSession -> { controllableTerminalSession.close(); diff --git a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java index 61dcf26bb..7347b2c01 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java @@ -38,14 +38,21 @@ public class SideMenuBarComp extends Comp> { var selectedBorder = Bindings.createObjectBinding( () -> { - var c = Platform.getPreferences().getAccentColor().desaturate().desaturate(); + var c = Platform.getPreferences() + .getAccentColor() + .desaturate() + .desaturate(); return new Background(new BackgroundFill(c, new CornerRadii(8), new Insets(14, 1, 14, 2))); }, Platform.getPreferences().accentColorProperty()); var hoverBorder = Bindings.createObjectBinding( () -> { - var c = Platform.getPreferences().getAccentColor().darker().desaturate().desaturate(); + var c = Platform.getPreferences() + .getAccentColor() + .darker() + .desaturate() + .desaturate(); return new Background(new BackgroundFill(c, new CornerRadii(8), new Insets(14, 1, 14, 2))); }, Platform.getPreferences().accentColorProperty()); diff --git a/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java index b1380c7a3..3ec273178 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java @@ -100,7 +100,10 @@ public class StandardStoreEntryComp extends StoreEntryComp { information.setGraphicTextGap(7); if (getWrapper().getEntry().getProvider() != null) { try { - information.textProperty().bind(PlatformThread.sync(getWrapper().getEntry().getProvider().informationString(section))); + information + .textProperty() + .bind(PlatformThread.sync( + getWrapper().getEntry().getProvider().informationString(section))); } catch (Exception e) { ErrorEvent.fromThrowable(e).handle(); } diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java index a17cd66f6..5ffa0d2d3 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java @@ -14,7 +14,6 @@ import io.xpipe.app.core.AppActionLinkDetector; import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppI18n; import io.xpipe.app.ext.ActionProvider; -import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.resources.AppResources; import io.xpipe.app.storage.DataColor; @@ -24,9 +23,7 @@ import io.xpipe.app.update.XPipeDistributionType; import io.xpipe.app.util.*; import javafx.beans.binding.Bindings; -import javafx.beans.property.SimpleStringProperty; import javafx.beans.value.ObservableDoubleValue; -import javafx.beans.value.ObservableValue; import javafx.css.PseudoClass; import javafx.geometry.Insets; import javafx.geometry.Pos; diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java index edd24f9c1..af7482a29 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java @@ -157,7 +157,8 @@ public class StoreEntryWrapper { busy.setValue(entry.getBusyCounter().get() != 0); deletable.setValue(entry.getConfiguration().isDeletable() - || (AppPrefs.get().developerMode().getValue() && AppPrefs.get().developerDisableGuiRestrictions().getValue())); + || (AppPrefs.get().developerMode().getValue() + && AppPrefs.get().developerDisableGuiRestrictions().getValue())); sessionActive.setValue(entry.getStore() instanceof SingletonSessionStore ss && entry.getStore() instanceof ShellStore && ss.isSessionRunning()); diff --git a/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java index 00e505f53..e57b77007 100644 --- a/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java @@ -29,9 +29,10 @@ public class AppHomebrewCoreutilsCheck { var loc = checkCoreutils(); if (loc.isPresent()) { - ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH at " + loc.get() + "." + - " The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects." + - " Please remove the coreutils commands from your PATH prior to launching XPipe.") + ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH at " + + loc.get() + "." + + " The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects." + + " Please remove the coreutils commands from your PATH prior to launching XPipe.") .term() .handle(); } diff --git a/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java index 45ea7e44d..ef367361a 100644 --- a/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java @@ -1,6 +1,5 @@ package io.xpipe.app.core.check; -import io.xpipe.app.core.AppProperties; import io.xpipe.app.issue.ErrorEvent; import org.apache.commons.io.FileUtils; diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 7d9dc6eb7..808897be4 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -4,7 +4,6 @@ import io.xpipe.app.beacon.AppBeaconServer; import io.xpipe.app.core.*; import io.xpipe.app.core.check.AppDebugModeCheck; import io.xpipe.app.core.check.AppTempCheck; -import io.xpipe.app.core.check.AppUserDirectoryCheck; import io.xpipe.app.core.launcher.LauncherCommand; import io.xpipe.app.core.window.ModifiedStage; import io.xpipe.app.issue.*; diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index 3b489c4cc..691b46ee6 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -15,7 +15,6 @@ import io.xpipe.core.process.OsType; import io.xpipe.core.util.InPlaceSecretValue; import io.xpipe.core.util.ModuleHelper; -import javafx.beans.binding.Bindings; import javafx.beans.property.*; import javafx.beans.value.ObservableBooleanValue; import javafx.beans.value.ObservableDoubleValue; @@ -43,13 +42,12 @@ public class AppPrefs { @Getter private final BooleanProperty requiresRestart = new SimpleBooleanProperty(false); - final BooleanProperty pinLocalMachineOnStartup = - map(Mapping.builder() - .property(new SimpleBooleanProperty(false)) - .key("pinLocalMachineOnStartup") - .valueClass(Boolean.class) - .requiresRestart(true) - .build()); + final BooleanProperty pinLocalMachineOnStartup = map(Mapping.builder() + .property(new SimpleBooleanProperty(false)) + .key("pinLocalMachineOnStartup") + .valueClass(Boolean.class) + .requiresRestart(true) + .build()); final BooleanProperty dontAllowTerminalRestart = mapVaultShared(new SimpleBooleanProperty(false), "dontAllowTerminalRestart", Boolean.class, false); final BooleanProperty enableHttpApi = diff --git a/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java b/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java index 9b89c8103..ae90c7f8d 100644 --- a/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java @@ -23,8 +23,7 @@ public class FileBrowserCategory extends AppPrefsCategory { .pref(prefs.downloadsDirectory) .addString(prefs.downloadsDirectory) .pref(prefs.pinLocalMachineOnStartup) - .addToggle(prefs.pinLocalMachineOnStartup) - ) + .addToggle(prefs.pinLocalMachineOnStartup)) .buildComp(); } } diff --git a/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java index 406b5c865..3fd39aba6 100644 --- a/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java @@ -19,8 +19,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm ExternalTerminalType WINDOWS_TERMINAL_CANARY = new Canary(); private static CommandBuilder toCommand(TerminalLaunchConfiguration configuration) throws Exception { - var cmd = CommandBuilder.of() - .addIf(configuration.isPreferTabs(), "-w", "1", "nt"); + var cmd = CommandBuilder.of().addIf(configuration.isPreferTabs(), "-w", "1", "nt"); if (configuration.getColor() != null) { cmd.add("--tabColor").addQuoted(configuration.getColor().toHexString()); diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 0fd7cefbd..0f2712d06 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -94,12 +94,16 @@ public class AppInstaller { : getPowershellCommand(file.toString(), logFile, exec, systemWide); String toRun; if (ProcessControlProvider.get().getEffectiveLocalDialect() == ShellDialects.CMD) { - toRun = systemWide ? "powershell -Command Start-Process -Verb runAs -WindowStyle Minimized -FilePath cmd -ArgumentList \"/c\", '\"" - + ScriptHelper.createLocalExecScript(command) + "\"'" : - "start \"XPipe Updater\" /min cmd /c \"" + ScriptHelper.createLocalExecScript(command) + "\""; + toRun = systemWide + ? "powershell -Command Start-Process -Verb runAs -WindowStyle Minimized -FilePath cmd -ArgumentList \"/c\", '\"" + + ScriptHelper.createLocalExecScript(command) + "\"'" + : "start \"XPipe Updater\" /min cmd /c \"" + ScriptHelper.createLocalExecScript(command) + + "\""; } else { - toRun = "Start-Process -WindowStyle Minimized -FilePath powershell -ArgumentList \"-ExecutionPolicy\", \"Bypass\", \"-File\", \"`\"" - + ScriptHelper.createLocalExecScript(command) + "`\"\"" + (systemWide ? " -Verb runAs" : ""); + toRun = + "Start-Process -WindowStyle Minimized -FilePath powershell -ArgumentList \"-ExecutionPolicy\", \"Bypass\", \"-File\", \"`\"" + + ScriptHelper.createLocalExecScript(command) + "`\"\"" + + (systemWide ? " -Verb runAs" : ""); } runAndClose(() -> { LocalShell.getShell().executeSimpleCommand(toRun); @@ -112,7 +116,8 @@ public class AppInstaller { } private boolean isSystemWide() { - return Files.exists(XPipeInstallation.getCurrentInstallationBasePath().resolve("system")); + return Files.exists( + XPipeInstallation.getCurrentInstallationBasePath().resolve("system")); } private String getCmdCommand(String file, String logFile, String exec, boolean systemWide) { diff --git a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java index 60a50af5d..81a84b18b 100644 --- a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java +++ b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java @@ -260,7 +260,7 @@ public class XPipeInstallation { String path; if (OsType.getLocal().equals(OsType.WINDOWS)) { var pg = System.getenv("ProgramFiles"); - var systemPath = Path.of(pg,stage ? "XPipe PTB" : "XPipe"); + var systemPath = Path.of(pg, stage ? "XPipe PTB" : "XPipe"); if (Files.exists(systemPath)) { return systemPath.toString(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/DownloadAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/DownloadAction.java index 89273a9ec..fdf26341a 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/DownloadAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/DownloadAction.java @@ -5,16 +5,15 @@ import io.xpipe.app.browser.action.BrowserLeafAction; import io.xpipe.app.browser.file.BrowserEntry; import io.xpipe.app.browser.file.BrowserFileSystemTabModel; import io.xpipe.app.core.AppI18n; -import io.xpipe.app.prefs.AppPrefs; -import io.xpipe.core.store.FileKind; + import javafx.beans.value.ObservableValue; import javafx.scene.Node; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; + import org.kordamp.ikonli.javafx.FontIcon; -import java.util.Collections; import java.util.List; public class DownloadAction implements BrowserLeafAction {