removed quitforced package, moved QuitForcedController into quit package and deleted not required files

This commit is contained in:
Jan-Peter Klein
2022-06-30 15:41:33 +02:00
parent 376733106b
commit b791df01f7
13 changed files with 49 additions and 162 deletions

View File

@@ -51,7 +51,6 @@ module org.cryptomator.desktop {
opens org.cryptomator.ui.migration to javafx.fxml;
opens org.cryptomator.ui.preferences to javafx.fxml;
opens org.cryptomator.ui.quit to javafx.fxml;
opens org.cryptomator.ui.quitforced to javafx.fxml;
opens org.cryptomator.ui.recoverykey to javafx.fxml;
opens org.cryptomator.ui.removevault to javafx.fxml;
opens org.cryptomator.ui.stats to javafx.fxml;

View File

@@ -14,7 +14,7 @@ import org.cryptomator.ui.lock.LockComponent;
import org.cryptomator.ui.mainwindow.MainWindowComponent;
import org.cryptomator.ui.preferences.PreferencesComponent;
import org.cryptomator.ui.quit.QuitComponent;
import org.cryptomator.ui.quitforced.QuitForcedComponent;
import org.cryptomator.ui.traymenu.TrayMenuComponent;
import org.cryptomator.ui.unlock.UnlockComponent;
@@ -26,7 +26,7 @@ import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.List;
@Module(includes = {UpdateCheckerModule.class}, subcomponents = {TrayMenuComponent.class, MainWindowComponent.class, PreferencesComponent.class, UnlockComponent.class, LockComponent.class, QuitComponent.class, QuitForcedComponent.class, ErrorComponent.class})
@Module(includes = {UpdateCheckerModule.class}, subcomponents = {TrayMenuComponent.class, MainWindowComponent.class, PreferencesComponent.class, UnlockComponent.class, LockComponent.class, QuitComponent.class, ErrorComponent.class})
abstract class FxApplicationModule {
private static Image createImageFromResource(String resourceName) throws IOException {
@@ -59,9 +59,5 @@ abstract class FxApplicationModule {
return builder.build();
}
@Provides
@FxApplicationScoped
static QuitForcedComponent provideQuitForcedComponent(QuitForcedComponent.Builder builder) {
return builder.build();
}
}

View File

@@ -115,11 +115,11 @@ public class FxApplicationTerminator {
});
lockAllTask.setOnFailed(event -> {
LOG.warn("Unable to lock all vaults.");
appWindows.showQuitForcedWindow(exitingResponse);
appWindows.showQuitWindow(exitingResponse, true);
});
lockAllTask.run();
} else {
appWindows.showQuitWindow(exitingResponse);
appWindows.showQuitWindow(exitingResponse, false);
}
}

View File

@@ -11,7 +11,7 @@ import org.cryptomator.ui.mainwindow.MainWindowComponent;
import org.cryptomator.ui.preferences.PreferencesComponent;
import org.cryptomator.ui.preferences.SelectedPreferencesTab;
import org.cryptomator.ui.quit.QuitComponent;
import org.cryptomator.ui.quitforced.QuitForcedComponent;
import org.cryptomator.ui.unlock.UnlockComponent;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
@@ -41,8 +41,10 @@ public class FxApplicationWindows {
private final Optional<TrayIntegrationProvider> trayIntegration;
private final Lazy<MainWindowComponent> mainWindow;
private final Lazy<PreferencesComponent> preferencesWindow;
private final Lazy<QuitComponent> quitWindow;
private final Lazy<QuitForcedComponent> quitForcedWindow;
private final QuitComponent.Builder quitWindowBuilder;
private final UnlockComponent.Factory unlockWorkflowFactory;
private final LockComponent.Factory lockWorkflowFactory;
private final ErrorComponent.Factory errorWindowFactory;
@@ -50,13 +52,13 @@ public class FxApplicationWindows {
private final FilteredList<Window> visibleWindows;
@Inject
public FxApplicationWindows(@PrimaryStage Stage primaryStage, Optional<TrayIntegrationProvider> trayIntegration, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Lazy<QuitComponent> quitWindow, Lazy<QuitForcedComponent> quitForcedWindow, UnlockComponent.Factory unlockWorkflowFactory, LockComponent.Factory lockWorkflowFactory, ErrorComponent.Factory errorWindowFactory, ExecutorService executor) {
public FxApplicationWindows(@PrimaryStage Stage primaryStage, Optional<TrayIntegrationProvider> trayIntegration, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, QuitComponent.Builder quitWindowBuilder, UnlockComponent.Factory unlockWorkflowFactory, LockComponent.Factory lockWorkflowFactory, ErrorComponent.Factory errorWindowFactory, ExecutorService executor) {
this.primaryStage = primaryStage;
this.trayIntegration = trayIntegration;
this.mainWindow = mainWindow;
this.preferencesWindow = preferencesWindow;
this.quitWindow = quitWindow;
this.quitForcedWindow = quitForcedWindow;
this.quitWindowBuilder = quitWindowBuilder;
this.unlockWorkflowFactory = unlockWorkflowFactory;
this.lockWorkflowFactory = lockWorkflowFactory;
this.errorWindowFactory = errorWindowFactory;
@@ -107,13 +109,10 @@ public class FxApplicationWindows {
return CompletableFuture.supplyAsync(() -> preferencesWindow.get().showPreferencesWindow(selectedTab), Platform::runLater).whenComplete(this::reportErrors);
}
public CompletionStage<Stage> showQuitWindow(QuitResponse response) {
return CompletableFuture.supplyAsync(() -> quitWindow.get().showQuitWindow(response), Platform::runLater).whenComplete(this::reportErrors);
public void showQuitWindow(QuitResponse response, boolean forced) {
CompletableFuture.runAsync(() -> quitWindowBuilder.build().showQuitWindow(response,forced), Platform::runLater);
}
public CompletionStage<Stage> showQuitForcedWindow(QuitResponse response) {
return CompletableFuture.supplyAsync(() -> quitForcedWindow.get().showQuitForcedWindow(response), Platform::runLater).whenComplete(this::reportErrors);
}
public CompletionStage<Void> startUnlockWorkflow(Vault vault, @Nullable Stage owner) {
return CompletableFuture.supplyAsync(() -> {

View File

@@ -22,23 +22,33 @@ public interface QuitComponent {
Stage window();
@FxmlScene(FxmlFile.QUIT)
Lazy<Scene> scene();
Lazy<Scene> quitScene();
QuitController controller();
@FxmlScene(FxmlFile.QUIT_FORCED)
Lazy<Scene> quitForcedScene();
default Stage showQuitWindow(QuitResponse response) {
controller().updateQuitRequest(response);
QuitController quitController();
QuitForcedController quitForcedController();
default void showQuitWindow(QuitResponse response, boolean forced) {
Stage stage = window();
stage.setScene(scene().get());
if(forced){
quitForcedController().updateQuitRequest(response);
stage.setScene(quitForcedScene().get());
} else{
quitController().updateQuitRequest(response);
stage.setScene(quitScene().get());
}
stage.sizeToScene();
stage.show();
stage.requestFocus();
return stage;
}
@Subcomponent.Builder
interface Builder {
QuitComponent build();
}
}

View File

@@ -83,7 +83,7 @@ public class QuitController implements FxController {
LOG.warn("Locking failed", lockAllTask.getException());
lockAndQuitButton.setDisable(false);
lockAndQuitButton.setContentDisplay(ContentDisplay.TEXT_ONLY);
appWindows.showQuitForcedWindow(quitResponse.get());
appWindows.showQuitWindow(quitResponse.get(),true);
window.close();
});
executorService.execute(lockAllTask);

View File

@@ -1,4 +1,4 @@
package org.cryptomator.ui.quitforced;
package org.cryptomator.ui.quit;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.ui.common.FxController;
@@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@QuitForcedScoped
public class QuitForcedController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(QuitForcedController.class);
@@ -35,7 +34,7 @@ public class QuitForcedController implements FxController {
public Button forceLockAndQuitButton;
@Inject
QuitForcedController(@QuitForcedWindow Stage window, ObservableList<Vault> vaults, ExecutorService executorService, VaultService vaultService) {
QuitForcedController(@QuitWindow Stage window, ObservableList<Vault> vaults, ExecutorService executorService, VaultService vaultService) {
this.window = window;
this.unlockedVaults = vaults.filtered(Vault::isUnlocked);
this.executorService = executorService;

View File

@@ -48,6 +48,14 @@ abstract class QuitModule {
return fxmlLoaders.createScene(FxmlFile.QUIT);
}
@Provides
@FxmlScene(FxmlFile.QUIT_FORCED)
@QuitScoped
static Scene provideQuitForcedScene(@QuitWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.QUIT_FORCED);
}
// ------------------
@Binds
@@ -55,4 +63,9 @@ abstract class QuitModule {
@FxControllerKey(QuitController.class)
abstract FxController bindQuitController(QuitController controller);
@Binds
@IntoMap
@FxControllerKey(QuitForcedController.class)
abstract FxController bindQuitForcedController(QuitForcedController controller);
}

View File

@@ -1,44 +0,0 @@
/*******************************************************************************
* 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.quitforced;
import dagger.Lazy;
import dagger.Subcomponent;
import org.cryptomator.ui.common.FxmlFile;
import org.cryptomator.ui.common.FxmlScene;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.awt.desktop.QuitResponse;
@QuitForcedScoped
@Subcomponent(modules = {QuitForcedModule.class})
public interface QuitForcedComponent {
@QuitForcedWindow
Stage window();
@FxmlScene(FxmlFile.QUIT_FORCED)
Lazy<Scene> scene();
QuitForcedController controller();
default Stage showQuitForcedWindow(QuitResponse response) {
controller().updateQuitRequest(response);
Stage stage = window();
stage.setScene(scene().get());
stage.show();
stage.requestFocus();
return stage;
}
@Subcomponent.Builder
interface Builder {
QuitForcedComponent build();
}
}

View File

@@ -1,58 +0,0 @@
package org.cryptomator.ui.quitforced;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import org.cryptomator.ui.common.DefaultSceneFactory;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.common.FxControllerKey;
import org.cryptomator.ui.common.FxmlFile;
import org.cryptomator.ui.common.FxmlLoaderFactory;
import org.cryptomator.ui.common.FxmlScene;
import org.cryptomator.ui.common.StageFactory;
import javax.inject.Provider;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.util.Map;
import java.util.ResourceBundle;
@Module
abstract class QuitForcedModule {
@Provides
@QuitForcedWindow
@QuitForcedScoped
static FxmlLoaderFactory provideFxmlLoaderFactory(Map<Class<? extends FxController>, Provider<FxController>> factories, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) {
return new FxmlLoaderFactory(factories, sceneFactory, resourceBundle);
}
@Provides
@QuitForcedWindow
@QuitForcedScoped
static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle) {
Stage stage = factory.create();
stage.setMinWidth(300);
stage.setMinHeight(100);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle(resourceBundle.getString("quit.title"));
return stage;
}
@Provides
@FxmlScene(FxmlFile.QUIT_FORCED)
@QuitForcedScoped
static Scene provideQuitScene(@QuitForcedWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.QUIT_FORCED);
}
// ------------------
@Binds
@IntoMap
@FxControllerKey(QuitForcedController.class)
abstract FxController bindQuitController(QuitForcedController controller);
}

View File

@@ -1,13 +0,0 @@
package org.cryptomator.ui.quitforced;
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 QuitForcedScoped {
}

View File

@@ -1,14 +0,0 @@
package org.cryptomator.ui.quitforced;
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)
@interface QuitForcedWindow {
}

View File

@@ -14,7 +14,7 @@
<?import javafx.scene.layout.Region?>
<HBox xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="org.cryptomator.ui.quitforced.QuitForcedController"
fx:controller="org.cryptomator.ui.quit.QuitForcedController"
minWidth="400"
maxWidth="400"
minHeight="145"