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

This commit is contained in:
Armin Schrenk
2021-05-21 15:56:32 +02:00
parent 85b761a9d7
commit e98f92c63f
4 changed files with 12 additions and 14 deletions

View File

@@ -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();
}

View File

@@ -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()));

View File

@@ -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

View File

@@ -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();
}
}
}