mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 20:21:27 +00:00
Added vault settings window (references #931)
This commit is contained in:
@@ -9,7 +9,8 @@ public enum FxmlFile {
|
||||
ADDVAULT_NEW_PASSWORD("/fxml/addvault_new_password.fxml"), //
|
||||
PREFERENCES("/fxml/preferences.fxml"), //
|
||||
UNLOCK("/fxml/unlock2.fxml"), // TODO rename
|
||||
UNLOCK_SUCCESS("/fxml/unlock_success.fxml");
|
||||
UNLOCK_SUCCESS("/fxml/unlock_success.fxml"),
|
||||
VAULT_OPTIONS("/fxml/vault_options.fxml");
|
||||
|
||||
private final String filename;
|
||||
|
||||
|
||||
@@ -13,12 +13,13 @@ import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class})
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class, VaultOptionsComponent.class})
|
||||
abstract class MainWindowModule {
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.Tasks;
|
||||
import org.cryptomator.ui.fxapp.FxApplication;
|
||||
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -21,12 +22,14 @@ public class VaultDetailController implements FxController {
|
||||
private final ReadOnlyObjectProperty<Vault> vault;
|
||||
private final ExecutorService executor;
|
||||
private final FxApplication application;
|
||||
private final VaultOptionsComponent.Builder vaultOptionsWindow;
|
||||
|
||||
@Inject
|
||||
VaultDetailController(ObjectProperty<Vault> vault, ExecutorService executor, FxApplication application) {
|
||||
VaultDetailController(ObjectProperty<Vault> vault, ExecutorService executor, FxApplication application, VaultOptionsComponent.Builder vaultOptionsWindow) {
|
||||
this.vault = vault;
|
||||
this.executor = executor;
|
||||
this.application = application;
|
||||
this.vaultOptionsWindow = vaultOptionsWindow;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -47,6 +50,11 @@ public class VaultDetailController implements FxController {
|
||||
// TODO
|
||||
}).runOnce(executor);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void showVaultOptions() {
|
||||
vaultOptionsWindow.vault(vault.get()).build().showVaultOptionsWindow();
|
||||
}
|
||||
|
||||
/* Observable Properties */
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class GeneralVaultOptionsController implements FxController {
|
||||
|
||||
@Inject
|
||||
GeneralVaultOptionsController(){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class MountOptionsController implements FxController {
|
||||
|
||||
@Inject
|
||||
MountOptionsController(){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Skymatic UG (haftungsbeschränkt).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the accompanying LICENSE file.
|
||||
*******************************************************************************/
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Lazy;
|
||||
import dagger.Subcomponent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
|
||||
@VaultOptionsScoped
|
||||
@Subcomponent(modules = {VaultOptionsModule.class})
|
||||
public interface VaultOptionsComponent {
|
||||
|
||||
@VaultOptionsWindow
|
||||
Stage window();
|
||||
|
||||
@FxmlScene(FxmlFile.VAULT_OPTIONS)
|
||||
Lazy<Scene> scene();
|
||||
|
||||
default void showVaultOptionsWindow() {
|
||||
Stage stage = window();
|
||||
stage.setScene(scene().get());
|
||||
stage.show();
|
||||
stage.requestFocus();
|
||||
}
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
VaultOptionsComponent.Builder vault(@VaultOptionsWindow Vault vault);
|
||||
|
||||
VaultOptionsComponent build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class VaultOptionsController implements FxController {
|
||||
|
||||
@Inject
|
||||
VaultOptionsController(){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FXMLLoaderFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.mainwindow.MainWindow;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module
|
||||
abstract class VaultOptionsModule {
|
||||
|
||||
@Provides
|
||||
@VaultOptionsWindow
|
||||
@VaultOptionsScoped
|
||||
static FXMLLoaderFactory provideFxmlLoaderFactory(Map<Class<? extends FxController>, Provider<FxController>> factories, ResourceBundle resourceBundle) {
|
||||
return new FXMLLoaderFactory(factories, resourceBundle);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@VaultOptionsWindow
|
||||
@VaultOptionsScoped
|
||||
static Stage provideStage(@MainWindow Stage owner, @VaultOptionsWindow Vault vault, ResourceBundle resourceBundle) {
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle(vault.getDisplayableName());
|
||||
// stage.setTitle(resourceBundle.getString("vaultOptions.title"));
|
||||
stage.setMinWidth(400);
|
||||
stage.setMinHeight(300);
|
||||
stage.initStyle(StageStyle.DECORATED);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(owner);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.VAULT_OPTIONS)
|
||||
@VaultOptionsScoped
|
||||
static Scene provideVaultOptionsScene(@VaultOptionsWindow FXMLLoaderFactory fxmlLoaders) {
|
||||
return fxmlLoaders.createScene("/fxml/vault_options.fxml");
|
||||
}
|
||||
|
||||
// ------------------
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(VaultOptionsController.class)
|
||||
abstract FxController bindVaultOptionsController(VaultOptionsController controller);
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(GeneralVaultOptionsController.class)
|
||||
abstract FxController bindGeneralVaultOptionsController(GeneralVaultOptionsController controller);
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(MountOptionsController.class)
|
||||
abstract FxController bindMountOptionsController(MountOptionsController controller);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import javax.inject.Scope;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Scope
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface VaultOptionsScoped {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Qualifier
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
public @interface VaultOptionsWindow {
|
||||
|
||||
}
|
||||
@@ -16,5 +16,6 @@
|
||||
|
||||
<Button text="TODO unlock" onAction="#unlock" visible="${controller.vault.locked}"/>
|
||||
<Button text="TODO lock" onAction="#lock" visible="${controller.vault.unlocked}"/>
|
||||
<Button text="TODO options" onAction="#showVaultOptions" visible="${controller.vault.locked}"/>
|
||||
</children>
|
||||
</VBox>
|
||||
|
||||
24
main/ui/src/main/resources/fxml/vault_options.fxml
Normal file
24
main/ui/src/main/resources/fxml/vault_options.fxml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Tab?>
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<TabPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:id="tabPane"
|
||||
fx:controller="org.cryptomator.ui.vaultoptions.VaultOptionsController"
|
||||
side="TOP"
|
||||
tabClosingPolicy="UNAVAILABLE"
|
||||
tabDragPolicy="FIXED">
|
||||
<tabs>
|
||||
<Tab fx:id="generalTab" text="TODO General">
|
||||
<content>
|
||||
<fx:include source="/fxml/vault_options_general.fxml"/>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab fx:id="updatesTab" text="TODO Mounting">
|
||||
<content>
|
||||
<fx:include source="/fxml/vault_options_mount.fxml"/>
|
||||
</content>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
16
main/ui/src/main/resources/fxml/vault_options_general.fxml
Normal file
16
main/ui/src/main/resources/fxml/vault_options_general.fxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.vaultoptions.GeneralVaultOptionsController"
|
||||
spacing="6">
|
||||
<padding>
|
||||
<Insets bottom="12" left="12" right="12" top="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Label text="todo general options"/>
|
||||
</children>
|
||||
</VBox>
|
||||
16
main/ui/src/main/resources/fxml/vault_options_mount.fxml
Normal file
16
main/ui/src/main/resources/fxml/vault_options_mount.fxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.vaultoptions.MountOptionsController"
|
||||
spacing="6">
|
||||
<padding>
|
||||
<Insets bottom="12" left="12" right="12" top="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Label text="todo mount options"/>
|
||||
</children>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user