Merge branch 'feature/3001-more-error-messages' into feature/2856-folder-mounts-win

# Conflicts:
# src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java
# src/main/resources/i18n/strings.properties
This commit is contained in:
JaniruTEC
2023-07-19 23:25:31 +02:00
4 changed files with 71 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
package org.cryptomator.ui.unlock;
import org.cryptomator.common.ObservableUtil;
import org.cryptomator.common.mount.HideawayNotDirectoryException;
import org.cryptomator.common.mount.IllegalMountPointException;
import org.cryptomator.common.mount.MountPointCleanupFailedException;
@@ -16,11 +17,12 @@ import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab;
import org.jetbrains.annotations.PropertyKey;
import javax.inject.Inject;
import javafx.beans.property.ObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.stage.Stage;
import java.nio.file.Path;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicReference;
//At the current point in time only the CustomMountPointChooser may cause this window to be shown.
@UnlockScoped
@@ -29,34 +31,31 @@ public class UnlockInvalidMountPointController implements FxController {
private final Stage window;
private final Vault vault;
private final FxApplicationWindows appWindows;
private final ResourceBundle resourceBundle;
private final ExceptionType exceptionType;
private final Path exceptionPath;
private final String exceptionMessage;
private final Path hideawayPath;
private final ObservableValue<ExceptionType> exceptionType;
private final ObservableValue<Path> exceptionPath;
private final ObservableValue<String> exceptionMessage;
private final ObservableValue<Path> hideawayPath;
private final ObservableValue<String> format;
private final ObservableValue<Boolean> showPreferences;
private final ObservableValue<Boolean> showVaultOptions;
public FormattedLabel dialogDescription;
@Inject
UnlockInvalidMountPointController(@UnlockWindow Stage window, @UnlockWindow Vault vault, @UnlockWindow AtomicReference<IllegalMountPointException> illegalMountPointException, FxApplicationWindows appWindows, ResourceBundle resourceBundle) {
UnlockInvalidMountPointController(@UnlockWindow Stage window, @UnlockWindow Vault vault, @UnlockWindow ObjectProperty<IllegalMountPointException> illegalMountPointException, FxApplicationWindows appWindows, ResourceBundle resourceBundle) {
this.window = window;
this.vault = vault;
this.appWindows = appWindows;
this.resourceBundle = resourceBundle;
var exc = illegalMountPointException.get();
this.exceptionType = getExceptionType(exc);
this.exceptionPath = exc.getMountpoint();
this.exceptionMessage = exc.getMessage();
this.hideawayPath = exc instanceof HideawayNotDirectoryException haeExc ? haeExc.getHideaway() : null;
}
this.exceptionType = illegalMountPointException.map(this::getExceptionType);
this.exceptionPath = illegalMountPointException.map(IllegalMountPointException::getMountpoint);
this.exceptionMessage = illegalMountPointException.map(IllegalMountPointException::getMessage);
this.hideawayPath = illegalMountPointException.map(e -> e instanceof HideawayNotDirectoryException haeExc ? haeExc.getHideaway() : null);
@FXML
public void initialize() {
dialogDescription.setFormat(resourceBundle.getString(exceptionType.translationKey));
dialogDescription.setArg1(exceptionPath);
dialogDescription.setArg2(exceptionMessage);
dialogDescription.setArg3(hideawayPath);
this.format = ObservableUtil.mapWithDefault(exceptionType, type -> resourceBundle.getString(type.translationKey), "");
this.showPreferences = ObservableUtil.mapWithDefault(exceptionType, type -> type.action == ButtonAction.SHOW_PREFERENCES, false);
this.showVaultOptions = ObservableUtil.mapWithDefault(exceptionType, type -> type.action == ButtonAction.SHOW_VAULT_OPTIONS, false);
}
@FXML
@@ -117,11 +116,51 @@ public class UnlockInvalidMountPointController implements FxController {
/* Getter */
public boolean isShowPreferences() {
return exceptionType.action == ButtonAction.SHOW_PREFERENCES;
public Path getExceptionPath() {
return exceptionPath.getValue();
}
public boolean isShowVaultOptions() {
return exceptionType.action == ButtonAction.SHOW_VAULT_OPTIONS;
public ObservableValue<Path> exceptionPathProperty() {
return exceptionPath;
}
public String getFormat() {
return format.getValue();
}
public ObservableValue<String> formatProperty() {
return format;
}
public String getExceptionMessage() {
return exceptionMessage.getValue();
}
public ObservableValue<String> exceptionMessageProperty() {
return exceptionMessage;
}
public Path getHideawayPath() {
return hideawayPath.getValue();
}
public ObservableValue<Path> hideawayPathProperty() {
return hideawayPath;
}
public Boolean getShowPreferences() {
return showPreferences.getValue();
}
public ObservableValue<Boolean> showPreferencesProperty() {
return showPreferences;
}
public Boolean getShowVaultOptions() {
return showVaultOptions.getValue();
}
public ObservableValue<Boolean> showVaultOptionsProperty() {
return showVaultOptions;
}
}

View File

@@ -19,12 +19,13 @@ import org.jetbrains.annotations.Nullable;
import javax.inject.Named;
import javax.inject.Provider;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicReference;
@Module(subcomponents = {KeyLoadingComponent.class})
abstract class UnlockModule {
@@ -62,8 +63,8 @@ abstract class UnlockModule {
@Provides
@UnlockWindow
@UnlockScoped
static AtomicReference<IllegalMountPointException> illegalMountPointException() {
return new AtomicReference<>();
static ObjectProperty<IllegalMountPointException> illegalMountPointException() {
return new SimpleObjectProperty<>();
}
@Provides

View File

@@ -17,11 +17,11 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
/**
* A multi-step task that consists of background activities as well as user interaction.
@@ -40,10 +40,10 @@ public class UnlockWorkflow extends Task<Boolean> {
private final Lazy<Scene> invalidMountPointScene;
private final FxApplicationWindows appWindows;
private final KeyLoadingStrategy keyLoadingStrategy;
private final AtomicReference<IllegalMountPointException> illegalMountPointException;
private final ObjectProperty<IllegalMountPointException> illegalMountPointException;
@Inject
UnlockWorkflow(@UnlockWindow Stage window, @UnlockWindow Vault vault, VaultService vaultService, @FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy<Scene> successScene, @FxmlScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT) Lazy<Scene> invalidMountPointScene, FxApplicationWindows appWindows, @UnlockWindow KeyLoadingStrategy keyLoadingStrategy, @UnlockWindow AtomicReference<IllegalMountPointException> illegalMountPointException) {
UnlockWorkflow(@UnlockWindow Stage window, @UnlockWindow Vault vault, VaultService vaultService, @FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy<Scene> successScene, @FxmlScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT) Lazy<Scene> invalidMountPointScene, FxApplicationWindows appWindows, @UnlockWindow KeyLoadingStrategy keyLoadingStrategy, @UnlockWindow ObjectProperty<IllegalMountPointException> illegalMountPointException) {
this.window = window;
this.vault = vault;
this.vaultService = vaultService;

View File

@@ -40,7 +40,7 @@
</padding>
</Label>
<FormattedLabel fx:id="dialogDescription" wrapText="true" textAlignment="LEFT"/>
<FormattedLabel fx:id="dialogDescription" wrapText="true" textAlignment="LEFT" format="${controller.format}" arg1="${controller.exceptionPath}" arg2="${controller.exceptionMessage}" arg3="${controller.hideawayPath}"/>
<Region VBox.vgrow="ALWAYS" minHeight="18"/>
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">