From e98f92c63f576dc29e4ddee2810337827c2a4cc3 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 21 May 2021 15:56:32 +0200 Subject: [PATCH] Only use CheckTask title in UI instead of HealthCheck::identifier --- .../cryptomator/ui/health/CheckDetailController.java | 10 ---------- .../org/cryptomator/ui/health/CheckListCell.java | 2 +- .../cryptomator/ui/health/CheckListController.java | 2 +- .../org/cryptomator/ui/health/HealthCheckTask.java | 12 ++++++++++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java index a285d3400..64f7cd6f3 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java @@ -19,7 +19,6 @@ public class CheckDetailController implements FxController { private final Binding> results; private final OptionalBinding taskState; private final Binding taskName; - private final Binding taskDescription; private final ResultListCellFactory resultListCellFactory; private final BooleanBinding producingResults; @@ -30,7 +29,6 @@ public class CheckDetailController implements FxController { this.results = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::results).orElse(FXCollections.emptyObservableList()); this.taskState = EasyBind.wrapNullable(selectedTask).mapObservable(HealthCheckTask::stateProperty); this.taskName = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::getTitle).orElse(""); - this.taskDescription = EasyBind.wrapNullable(selectedTask).map(task -> task.getCheck().toString()).orElse(""); this.resultListCellFactory = resultListCellFactory; this.producingResults = taskState.filter(this::producesResults).isPresent(); } @@ -58,14 +56,6 @@ public class CheckDetailController implements FxController { return taskName; } - public String getTaskDescription() { - return taskDescription.getValue(); - } - - public Binding taskDescriptionProperty() { - return taskDescription; - } - public boolean isProducingResults() { return producingResults.get(); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java index 1b95f91f3..f9e1beda9 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java @@ -21,7 +21,7 @@ class CheckListCell extends ListCell { protected void updateItem(HealthCheckTask item, boolean empty) { super.updateItem(item, empty); if (item != null) { - setText(item.getCheck().identifier()); + setText(item.getTitle()); item.stateProperty().addListener(this::stateChanged); setGraphic(stateIcon); stateIcon.setGlyph(glyphForState(item.getState())); diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java index 9a4fd299f..bfd64dba3 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java @@ -87,7 +87,7 @@ public class CheckListController implements FxController { checksListView.setCellFactory(CheckBoxListCell.forListView(listPickIndicators::get, new StringConverter() { @Override public String toString(HealthCheckTask object) { - return object.getCheck().identifier(); + return object.getTitle(); } @Override diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/HealthCheckTask.java b/main/ui/src/main/java/org/cryptomator/ui/health/HealthCheckTask.java index 493ee9c23..db4fb71cb 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/HealthCheckTask.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/HealthCheckTask.java @@ -3,6 +3,7 @@ package org.cryptomator.ui.health; import org.cryptomator.cryptofs.VaultConfig; import org.cryptomator.cryptofs.health.api.DiagnosticResult; import org.cryptomator.cryptofs.health.api.HealthCheck; +import org.cryptomator.cryptofs.health.dirid.DirIdCheck; import org.cryptomator.cryptolib.api.Masterkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,8 +36,7 @@ class HealthCheckTask extends Task { this.check = Objects.requireNonNull(check); this.results = FXCollections.observableArrayList(); - var tmp = check.identifier(); - updateTitle(tmp.substring(tmp.length() - 10)); //TODO: new method with reliable logic + updateTitle(getDisplayNameOf(check)); } @Override @@ -83,4 +83,12 @@ class HealthCheckTask extends Task { public HealthCheck getCheck() { return check; } + + static String getDisplayNameOf(HealthCheck check) { + if( check instanceof DirIdCheck) { //TODO: discuss if this should be localized + return "DirectoryCheck"; + } else { + return check.identifier(); + } + } }