mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
style the eventlist cell more
This commit is contained in:
@@ -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<Exception> lastKnownException, //
|
||||
VaultStats stats, //
|
||||
Mounter mounter, Settings settings, //
|
||||
ObservableList<Event> eventQueue
|
||||
) {
|
||||
ObservableList<Event> 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)));
|
||||
}
|
||||
|
||||
// ******************************************************************************
|
||||
|
||||
@@ -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> event;
|
||||
private final ObservableValue<String> message;
|
||||
private final ObservableValue<String> description;
|
||||
private final ObservableValue<FontAwesome5Icon> 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<String> messageProperty() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message.getValue();
|
||||
}
|
||||
|
||||
public ObservableValue<String> descriptionProperty() {
|
||||
return description;
|
||||
}
|
||||
@@ -36,4 +70,13 @@ public class EventListCellController implements FxController {
|
||||
public String getDescription() {
|
||||
return description.getValue();
|
||||
}
|
||||
|
||||
public ObservableValue<FontAwesome5Icon> iconProperty() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public FontAwesome5Icon getIcon() {
|
||||
return icon.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user