mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 20:21:27 +00:00
cleanup & renaming
This commit is contained in:
@@ -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<Result> results;
|
||||
private final OptionalBinding<Check.CheckState> taskState;
|
||||
private final Binding<String> taskName;
|
||||
private final Binding<Boolean> taskRunning;
|
||||
private final Binding<Boolean> taskScheduled;
|
||||
private final Binding<Boolean> taskFinished;
|
||||
private final Binding<Boolean> taskNotStarted;
|
||||
private final Binding<Boolean> taskSucceeded;
|
||||
private final Binding<Boolean> taskFailed;
|
||||
private final Binding<Boolean> taskCancelled;
|
||||
private final OptionalBinding<Check.CheckState> checkState;
|
||||
private final Binding<String> checkName;
|
||||
private final Binding<Boolean> checkRunning;
|
||||
private final Binding<Boolean> checkScheduled;
|
||||
private final Binding<Boolean> checkFinished;
|
||||
private final Binding<Boolean> checkSkipped;
|
||||
private final Binding<Boolean> checkSucceeded;
|
||||
private final Binding<Boolean> checkFailed;
|
||||
private final Binding<Boolean> checkCancelled;
|
||||
private final Binding<Number> countOfWarnSeverity;
|
||||
private final Binding<Number> countOfCritSeverity;
|
||||
private final ResultListCellFactory resultListCellFactory;
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
public ListView<Result> resultsListView;
|
||||
private Subscription resultSubscription;
|
||||
|
||||
@Inject
|
||||
public CheckDetailController(ObjectProperty<Check> selectedTask, ResultListCellFactory resultListCellFactory, ResourceBundle resourceBundle) {
|
||||
public CheckDetailController(ObjectProperty<Check> 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<String> taskNameProperty() {
|
||||
return taskName;
|
||||
public Binding<String> 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<Boolean> taskRunningProperty() {
|
||||
return taskRunning;
|
||||
public Binding<Boolean> checkRunningProperty() {
|
||||
return checkRunning;
|
||||
}
|
||||
|
||||
public boolean isTaskFinished() {
|
||||
return taskFinished.getValue();
|
||||
public boolean isCheckFinished() {
|
||||
return checkFinished.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> taskFinishedProperty() {
|
||||
return taskFinished;
|
||||
public Binding<Boolean> checkFinishedProperty() {
|
||||
return checkFinished;
|
||||
}
|
||||
|
||||
public boolean isTaskScheduled() {
|
||||
return taskScheduled.getValue();
|
||||
public boolean isCheckScheduled() {
|
||||
return checkScheduled.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> taskScheduledProperty() {
|
||||
return taskScheduled;
|
||||
public Binding<Boolean> checkScheduledProperty() {
|
||||
return checkScheduled;
|
||||
}
|
||||
|
||||
public boolean isTaskNotStarted() {
|
||||
return taskNotStarted.getValue();
|
||||
public boolean isCheckSkipped() {
|
||||
return checkSkipped.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> taskNotStartedProperty() {
|
||||
return taskNotStarted;
|
||||
public Binding<Boolean> checkSkippedProperty() {
|
||||
return checkSkipped;
|
||||
}
|
||||
|
||||
public boolean isTaskSucceeded() {
|
||||
return taskSucceeded.getValue();
|
||||
public boolean isCheckSucceeded() {
|
||||
return checkSucceeded.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> taskSucceededProperty() {
|
||||
return taskSucceeded;
|
||||
public Binding<Boolean> checkSucceededProperty() {
|
||||
return checkSucceeded;
|
||||
}
|
||||
|
||||
public boolean isTaskFailed() {
|
||||
return taskFailed.getValue();
|
||||
public boolean isCheckFailed() {
|
||||
return checkFailed.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> taskFailedProperty() {
|
||||
return taskFailed;
|
||||
public Binding<Boolean> checkFailedProperty() {
|
||||
return checkFailed;
|
||||
}
|
||||
|
||||
public boolean isTaskCancelled() {
|
||||
return taskCancelled.getValue();
|
||||
public boolean isCheckCancelled() {
|
||||
return checkCancelled.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> 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<Boolean> checkCancelledProperty() {
|
||||
return checkCancelled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
fx:controller="org.cryptomator.ui.health.CheckDetailController"
|
||||
prefWidth="500"
|
||||
spacing="6">
|
||||
<FormattedLabel fx:id="checkTitle" styleClass="label-large" format="%health.check.detail.header" arg1="${controller.taskName}"/>
|
||||
<FormattedLabel fx:id="checkTitle" styleClass="label-large" format="%health.check.detail.header" arg1="${controller.checkName}"/>
|
||||
|
||||
<Label text="%health.check.detail.taskNotStarted" visible="${controller.taskNotStarted}" managed="${controller.taskNotStarted}"/>
|
||||
<Label text="%health.check.detail.taskRunning" visible="${controller.taskRunning}" managed="${controller.taskRunning}"/>
|
||||
<Label text="%health.check.detail.taskScheduled" visible="${controller.taskScheduled}" managed="${controller.taskScheduled}"/>
|
||||
<Label text="%health.check.detail.taskCancelled" visible="${controller.taskCancelled}" managed="${controller.taskCancelled}"/>
|
||||
<Label text="%health.check.detail.taskFailed" visible="${controller.taskFailed}" managed="${controller.taskFailed}"/>
|
||||
<Label text="%health.check.detail.taskSucceeded" visible="${controller.taskSucceeded}" managed="${controller.taskSucceeded}"/>
|
||||
<Label text="%health.check.detail.checkRunning" visible="${controller.checkRunning}" managed="${controller.checkRunning}"/>
|
||||
<Label text="%health.check.detail.checkScheduled" visible="${controller.checkScheduled}" managed="${controller.checkScheduled}"/>
|
||||
<Label text="%health.check.detail.checkSkipped" visible="${controller.checkSkipped}" managed="${controller.checkSkipped}"/>
|
||||
<Label text="%health.check.detail.checkCancelled" visible="${controller.checkCancelled}" managed="${controller.checkCancelled}"/>
|
||||
<Label text="%health.check.detail.checkFailed" visible="${controller.checkFailed}" managed="${controller.checkFailed}"/>
|
||||
<Label text="%health.check.detail.checkSucceeded" visible="${controller.checkSucceeded}" managed="${controller.checkSucceeded}"/>
|
||||
|
||||
<FormattedLabel styleClass="label" format="%health.check.detail.problemCount" arg1="${controller.countOfWarnSeverity}" arg2="${controller.countOfCritSeverity}" visible="${!controller.taskNotStarted}"
|
||||
managed="${!controller.taskNotStarted}" />
|
||||
|
||||
@@ -156,12 +156,12 @@ health.check.runBatchBtn=Run Selected Checks
|
||||
## Detail view
|
||||
health.check.detail.noSelectedCheck=For results select a finished health check in the left list.
|
||||
health.check.detail.header=Results of %s
|
||||
health.check.detail.taskNotStarted=The check was not selected to run.
|
||||
health.check.detail.taskScheduled=The check is scheduled.
|
||||
health.check.detail.taskRunning=The check is currently running…
|
||||
health.check.detail.taskSucceeded=The check finished successfully.
|
||||
health.check.detail.taskFailed=The check exited due to an error.
|
||||
health.check.detail.taskCancelled=The check was cancelled.
|
||||
health.check.detail.checkScheduled=The check is scheduled.
|
||||
health.check.detail.checkRunning=The check is currently running…
|
||||
health.check.detail.checkSkipped=The check was not selected to run.
|
||||
health.check.detail.checkSucceeded=The check finished successfully.
|
||||
health.check.detail.checkFailed=The check exited due to an error.
|
||||
health.check.detail.checkCancelled=The check was cancelled.
|
||||
health.check.detail.problemCount=Found %d problems and %d unfixable errors.
|
||||
health.check.exportBtn=Export Report
|
||||
health.check.fixBtn=Fix
|
||||
|
||||
Reference in New Issue
Block a user