diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index e6909cbe1..0bd12c350 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -22,19 +22,20 @@ import org.cryptomator.cryptofs.event.FilesystemEvent; import org.cryptomator.cryptolib.api.CryptoException; import org.cryptomator.cryptolib.api.MasterkeyLoader; import org.cryptomator.cryptolib.api.MasterkeyLoadingFailedException; +import org.cryptomator.event.Event; +import org.cryptomator.event.VaultEvent; import org.cryptomator.integrations.mount.MountFailedException; import org.cryptomator.integrations.mount.Mountpoint; import org.cryptomator.integrations.mount.UnmountFailedException; import org.cryptomator.integrations.quickaccess.QuickAccessService; import org.cryptomator.integrations.quickaccess.QuickAccessServiceException; -import org.cryptomator.event.Event; -import org.cryptomator.event.VaultEvent; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; +import javafx.application.Platform; import javafx.beans.Observable; import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; @@ -49,6 +50,7 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.ReadOnlyFileSystemException; +import java.time.Instant; import java.util.EnumSet; import java.util.Objects; import java.util.Set; @@ -91,8 +93,7 @@ public class Vault { @Named("lastKnownException") ObjectProperty lastKnownException, // VaultStats stats, // Mounter mounter, Settings settings, // - ObservableList eventQueue - ) { + ObservableList eventQueue) { this.vaultSettings = vaultSettings; this.configCache = configCache; this.cryptoFileSystem = cryptoFileSystem; @@ -151,7 +152,7 @@ public class Vault { .withFlags(flags) // .withMaxCleartextNameLength(vaultSettings.maxCleartextFilenameLength.get()) // .withVaultConfigFilename(Constants.VAULTCONFIG_FILENAME) // - .withFilesystemEventConsumer(this::consumeVaultEvent) + .withFilesystemEventConsumer(this::consumeVaultEvent) // .build(); return CryptoFileSystemProvider.newFileSystem(getPath(), fsProps); } @@ -261,7 +262,8 @@ public class Vault { } private void consumeVaultEvent(FilesystemEvent e) { - eventQueue.addLast(new VaultEvent(vaultSettings.id, vaultSettings.path.get().toString(), e)); + long timestamp = Instant.now().toEpochMilli(); + Platform.runLater(() -> eventQueue.addLast(new VaultEvent(timestamp, vaultSettings.id, vaultSettings.path.get().toString(), e))); } // ****************************************************************************** diff --git a/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java b/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java index b813bc3d5..78b454661 100644 --- a/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java +++ b/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java @@ -2,7 +2,10 @@ package org.cryptomator.ui.eventview; import org.cryptomator.common.ObservableUtil; import org.cryptomator.event.Event; +import org.cryptomator.event.UpdateEvent; +import org.cryptomator.event.VaultEvent; import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.controls.FontAwesome5Icon; import org.cryptomator.ui.controls.FontAwesome5IconView; import javax.inject.Inject; @@ -10,25 +13,56 @@ import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; import javafx.scene.layout.HBox; +import java.util.ResourceBundle; public class EventListCellController implements FxController { + private final ResourceBundle resourceBundle; private final ObjectProperty event; + private final ObservableValue message; private final ObservableValue description; + private final ObservableValue icon; public FontAwesome5IconView eventIcon; public HBox eventListCell; @Inject - public EventListCellController() { + public EventListCellController(ResourceBundle resourceBundle) { + this.resourceBundle = resourceBundle; this.event = new SimpleObjectProperty<>(null); - this.description = ObservableUtil.mapWithDefault(event, e -> e.getClass().getName(),""); + this.message = ObservableUtil.mapWithDefault(event, e -> e.getClass().getName(),""); + this.description = ObservableUtil.mapWithDefault(event, this::selectDescription,""); + this.icon = ObservableUtil.mapWithDefault(event, this::selectIcon, FontAwesome5Icon.BELL); } public void setEvent(Event item) { event.set(item); } + private FontAwesome5Icon selectIcon(Event e) { + return switch (e) { + case UpdateEvent _ -> FontAwesome5Icon.BELL; + case VaultEvent _ -> FontAwesome5Icon.FILE; + }; + } + + private String selectDescription(Event e) { + return switch (e) { + case UpdateEvent(_,String newVersion) -> resourceBundle.getString("preferences.updates.updateAvailable").formatted(newVersion); + case VaultEvent _ -> "A vault is weird!"; + }; + } + + + //-- property accessors -- + public ObservableValue messageProperty() { + return message; + } + + public String getMessage() { + return message.getValue(); + } + public ObservableValue descriptionProperty() { return description; } @@ -36,4 +70,13 @@ public class EventListCellController implements FxController { public String getDescription() { return description.getValue(); } + + public ObservableValue iconProperty() { + return icon; + } + + public FontAwesome5Icon getIcon() { + return icon.getValue(); + } + } diff --git a/src/main/resources/css/light_theme.css b/src/main/resources/css/light_theme.css index ffa9604f1..9f9d83fb1 100644 --- a/src/main/resources/css/light_theme.css +++ b/src/main/resources/css/light_theme.css @@ -215,9 +215,17 @@ -fx-background-color: CONTROL_BORDER_NORMAL, CONTROL_BG_ARMED; } +.event-window .button-bar { + -fx-min-height:42px; + -fx-max-height:42px; + -fx-background-color: MAIN_BG; + -fx-border-color: transparent transparent CONTROL_BORDER_NORMAL transparent; + -fx-border-width: 0 0 1px 0; +} + .event-window .button-bar .button-right { -fx-border-color: CONTROL_BORDER_NORMAL; - -fx-border-width: 0 0 0 1px; + -fx-border-width: 0 0 1px 1px; -fx-background-color: MAIN_BG; -fx-background-radius: 0px; -fx-min-height: 42px; @@ -227,14 +235,6 @@ .event-window .button-bar .button-right:armed { -fx-background-color: CONTROL_BORDER_NORMAL, CONTROL_BG_ARMED; } - -.event-window .button-bar { - -fx-min-height:42px; - -fx-max-height:42px; - -fx-background-color: MAIN_BG; - -fx-border-color: CONTROL_BORDER_NORMAL transparent transparent transparent; - -fx-border-width: 1px 0 0 0; -} /******************************************************************************* * * * TabPane * diff --git a/src/main/resources/fxml/eventview_cell.fxml b/src/main/resources/fxml/eventview_cell.fxml index 354b387f1..b76ece770 100644 --- a/src/main/resources/fxml/eventview_cell.fxml +++ b/src/main/resources/fxml/eventview_cell.fxml @@ -4,6 +4,7 @@ + + + + - diff --git a/src/main/resources/fxml/vault_list_cell.fxml b/src/main/resources/fxml/vault_list_cell.fxml index 20df9b924..11bfd5927 100644 --- a/src/main/resources/fxml/vault_list_cell.fxml +++ b/src/main/resources/fxml/vault_list_cell.fxml @@ -14,17 +14,15 @@ spacing="12" alignment="CENTER_LEFT"> - - - - - - - + + + + +