diff --git a/src/main/java/org/cryptomator/common/EventMap.java b/src/main/java/org/cryptomator/common/VaultEventsMap.java similarity index 93% rename from src/main/java/org/cryptomator/common/EventMap.java rename to src/main/java/org/cryptomator/common/VaultEventsMap.java index 2e8dbf035..4bf58a47c 100644 --- a/src/main/java/org/cryptomator/common/EventMap.java +++ b/src/main/java/org/cryptomator/common/VaultEventsMap.java @@ -26,21 +26,21 @@ import java.util.Set; * Map containing {@link VaultEvent}s. * The map is keyed by the ciphertext path of the affected resource _and_ the {@link FilesystemEvent}s class in order to group same events *

- * Use {@link EventMap#put(VaultEvent)} to add an element and {@link EventMap#remove(VaultEvent)} to remove it. + * Use {@link VaultEventsMap#put(VaultEvent)} to add an element and {@link VaultEventsMap#remove(VaultEvent)} to remove it. *

* The map is size restricted to {@value MAX_SIZE} elements. If a _new_ element (i.e. not already present) is added, the least recently added is removed. */ @Singleton -public class EventMap implements ObservableMap { +public class VaultEventsMap implements ObservableMap { private static final int MAX_SIZE = 300; public record EventKey(Path ciphertextPath, Class c) {} - private final ObservableMap delegate; + private final ObservableMap delegate; @Inject - public EventMap() { + public VaultEventsMap() { delegate = FXCollections.observableHashMap(); } diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index b4fce3022..a8d63f139 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -10,7 +10,7 @@ package org.cryptomator.common.vaults; import org.apache.commons.lang3.SystemUtils; import org.cryptomator.common.Constants; -import org.cryptomator.common.EventMap; +import org.cryptomator.common.VaultEventsMap; import org.cryptomator.common.mount.Mounter; import org.cryptomator.common.settings.Settings; import org.cryptomator.common.settings.VaultSettings; @@ -78,7 +78,7 @@ public class Vault { private final ObjectBinding mountPoint; private final Mounter mounter; private final Settings settings; - private final EventMap eventMap; + private final VaultEventsMap vaultEventsMap; private final BooleanProperty showingStats; private final AtomicReference mountHandle = new AtomicReference<>(null); @@ -91,7 +91,7 @@ public class Vault { @Named("lastKnownException") ObjectProperty lastKnownException, // VaultStats stats, // Mounter mounter, Settings settings, // - EventMap eventMap) { + VaultEventsMap vaultEventsMap) { this.vaultSettings = vaultSettings; this.configCache = configCache; this.cryptoFileSystem = cryptoFileSystem; @@ -108,7 +108,7 @@ public class Vault { this.mountPoint = Bindings.createObjectBinding(this::getMountPoint, state); this.mounter = mounter; this.settings = settings; - this.eventMap = eventMap; + this.vaultEventsMap = vaultEventsMap; this.showingStats = new SimpleBooleanProperty(false); this.quickAccessEntry = new AtomicReference<>(null); } @@ -263,7 +263,7 @@ public class Vault { private void consumeVaultEvent(FilesystemEvent e) { var wrapper = new VaultEvent(this, e); Platform.runLater(() -> { - eventMap.put(wrapper); + vaultEventsMap.put(wrapper); }); } diff --git a/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java b/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java index 613ba43c5..21a61950d 100644 --- a/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java +++ b/src/main/java/org/cryptomator/ui/eventview/EventListCellController.java @@ -1,6 +1,6 @@ package org.cryptomator.ui.eventview; -import org.cryptomator.common.EventMap; +import org.cryptomator.common.VaultEventsMap; import org.cryptomator.common.Nullable; import org.cryptomator.common.ObservableUtil; import org.cryptomator.cryptofs.CryptoPath; @@ -51,7 +51,7 @@ public class EventListCellController implements FxController { private static final DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).withZone(ZoneId.systemDefault()); private static final DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withZone(ZoneId.systemDefault()); - private final EventMap eventMap; + private final VaultEventsMap vaultEventsMap; @Nullable private final RevealPathService revealService; private final ResourceBundle resourceBundle; @@ -77,8 +77,8 @@ public class EventListCellController implements FxController { Button eventActionsButton; @Inject - public EventListCellController(EventMap eventMap, Optional revealService, ResourceBundle resourceBundle) { - this.eventMap = eventMap; + public EventListCellController(VaultEventsMap vaultEventsMap, Optional revealService, ResourceBundle resourceBundle) { + this.vaultEventsMap = vaultEventsMap; this.revealService = revealService.orElseGet(() -> null); this.resourceBundle = resourceBundle; this.event = new SimpleObjectProperty<>(null); @@ -113,7 +113,7 @@ public class EventListCellController implements FxController { eventActionsMenu.hide(); eventActionsMenu.getItems().clear(); eventTooltip.setText(item.v().getDisplayName()); - addAction("generic.action.dismiss", () -> eventMap.remove(item)); + addAction("generic.action.dismiss", () -> vaultEventsMap.remove(item)); switch (item.actualEvent()) { case ConflictResolvedEvent fse -> this.adjustToConflictResolvedEvent(fse); case ConflictResolutionFailedEvent fse -> this.adjustToConflictEvent(fse); diff --git a/src/main/java/org/cryptomator/ui/eventview/EventViewController.java b/src/main/java/org/cryptomator/ui/eventview/EventViewController.java index 2a58381e5..c3e0e7b24 100644 --- a/src/main/java/org/cryptomator/ui/eventview/EventViewController.java +++ b/src/main/java/org/cryptomator/ui/eventview/EventViewController.java @@ -1,6 +1,6 @@ package org.cryptomator.ui.eventview; -import org.cryptomator.common.EventMap; +import org.cryptomator.common.VaultEventsMap; import org.cryptomator.common.vaults.Vault; import org.cryptomator.event.VaultEvent; import org.cryptomator.ui.common.FxController; @@ -23,7 +23,7 @@ import java.util.ResourceBundle; @EventViewScoped public class EventViewController implements FxController { - private final EventMap eventMap; + private final VaultEventsMap vaultEventsMap; private final ObservableList eventList; private final FilteredList filteredEventList; private final ObservableList vaults; @@ -38,8 +38,8 @@ public class EventViewController implements FxController { ListView eventListView; @Inject - public EventViewController(EventMap eventMap, ObservableList vaults, ResourceBundle resourceBundle, EventListCellFactory cellFactory) { - this.eventMap = eventMap; + public EventViewController(VaultEventsMap vaultEventsMap, ObservableList vaults, ResourceBundle resourceBundle, EventListCellFactory cellFactory) { + this.vaultEventsMap = vaultEventsMap; this.eventList = FXCollections.observableArrayList(); this.filteredEventList = eventList.filtered(_ -> true); this.vaults = vaults; @@ -60,8 +60,8 @@ public class EventViewController implements FxController { } }); - eventList.addAll(eventMap.values()); - eventMap.addListener((MapChangeListener) this::updateList); + eventList.addAll(vaultEventsMap.values()); + vaultEventsMap.addListener((MapChangeListener) this::updateList); eventListView.setCellFactory(cellFactory); eventListView.setItems(reversedEventList); @@ -70,7 +70,7 @@ public class EventViewController implements FxController { vaultFilterChoiceBox.setConverter(new VaultConverter(resourceBundle)); } - private void updateList(MapChangeListener.Change change) { + private void updateList(MapChangeListener.Change change) { if (change.wasAdded() && change.wasRemoved()) { //entry updated eventList.remove(change.getValueRemoved()); @@ -92,7 +92,7 @@ public class EventViewController implements FxController { @FXML void clearEvents() { - eventMap.clear(); + vaultEventsMap.clear(); } private static class VaultConverter extends StringConverter { diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index b18ada465..a3b7761f5 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -1,7 +1,7 @@ package org.cryptomator.ui.mainwindow; import org.apache.commons.lang3.SystemUtils; -import org.cryptomator.common.EventMap; +import org.cryptomator.common.VaultEventsMap; import org.cryptomator.common.settings.Settings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; @@ -69,7 +69,7 @@ public class VaultListController implements FxController { private final VaultListCellFactory cellFactory; private final AddVaultWizardComponent.Builder addVaultWizard; private final BooleanBinding emptyVaultList; - private final EventMap eventMap; + private final VaultEventsMap vaultEventsMap; private final BooleanProperty newEventsPresent; private final VaultListManager vaultListManager; private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty(); @@ -97,7 +97,7 @@ public class VaultListController implements FxController { FxApplicationWindows appWindows, // Settings settings, // Dialogs dialogs, // - EventMap eventMap) { + VaultEventsMap vaultEventsMap) { this.mainWindow = mainWindow; this.vaults = vaults; this.selectedVault = selectedVault; @@ -110,9 +110,9 @@ public class VaultListController implements FxController { this.dialogs = dialogs; this.emptyVaultList = Bindings.isEmpty(vaults); - this.eventMap = eventMap; + this.vaultEventsMap = vaultEventsMap; this.newEventsPresent = new SimpleBooleanProperty(false); - eventMap.addListener((MapChangeListener) change -> { + vaultEventsMap.addListener((MapChangeListener) change -> { if (change.wasAdded()) { newEventsPresent.setValue(true); }