mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-10 12:26:16 -04:00
清理 FXUtils (#3667)
This commit is contained in:
parent
96e1ddff79
commit
04781da3a7
@ -31,7 +31,6 @@ import javafx.beans.value.*;
|
|||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventDispatcher;
|
import javafx.event.EventDispatcher;
|
||||||
import javafx.event.EventType;
|
import javafx.event.EventType;
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
@ -255,20 +254,6 @@ public final class FXUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, T> void setupCellValueFactory(JFXTreeTableColumn<K, T> column, Function<K, ObservableValue<T>> 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) {
|
public static void setValidateWhileTextChanged(Node field, boolean validate) {
|
||||||
if (field instanceof JFXTextField) {
|
if (field instanceof JFXTextField) {
|
||||||
if (validate) {
|
if (validate) {
|
||||||
@ -622,22 +607,6 @@ public final class FXUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindBoolean(JFXToggleButton toggleButton, Property<Boolean> property) {
|
|
||||||
toggleButton.selectedProperty().bindBidirectional(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unbindBoolean(JFXToggleButton toggleButton, Property<Boolean> property) {
|
|
||||||
toggleButton.selectedProperty().unbindBidirectional(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void bindBoolean(JFXCheckBox checkBox, Property<Boolean> property) {
|
|
||||||
checkBox.selectedProperty().bindBidirectional(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unbindBoolean(JFXCheckBox checkBox, Property<Boolean> property) {
|
|
||||||
checkBox.selectedProperty().unbindBidirectional(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class EnumBidirectionalBinding<E extends Enum<E>> implements InvalidationListener, WeakListener {
|
private static final class EnumBidirectionalBinding<E extends Enum<E>> implements InvalidationListener, WeakListener {
|
||||||
private final WeakReference<JFXComboBox<E>> comboBoxRef;
|
private final WeakReference<JFXComboBox<E>> comboBoxRef;
|
||||||
private final WeakReference<Property<E>> propertyRef;
|
private final WeakReference<Property<E>> propertyRef;
|
||||||
|
@ -551,8 +551,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
javaCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.javaDirProperty());
|
javaCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.javaDirProperty());
|
||||||
gameDirCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.gameDirProperty());
|
gameDirCustomOption.valueProperty().unbindBidirectional(lastVersionSetting.gameDirProperty());
|
||||||
FXUtils.unbind(txtServerIP, lastVersionSetting.serverIpProperty());
|
FXUtils.unbind(txtServerIP, lastVersionSetting.serverIpProperty());
|
||||||
FXUtils.unbindBoolean(chkAutoAllocate, lastVersionSetting.autoMemoryProperty());
|
chkAutoAllocate.selectedProperty().unbindBidirectional(lastVersionSetting.autoMemoryProperty());
|
||||||
FXUtils.unbindBoolean(chkFullscreen, lastVersionSetting.fullscreenProperty());
|
chkFullscreen.selectedProperty().unbindBidirectional(lastVersionSetting.fullscreenProperty());
|
||||||
showLogsPane.selectedProperty().unbindBidirectional(lastVersionSetting.showLogsProperty());
|
showLogsPane.selectedProperty().unbindBidirectional(lastVersionSetting.showLogsProperty());
|
||||||
FXUtils.unbindEnum(cboLauncherVisibility, lastVersionSetting.launcherVisibilityProperty());
|
FXUtils.unbindEnum(cboLauncherVisibility, lastVersionSetting.launcherVisibilityProperty());
|
||||||
FXUtils.unbindEnum(cboProcessPriority, lastVersionSetting.processPriorityProperty());
|
FXUtils.unbindEnum(cboProcessPriority, lastVersionSetting.processPriorityProperty());
|
||||||
@ -586,8 +586,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
javaCustomOption.bindBidirectional(versionSetting.javaDirProperty());
|
javaCustomOption.bindBidirectional(versionSetting.javaDirProperty());
|
||||||
gameDirCustomOption.bindBidirectional(versionSetting.gameDirProperty());
|
gameDirCustomOption.bindBidirectional(versionSetting.gameDirProperty());
|
||||||
FXUtils.bindString(txtServerIP, versionSetting.serverIpProperty());
|
FXUtils.bindString(txtServerIP, versionSetting.serverIpProperty());
|
||||||
FXUtils.bindBoolean(chkAutoAllocate, versionSetting.autoMemoryProperty());
|
chkAutoAllocate.selectedProperty().bindBidirectional(versionSetting.autoMemoryProperty());
|
||||||
FXUtils.bindBoolean(chkFullscreen, versionSetting.fullscreenProperty());
|
chkFullscreen.selectedProperty().bindBidirectional(versionSetting.fullscreenProperty());
|
||||||
showLogsPane.selectedProperty().bindBidirectional(versionSetting.showLogsProperty());
|
showLogsPane.selectedProperty().bindBidirectional(versionSetting.showLogsProperty());
|
||||||
FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty());
|
FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty());
|
||||||
FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());
|
FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user