changed checkFailed property to ObservableValue

This commit is contained in:
Jan-Peter Klein 2024-05-06 13:46:49 +02:00
parent 08f81b7df4
commit e79257e5ea
No known key found for this signature in database
GPG Key ID: 90EDA3A7C822FD0E
2 changed files with 8 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Worker;
import javafx.concurrent.WorkerStateEvent;
@ -35,7 +36,8 @@ public class UpdateChecker {
private final ObjectProperty<Instant> lastSuccessfulUpdateCheck = new SimpleObjectProperty<>();
private final Comparator<String> versionComparator = new SemVerComparator();
private final BooleanBinding updateAvailable;
private final BooleanBinding checkFailed;
//private final BooleanBinding checkFailed;
private final ObservableValue<Boolean> checkFailed;
@Inject
UpdateChecker(Settings settings, //
@ -50,7 +52,7 @@ public class UpdateChecker {
var latestVersion = this.latestVersion.get();
return latestVersion != null && versionComparator.compare(getCurrentVersion(), latestVersion) < 0;
}, latestVersion);
this.checkFailed = Bindings.createBooleanBinding(() -> state.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_FAILED).get(), state);
this.checkFailed = state.map(UpdateCheckState.CHECK_FAILED::equals);
}
public void automaticallyCheckForUpdatesIfEnabled() {
@ -109,7 +111,7 @@ public class UpdateChecker {
public BooleanBinding updateAvailableProperty() {
return updateAvailable;
}
public BooleanBinding checkFailedProperty() {
public ObservableValue<Boolean> checkFailedProperty() {
return checkFailed;
}

View File

@ -47,7 +47,7 @@ public class UpdatesPreferencesController implements FxController {
private final ObservableValue<String> timeDifferenceMessage;
private final String currentVersion;
private final BooleanBinding updateAvailable;
private final BooleanBinding checkFailed;
private final ObservableValue<Boolean> checkFailed;
private final BooleanProperty upToDateLabelVisible = new SimpleBooleanProperty(false);
private final ObjectProperty<UpdateChecker.UpdateCheckState> updateCheckState;
private final DateTimeFormatter formatter;
@ -181,12 +181,12 @@ public class UpdatesPreferencesController implements FxController {
return updateAvailable.get();
}
public BooleanBinding checkFailedProperty() {
public ObservableValue<Boolean> checkFailedProperty() {
return checkFailed;
}
public boolean isCheckFailed() {
return checkFailed.get();
return checkFailed.getValue();
}
}