mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-22 18:46:53 -04:00
ui adjustments & code cleanup
This commit is contained in:
@@ -37,7 +37,6 @@ public class CheckDetailController implements FxController {
|
||||
private final Binding<Boolean> warnOrCritsExist;
|
||||
private final ResultListCellFactory resultListCellFactory;
|
||||
|
||||
public CheckStateIconView checkStateIconView;
|
||||
public ListView<Result> resultsListView;
|
||||
private Subscription resultSubscription;
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package org.cryptomator.ui.health;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.cryptofs.VaultConfigLoadException;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
@@ -23,15 +19,18 @@ import java.nio.charset.StandardCharsets;
|
||||
@HealthCheckScoped
|
||||
public class StartFailController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final ObjectProperty<Throwable> loadError;
|
||||
private final ObjectProperty<FontAwesome5Icon> moreInfoIcon;
|
||||
|
||||
/* FXML */
|
||||
public TitledPane moreInfoPane;
|
||||
|
||||
@Inject
|
||||
public StartFailController(@HealthCheckWindow Stage window, HealthCheckComponent.LoadUnverifiedConfigResult configLoadResult) {
|
||||
Preconditions.checkNotNull(configLoadResult.error());
|
||||
this.window = window;
|
||||
this.loadError = new SimpleObjectProperty<>(configLoadResult.error());
|
||||
this.localizedErrorMessage = EasyBind.map(loadError, Throwable::getLocalizedMessage);
|
||||
this.parseException = Bindings.createBooleanBinding(() -> loadError.get() instanceof VaultConfigLoadException);
|
||||
this.ioException = parseException.not();
|
||||
this.stackTrace = EasyBind.map(loadError, this::createPrintableStacktrace);
|
||||
this.moreInfoIcon = new SimpleObjectProperty<>(FontAwesome5Icon.CARET_RIGHT);
|
||||
}
|
||||
|
||||
@@ -43,48 +42,12 @@ public class StartFailController implements FxController {
|
||||
moreInfoIcon.set(willExpand ? FontAwesome5Icon.CARET_DOWN : FontAwesome5Icon.CARET_RIGHT);
|
||||
}
|
||||
|
||||
private String createPrintableStacktrace(Throwable t) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
t.printStackTrace(new PrintStream(baos));
|
||||
return baos.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void close() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
public Binding<String> stackTraceProperty() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
public String getStackTrace() {
|
||||
return stackTrace.getValue();
|
||||
}
|
||||
|
||||
public Binding<String> localizedErrorMessageProperty() {
|
||||
return localizedErrorMessage;
|
||||
}
|
||||
|
||||
public String getLocalizedErrorMessage() {
|
||||
return localizedErrorMessage.getValue();
|
||||
}
|
||||
|
||||
public BooleanBinding parseExceptionProperty() {
|
||||
return parseException;
|
||||
}
|
||||
|
||||
public boolean isParseException() {
|
||||
return parseException.getValue();
|
||||
}
|
||||
|
||||
public BooleanBinding ioExceptionProperty() {
|
||||
return ioException;
|
||||
}
|
||||
|
||||
public boolean isIoException() {
|
||||
return ioException.getValue();
|
||||
}
|
||||
/* Getter & Setter */
|
||||
|
||||
public ObjectProperty<FontAwesome5Icon> moreInfoIconProperty() {
|
||||
return moreInfoIcon;
|
||||
@@ -94,15 +57,22 @@ public class StartFailController implements FxController {
|
||||
return moreInfoIcon.getValue();
|
||||
}
|
||||
|
||||
private final Stage window;
|
||||
private final ObjectProperty<Throwable> loadError;
|
||||
private final Binding<String> stackTrace;
|
||||
private final Binding<String> localizedErrorMessage;
|
||||
private final BooleanBinding ioException;
|
||||
private final BooleanBinding parseException;
|
||||
private final ObjectProperty<FontAwesome5Icon> moreInfoIcon;
|
||||
public String getStackTrace() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
loadError.get().printStackTrace(new PrintStream(baos));
|
||||
return baos.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/* FXML */
|
||||
public TitledPane moreInfoPane;
|
||||
public String getLocalizedErrorMessage() {
|
||||
return loadError.get().getLocalizedMessage();
|
||||
}
|
||||
|
||||
public boolean isParseException() {
|
||||
return loadError.get() instanceof VaultConfigLoadException;
|
||||
}
|
||||
|
||||
public boolean isIoException() {
|
||||
return !isParseException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user