mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-22 18:46:53 -04:00
Further adjustment to workflow:
* bind modality to vault options window * open unlock in a new window and close it afterwards
This commit is contained in:
@@ -8,6 +8,7 @@ import org.cryptomator.cryptofs.VaultConfig;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@@ -44,6 +45,9 @@ public interface HealthCheckComponent {
|
||||
@BindsInstance
|
||||
Builder vault(@HealthCheckWindow Vault vault);
|
||||
|
||||
@BindsInstance
|
||||
Builder owner(@Named("healthCheckOwner") Stage owner);
|
||||
|
||||
HealthCheckComponent build();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.common.StageFactory;
|
||||
import org.cryptomator.ui.keyloading.KeyLoadingComponent;
|
||||
import org.cryptomator.ui.keyloading.KeyLoadingStrategy;
|
||||
import org.cryptomator.ui.mainwindow.MainWindow;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -74,7 +74,7 @@ abstract class HealthCheckModule {
|
||||
@Provides
|
||||
@HealthCheckWindow
|
||||
@HealthCheckScoped
|
||||
static KeyLoadingStrategy provideKeyLoadingStrategy(KeyLoadingComponent.Builder compBuilder, @HealthCheckWindow Vault vault, @HealthCheckWindow Stage window) {
|
||||
static KeyLoadingStrategy provideKeyLoadingStrategy(KeyLoadingComponent.Builder compBuilder, @HealthCheckWindow Vault vault, @Named("unlockWindow") Stage window ) {
|
||||
return compBuilder.vault(vault).window(window).build().keyloadingStrategy();
|
||||
}
|
||||
|
||||
@@ -85,14 +85,26 @@ abstract class HealthCheckModule {
|
||||
return new FxmlLoaderFactory(factories, sceneFactory, resourceBundle);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("unlockWindow")
|
||||
@HealthCheckScoped
|
||||
static Stage provideUnlockWindow (@HealthCheckWindow Stage window, @HealthCheckWindow Vault vault, StageFactory factory, ResourceBundle resourceBundle) {
|
||||
Stage stage = factory.create();
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(window);
|
||||
stage.setTitle(String.format("TODO: Unlock \"%s\"", vault.getDisplayName()));
|
||||
stage.setResizable(false);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@HealthCheckWindow
|
||||
@HealthCheckScoped
|
||||
static Stage provideStage(StageFactory factory, @MainWindow Stage owner, ResourceBundle resourceBundle, ChangeListener<Boolean> showingListener) {
|
||||
static Stage provideStage(StageFactory factory, @Named("healthCheckOwner") Stage owner, @HealthCheckWindow Vault vault, ChangeListener<Boolean> showingListener, ResourceBundle resourceBundle) {
|
||||
Stage stage = factory.create();
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(owner);
|
||||
stage.setTitle(resourceBundle.getString("health.title"));
|
||||
stage.setTitle(String.format(resourceBundle.getString("health.title"), vault.getDisplayName()));
|
||||
stage.setResizable(true);
|
||||
stage.showingProperty().addListener(showingListener); // bind masterkey lifecycle to window
|
||||
return stage;
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -34,6 +35,7 @@ public class StartController implements FxController {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StartController.class);
|
||||
|
||||
private final Stage window;
|
||||
private final Stage unlockWindow;
|
||||
private final ObjectProperty<VaultConfig.UnverifiedVaultConfig> unverifiedVaultConfig;
|
||||
private final KeyLoadingStrategy keyLoadingStrategy;
|
||||
private final ExecutorService executor;
|
||||
@@ -43,9 +45,10 @@ public class StartController implements FxController {
|
||||
private final Lazy<ErrorComponent.Builder> errorComponent;
|
||||
|
||||
@Inject
|
||||
public StartController(@HealthCheckWindow Stage window, HealthCheckComponent.LoadUnverifiedConfigResult configLoadResult, @HealthCheckWindow KeyLoadingStrategy keyLoadingStrategy, ExecutorService executor, AtomicReference<Masterkey> masterkeyRef, AtomicReference<VaultConfig> vaultConfigRef, @FxmlScene(FxmlFile.HEALTH_CHECK_LIST) Lazy<Scene> checkScene, Lazy<ErrorComponent.Builder> errorComponent) {
|
||||
public StartController(@HealthCheckWindow Stage window, HealthCheckComponent.LoadUnverifiedConfigResult configLoadResult, @HealthCheckWindow KeyLoadingStrategy keyLoadingStrategy, ExecutorService executor, AtomicReference<Masterkey> masterkeyRef, AtomicReference<VaultConfig> vaultConfigRef, @FxmlScene(FxmlFile.HEALTH_CHECK_LIST) Lazy<Scene> checkScene, Lazy<ErrorComponent.Builder> errorComponent, @Named("unlockWindow") Stage unlockWindow) {
|
||||
Preconditions.checkNotNull(configLoadResult.config());
|
||||
this.window = window;
|
||||
this.unlockWindow = unlockWindow;
|
||||
this.unverifiedVaultConfig = new SimpleObjectProperty<>(configLoadResult.config());
|
||||
this.keyLoadingStrategy = keyLoadingStrategy;
|
||||
this.executor = executor;
|
||||
@@ -98,6 +101,7 @@ public class StartController implements FxController {
|
||||
loadingKeyFailed(exception);
|
||||
} else {
|
||||
LOG.debug("Loaded valid key");
|
||||
unlockWindow.close();
|
||||
window.setScene(checkScene.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,6 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
}
|
||||
|
||||
public void startHealthCheck() {
|
||||
healthCheckWindow.vault(vault).build().showHealthCheckWindow();
|
||||
healthCheckWindow.vault(vault).owner(window).build().showHealthCheckWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user