From 8e7f3f5aabc7d2a8e8c108d47fb13d7da9e26bf6 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 19 May 2023 18:26:47 +0000 Subject: [PATCH] Workaround for settings cancel bug and cleanup --- .../app/browser/BrowserFileListComp.java | 14 ++--- .../xpipe/app/browser/OpenFileSystemComp.java | 4 +- .../java/io/xpipe/app/comp/PrefsComp.java | 24 +------ .../app/prefs/ExternalApplicationType.java | 5 ++ .../java/io/xpipe/app/util/Containers.java | 62 ------------------- .../main/java/io/xpipe/app/util/Controls.java | 5 -- .../resources/lang/translations_en.properties | 2 + .../io/xpipe/app/resources/style/browser.css | 4 +- .../resources/style/modal-overlay-comp.css | 2 - 9 files changed, 18 insertions(+), 104 deletions(-) delete mode 100644 app/src/main/java/io/xpipe/app/util/Containers.java delete mode 100644 app/src/main/java/io/xpipe/app/util/Controls.java 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 1b643a1a..26ed4404 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java @@ -4,13 +4,13 @@ import atlantafx.base.theme.Styles; import io.xpipe.app.browser.action.BrowserAction; import io.xpipe.app.browser.icon.FileIconManager; import io.xpipe.app.comp.base.LazyTextFieldComp; +import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.fxcomps.SimpleCompStructure; import io.xpipe.app.fxcomps.augment.ContextMenuAugment; import io.xpipe.app.fxcomps.impl.SvgCacheComp; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.fxcomps.util.SimpleChangeListener; import io.xpipe.app.util.BusyProperty; -import io.xpipe.app.util.Containers; import io.xpipe.app.util.HumanReadableFormat; import io.xpipe.app.util.ThreadHelper; import io.xpipe.core.impl.FileNames; @@ -24,7 +24,6 @@ import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.css.PseudoClass; import javafx.geometry.Bounds; -import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; @@ -42,7 +41,7 @@ import java.util.Objects; import static io.xpipe.app.util.HumanReadableFormat.byteCount; import static javafx.scene.control.TableColumn.SortType.ASCENDING; -final class BrowserFileListComp extends AnchorPane { +final class BrowserFileListComp extends SimpleComp { private static final PseudoClass HIDDEN = PseudoClass.getPseudoClass("hidden"); private static final PseudoClass EMPTY = PseudoClass.getPseudoClass("empty"); @@ -56,14 +55,15 @@ final class BrowserFileListComp extends AnchorPane { public BrowserFileListComp(BrowserFileListModel fileList) { this.fileList = fileList; + } + + @Override + protected Region createSimple() { TableView table = createTable(); SimpleChangeListener.apply(table.comparatorProperty(), (newValue) -> { fileList.setComparator(newValue); }); - - getChildren().setAll(table); - getStyleClass().addAll("table-directory-view"); - Containers.setAnchors(table, Insets.EMPTY); + return table; } @SuppressWarnings("unchecked") diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java index 6bfb582c..225dc4c1 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java @@ -66,9 +66,7 @@ public class OpenFileSystemComp extends SimpleComp { topBar.getItems() .setAll(backBtn, forthBtn, new Spacer(10), new BrowserNavBar(model).createRegion(), filter.get(), refreshBtn, terminalBtn, menuButton); - // ~ - - BrowserFileListComp directoryView = new BrowserFileListComp(model.getFileList()); + var directoryView = new BrowserFileListComp(model.getFileList()).createRegion(); var root = new VBox(topBar, directoryView); if (model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER) { diff --git a/app/src/main/java/io/xpipe/app/comp/PrefsComp.java b/app/src/main/java/io/xpipe/app/comp/PrefsComp.java index 841300c5..9c1ba13a 100644 --- a/app/src/main/java/io/xpipe/app/comp/PrefsComp.java +++ b/app/src/main/java/io/xpipe/app/comp/PrefsComp.java @@ -6,7 +6,6 @@ import io.xpipe.app.core.AppI18n; import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.prefs.ClearCacheAlert; -import javafx.beans.binding.Bindings; import javafx.geometry.Pos; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; @@ -33,27 +32,6 @@ public class PrefsComp extends SimpleComp { MasterDetailPane p = (MasterDetailPane) pfx.getCenter(); p.dividerPositionProperty().setValue(0.27); - var cancel = new ButtonComp(AppI18n.observable("cancel"), null, () -> { - AppPrefs.get().cancel(); - layout.selectedProperty().setValue(layout.getEntries().get(0)); - }) - .createRegion(); - var apply = new ButtonComp(AppI18n.observable("apply"), null, () -> { - AppPrefs.get().save(); - layout.selectedProperty().setValue(layout.getEntries().get(0)); - }) - .createRegion(); - var maxWidth = Bindings.max(cancel.widthProperty(), apply.widthProperty()); - cancel.minWidthProperty().bind(maxWidth); - apply.minWidthProperty().bind(maxWidth); - var rightButtons = new HBox(apply, cancel); - rightButtons.setSpacing(8); - - var rightPane = new AnchorPane(rightButtons); - rightPane.setPickOnBounds(false); - AnchorPane.setBottomAnchor(rightButtons, 15.0); - AnchorPane.setRightAnchor(rightButtons, 55.0); - var clearCaches = new ButtonComp(AppI18n.observable("clearCaches"), null, ClearCacheAlert::show).createRegion(); // var reload = new ButtonComp(AppI18n.observable("reload"), null, () -> OperationMode.reload()).createRegion(); var leftButtons = new HBox(clearCaches); @@ -65,7 +43,7 @@ public class PrefsComp extends SimpleComp { AnchorPane.setBottomAnchor(leftButtons, 15.0); AnchorPane.setLeftAnchor(leftButtons, 15.0); - var stack = new StackPane(pfx, rightPane, leftPane); + var stack = new StackPane(pfx, leftPane); stack.setPickOnBounds(false); AppFont.medium(stack); diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java index dbac96cd..94beeabf 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java @@ -27,6 +27,11 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue { public abstract boolean isAvailable(); + @Override + public String toString() { + return getId(); + } + public static class MacApplication extends ExternalApplicationType { protected final String applicationName; diff --git a/app/src/main/java/io/xpipe/app/util/Containers.java b/app/src/main/java/io/xpipe/app/util/Containers.java deleted file mode 100644 index 30010221..00000000 --- a/app/src/main/java/io/xpipe/app/util/Containers.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.xpipe.app.util; - -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; - -import static javafx.scene.layout.Region.USE_COMPUTED_SIZE; -import static javafx.scene.layout.Region.USE_PREF_SIZE; - -public final class Containers { - - public static final ColumnConstraints H_GROW_NEVER = columnConstraints(Priority.NEVER); - - public static void setAnchors(Node node, Insets insets) { - if (insets.getTop() >= 0) { - AnchorPane.setTopAnchor(node, insets.getTop()); - } - if (insets.getRight() >= 0) { - AnchorPane.setRightAnchor(node, insets.getRight()); - } - if (insets.getBottom() >= 0) { - AnchorPane.setBottomAnchor(node, insets.getBottom()); - } - if (insets.getLeft() >= 0) { - AnchorPane.setLeftAnchor(node, insets.getLeft()); - } - } - - public static void setScrollConstraints(ScrollPane scrollPane, - ScrollPane.ScrollBarPolicy vbarPolicy, boolean fitHeight, - ScrollPane.ScrollBarPolicy hbarPolicy, boolean fitWidth) { - scrollPane.setVbarPolicy(vbarPolicy); - scrollPane.setFitToHeight(fitHeight); - scrollPane.setHbarPolicy(hbarPolicy); - scrollPane.setFitToWidth(fitWidth); - } - - public static ColumnConstraints columnConstraints(Priority hgrow) { - return columnConstraints(USE_COMPUTED_SIZE, hgrow); - } - - public static ColumnConstraints columnConstraints(double minWidth, Priority hgrow) { - double maxWidth = hgrow == Priority.ALWAYS ? Double.MAX_VALUE : USE_PREF_SIZE; - ColumnConstraints constraints = new ColumnConstraints(minWidth, USE_COMPUTED_SIZE, maxWidth); - constraints.setHgrow(hgrow); - return constraints; - } - - public static void usePrefWidth(Region region) { - region.setMinWidth(USE_PREF_SIZE); - region.setMaxWidth(USE_PREF_SIZE); - } - - public static void usePrefHeight(Region region) { - region.setMinHeight(USE_PREF_SIZE); - region.setMaxHeight(USE_PREF_SIZE); - } -} diff --git a/app/src/main/java/io/xpipe/app/util/Controls.java b/app/src/main/java/io/xpipe/app/util/Controls.java deleted file mode 100644 index 6efe3d5e..00000000 --- a/app/src/main/java/io/xpipe/app/util/Controls.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.xpipe.app.util; - -public final class Controls { - -} diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties index 450224ae..470e509c 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties @@ -12,6 +12,8 @@ lockCreationAlertHeader=Set your new lock password finish=Finish error=Error ok=Ok +newFile=New file +newDirectory=New directory password=Password unlockAlertTitle=Unlock workspace unlockAlertHeader=Enter your lock password to continue diff --git a/app/src/main/resources/io/xpipe/app/resources/style/browser.css b/app/src/main/resources/io/xpipe/app/resources/style/browser.css index 52592675..a60e4a78 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/browser.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/browser.css @@ -148,7 +148,7 @@ visibility: hidden ; } -.browser .table-directory-view .table-view { +.browser .table-view { -color-header-bg: -color-bg-default; -color-cell-bg-selected: -color-neutral-emphasis; -color-cell-fg-selected: -color-fg-emphasis; @@ -161,7 +161,7 @@ -fx-opacity: 0.75; } -.browser .table-directory-view .table-view:drag-into-current .table-row-cell { +.browser .table-view:drag-into-current .table-row-cell { -fx-opacity: 0.8; } diff --git a/app/src/main/resources/io/xpipe/app/resources/style/modal-overlay-comp.css b/app/src/main/resources/io/xpipe/app/resources/style/modal-overlay-comp.css index d7316b39..229981cd 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/modal-overlay-comp.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/modal-overlay-comp.css @@ -1,5 +1,4 @@ .modal-overlay-comp .titled-pane { --fx-font-size: 1.6em; -fx-padding: 0; -fx-border-radius: 0; } @@ -10,7 +9,6 @@ } .modal-overlay-comp .titled-pane > * { --fx-font-size: 1.0em; -fx-border-radius: 0; }