diff --git a/src/main/java/org/cryptomator/ui/health/CheckDetailController.java b/src/main/java/org/cryptomator/ui/health/CheckDetailController.java index 83f5dae4a..b08c32b9e 100644 --- a/src/main/java/org/cryptomator/ui/health/CheckDetailController.java +++ b/src/main/java/org/cryptomator/ui/health/CheckDetailController.java @@ -14,8 +14,6 @@ import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.ListView; -import java.time.Duration; -import java.util.ResourceBundle; import java.util.function.Function; import java.util.stream.Stream; @@ -23,37 +21,35 @@ import java.util.stream.Stream; public class CheckDetailController implements FxController { private final EasyObservableList results; - private final OptionalBinding taskState; - private final Binding taskName; - private final Binding taskRunning; - private final Binding taskScheduled; - private final Binding taskFinished; - private final Binding taskNotStarted; - private final Binding taskSucceeded; - private final Binding taskFailed; - private final Binding taskCancelled; + private final OptionalBinding checkState; + private final Binding checkName; + private final Binding checkRunning; + private final Binding checkScheduled; + private final Binding checkFinished; + private final Binding checkSkipped; + private final Binding checkSucceeded; + private final Binding checkFailed; + private final Binding checkCancelled; private final Binding countOfWarnSeverity; private final Binding countOfCritSeverity; private final ResultListCellFactory resultListCellFactory; - private final ResourceBundle resourceBundle; public ListView resultsListView; private Subscription resultSubscription; @Inject - public CheckDetailController(ObjectProperty selectedTask, ResultListCellFactory resultListCellFactory, ResourceBundle resourceBundle) { + public CheckDetailController(ObjectProperty selectedTask, ResultListCellFactory resultListCellFactory) { this.resultListCellFactory = resultListCellFactory; - this.resourceBundle = resourceBundle; this.results = EasyBind.wrapList(FXCollections.observableArrayList()); - this.taskState = EasyBind.wrapNullable(selectedTask).mapObservable(Check::stateProperty); - this.taskName = EasyBind.wrapNullable(selectedTask).map(Check::getLocalizedName).orElse(""); - this.taskRunning = taskState.map(Check.CheckState.RUNNING::equals).orElse(false); - this.taskScheduled = taskState.map(Check.CheckState.SCHEDULED::equals).orElse(false); - this.taskNotStarted = taskState.map(Check.CheckState.SKIPPED::equals).orElse(false); - this.taskSucceeded = taskState.map(state -> state == Check.CheckState.ALL_GOOD || state == Check.CheckState.WITH_WARNINGS || state == Check.CheckState.WITH_CRITICALS).orElse(false); - this.taskFailed = taskState.map(Check.CheckState.ERROR::equals).orElse(false); - this.taskCancelled = taskState.map(Check.CheckState.CANCELLED::equals).orElse(false); - this.taskFinished = EasyBind.combine(taskSucceeded, taskFailed, taskCancelled, (a, b, c) -> a || b || c); + this.checkState = EasyBind.wrapNullable(selectedTask).mapObservable(Check::stateProperty); + this.checkName = EasyBind.wrapNullable(selectedTask).map(Check::getLocalizedName).orElse(""); + this.checkRunning = checkState.map(Check.CheckState.RUNNING::equals).orElse(false); + this.checkScheduled = checkState.map(Check.CheckState.SCHEDULED::equals).orElse(false); + this.checkSkipped = checkState.map(Check.CheckState.SKIPPED::equals).orElse(false); + this.checkSucceeded = checkState.map(state -> state == Check.CheckState.ALL_GOOD || state == Check.CheckState.WITH_WARNINGS || state == Check.CheckState.WITH_CRITICALS).orElse(false); + this.checkFailed = checkState.map(Check.CheckState.ERROR::equals).orElse(false); + this.checkCancelled = checkState.map(Check.CheckState.CANCELLED::equals).orElse(false); + this.checkFinished = EasyBind.combine(checkSucceeded, checkFailed, checkCancelled, (a, b, c) -> a || b || c); this.countOfWarnSeverity = results.reduce(countSeverity(DiagnosticResult.Severity.WARN)); this.countOfCritSeverity = results.reduce(countSeverity(DiagnosticResult.Severity.CRITICAL)); selectedTask.addListener(this::selectedTaskChanged); @@ -80,12 +76,12 @@ public class CheckDetailController implements FxController { /* Getter/Setter */ - public String getTaskName() { - return taskName.getValue(); + public String getCheckName() { + return checkName.getValue(); } - public Binding taskNameProperty() { - return taskName; + public Binding checkNameProperty() { + return checkName; } public long getCountOfWarnSeverity() { @@ -104,77 +100,60 @@ public class CheckDetailController implements FxController { return countOfCritSeverity; } - public boolean isTaskRunning() { - return taskRunning.getValue(); + public boolean isCheckRunning() { + return checkRunning.getValue(); } - public Binding taskRunningProperty() { - return taskRunning; + public Binding checkRunningProperty() { + return checkRunning; } - public boolean isTaskFinished() { - return taskFinished.getValue(); + public boolean isCheckFinished() { + return checkFinished.getValue(); } - public Binding taskFinishedProperty() { - return taskFinished; + public Binding checkFinishedProperty() { + return checkFinished; } - public boolean isTaskScheduled() { - return taskScheduled.getValue(); + public boolean isCheckScheduled() { + return checkScheduled.getValue(); } - public Binding taskScheduledProperty() { - return taskScheduled; + public Binding checkScheduledProperty() { + return checkScheduled; } - public boolean isTaskNotStarted() { - return taskNotStarted.getValue(); + public boolean isCheckSkipped() { + return checkSkipped.getValue(); } - public Binding taskNotStartedProperty() { - return taskNotStarted; + public Binding checkSkippedProperty() { + return checkSkipped; } - public boolean isTaskSucceeded() { - return taskSucceeded.getValue(); + public boolean isCheckSucceeded() { + return checkSucceeded.getValue(); } - public Binding taskSucceededProperty() { - return taskSucceeded; + public Binding checkSucceededProperty() { + return checkSucceeded; } - public boolean isTaskFailed() { - return taskFailed.getValue(); + public boolean isCheckFailed() { + return checkFailed.getValue(); } - public Binding taskFailedProperty() { - return taskFailed; + public Binding checkFailedProperty() { + return checkFailed; } - public boolean isTaskCancelled() { - return taskCancelled.getValue(); + public boolean isCheckCancelled() { + return checkCancelled.getValue(); } - public Binding taskCancelledProperty() { - return taskCancelled; - } - - private String millisToReadAbleDuration(Number millis) { - Duration tmp = Duration.ofMillis(millis.longValue()); - long hours = tmp.toHoursPart(); - long minutes = tmp.toMinutesPart(); - long seconds = tmp.toSecondsPart(); - if (hours != 0) { - String hms_format = resourceBundle.getString("health.check.detail.hmsFormat"); - return String.format(hms_format, hours, minutes, seconds); - } else if (minutes != 0) { - String ms_format = resourceBundle.getString("health.check.detail.msFormat"); - return String.format(ms_format, minutes, seconds); - } else { - String s_format = resourceBundle.getString("health.check.detail.sFormat"); - return String.format(s_format, seconds); - } + public Binding checkCancelledProperty() { + return checkCancelled; } } diff --git a/src/main/resources/fxml/health_check_details.fxml b/src/main/resources/fxml/health_check_details.fxml index 198d43cde..f2393a9f2 100644 --- a/src/main/resources/fxml/health_check_details.fxml +++ b/src/main/resources/fxml/health_check_details.fxml @@ -9,14 +9,14 @@ fx:controller="org.cryptomator.ui.health.CheckDetailController" prefWidth="500" spacing="6"> - + -