Parcourir la source

Only use CheckTask title in UI instead of HealthCheck::identifier

Armin Schrenk il y a 3 ans
Parent
commit
e98f92c63f

+ 0 - 10
main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java

@@ -19,7 +19,6 @@ public class CheckDetailController implements FxController {
 	private final Binding<ObservableList<DiagnosticResultAction>> results;
 	private final OptionalBinding<Worker.State> taskState;
 	private final Binding<String> taskName;
-	private final Binding<String> 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<String> taskDescriptionProperty() {
-		return taskDescription;
-	}
-
 	public boolean isProducingResults() {
 		return producingResults.get();
 	}

+ 1 - 1
main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java

@@ -21,7 +21,7 @@ class CheckListCell extends ListCell<HealthCheckTask> {
 	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()));

+ 1 - 1
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<HealthCheckTask>() {
 			@Override
 			public String toString(HealthCheckTask object) {
-				return object.getCheck().identifier();
+				return object.getTitle();
 			}
 
 			@Override

+ 10 - 2
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<Void> {
 		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<Void> {
 	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();
+		}
+	}
 }