mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-19 02:39:01 +12:00
Workaround for settings cancel bug and cleanup
This commit is contained in:
parent
7b5ea652b6
commit
8e7f3f5aab
9 changed files with 18 additions and 104 deletions
|
@ -4,13 +4,13 @@ import atlantafx.base.theme.Styles;
|
||||||
import io.xpipe.app.browser.action.BrowserAction;
|
import io.xpipe.app.browser.action.BrowserAction;
|
||||||
import io.xpipe.app.browser.icon.FileIconManager;
|
import io.xpipe.app.browser.icon.FileIconManager;
|
||||||
import io.xpipe.app.comp.base.LazyTextFieldComp;
|
import io.xpipe.app.comp.base.LazyTextFieldComp;
|
||||||
|
import io.xpipe.app.fxcomps.SimpleComp;
|
||||||
import io.xpipe.app.fxcomps.SimpleCompStructure;
|
import io.xpipe.app.fxcomps.SimpleCompStructure;
|
||||||
import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
|
import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
|
||||||
import io.xpipe.app.fxcomps.impl.SvgCacheComp;
|
import io.xpipe.app.fxcomps.impl.SvgCacheComp;
|
||||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||||
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
||||||
import io.xpipe.app.util.BusyProperty;
|
import io.xpipe.app.util.BusyProperty;
|
||||||
import io.xpipe.app.util.Containers;
|
|
||||||
import io.xpipe.app.util.HumanReadableFormat;
|
import io.xpipe.app.util.HumanReadableFormat;
|
||||||
import io.xpipe.app.util.ThreadHelper;
|
import io.xpipe.app.util.ThreadHelper;
|
||||||
import io.xpipe.core.impl.FileNames;
|
import io.xpipe.core.impl.FileNames;
|
||||||
|
@ -24,7 +24,6 @@ import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.css.PseudoClass;
|
import javafx.css.PseudoClass;
|
||||||
import javafx.geometry.Bounds;
|
import javafx.geometry.Bounds;
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
@ -42,7 +41,7 @@ import java.util.Objects;
|
||||||
import static io.xpipe.app.util.HumanReadableFormat.byteCount;
|
import static io.xpipe.app.util.HumanReadableFormat.byteCount;
|
||||||
import static javafx.scene.control.TableColumn.SortType.ASCENDING;
|
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 HIDDEN = PseudoClass.getPseudoClass("hidden");
|
||||||
private static final PseudoClass EMPTY = PseudoClass.getPseudoClass("empty");
|
private static final PseudoClass EMPTY = PseudoClass.getPseudoClass("empty");
|
||||||
|
@ -56,14 +55,15 @@ final class BrowserFileListComp extends AnchorPane {
|
||||||
|
|
||||||
public BrowserFileListComp(BrowserFileListModel fileList) {
|
public BrowserFileListComp(BrowserFileListModel fileList) {
|
||||||
this.fileList = fileList;
|
this.fileList = fileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Region createSimple() {
|
||||||
TableView<BrowserEntry> table = createTable();
|
TableView<BrowserEntry> table = createTable();
|
||||||
SimpleChangeListener.apply(table.comparatorProperty(), (newValue) -> {
|
SimpleChangeListener.apply(table.comparatorProperty(), (newValue) -> {
|
||||||
fileList.setComparator(newValue);
|
fileList.setComparator(newValue);
|
||||||
});
|
});
|
||||||
|
return table;
|
||||||
getChildren().setAll(table);
|
|
||||||
getStyleClass().addAll("table-directory-view");
|
|
||||||
Containers.setAnchors(table, Insets.EMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -66,9 +66,7 @@ public class OpenFileSystemComp extends SimpleComp {
|
||||||
topBar.getItems()
|
topBar.getItems()
|
||||||
.setAll(backBtn, forthBtn, new Spacer(10), new BrowserNavBar(model).createRegion(), filter.get(), refreshBtn, terminalBtn, menuButton);
|
.setAll(backBtn, forthBtn, new Spacer(10), new BrowserNavBar(model).createRegion(), filter.get(), refreshBtn, terminalBtn, menuButton);
|
||||||
|
|
||||||
// ~
|
var directoryView = new BrowserFileListComp(model.getFileList()).createRegion();
|
||||||
|
|
||||||
BrowserFileListComp directoryView = new BrowserFileListComp(model.getFileList());
|
|
||||||
|
|
||||||
var root = new VBox(topBar, directoryView);
|
var root = new VBox(topBar, directoryView);
|
||||||
if (model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER) {
|
if (model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import io.xpipe.app.core.AppI18n;
|
||||||
import io.xpipe.app.fxcomps.SimpleComp;
|
import io.xpipe.app.fxcomps.SimpleComp;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import io.xpipe.app.prefs.ClearCacheAlert;
|
import io.xpipe.app.prefs.ClearCacheAlert;
|
||||||
import javafx.beans.binding.Bindings;
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
|
@ -33,27 +32,6 @@ public class PrefsComp extends SimpleComp {
|
||||||
MasterDetailPane p = (MasterDetailPane) pfx.getCenter();
|
MasterDetailPane p = (MasterDetailPane) pfx.getCenter();
|
||||||
p.dividerPositionProperty().setValue(0.27);
|
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 clearCaches = new ButtonComp(AppI18n.observable("clearCaches"), null, ClearCacheAlert::show).createRegion();
|
||||||
// var reload = new ButtonComp(AppI18n.observable("reload"), null, () -> OperationMode.reload()).createRegion();
|
// var reload = new ButtonComp(AppI18n.observable("reload"), null, () -> OperationMode.reload()).createRegion();
|
||||||
var leftButtons = new HBox(clearCaches);
|
var leftButtons = new HBox(clearCaches);
|
||||||
|
@ -65,7 +43,7 @@ public class PrefsComp extends SimpleComp {
|
||||||
AnchorPane.setBottomAnchor(leftButtons, 15.0);
|
AnchorPane.setBottomAnchor(leftButtons, 15.0);
|
||||||
AnchorPane.setLeftAnchor(leftButtons, 15.0);
|
AnchorPane.setLeftAnchor(leftButtons, 15.0);
|
||||||
|
|
||||||
var stack = new StackPane(pfx, rightPane, leftPane);
|
var stack = new StackPane(pfx, leftPane);
|
||||||
stack.setPickOnBounds(false);
|
stack.setPickOnBounds(false);
|
||||||
AppFont.medium(stack);
|
AppFont.medium(stack);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,11 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
|
||||||
|
|
||||||
public abstract boolean isAvailable();
|
public abstract boolean isAvailable();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getId();
|
||||||
|
}
|
||||||
|
|
||||||
public static class MacApplication extends ExternalApplicationType {
|
public static class MacApplication extends ExternalApplicationType {
|
||||||
|
|
||||||
protected final String applicationName;
|
protected final String applicationName;
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package io.xpipe.app.util;
|
|
||||||
|
|
||||||
public final class Controls {
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,6 +12,8 @@ lockCreationAlertHeader=Set your new lock password
|
||||||
finish=Finish
|
finish=Finish
|
||||||
error=Error
|
error=Error
|
||||||
ok=Ok
|
ok=Ok
|
||||||
|
newFile=New file
|
||||||
|
newDirectory=New directory
|
||||||
password=Password
|
password=Password
|
||||||
unlockAlertTitle=Unlock workspace
|
unlockAlertTitle=Unlock workspace
|
||||||
unlockAlertHeader=Enter your lock password to continue
|
unlockAlertHeader=Enter your lock password to continue
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
visibility: hidden ;
|
visibility: hidden ;
|
||||||
}
|
}
|
||||||
|
|
||||||
.browser .table-directory-view .table-view {
|
.browser .table-view {
|
||||||
-color-header-bg: -color-bg-default;
|
-color-header-bg: -color-bg-default;
|
||||||
-color-cell-bg-selected: -color-neutral-emphasis;
|
-color-cell-bg-selected: -color-neutral-emphasis;
|
||||||
-color-cell-fg-selected: -color-fg-emphasis;
|
-color-cell-fg-selected: -color-fg-emphasis;
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
-fx-opacity: 0.75;
|
-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;
|
-fx-opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
.modal-overlay-comp .titled-pane {
|
.modal-overlay-comp .titled-pane {
|
||||||
-fx-font-size: 1.6em;
|
|
||||||
-fx-padding: 0;
|
-fx-padding: 0;
|
||||||
-fx-border-radius: 0;
|
-fx-border-radius: 0;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +9,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-overlay-comp .titled-pane > * {
|
.modal-overlay-comp .titled-pane > * {
|
||||||
-fx-font-size: 1.0em;
|
|
||||||
-fx-border-radius: 0;
|
-fx-border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue