mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-07-20 06:52:36 +00:00
#927 :adding stubs for change password dialogue
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package org.cryptomator.ui.changepassword;
|
||||
|
||||
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;
|
||||
|
||||
@ChangePasswordScoped
|
||||
@Subcomponent(modules = {ChangePasswordModule.class})
|
||||
public interface ChangePasswordComponent {
|
||||
|
||||
@ChangePasswordWindow
|
||||
Stage window();
|
||||
|
||||
@FxmlScene(FxmlFile.CHANGEPASSWORD)
|
||||
Lazy<Scene> scene();
|
||||
|
||||
default void showChangePasswordWindow() {
|
||||
Stage stage = window();
|
||||
stage.setScene(scene().get());
|
||||
stage.show();
|
||||
}
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
Builder vault(@ChangePasswordWindow Vault vault);
|
||||
|
||||
ChangePasswordComponent build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.cryptomator.ui.changepassword;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@ChangePasswordScoped
|
||||
public class ChangePasswordController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
@Inject
|
||||
public ChangePasswordController(@ChangePasswordWindow Stage window, @ChangePasswordWindow Vault vault, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.cryptomator.ui.changepassword;
|
||||
|
||||
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 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 javax.inject.Provider;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module
|
||||
abstract class ChangePasswordModule {
|
||||
|
||||
@Provides
|
||||
@ChangePasswordWindow
|
||||
@ChangePasswordScoped
|
||||
static FXMLLoaderFactory provideFxmlLoaderFactory(Map<Class<? extends FxController>, Provider<FxController>> factories, ResourceBundle resourceBundle) {
|
||||
return new FXMLLoaderFactory(factories, resourceBundle);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ChangePasswordWindow
|
||||
@ChangePasswordScoped
|
||||
static Stage provideStage(ResourceBundle resourceBundle) {
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle(resourceBundle.getString("changepassword.title"));
|
||||
stage.setResizable(false);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.CHANGEPASSWORD)
|
||||
@ChangePasswordScoped
|
||||
static Scene provideUnlockScene(@ChangePasswordWindow FXMLLoaderFactory fxmlLoaders) {
|
||||
return fxmlLoaders.createScene("/fxml/changepassword.fxml");
|
||||
}
|
||||
|
||||
|
||||
// ------------------
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(ChangePasswordController.class)
|
||||
abstract FxController bindUnlockController(ChangePasswordController controller);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.changepassword;
|
||||
|
||||
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 ChangePasswordScoped {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.cryptomator.ui.changepassword;
|
||||
|
||||
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 ChangePasswordWindow {
|
||||
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.cryptomator.ui.common;
|
||||
|
||||
public enum FxmlFile {
|
||||
MAIN_WINDOW("/fxml/main_window.fxml"), //
|
||||
ADDVAULT_WELCOME("/fxml/addvault_welcome.fxml"), //
|
||||
ADDVAULT_EXISTING("/fxml/addvault_existing.fxml"), //
|
||||
ADDVAULT_NEW_NAME("/fxml/addvault_new_name.fxml"), //
|
||||
ADDVAULT_NEW_LOCATION("/fxml/addvault_new_location.fxml"), //
|
||||
ADDVAULT_NEW_PASSWORD("/fxml/addvault_new_password.fxml"), //
|
||||
CHANGEPASSWORD("/fxml/changepassword.fxml"),
|
||||
MAIN_WINDOW("/fxml/main_window.fxml"), //
|
||||
PREFERENCES("/fxml/preferences.fxml"), //
|
||||
QUIT("/fxml/quit.fxml"),
|
||||
UNLOCK("/fxml/unlock2.fxml"), // TODO rename
|
||||
|
||||
@@ -11,6 +11,7 @@ import javafx.scene.input.KeyCombination;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.cryptomator.ui.addvaultwizard.AddVaultWizardComponent;
|
||||
import org.cryptomator.ui.changepassword.ChangePasswordComponent;
|
||||
import org.cryptomator.ui.common.FXMLLoaderFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
@@ -22,7 +23,7 @@ import javax.inject.Provider;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class, VaultOptionsComponent.class})
|
||||
@Module(subcomponents = {AddVaultWizardComponent.class, VaultOptionsComponent.class, ChangePasswordComponent.class})
|
||||
abstract class MainWindowModule {
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -4,6 +4,7 @@ import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.changepassword.ChangePasswordComponent;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.Tasks;
|
||||
import org.cryptomator.ui.fxapp.FxApplication;
|
||||
@@ -23,13 +24,15 @@ public class VaultDetailController implements FxController {
|
||||
private final ExecutorService executor;
|
||||
private final FxApplication application;
|
||||
private final VaultOptionsComponent.Builder vaultOptionsWindow;
|
||||
private final ChangePasswordComponent.Builder changePasswordWindow;
|
||||
|
||||
@Inject
|
||||
VaultDetailController(ObjectProperty<Vault> vault, ExecutorService executor, FxApplication application, VaultOptionsComponent.Builder vaultOptionsWindow) {
|
||||
VaultDetailController(ObjectProperty<Vault> vault, ExecutorService executor, FxApplication application, VaultOptionsComponent.Builder vaultOptionsWindow, ChangePasswordComponent.Builder changePasswordWindow) {
|
||||
this.vault = vault;
|
||||
this.executor = executor;
|
||||
this.application = application;
|
||||
this.vaultOptionsWindow = vaultOptionsWindow;
|
||||
this.changePasswordWindow = changePasswordWindow;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -50,12 +53,17 @@ public class VaultDetailController implements FxController {
|
||||
// TODO
|
||||
}).runOnce(executor);
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void showVaultOptions() {
|
||||
vaultOptionsWindow.vault(vault.get()).build().showVaultOptionsWindow();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void changePassword() {
|
||||
changePasswordWindow.vault(vault.get()).build().showChangePasswordWindow();
|
||||
}
|
||||
|
||||
/* Observable Properties */
|
||||
|
||||
public ReadOnlyObjectProperty<Vault> vaultProperty() {
|
||||
@@ -65,5 +73,5 @@ public class VaultDetailController implements FxController {
|
||||
public Vault getVault() {
|
||||
return vault.get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.changepassword.ChangePasswordController"
|
||||
minWidth="300"
|
||||
maxWidth="300"
|
||||
spacing="6">
|
||||
<padding>
|
||||
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0"/>
|
||||
</padding>
|
||||
<children>
|
||||
</children>
|
||||
</VBox>
|
||||
@@ -17,5 +17,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}"/>
|
||||
<Button text="TODO change password" onAction="#changePassword" visible="${controller.vault.locked}"/>
|
||||
</children>
|
||||
</VBox>
|
||||
|
||||
@@ -28,6 +28,9 @@ addvaultwizard.new.reenterPassword=Please retype the password:
|
||||
addvaultwizard.new.passwordsMatch=Passwords match!
|
||||
addvaultwizard.new.passwordsDoNotMatch=Passwords do not match.
|
||||
|
||||
#ChangePassword
|
||||
changepassword.title=Change Password
|
||||
|
||||
#Unlock
|
||||
unlock.title=Unlock Vault
|
||||
unlock.passwordPrompt=Enter Password for
|
||||
|
||||
Reference in New Issue
Block a user