From d3f4bd30440f29fa14c6cf80812046bb30cefac8 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 27 Mar 2024 18:19:03 +0000 Subject: [PATCH] Reformat --- .../io/xpipe/app/browser/BrowserComp.java | 2 +- .../app/browser/BrowserFileListComp.java | 39 +++++++++++-------- .../browser/BrowserQuickAccessButtonComp.java | 22 +++++++++-- .../xpipe/app/browser/action/LeafAction.java | 3 +- .../xpipe/app/comp/base/ErrorOverlayComp.java | 15 ++++--- .../xpipe/app/comp/base/ModalOverlayComp.java | 4 +- .../io/xpipe/app/comp/base/OsLogoComp.java | 5 +-- .../xpipe/app/comp/store/StoreIntroComp.java | 3 +- .../store/StoreQuickAccessButtonComp.java | 8 +++- .../app/comp/store/StoreSectionMiniComp.java | 3 +- .../main/java/io/xpipe/app/core/AppLogs.java | 14 +++---- .../main/java/io/xpipe/app/core/AppSid.java | 7 +++- .../app/fxcomps/impl/DataStoreChoiceComp.java | 10 +++-- .../xpipe/app/launcher/LauncherCommand.java | 2 +- .../xpipe/app/prefs/ExternalEditorType.java | 4 +- .../app/terminal/ExternalTerminalType.java | 3 +- .../java/io/xpipe/app/util/SecretQuery.java | 3 +- .../java/io/xpipe/app/util/ShellTemp.java | 3 +- .../java/io/xpipe/core/store/FilePath.java | 18 +++++---- .../ext/base/browser/FileTypeAction.java | 2 +- 20 files changed, 106 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java index 7a0e4320..f9a35de3 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java @@ -4,8 +4,8 @@ import atlantafx.base.controls.RingProgressIndicator; import atlantafx.base.controls.Spacer; import atlantafx.base.theme.Styles; import io.xpipe.app.browser.icon.BrowserIconDirectoryType; -import io.xpipe.app.browser.icon.FileIconManager; import io.xpipe.app.browser.icon.BrowserIconFileType; +import io.xpipe.app.browser.icon.FileIconManager; import io.xpipe.app.comp.base.MultiContentComp; import io.xpipe.app.comp.base.SideSplitPaneComp; import io.xpipe.app.core.AppLayoutModel; diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java index 04427da1..5fce54b5 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java @@ -497,16 +497,27 @@ final class BrowserFileListComp extends SimpleComp { itemProperty())); setAccessibleRole(AccessibleRole.TEXT); - var textField = new LazyTextFieldComp(text).minWidth(USE_PREF_SIZE).createStructure().get(); - var quickAccess = new BrowserQuickAccessButtonComp(() -> getTableRow().getItem(), fileList.getFileSystemModel()) - .hide(Bindings.createBooleanBinding(() -> { - var notDir = getTableRow().getItem().getRawFileEntry().getKind() != FileKind.DIRECTORY; - var isParentLink = getTableRow() - .getItem() - .getRawFileEntry() - .equals(fileList.getFileSystemModel().getCurrentParentDirectory()); - return notDir || isParentLink; - }, itemProperty())).createRegion(); + var textField = new LazyTextFieldComp(text) + .minWidth(USE_PREF_SIZE) + .createStructure() + .get(); + var quickAccess = new BrowserQuickAccessButtonComp( + () -> getTableRow().getItem(), fileList.getFileSystemModel()) + .hide(Bindings.createBooleanBinding( + () -> { + var notDir = getTableRow() + .getItem() + .getRawFileEntry() + .getKind() + != FileKind.DIRECTORY; + var isParentLink = getTableRow() + .getItem() + .getRawFileEntry() + .equals(fileList.getFileSystemModel().getCurrentParentDirectory()); + return notDir || isParentLink; + }, + itemProperty())) + .createRegion(); editing.addListener((observable, oldValue, newValue) -> { if (getTableRow().getItem() != null && getTableRow().getItem().equals(newValue)) { @@ -527,11 +538,7 @@ final class BrowserFileListComp extends SimpleComp { text.addListener(listener); Node imageView = PrettyImageHelper.ofFixedSize(img, 24, 24).createRegion(); - HBox graphic = new HBox(imageView, - new Spacer(5), - quickAccess, - new Spacer(1), - textField); + HBox graphic = new HBox(imageView, new Spacer(5), quickAccess, new Spacer(1), textField); quickAccess.prefHeightProperty().bind(graphic.heightProperty()); graphic.setAlignment(Pos.CENTER_LEFT); graphic.setPrefHeight(34); @@ -553,7 +560,7 @@ final class BrowserFileListComp extends SimpleComp { // Don't set image as that would trigger image comp update // and cells are emptied on each change, leading to unnecessary changes // img.set(null); - + // Visibility seems to be bugged, so use opacity setOpacity(0.0); } else { diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserQuickAccessButtonComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserQuickAccessButtonComp.java index 1df93da5..aa276d57 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserQuickAccessButtonComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserQuickAccessButtonComp.java @@ -74,7 +74,8 @@ public class BrowserQuickAccessButtonComp extends SimpleComp { }); } - private MenuItem createItem(ContextMenu contextMenu, FileSystem.FileEntry fileEntry, AtomicReference showingActionsMenu) { + private MenuItem createItem( + ContextMenu contextMenu, FileSystem.FileEntry fileEntry, AtomicReference showingActionsMenu) { var browserCm = new BrowserContextMenu(model, new BrowserEntry(fileEntry, model.getFileList(), false)); browserCm.setOnAction(e -> { contextMenu.hide(); @@ -165,7 +166,12 @@ public class BrowserQuickAccessButtonComp extends SimpleComp { } private List updateMenuItems( - ContextMenu contextMenu, Menu m, FileSystem.FileEntry fileEntry, boolean updateInstantly, AtomicReference showingActionsMenu) throws Exception { + ContextMenu contextMenu, + Menu m, + FileSystem.FileEntry fileEntry, + boolean updateInstantly, + AtomicReference showingActionsMenu) + throws Exception { var newFiles = model.getFileSystem().listFiles(fileEntry.getPath()); try (var s = newFiles) { var list = s.toList(); @@ -187,12 +193,20 @@ public class BrowserQuickAccessButtonComp extends SimpleComp { return o1.getName().compareToIgnoreCase(o2.getName()); }) .collect(Collectors.toMap( - e -> e, e -> createItem(contextMenu, e, showingActionsMenu), (v1, v2) -> v2, LinkedHashMap::new)); + e -> e, + e -> createItem(contextMenu, e, showingActionsMenu), + (v1, v2) -> v2, + LinkedHashMap::new)); var dirs = list.stream() .filter(e -> e.getKind() == FileKind.DIRECTORY) .toList(); if (dirs.size() == 1) { - updateMenuItems(contextMenu, (Menu) menus.get(dirs.getFirst()), list.getFirst(), updateInstantly, showingActionsMenu); + updateMenuItems( + contextMenu, + (Menu) menus.get(dirs.getFirst()), + list.getFirst(), + updateInstantly, + showingActionsMenu); } newItems.addAll(menus.values()); } diff --git a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java index 61233179..4c776489 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java @@ -61,7 +61,8 @@ public interface LeafAction extends BrowserAction { return b; } - default MenuItem toMenuItem(OpenFileSystemModel model, List selected, UnaryOperator nameFunc) { + default MenuItem toMenuItem( + OpenFileSystemModel model, List selected, UnaryOperator nameFunc) { var name = nameFunc.apply(getName(model, selected)); var mi = new MenuItem(name); mi.setOnAction(event -> { diff --git a/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java b/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java index b97b63fe..169971d6 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java @@ -37,11 +37,16 @@ public class ErrorOverlayComp extends SimpleComp { l.setEditable(false); return l; }); - content.set(new ModalOverlayComp.OverlayContent("error", comp, Comp.of(() -> { - var graphic = new FontIcon("mdomz-warning"); - graphic.setIconColor(Color.RED); - return new StackPane(graphic); - }), null, () -> {})); + content.set(new ModalOverlayComp.OverlayContent( + "error", + comp, + Comp.of(() -> { + var graphic = new FontIcon("mdomz-warning"); + graphic.setIconColor(Color.RED); + return new StackPane(graphic); + }), + null, + () -> {})); }); }); content.addListener((observable, oldValue, newValue) -> { diff --git a/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java b/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java index 9261be24..176c216d 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java @@ -43,7 +43,9 @@ public class ModalOverlayComp extends SimpleComp { } if (newValue != null) { - var l = new Label(AppI18n.get(newValue.titleKey), newValue.graphic != null ? newValue.graphic.createRegion() : null); + var l = new Label( + AppI18n.get(newValue.titleKey), + newValue.graphic != null ? newValue.graphic.createRegion() : null); l.setGraphicTextGap(6); AppFont.normal(l); var r = newValue.content.createRegion(); diff --git a/app/src/main/java/io/xpipe/app/comp/base/OsLogoComp.java b/app/src/main/java/io/xpipe/app/comp/base/OsLogoComp.java index c608d08c..a6d27f68 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/OsLogoComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/OsLogoComp.java @@ -53,9 +53,8 @@ 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), new PrettyImageComp(img, 24, 24).visible(hide))) .createRegion(); } diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreIntroComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreIntroComp.java index 511206df..dd5c0ed2 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreIntroComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreIntroComp.java @@ -35,8 +35,7 @@ public class StoreIntroComp extends SimpleComp { 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("Wave.svg"), 80, 150).createRegion(); var text = new VBox(title, introDesc); text.setSpacing(5); text.setAlignment(Pos.CENTER_LEFT); diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreQuickAccessButtonComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreQuickAccessButtonComp.java index 07b9ed83..5bcf921b 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreQuickAccessButtonComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreQuickAccessButtonComp.java @@ -62,7 +62,9 @@ public class StoreQuickAccessButtonComp extends SimpleComp { var graphic = w.getEntry().getProvider().getDisplayIconFileName(w.getEntry().getStore()); if (c.isEmpty()) { - var item = new MenuItem(w.getName().getValue(), PrettyImageHelper.ofFixedSizeSquare(graphic, 16).createRegion()); + var item = new MenuItem( + w.getName().getValue(), + PrettyImageHelper.ofFixedSizeSquare(graphic, 16).createRegion()); item.setOnAction(event -> { action.accept(w); contextMenu.hide(); @@ -79,7 +81,9 @@ public class StoreQuickAccessButtonComp extends SimpleComp { items.add(recurse(contextMenu, sub)); } - var m = new Menu(w.getName().getValue(), PrettyImageHelper.ofFixedSizeSquare(graphic, 16).createRegion()); + var m = new Menu( + w.getName().getValue(), + PrettyImageHelper.ofFixedSizeSquare(graphic, 16).createRegion()); m.getItems().setAll(items); m.setOnAction(event -> { if (event.getTarget() == m) { diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreSectionMiniComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreSectionMiniComp.java index 226b9eec..f8f756fa 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreSectionMiniComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreSectionMiniComp.java @@ -64,7 +64,8 @@ public class StoreSectionMiniComp extends Comp> { ? provider.getDisplayIconFileName(section.getWrapper() .getEntry() .getStore()) - : null, 16) + : null, + 16) .createRegion()); }) .apply(struc -> { diff --git a/app/src/main/java/io/xpipe/app/core/AppLogs.java b/app/src/main/java/io/xpipe/app/core/AppLogs.java index 50501aca..f5b13294 100644 --- a/app/src/main/java/io/xpipe/app/core/AppLogs.java +++ b/app/src/main/java/io/xpipe/app/core/AppLogs.java @@ -317,13 +317,13 @@ public class AppLogs { // Only change this when debugging the logs of other libraries return NOPLogger.NOP_LOGGER; -// // Don't use fully qualified class names -// var normalizedName = FilenameUtils.getExtension(name); -// if (normalizedName == null || normalizedName.isEmpty()) { -// normalizedName = name; -// } -// -// return loggers.computeIfAbsent(normalizedName, s -> new Slf4jLogger()); + // // Don't use fully qualified class names + // var normalizedName = FilenameUtils.getExtension(name); + // if (normalizedName == null || normalizedName.isEmpty()) { + // normalizedName = name; + // } + // + // return loggers.computeIfAbsent(normalizedName, s -> new Slf4jLogger()); } }; diff --git a/app/src/main/java/io/xpipe/app/core/AppSid.java b/app/src/main/java/io/xpipe/app/core/AppSid.java index 62309502..1149534f 100644 --- a/app/src/main/java/io/xpipe/app/core/AppSid.java +++ b/app/src/main/java/io/xpipe/app/core/AppSid.java @@ -18,7 +18,9 @@ public class AppSid { return; } - var checkProcess = new ProcessBuilder("which", "setsid").redirectErrorStream(true).redirectOutput(ProcessBuilder.Redirect.DISCARD); + var checkProcess = new ProcessBuilder("which", "setsid") + .redirectErrorStream(true) + .redirectOutput(ProcessBuilder.Redirect.DISCARD); try { var p = checkProcess.start(); if (p.waitFor(1000, TimeUnit.MILLISECONDS)) { @@ -34,7 +36,8 @@ public class AppSid { } // Don't set this in development mode or debug mode - if (AppProperties.get().isDevelopmentEnvironment() || AppLogs.get().getLogLevel().equals("trace")) { + if (AppProperties.get().isDevelopmentEnvironment() + || AppLogs.get().getLogLevel().equals("trace")) { return; } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java index c9ffd5ba..0663f380 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java @@ -186,10 +186,12 @@ public class DataStoreChoiceComp extends SimpleComp { button.apply(struc -> { struc.get().setMaxWidth(2000); struc.get().setAlignment(Pos.CENTER_LEFT); - Comp graphic = new PrettySvgComp(Bindings.createStringBinding(() -> { - if (selected.getValue() == null) { - return null; - } + Comp graphic = new PrettySvgComp( + Bindings.createStringBinding( + () -> { + if (selected.getValue() == null) { + return null; + } return selected.getValue() .get() diff --git a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java index 88ca112f..7f0c8cd5 100644 --- a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java +++ b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java @@ -56,7 +56,7 @@ public class LauncherCommand implements Callable { return 1; }); cmd.setParameterExceptionHandler((ex, args1) -> { - var event = ErrorEvent.fromThrowable(ex).term().build(); + var event = ErrorEvent.fromThrowable(ex).term().expected().build(); // Print error in case we launched from the command-line new LogErrorHandler().handle(event); event.handle(); diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java index 7bcd6ff2..ea76403e 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java @@ -257,8 +257,8 @@ public interface ExternalEditorType extends PrefsChoiceValue { if (location.isEmpty()) { location = determineInstallation(); if (location.isEmpty()) { - throw ErrorEvent.expected( - new IOException("Unable to find installation of " + toTranslatedString().getValue())); + throw ErrorEvent.expected(new IOException("Unable to find installation of " + + toTranslatedString().getValue())); } } diff --git a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java index 585a126f..2523f8cb 100644 --- a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java @@ -729,7 +729,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue { if (location.isEmpty()) { location = determineInstallation(); if (location.isEmpty()) { - throw new IOException("Unable to find installation of " + toTranslatedString().getValue()); + throw new IOException("Unable to find installation of " + + toTranslatedString().getValue()); } } diff --git a/app/src/main/java/io/xpipe/app/util/SecretQuery.java b/app/src/main/java/io/xpipe/app/util/SecretQuery.java index 16e13054..2897b7a1 100644 --- a/app/src/main/java/io/xpipe/app/util/SecretQuery.java +++ b/app/src/main/java/io/xpipe/app/util/SecretQuery.java @@ -64,7 +64,8 @@ public interface SecretQuery { @Override public boolean requiresUserInteraction() { - return original.requiresUserInteraction() || AppPrefs.get().alwaysConfirmElevation().getValue(); + return original.requiresUserInteraction() + || AppPrefs.get().alwaysConfirmElevation().getValue(); } }; } diff --git a/app/src/main/java/io/xpipe/app/util/ShellTemp.java b/app/src/main/java/io/xpipe/app/util/ShellTemp.java index 591cb2eb..ba78ac4c 100644 --- a/app/src/main/java/io/xpipe/app/util/ShellTemp.java +++ b/app/src/main/java/io/xpipe/app/util/ShellTemp.java @@ -43,7 +43,8 @@ public class ShellTemp { base = FileNames.join(temp, "xpipe"); // We have to make sure that also other users can create files here // This command should work in all shells - proc.command("chmod 777 " + proc.getShellDialect().fileArgument(base)).executeAndCheck(); + proc.command("chmod 777 " + proc.getShellDialect().fileArgument(base)) + .executeAndCheck(); var user = proc.getShellDialect().printUsernameCommand(proc).readStdoutOrThrow(); base = FileNames.join(base, user); } else { diff --git a/core/src/main/java/io/xpipe/core/store/FilePath.java b/core/src/main/java/io/xpipe/core/store/FilePath.java index 53df1b2b..61228982 100644 --- a/core/src/main/java/io/xpipe/core/store/FilePath.java +++ b/core/src/main/java/io/xpipe/core/store/FilePath.java @@ -31,7 +31,7 @@ public final class FilePath { return value.contains(" ") ? "\"" + value + "\"" : value; } - public FilePath toDirectory() { + public FilePath toDirectory() { if (value.endsWith("/") || value.endsWith("\\")) { return new FilePath(value); } @@ -43,7 +43,7 @@ public final class FilePath { return new FilePath(value + "/"); } - public FilePath removeTrailingSlash() { + public FilePath removeTrailingSlash() { if (value.equals("/")) { return new FilePath(value); } @@ -83,7 +83,7 @@ public final class FilePath { return list; } - public String getBaseName() { + public String getBaseName() { var split = value.lastIndexOf("."); if (split == -1) { return value; @@ -91,7 +91,7 @@ public final class FilePath { return value.substring(0, split); } - public String getExtension() { + public String getExtension() { var name = FileNames.getFileName(value); var split = name.split("\\."); if (split.length == 0) { @@ -129,12 +129,14 @@ public final class FilePath { return new FilePath(value.substring(0, value.length() - getFileName().length() - 1)); } - public boolean startsWith(FilePath start) { + public boolean startsWith(FilePath start) { return normalize().startsWith(start.normalize()); } public FilePath relativize(FilePath base) { - return new FilePath(normalize().toString().substring(base.normalize().toDirectory().toString().length())); + return new FilePath(normalize() + .toString() + .substring(base.normalize().toDirectory().toString().length())); } public FilePath normalize() { @@ -147,14 +149,14 @@ public final class FilePath { return Arrays.stream(split).filter(s -> !s.isEmpty()).toList(); } - public String toUnix() { + public String toUnix() { var joined = String.join("/", split()); var prefix = value.startsWith("/") ? "/" : ""; var suffix = value.endsWith("/") || value.endsWith("\\") ? "/" : ""; return prefix + joined + suffix; } - public String toWindows() { + public String toWindows() { var suffix = value.endsWith("/") || value.endsWith("\\") ? "\\" : ""; return String.join("\\", split()) + suffix; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/FileTypeAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/FileTypeAction.java index 031d9e8a..1705ae09 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/FileTypeAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/FileTypeAction.java @@ -3,8 +3,8 @@ package io.xpipe.ext.base.browser; import io.xpipe.app.browser.BrowserEntry; import io.xpipe.app.browser.OpenFileSystemModel; import io.xpipe.app.browser.action.BrowserAction; -import io.xpipe.app.browser.icon.BrowserIcons; import io.xpipe.app.browser.icon.BrowserIconFileType; +import io.xpipe.app.browser.icon.BrowserIcons; import javafx.scene.Node; import java.util.List;