清理编译警告 (#2148)

This commit is contained in:
Glavo 2023-02-24 04:14:23 +08:00 committed by GitHub
parent 9a4286620f
commit d71815aa3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View File

@ -625,16 +625,17 @@ public final class FXUtils {
* @param comboBox the combo box being bound with {@code property}. * @param comboBox the combo box being bound with {@code property}.
* @param property the property being bound with {@code combo box}. * @param property the property being bound with {@code combo box}.
* @see #unbindEnum(JFXComboBox) * @see #unbindEnum(JFXComboBox)
* @deprecated Use {@link ExtendedProperties#selectedItemPropertyFor(ComboBox)} * @see ExtendedProperties#selectedItemPropertyFor(ComboBox)
*/ */
@SuppressWarnings("unchecked") public static <T extends Enum<T>> void bindEnum(JFXComboBox<T> comboBox, Property<T> property) {
@Deprecated
public static void bindEnum(JFXComboBox<?> comboBox, Property<? extends Enum<?>> property) {
unbindEnum(comboBox); unbindEnum(comboBox);
@SuppressWarnings("rawtypes")
ChangeListener<Number> listener = (a, b, newValue) -> T currentValue = property.getValue();
((Property) property).setValue(property.getValue().getClass().getEnumConstants()[newValue.intValue()]); @SuppressWarnings("unchecked")
comboBox.getSelectionModel().select(property.getValue().ordinal()); T[] enumConstants = (T[]) currentValue.getClass().getEnumConstants();
ChangeListener<Number> listener = (a, b, newValue) -> property.setValue(enumConstants[newValue.intValue()]);
comboBox.getSelectionModel().select(currentValue.ordinal());
comboBox.getProperties().put("FXUtils.bindEnum.listener", listener); comboBox.getProperties().put("FXUtils.bindEnum.listener", listener);
comboBox.getSelectionModel().selectedIndexProperty().addListener(listener); comboBox.getSelectionModel().selectedIndexProperty().addListener(listener);
} }
@ -645,15 +646,13 @@ public final class FXUtils {
* *
* @param comboBox the combo box being bound with the property which can be inferred by {@code bindEnum}. * @param comboBox the combo box being bound with the property which can be inferred by {@code bindEnum}.
* @see #bindEnum(JFXComboBox, Property) * @see #bindEnum(JFXComboBox, Property)
* @deprecated Use {@link ExtendedProperties#selectedItemPropertyFor(ComboBox)} * @see ExtendedProperties#selectedItemPropertyFor(ComboBox)
*/ */
@SuppressWarnings("unchecked") public static void unbindEnum(JFXComboBox<? extends Enum<?>> comboBox) {
@Deprecated @SuppressWarnings("unchecked")
public static void unbindEnum(JFXComboBox<?> comboBox) { ChangeListener<Number> listener = (ChangeListener<Number>) comboBox.getProperties().remove("FXUtils.bindEnum.listener");
@SuppressWarnings("rawtypes") if (listener != null)
ChangeListener listener = tryCast(comboBox.getProperties().get("FXUtils.bindEnum.listener"), ChangeListener.class).orElse(null); comboBox.getSelectionModel().selectedIndexProperty().removeListener(listener);
if (listener == null) return;
comboBox.getSelectionModel().selectedIndexProperty().removeListener(listener);
} }
/** /**

View File

@ -204,7 +204,6 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor
bindProperties(); bindProperties();
} }
@SuppressWarnings("deprecation")
void bindProperties() { void bindProperties() {
nativesDirCustomOption.bindBidirectional(versionSetting.nativesDirProperty()); nativesDirCustomOption.bindBidirectional(versionSetting.nativesDirProperty());
FXUtils.bindString(txtJVMArgs, versionSetting.javaArgsProperty()); FXUtils.bindString(txtJVMArgs, versionSetting.javaArgsProperty());