rename eventMap to make purpose clearer

This commit is contained in:
Armin Schrenk
2025-03-18 12:10:44 +01:00
parent 36dd98127d
commit 2bbffc3623
5 changed files with 27 additions and 27 deletions

View File

@@ -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
* <p>
* 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.
* <p>
* 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<EventMap.EventKey, VaultEvent> {
public class VaultEventsMap implements ObservableMap<VaultEventsMap.EventKey, VaultEvent> {
private static final int MAX_SIZE = 300;
public record EventKey(Path ciphertextPath, Class<? extends FilesystemEvent> c) {}
private final ObservableMap<EventMap.EventKey, VaultEvent> delegate;
private final ObservableMap<VaultEventsMap.EventKey, VaultEvent> delegate;
@Inject
public EventMap() {
public VaultEventsMap() {
delegate = FXCollections.observableHashMap();
}

View File

@@ -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> mountPoint;
private final Mounter mounter;
private final Settings settings;
private final EventMap eventMap;
private final VaultEventsMap vaultEventsMap;
private final BooleanProperty showingStats;
private final AtomicReference<Mounter.MountHandle> mountHandle = new AtomicReference<>(null);
@@ -91,7 +91,7 @@ public class Vault {
@Named("lastKnownException") ObjectProperty<Exception> 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);
});
}

View File

@@ -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<RevealPathService> revealService, ResourceBundle resourceBundle) {
this.eventMap = eventMap;
public EventListCellController(VaultEventsMap vaultEventsMap, Optional<RevealPathService> 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);

View File

@@ -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<VaultEvent> eventList;
private final FilteredList<VaultEvent> filteredEventList;
private final ObservableList<Vault> vaults;
@@ -38,8 +38,8 @@ public class EventViewController implements FxController {
ListView<VaultEvent> eventListView;
@Inject
public EventViewController(EventMap eventMap, ObservableList<Vault> vaults, ResourceBundle resourceBundle, EventListCellFactory cellFactory) {
this.eventMap = eventMap;
public EventViewController(VaultEventsMap vaultEventsMap, ObservableList<Vault> 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<? super EventMap.EventKey, ? super VaultEvent>) this::updateList);
eventList.addAll(vaultEventsMap.values());
vaultEventsMap.addListener((MapChangeListener<? super VaultEventsMap.EventKey, ? super VaultEvent>) 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<? extends EventMap.EventKey, ? extends VaultEvent> change) {
private void updateList(MapChangeListener.Change<? extends VaultEventsMap.EventKey, ? extends VaultEvent> 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<Vault> {

View File

@@ -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<? super EventMap.EventKey, ? super VaultEvent>) change -> {
vaultEventsMap.addListener((MapChangeListener<? super VaultEventsMap.EventKey, ? super VaultEvent>) change -> {
if (change.wasAdded()) {
newEventsPresent.setValue(true);
}