mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 18:51:26 +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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user