diff --git a/src/main/java/org/cryptomator/ui/eventview/EventViewComponent.java b/src/main/java/org/cryptomator/ui/eventview/EventViewComponent.java index ceca15227..443885ec6 100644 --- a/src/main/java/org/cryptomator/ui/eventview/EventViewComponent.java +++ b/src/main/java/org/cryptomator/ui/eventview/EventViewComponent.java @@ -1,12 +1,10 @@ package org.cryptomator.ui.eventview; -import dagger.BindsInstance; import dagger.Lazy; import dagger.Subcomponent; import org.cryptomator.ui.common.FxmlFile; import org.cryptomator.ui.common.FxmlScene; -import javax.inject.Named; import javafx.scene.Scene; import javafx.stage.Stage; @@ -20,16 +18,18 @@ public interface EventViewComponent { @FxmlScene(FxmlFile.EVENT_VIEW) Lazy scene(); - default void showEventViewerWindow() { + default Stage showEventViewerWindow() { Stage stage = window(); stage.setScene(scene().get()); stage.sizeToScene(); stage.show(); + stage.requestFocus(); + return stage; } @Subcomponent.Factory interface Factory { - EventViewComponent create(@BindsInstance @Named("owner") Stage owner); + EventViewComponent create(); } } diff --git a/src/main/java/org/cryptomator/ui/eventview/EventViewModule.java b/src/main/java/org/cryptomator/ui/eventview/EventViewModule.java index 4c981bf50..bee37f4b7 100644 --- a/src/main/java/org/cryptomator/ui/eventview/EventViewModule.java +++ b/src/main/java/org/cryptomator/ui/eventview/EventViewModule.java @@ -12,7 +12,6 @@ import org.cryptomator.ui.common.FxmlLoaderFactory; import org.cryptomator.ui.common.FxmlScene; import org.cryptomator.ui.common.StageFactory; -import javax.inject.Named; import javax.inject.Provider; import javafx.scene.Scene; import javafx.stage.Modality; @@ -26,12 +25,11 @@ abstract class EventViewModule { @Provides @EventViewScoped @EventViewWindow - static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle, @Named("owner") Stage owner) { + static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle) { Stage stage = factory.create(); stage.setTitle("TODO EVENTVIEWER"); stage.setResizable(true); stage.initModality(Modality.NONE); - stage.initOwner(owner); return stage; } diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java index fabb8c164..a32059036 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java @@ -68,4 +68,10 @@ abstract class FxApplicationModule { return builder.build(); } + @Provides + @FxApplicationScoped + static EventViewComponent provideEventViewComponent(EventViewComponent.Factory factory) { + return factory.create(); + } + } \ No newline at end of file diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java index f319d1abb..162874dce 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java @@ -52,7 +52,7 @@ public class FxApplicationWindows { private final UpdateReminderComponent.Factory updateReminderWindowFactory; private final LockComponent.Factory lockWorkflowFactory; private final ErrorComponent.Factory errorWindowFactory; - private final EventViewComponent.Factory eventViewWindow; + private final Lazy eventViewWindow; private final ExecutorService executor; private final VaultOptionsComponent.Factory vaultOptionsWindow; private final ShareVaultComponent.Factory shareVaultWindow; @@ -71,7 +71,7 @@ public class FxApplicationWindows { ErrorComponent.Factory errorWindowFactory, // VaultOptionsComponent.Factory vaultOptionsWindow, // ShareVaultComponent.Factory shareVaultWindow, // - EventViewComponent.Factory eventViewWindow, // + Lazy eventViewWindow, // ExecutorService executor, // Dialogs dialogs) { this.primaryStage = primaryStage; @@ -186,6 +186,11 @@ public class FxApplicationWindows { }); } + + public CompletionStage showEventViewer() { + return CompletableFuture.supplyAsync(() -> eventViewWindow.get().showEventViewerWindow(), Platform::runLater).whenComplete(this::reportErrors); + } + /** * Displays the generic error scene in the given window. * @@ -203,15 +208,4 @@ public class FxApplicationWindows { LOG.error("Failed to display stage", error); } } - - public CompletionStage showEventViewer(@Nullable Stage owner) { - return CompletableFuture.supplyAsync(() -> { - eventViewWindow.create(owner).showEventViewerWindow(); - return null; - }, Platform::runLater).exceptionally(t -> { - LOG.error("Unable to display event viewer.", t); - - return null; - }); - } } diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index 8af7befe1..1c9da08f9 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -266,7 +266,7 @@ public class VaultListController implements FxController { @FXML public void showEventViewer() { - appWindows.showEventViewer(mainWindow); + appWindows.showEventViewer(); } // Getter and Setter