Search in sources :

Example 6 with Vault

use of org.cryptomator.common.vaults.Vault in project cryptomator by cryptomator.

the class ChooseExistingVaultController method chooseFileAndNext.

@FXML
public void chooseFileAndNext() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(resourceBundle.getString("addvaultwizard.existing.filePickerTitle"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Cryptomator Vault", "*.cryptomator"));
    File masterkeyFile = fileChooser.showOpenDialog(window);
    if (masterkeyFile != null) {
        vaultPath.setValue(masterkeyFile.toPath().toAbsolutePath().getParent());
        try {
            Vault newVault = vaultListManager.add(vaultPath.get());
            vault.set(newVault);
            window.setScene(successScene.get());
        } catch (IOException e) {
            LOG.error("Failed to open existing vault.", e);
            errorComponent.cause(e).window(window).returnToScene(window.getScene()).build().showErrorScene();
        }
    }
}
Also used : FileChooser(javafx.stage.FileChooser) Vault(org.cryptomator.common.vaults.Vault) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) FxmlFile(org.cryptomator.ui.common.FxmlFile) File(java.io.File) FXML(javafx.fxml.FXML)

Example 7 with Vault

use of org.cryptomator.common.vaults.Vault in project cryptomator by cryptomator.

the class UiLauncher method launch.

private void launch(boolean withTrayIcon, boolean hidden) {
    // start hidden, minimized or normal?
    if (withTrayIcon && hidden) {
        LOG.debug("Hiding application...");
        trayIntegration.ifPresent(TrayIntegrationProvider::minimizedToTray);
    } else if (!withTrayIcon && hidden) {
        LOG.debug("Minimizing application...");
        showMainWindowAsync(true);
    } else {
        LOG.debug("Showing application...");
        showMainWindowAsync(false);
    }
    // register app reopen listener
    Desktop.getDesktop().addAppEventListener((AppReopenedListener) e -> showMainWindowAsync(false));
    // auto unlock
    Collection<Vault> vaultsToAutoUnlock = vaults.filtered(this::shouldAttemptAutoUnlock);
    if (!vaultsToAutoUnlock.isEmpty()) {
        fxApplicationStarter.get().thenAccept(app -> {
            for (Vault vault : vaultsToAutoUnlock) {
                app.startUnlockWorkflow(vault, Optional.empty());
            }
        });
    }
    launchEventHandler.startHandlingLaunchEvents();
}
Also used : Desktop(java.awt.Desktop) AppReopenedListener(java.awt.desktop.AppReopenedListener) Logger(org.slf4j.Logger) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) FxApplication(org.cryptomator.ui.fxapp.FxApplication) TrayMenuComponent(org.cryptomator.ui.traymenu.TrayMenuComponent) Singleton(javax.inject.Singleton) Lazy(dagger.Lazy) Inject(javax.inject.Inject) Vault(org.cryptomator.common.vaults.Vault) TrayIntegrationProvider(org.cryptomator.integrations.tray.TrayIntegrationProvider) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) SystemTray(java.awt.SystemTray) Settings(org.cryptomator.common.settings.Settings) TrayIntegrationProvider(org.cryptomator.integrations.tray.TrayIntegrationProvider) Vault(org.cryptomator.common.vaults.Vault)

Aggregations

Vault (org.cryptomator.common.vaults.Vault)7 IOException (java.io.IOException)4 UncheckedIOException (java.io.UncheckedIOException)4 Lazy (dagger.Lazy)3 FXML (javafx.fxml.FXML)3 Inject (javax.inject.Inject)3 FxmlFile (org.cryptomator.ui.common.FxmlFile)3 URI (java.net.URI)2 WritableByteChannel (java.nio.channels.WritableByteChannel)2 US_ASCII (java.nio.charset.StandardCharsets.US_ASCII)2 FileSystem (java.nio.file.FileSystem)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 StandardOpenOption (java.nio.file.StandardOpenOption)2 SecureRandom (java.security.SecureRandom)2 ResourceBundle (java.util.ResourceBundle)2 ExecutorService (java.util.concurrent.ExecutorService)2 Bindings (javafx.beans.binding.Bindings)2 ObjectBinding (javafx.beans.binding.ObjectBinding)2 BooleanProperty (javafx.beans.property.BooleanProperty)2