From fa3e0efd124fc76ebc5f62554da85277e2f58c1d Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Thu, 3 Aug 2023 12:53:44 +0200 Subject: [PATCH] init commit added new string properties added ui elements for user permission to look up error solutions in database modified ErrorController for permission handling --- .../cryptomator/ui/error/ErrorController.java | 46 ++++++++++----- src/main/resources/fxml/error.fxml | 56 ++++++++++++------- src/main/resources/i18n/strings.properties | 4 +- 3 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/error/ErrorController.java b/src/main/java/org/cryptomator/ui/error/ErrorController.java index 4b5b9b741..35941ad62 100644 --- a/src/main/java/org/cryptomator/ui/error/ErrorController.java +++ b/src/main/java/org/cryptomator/ui/error/ErrorController.java @@ -49,13 +49,13 @@ public class ErrorController implements FxController { private static final String REPORT_BODY_TEMPLATE = """ OS: %s / %s App: %s / %s - + - + - + - + """; @@ -65,11 +65,13 @@ public class ErrorController implements FxController { private final Scene previousScene; private final Stage window; private final Environment environment; + private final ExecutorService executorService; private final BooleanProperty copiedDetails = new SimpleBooleanProperty(); private final ObjectProperty matchingErrorDiscussion = new SimpleObjectProperty<>(); private final BooleanExpression errorSolutionFound = matchingErrorDiscussion.isNotNull(); private final BooleanProperty isLoadingHttpResponse = new SimpleBooleanProperty(); + private final BooleanProperty lookupDatabaseUserPermission = new SimpleBooleanProperty(); @Inject ErrorController(Application application, @Named("stackTrace") String stackTrace, ErrorCode errorCode, @Nullable Scene previousScene, Stage window, Environment environment, ExecutorService executorService) { @@ -79,15 +81,7 @@ public class ErrorController implements FxController { this.previousScene = previousScene; this.window = window; this.environment = environment; - - isLoadingHttpResponse.set(true); - HttpClient httpClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build(); - HttpRequest httpRequest = HttpRequest.newBuilder()// - .uri(URI.create(ERROR_CODES_URL))// - .build(); - httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofInputStream())// - .thenAcceptAsync(this::loadHttpResponse, executorService)// - .whenCompleteAsync((r, e) -> isLoadingHttpResponse.set(false), Platform::runLater); + this.executorService = executorService; } @FXML @@ -140,6 +134,24 @@ public class ErrorController implements FxController { CompletableFuture.delayedExecutor(2, TimeUnit.SECONDS, Platform::runLater).execute(() -> copiedDetails.set(false)); } + @FXML + public void dismiss() { + lookupDatabaseUserPermission.set(true); + } + + @FXML + public void lookUpSolution() { + lookupDatabaseUserPermission.set(true); + isLoadingHttpResponse.set(true); + HttpClient httpClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build(); + HttpRequest httpRequest = HttpRequest.newBuilder()// + .uri(URI.create(ERROR_CODES_URL))// + .build(); + httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofInputStream())// + .thenAcceptAsync(this::loadHttpResponse, executorService)// + .whenCompleteAsync((r, e) -> isLoadingHttpResponse.set(false), Platform::runLater); + } + private void loadHttpResponse(HttpResponse response) { if (response.statusCode() != 200) { LOG.error("Status code {} when trying to load {} ", response.statusCode(), response.uri()); @@ -293,4 +305,12 @@ public class ErrorController implements FxController { return isLoadingHttpResponse.get(); } + public BooleanProperty lookupDatabaseUserPermissionProperty() { + return lookupDatabaseUserPermission; + } + + public boolean isLookupDatabaseUserPermission() { + return lookupDatabaseUserPermission.get(); + } + } \ No newline at end of file diff --git a/src/main/resources/fxml/error.fxml b/src/main/resources/fxml/error.fxml index cc11db58a..d54a3f3c1 100644 --- a/src/main/resources/fxml/error.fxml +++ b/src/main/resources/fxml/error.fxml @@ -14,6 +14,8 @@ + + - - -