mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-21 10:06:55 -04:00
Rework vautl detail unknown error dialog:
* add buttons to reload, remove and show error dialog * restyling * add new strings
This commit is contained in:
@@ -6,6 +6,7 @@ import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.addvaultwizard.AddVaultWizardComponent;
|
||||
import org.cryptomator.ui.common.ErrorComponent;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
@@ -19,16 +20,18 @@ import org.cryptomator.ui.stats.VaultStatisticsComponent;
|
||||
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
|
||||
import org.cryptomator.ui.wrongfilealert.WrongFileAlertComponent;
|
||||
|
||||
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 javafx.stage.StageStyle;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class, HealthCheckComponent.class, MigrationComponent.class, RemoveVaultComponent.class, VaultOptionsComponent.class, VaultStatisticsComponent.class, WrongFileAlertComponent.class})
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class, HealthCheckComponent.class, MigrationComponent.class, RemoveVaultComponent.class, VaultOptionsComponent.class, VaultStatisticsComponent.class, WrongFileAlertComponent.class, ErrorComponent.class})
|
||||
abstract class MainWindowModule {
|
||||
|
||||
@Provides
|
||||
@@ -55,6 +58,17 @@ abstract class MainWindowModule {
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@MainWindowScoped
|
||||
@Named("errorWindow")
|
||||
static Stage provideErrorStage(@MainWindow Stage window, StageFactory factory, ResourceBundle resourceBundle) {
|
||||
Stage stage = factory.create(StageStyle.DECORATED);
|
||||
stage.setTitle(resourceBundle.getString("main.vaultDetail.error.windowTitle"));
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.initOwner(window);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.MAIN_WINDOW)
|
||||
@MainWindowScoped
|
||||
|
||||
@@ -2,45 +2,46 @@ package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultListManager;
|
||||
import org.cryptomator.ui.common.ErrorComponent;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.removevault.RemoveVaultComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@MainWindowScoped
|
||||
public class VaultDetailUnknownErrorController implements FxController {
|
||||
|
||||
private final Binding<String> stackTrace;
|
||||
private final ObjectProperty<Vault> vault;
|
||||
private final ErrorComponent.Builder errorComponentBuilder;
|
||||
private final Stage errorWindow;
|
||||
private final RemoveVaultComponent.Builder removeVault;
|
||||
|
||||
@Inject
|
||||
public VaultDetailUnknownErrorController(ObjectProperty<Vault> vault) {
|
||||
this.stackTrace = EasyBind.select(vault) //
|
||||
.selectObject(Vault::lastKnownExceptionProperty) //
|
||||
.map(this::provideStackTrace);
|
||||
public VaultDetailUnknownErrorController(ObjectProperty<Vault> vault, ErrorComponent.Builder errorComponentBuilder, @Named("errorWindow") Stage errorWindow, RemoveVaultComponent.Builder removeVault) {
|
||||
this.vault = vault;
|
||||
this.errorComponentBuilder = errorComponentBuilder;
|
||||
this.errorWindow = errorWindow;
|
||||
this.removeVault = removeVault;
|
||||
}
|
||||
|
||||
private String provideStackTrace(Throwable cause) {
|
||||
// TODO deduplicate ErrorModule.java
|
||||
if (cause != null) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
cause.printStackTrace(new PrintStream(baos));
|
||||
return baos.toString(StandardCharsets.UTF_8);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
@FXML
|
||||
public void showError() {
|
||||
errorComponentBuilder.window(errorWindow).cause(vault.get().getLastKnownException()).build().showErrorScene();
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
public Binding<String> stackTraceProperty() {
|
||||
return stackTrace;
|
||||
@FXML
|
||||
public void reload() {
|
||||
VaultListManager.redetermineVaultState(vault.get());
|
||||
}
|
||||
|
||||
public String getStackTrace() {
|
||||
return stackTrace.getValue();
|
||||
@FXML
|
||||
void didClickRemoveVault() {
|
||||
removeVault.vault(vault.get()).build().showRemoveVault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,42 @@
|
||||
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="org.cryptomator.ui.mainwindow.VaultDetailUnknownErrorController"
|
||||
alignment="CENTER"
|
||||
spacing="24">
|
||||
alignment="BASELINE_CENTER"
|
||||
spacing="9">
|
||||
<children>
|
||||
<Label text="%generic.error.title" wrapText="true"/>
|
||||
<Label text="%generic.error.instruction" wrapText="true"/>
|
||||
|
||||
<TextArea VBox.vgrow="ALWAYS" text="${controller.stackTrace}" prefRowCount="5" editable="false"/>
|
||||
<StackPane VBox.vgrow="NEVER">
|
||||
<Circle styleClass="glyph-icon-primary" radius="48"/>
|
||||
<FontAwesome5IconView styleClass="glyph-icon-white" glyph="FILE" glyphSize="48"/>
|
||||
<FontAwesome5IconView styleClass="glyph-icon-primary" glyph="TIMES" glyphSize="24">
|
||||
<StackPane.margin>
|
||||
<Insets top="12"/>
|
||||
</StackPane.margin>
|
||||
</FontAwesome5IconView>
|
||||
</StackPane>
|
||||
<Label text="%main.vaultDetail.error.info" wrapText="true"/>
|
||||
<VBox spacing="6" alignment="BASELINE_CENTER" VBox.vgrow="NEVER">
|
||||
<Button styleClass="" text="Show Error Details" onAction="#showError">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="INFO"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button text="%main.vaultDetail.error.reload" minWidth="120" onAction="#reload">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="REDO"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button text="%main.vaultDetail.missing.remove" minWidth="120" onAction="#didClickRemoveVault">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="TRASH"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
</VBox>
|
||||
</children>
|
||||
</VBox>
|
||||
@@ -300,6 +300,10 @@ main.vaultDetail.missing.changeLocation=Change Vault Location…
|
||||
### Needs Migration
|
||||
main.vaultDetail.migrateButton=Upgrade Vault
|
||||
main.vaultDetail.migratePrompt=Your vault needs to be upgraded to a new format, before you can access it
|
||||
### Error
|
||||
main.vaultDetail.error.info=An error occurred loading the vault from disk.
|
||||
main.vaultDetail.error.reload=Reload
|
||||
main.vaultDetail.error.windowTitle=Error loading vault
|
||||
|
||||
# Wrong File Alert
|
||||
wrongFileAlert.title=How to Encrypt Files
|
||||
|
||||
Reference in New Issue
Block a user