From 04781da3a75e8ec51cbf362c0863fa40d5dcea8d Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 28 Feb 2025 01:53:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=20FXUtils=20(#3667)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jackhuang/hmcl/ui/FXUtils.java | 31 ------------------- .../hmcl/ui/versions/VersionSettingsPage.java | 8 ++--- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java index 4d43f7c20..41665da88 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java @@ -31,7 +31,6 @@ import javafx.beans.value.*; import javafx.event.Event; import javafx.event.EventDispatcher; import javafx.event.EventType; -import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Cursor; import javafx.scene.Node; @@ -255,20 +254,6 @@ public final class FXUtils { }); } - public static void setupCellValueFactory(JFXTreeTableColumn column, Function> mapper) { - column.setCellValueFactory(param -> { - if (column.validateValue(param)) - return mapper.apply(param.getValue().getValue()); - else - return column.getComputedValue(param); - }); - } - - public static Node wrapMargin(Node node, Insets insets) { - StackPane.setMargin(node, insets); - return new StackPane(node); - } - public static void setValidateWhileTextChanged(Node field, boolean validate) { if (field instanceof JFXTextField) { if (validate) { @@ -622,22 +607,6 @@ public final class FXUtils { } } - public static void bindBoolean(JFXToggleButton toggleButton, Property property) { - toggleButton.selectedProperty().bindBidirectional(property); - } - - public static void unbindBoolean(JFXToggleButton toggleButton, Property property) { - toggleButton.selectedProperty().unbindBidirectional(property); - } - - public static void bindBoolean(JFXCheckBox checkBox, Property property) { - checkBox.selectedProperty().bindBidirectional(property); - } - - public static void unbindBoolean(JFXCheckBox checkBox, Property property) { - checkBox.selectedProperty().unbindBidirectional(property); - } - private static final class EnumBidirectionalBinding> implements InvalidationListener, WeakListener { private final WeakReference> comboBoxRef; private final WeakReference> propertyRef; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionSettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionSettingsPage.java index f1ff1402c..62dfe743f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionSettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionSettingsPage.java @@ -551,8 +551,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag javaCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.javaDirProperty()); gameDirCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.gameDirProperty()); FXUtils.unbind(txtServerIP, lastVersionSetting.serverIpProperty()); - FXUtils.unbindBoolean(chkAutoAllocate, lastVersionSetting.autoMemoryProperty()); - FXUtils.unbindBoolean(chkFullscreen, lastVersionSetting.fullscreenProperty()); + chkAutoAllocate.selectedProperty().unbindBidirectional(lastVersionSetting.autoMemoryProperty()); + chkFullscreen.selectedProperty().unbindBidirectional(lastVersionSetting.fullscreenProperty()); showLogsPane.selectedProperty().unbindBidirectional(lastVersionSetting.showLogsProperty()); FXUtils.unbindEnum(cboLauncherVisibility, lastVersionSetting.launcherVisibilityProperty()); FXUtils.unbindEnum(cboProcessPriority, lastVersionSetting.processPriorityProperty()); @@ -586,8 +586,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag javaCustomOption.bindBidirectional(versionSetting.javaDirProperty()); gameDirCustomOption.bindBidirectional(versionSetting.gameDirProperty()); FXUtils.bindString(txtServerIP, versionSetting.serverIpProperty()); - FXUtils.bindBoolean(chkAutoAllocate, versionSetting.autoMemoryProperty()); - FXUtils.bindBoolean(chkFullscreen, versionSetting.fullscreenProperty()); + chkAutoAllocate.selectedProperty().bindBidirectional(versionSetting.autoMemoryProperty()); + chkFullscreen.selectedProperty().bindBidirectional(versionSetting.fullscreenProperty()); showLogsPane.selectedProperty().bindBidirectional(versionSetting.showLogsProperty()); FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty()); FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());