the great rename

This commit is contained in:
Armin Schrenk
2025-03-19 12:25:26 +01:00
parent e61fb74367
commit 893a4bcae9
8 changed files with 70 additions and 70 deletions

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.event.VaultEventsMap;
import org.cryptomator.event.FileSystemEventRegistry;
import org.cryptomator.common.mount.Mounter;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.common.settings.VaultSettings;
@@ -76,7 +76,7 @@ public class Vault {
private final ObjectBinding<Mountpoint> mountPoint;
private final Mounter mounter;
private final Settings settings;
private final VaultEventsMap vaultEventsMap;
private final FileSystemEventRegistry fileSystemEventRegistry;
private final BooleanProperty showingStats;
private final AtomicReference<Mounter.MountHandle> mountHandle = new AtomicReference<>(null);
@@ -89,7 +89,7 @@ public class Vault {
@Named("lastKnownException") ObjectProperty<Exception> lastKnownException, //
VaultStats stats, //
Mounter mounter, Settings settings, //
VaultEventsMap vaultEventsMap) {
FileSystemEventRegistry fileSystemEventRegistry) {
this.vaultSettings = vaultSettings;
this.configCache = configCache;
this.cryptoFileSystem = cryptoFileSystem;
@@ -106,7 +106,7 @@ public class Vault {
this.mountPoint = Bindings.createObjectBinding(this::getMountPoint, state);
this.mounter = mounter;
this.settings = settings;
this.vaultEventsMap = vaultEventsMap;
this.fileSystemEventRegistry = fileSystemEventRegistry;
this.showingStats = new SimpleBooleanProperty(false);
this.quickAccessEntry = new AtomicReference<>(null);
}
@@ -259,7 +259,7 @@ public class Vault {
private void consumeVaultEvent(FilesystemEvent e) {
vaultEventsMap.enque(this, e);
fileSystemEventRegistry.enque(this, e);
}
// ******************************************************************************

View File

@@ -0,0 +1,21 @@
package org.cryptomator.event;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.cryptofs.event.FilesystemEvent;
public record FileSystemEventBucket(Vault v, FilesystemEvent mostRecent, int count) implements Comparable<FileSystemEventBucket> {
@Override
public int compareTo(FileSystemEventBucket other) {
var timeResult = mostRecent.getTimestamp().compareTo(other.mostRecent().getTimestamp());
if (timeResult != 0) {
return timeResult;
}
var vaultIdResult = v.getId().compareTo(other.v.getId());
if (vaultIdResult != 0) {
return vaultIdResult;
}
return this.mostRecent.getClass().getName().compareTo(other.mostRecent.getClass().getName());
}
}

View File

@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@Singleton
public class VaultEventsMap {
public class FileSystemEventRegistry {
private static final int MAX_MAP_SIZE = 400;
@@ -51,7 +51,7 @@ public class VaultEventsMap {
private final AtomicBoolean queueHasElements;
@Inject
public VaultEventsMap(ScheduledExecutorService scheduledExecutorService) {
public FileSystemEventRegistry(ScheduledExecutorService scheduledExecutorService) {
this.queue = new ConcurrentHashMap<>();
this.lruCache = new TreeSet<>(this::compareKeys);
this.map = FXCollections.observableHashMap();
@@ -85,19 +85,19 @@ public class VaultEventsMap {
/**
* Lists all entries in this map as {@link VaultEvent}. The list is sorted ascending by the timestamp of event occurral (and more if it is the same timestamp).
* Lists all entries in this map as {@link FileSystemEventBucket}. The list is sorted ascending by the timestamp of event occurral (and more if it is the same timestamp).
* Must be executed on the JavaFX application thread
*
* @return a list of vault events, mainly sorted ascending by the event timestamp
* @implNote Method is not synchronized, because it is only executed if executed by JavaFX application thread
*/
public List<VaultEvent> listAll() {
public List<FileSystemEventBucket> listAll() {
if (!Platform.isFxApplicationThread()) {
throw new IllegalStateException("Listing map entries must be performed on JavaFX application thread");
}
return lruCache.stream().map(key -> {
var value = map.get(key);
return new VaultEvent(key.vault(), value.mostRecentEvent(), value.count());
return new FileSystemEventBucket(key.vault(), value.mostRecentEvent(), value.count());
}).toList();
}
@@ -225,7 +225,7 @@ public class VaultEventsMap {
* @param event Actual {@link FilesystemEvent}
* @return a {@link Key} used in the map and lru cache
*/
private Key computeKey(Vault v, FilesystemEvent event) {
private static Key computeKey(Vault v, FilesystemEvent event) {
var p = switch (event) {
case DecryptionFailedEvent(_, Path ciphertextPath, _) -> ciphertextPath;
case ConflictResolvedEvent(_, _, _, _, Path resolvedCiphertext) -> resolvedCiphertext;

View File

@@ -1,21 +0,0 @@
package org.cryptomator.event;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.cryptofs.event.FilesystemEvent;
public record VaultEvent(Vault v, FilesystemEvent actualEvent, int count) implements Comparable<VaultEvent> {
@Override
public int compareTo(VaultEvent other) {
var timeResult = actualEvent.getTimestamp().compareTo(other.actualEvent().getTimestamp());
if (timeResult != 0) {
return timeResult;
}
var vaultIdResult = v.getId().compareTo(other.v.getId());
if (vaultIdResult != 0) {
return vaultIdResult;
}
return this.actualEvent.getClass().getName().compareTo(other.actualEvent.getClass().getName());
}
}

View File

@@ -1,6 +1,6 @@
package org.cryptomator.ui.eventview;
import org.cryptomator.event.VaultEventsMap;
import org.cryptomator.event.FileSystemEventRegistry;
import org.cryptomator.common.Nullable;
import org.cryptomator.common.ObservableUtil;
import org.cryptomator.cryptofs.CryptoPath;
@@ -9,7 +9,7 @@ import org.cryptomator.cryptofs.event.BrokenFileNodeEvent;
import org.cryptomator.cryptofs.event.ConflictResolutionFailedEvent;
import org.cryptomator.cryptofs.event.ConflictResolvedEvent;
import org.cryptomator.cryptofs.event.DecryptionFailedEvent;
import org.cryptomator.event.VaultEvent;
import org.cryptomator.event.FileSystemEventBucket;
import org.cryptomator.integrations.revealpath.RevealFailedException;
import org.cryptomator.integrations.revealpath.RevealPathService;
import org.cryptomator.ui.common.FxController;
@@ -51,11 +51,11 @@ 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 VaultEventsMap vaultEventsMap;
private final FileSystemEventRegistry fileSystemEventRegistry;
@Nullable
private final RevealPathService revealService;
private final ResourceBundle resourceBundle;
private final ObjectProperty<VaultEvent> event;
private final ObjectProperty<FileSystemEventBucket> event;
private final StringProperty eventMessage;
private final StringProperty eventDescription;
private final ObjectProperty<FontAwesome5Icon> eventIcon;
@@ -77,8 +77,8 @@ public class EventListCellController implements FxController {
Button eventActionsButton;
@Inject
public EventListCellController(VaultEventsMap vaultEventsMap, Optional<RevealPathService> revealService, ResourceBundle resourceBundle) {
this.vaultEventsMap = vaultEventsMap;
public EventListCellController(FileSystemEventRegistry fileSystemEventRegistry, Optional<RevealPathService> revealService, ResourceBundle resourceBundle) {
this.fileSystemEventRegistry = fileSystemEventRegistry;
this.revealService = revealService.orElseGet(() -> null);
this.resourceBundle = resourceBundle;
this.event = new SimpleObjectProperty<>(null);
@@ -87,8 +87,8 @@ public class EventListCellController implements FxController {
this.eventIcon = new SimpleObjectProperty<>();
this.eventCount = ObservableUtil.mapWithDefault(event, e -> e.count() == 1? "" : "("+ e.count() +")", "");
this.vaultUnlocked = ObservableUtil.mapWithDefault(event.flatMap(e -> e.v().unlockedProperty()), Function.identity(), false);
this.readableTime = ObservableUtil.mapWithDefault(event, e -> LOCAL_TIME_FORMATTER.format(e.actualEvent().getTimestamp()), "");
this.readableDate = ObservableUtil.mapWithDefault(event, e -> LOCAL_DATE_FORMATTER.format(e.actualEvent().getTimestamp()), "");
this.readableTime = ObservableUtil.mapWithDefault(event, e -> LOCAL_TIME_FORMATTER.format(e.mostRecent().getTimestamp()), "");
this.readableDate = ObservableUtil.mapWithDefault(event, e -> LOCAL_DATE_FORMATTER.format(e.mostRecent().getTimestamp()), "");
this.message = Bindings.createStringBinding(this::selectMessage, vaultUnlocked, eventMessage);
this.description = Bindings.createStringBinding(this::selectDescription, vaultUnlocked, eventDescription);
this.icon = Bindings.createObjectBinding(this::selectIcon, vaultUnlocked, eventIcon);
@@ -108,13 +108,13 @@ public class EventListCellController implements FxController {
return vaultUnlocked.getValue() && (eventActionsMenu.isShowing() || root.isHover());
}
public void setEvent(@NotNull VaultEvent item) {
public void setEvent(@NotNull FileSystemEventBucket item) {
event.set(item);
eventActionsMenu.hide();
eventActionsMenu.getItems().clear();
eventTooltip.setText(item.v().getDisplayName());
addAction("generic.action.dismiss", () -> vaultEventsMap.remove(item.v(),item.actualEvent()));
switch (item.actualEvent()) {
addAction("generic.action.dismiss", () -> fileSystemEventRegistry.remove(item.v(),item.mostRecent()));
switch (item.mostRecent()) {
case ConflictResolvedEvent fse -> this.adjustToConflictResolvedEvent(fse);
case ConflictResolutionFailedEvent fse -> this.adjustToConflictEvent(fse);
case DecryptionFailedEvent fse -> this.adjustToDecryptionFailedEvent(fse);

View File

@@ -1,6 +1,6 @@
package org.cryptomator.ui.eventview;
import org.cryptomator.event.VaultEvent;
import org.cryptomator.event.FileSystemEventBucket;
import org.cryptomator.ui.common.FxmlLoaderFactory;
import javax.inject.Inject;
@@ -14,7 +14,7 @@ import java.io.IOException;
import java.io.UncheckedIOException;
@EventViewScoped
public class EventListCellFactory implements Callback<ListView<VaultEvent>, ListCell<VaultEvent>> {
public class EventListCellFactory implements Callback<ListView<FileSystemEventBucket>, ListCell<FileSystemEventBucket>> {
private static final String FXML_PATH = "/fxml/eventview_cell.fxml";
@@ -27,7 +27,7 @@ public class EventListCellFactory implements Callback<ListView<VaultEvent>, List
@Override
public ListCell<VaultEvent> call(ListView<VaultEvent> eventListView) {
public ListCell<FileSystemEventBucket> call(ListView<FileSystemEventBucket> eventListView) {
try {
FXMLLoader fxmlLoader = fxmlLoaders.load(FXML_PATH);
return new Cell(fxmlLoader.getRoot(), fxmlLoader.getController());
@@ -36,7 +36,7 @@ public class EventListCellFactory implements Callback<ListView<VaultEvent>, List
}
}
private static class Cell extends ListCell<VaultEvent> {
private static class Cell extends ListCell<FileSystemEventBucket> {
private final Parent root;
private final EventListCellController controller;
@@ -47,7 +47,7 @@ public class EventListCellFactory implements Callback<ListView<VaultEvent>, List
}
@Override
protected void updateItem(VaultEvent item, boolean empty) {
protected void updateItem(FileSystemEventBucket item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {

View File

@@ -1,8 +1,8 @@
package org.cryptomator.ui.eventview;
import org.cryptomator.event.VaultEventsMap;
import org.cryptomator.event.FileSystemEventRegistry;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.event.VaultEvent;
import org.cryptomator.event.FileSystemEventBucket;
import org.cryptomator.ui.common.FxController;
import javax.inject.Inject;
@@ -23,11 +23,11 @@ import java.util.ResourceBundle;
@EventViewScoped
public class EventViewController implements FxController {
private final VaultEventsMap vaultEventsMap;
private final ObservableList<VaultEvent> eventList;
private final FilteredList<VaultEvent> filteredEventList;
private final FileSystemEventRegistry fileSystemEventRegistry;
private final ObservableList<FileSystemEventBucket> eventList;
private final FilteredList<FileSystemEventBucket> filteredEventList;
private final ObservableList<Vault> vaults;
private final SortedList<VaultEvent> reversedEventList;
private final SortedList<FileSystemEventBucket> reversedEventList;
private final ObservableList<Vault> choiceBoxEntries;
private final ResourceBundle resourceBundle;
private final EventListCellFactory cellFactory;
@@ -35,11 +35,11 @@ public class EventViewController implements FxController {
@FXML
ChoiceBox<Vault> vaultFilterChoiceBox;
@FXML
ListView<VaultEvent> eventListView;
ListView<FileSystemEventBucket> eventListView;
@Inject
public EventViewController(VaultEventsMap vaultEventsMap, ObservableList<Vault> vaults, ResourceBundle resourceBundle, EventListCellFactory cellFactory) {
this.vaultEventsMap = vaultEventsMap;
public EventViewController(FileSystemEventRegistry fileSystemEventRegistry, ObservableList<Vault> vaults, ResourceBundle resourceBundle, EventListCellFactory cellFactory) {
this.fileSystemEventRegistry = fileSystemEventRegistry;
this.eventList = FXCollections.observableArrayList();
this.filteredEventList = eventList.filtered(_ -> true);
this.vaults = vaults;
@@ -60,8 +60,8 @@ public class EventViewController implements FxController {
}
});
eventList.addAll(vaultEventsMap.listAll());
vaultEventsMap.addListener((MapChangeListener<? super VaultEventsMap.Key, ? super VaultEventsMap.Value>) this::updateList);
eventList.addAll(fileSystemEventRegistry.listAll());
fileSystemEventRegistry.addListener((MapChangeListener<? super FileSystemEventRegistry.Key, ? super FileSystemEventRegistry.Value>) this::updateList);
eventListView.setCellFactory(cellFactory);
eventListView.setItems(reversedEventList);
@@ -70,16 +70,16 @@ public class EventViewController implements FxController {
vaultFilterChoiceBox.setConverter(new VaultConverter(resourceBundle));
}
private void updateList(MapChangeListener.Change<? extends VaultEventsMap.Key, ? extends VaultEventsMap.Value> change) {
private void updateList(MapChangeListener.Change<? extends FileSystemEventRegistry.Key, ? extends FileSystemEventRegistry.Value> change) {
var vault = change.getKey().vault();
if (change.wasAdded() && change.wasRemoved()) {
//entry updated
eventList.remove(new VaultEvent(vault, change.getValueRemoved().mostRecentEvent(), change.getValueRemoved().count()));
eventList.addLast(new VaultEvent(vault, change.getValueAdded().mostRecentEvent(), change.getValueAdded().count()));
eventList.remove(new FileSystemEventBucket(vault, change.getValueRemoved().mostRecentEvent(), change.getValueRemoved().count()));
eventList.addLast(new FileSystemEventBucket(vault, change.getValueAdded().mostRecentEvent(), change.getValueAdded().count()));
} else if (change.wasAdded()) {
eventList.addLast(new VaultEvent(vault, change.getValueAdded().mostRecentEvent(), change.getValueAdded().count()));
eventList.addLast(new FileSystemEventBucket(vault, change.getValueAdded().mostRecentEvent(), change.getValueAdded().count()));
} else { //removed
eventList.remove(new VaultEvent(vault, change.getValueRemoved().mostRecentEvent(), change.getValueRemoved().count()));
eventList.remove(new FileSystemEventBucket(vault, change.getValueRemoved().mostRecentEvent(), change.getValueRemoved().count()));
}
}
@@ -93,7 +93,7 @@ public class EventViewController implements FxController {
@FXML
void clearEvents() {
vaultEventsMap.clear();
fileSystemEventRegistry.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.event.VaultEventsMap;
import org.cryptomator.event.FileSystemEventRegistry;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultListManager;
@@ -68,7 +68,7 @@ public class VaultListController implements FxController {
private final VaultListCellFactory cellFactory;
private final AddVaultWizardComponent.Builder addVaultWizard;
private final BooleanBinding emptyVaultList;
private final VaultEventsMap vaultEventsMap;
private final FileSystemEventRegistry fileSystemEventRegistry;
private final BooleanProperty newEventsPresent;
private final VaultListManager vaultListManager;
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
@@ -96,7 +96,7 @@ public class VaultListController implements FxController {
FxApplicationWindows appWindows, //
Settings settings, //
Dialogs dialogs, //
VaultEventsMap vaultEventsMap) {
FileSystemEventRegistry fileSystemEventRegistry) {
this.mainWindow = mainWindow;
this.vaults = vaults;
this.selectedVault = selectedVault;
@@ -109,9 +109,9 @@ public class VaultListController implements FxController {
this.dialogs = dialogs;
this.emptyVaultList = Bindings.isEmpty(vaults);
this.vaultEventsMap = vaultEventsMap;
this.fileSystemEventRegistry = fileSystemEventRegistry;
this.newEventsPresent = new SimpleBooleanProperty(false);
vaultEventsMap.addListener((MapChangeListener<? super VaultEventsMap.Key, ? super VaultEventsMap.Value>) change -> {
fileSystemEventRegistry.addListener((MapChangeListener<? super FileSystemEventRegistry.Key, ? super FileSystemEventRegistry.Value>) change -> {
if (change.wasAdded()) {
newEventsPresent.setValue(true);
}