style the eventlist cell more

This commit is contained in:
Armin Schrenk
2025-02-14 16:47:15 +01:00
parent 7af7c920e3
commit 3b2ddcf98d
5 changed files with 79 additions and 31 deletions

View File

@@ -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)));
}
// ******************************************************************************

View File

@@ -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();
}
}

View File

@@ -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 *

View File

@@ -4,6 +4,7 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<HBox xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:id="eventListCell"
@@ -12,11 +13,15 @@
prefWidth="200"
spacing="12"
alignment="CENTER_LEFT">
<padding>
<Insets topRightBottomLeft="12"/>
</padding>
<!-- Remark Check the containing list view for a fixed cell size before editing height properties -->
<VBox alignment="CENTER" minWidth="20">
<FontAwesome5IconView fx:id="eventIcon" glyph="BELL" HBox.hgrow="NEVER" glyphSize="16"/>
</VBox>
<VBox spacing="4" HBox.hgrow="ALWAYS">
<Label styleClass="header-label" text="Hey, listen!"/>
<Label styleClass="header-label" text="${controller.message}"/>
<Label styleClass="detail-label" text="${controller.description}" textOverrun="CENTER_ELLIPSIS" />
</VBox>
</HBox>

View File

@@ -14,17 +14,15 @@
spacing="12"
alignment="CENTER_LEFT">
<!-- Remark Check the containing list view for a fixed cell size before editing height properties -->
<children>
<VBox alignment="CENTER" minWidth="20">
<FontAwesome5IconView fx:id="vaultStateView" glyph="${controller.glyph}" HBox.hgrow="NEVER" glyphSize="16"/>
</VBox>
<VBox spacing="4" HBox.hgrow="ALWAYS">
<Label styleClass="header-label" text="${controller.vault.displayName}"/>
<Label styleClass="detail-label" text="${controller.vault.displayablePath}" textOverrun="CENTER_ELLIPSIS" visible="${!controller.compactMode}" managed="${!controller.compactMode}">
<tooltip>
<Tooltip text="${controller.vault.displayablePath}"/>
</tooltip>
</Label>
</VBox>
</children>
<VBox alignment="CENTER" minWidth="20">
<FontAwesome5IconView fx:id="vaultStateView" glyph="${controller.glyph}" HBox.hgrow="NEVER" glyphSize="16"/>
</VBox>
<VBox spacing="4" HBox.hgrow="ALWAYS">
<Label styleClass="header-label" text="${controller.vault.displayName}"/>
<Label styleClass="detail-label" text="${controller.vault.displayablePath}" textOverrun="CENTER_ELLIPSIS" visible="${!controller.compactMode}" managed="${!controller.compactMode}">
<tooltip>
<Tooltip text="${controller.vault.displayablePath}"/>
</tooltip>
</Label>
</VBox>
</HBox>