|
@@ -6,32 +6,40 @@ 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;
|
|
|
import javafx.beans.property.ObjectProperty;
|
|
|
import javafx.beans.property.SimpleObjectProperty;
|
|
|
import javafx.beans.value.ObservableValue;
|
|
|
-import javafx.scene.layout.HBox;
|
|
|
+import javafx.collections.ObservableList;
|
|
|
+import javafx.event.ActionEvent;
|
|
|
+import javafx.fxml.FXML;
|
|
|
+import javafx.geometry.Side;
|
|
|
+import javafx.scene.control.Button;
|
|
|
+import javafx.scene.control.ContextMenu;
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
|
public class EventListCellController implements FxController {
|
|
|
|
|
|
+ private final ObservableList<Event> eventList;
|
|
|
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;
|
|
|
+ @FXML
|
|
|
+ ContextMenu eventActionsContextMenu;
|
|
|
+ @FXML
|
|
|
+ Button eventActionsButton;
|
|
|
|
|
|
@Inject
|
|
|
- public EventListCellController(ResourceBundle resourceBundle) {
|
|
|
+ public EventListCellController(ObservableList<Event> eventList, ResourceBundle resourceBundle) {
|
|
|
+ this.eventList = eventList;
|
|
|
this.resourceBundle = resourceBundle;
|
|
|
this.event = new SimpleObjectProperty<>(null);
|
|
|
- this.message = ObservableUtil.mapWithDefault(event, e -> e.getClass().getName(),"");
|
|
|
- this.description = ObservableUtil.mapWithDefault(event, this::selectDescription,"");
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
@@ -48,11 +56,24 @@ public class EventListCellController implements FxController {
|
|
|
|
|
|
private String selectDescription(Event e) {
|
|
|
return switch (e) {
|
|
|
- case UpdateEvent(_,String newVersion) -> resourceBundle.getString("preferences.updates.updateAvailable").formatted(newVersion);
|
|
|
+ case UpdateEvent(_, String newVersion) -> resourceBundle.getString("preferences.updates.updateAvailable").formatted(newVersion);
|
|
|
case VaultEvent _ -> "A vault is weird!";
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ @FXML
|
|
|
+ public void toggleEventActionsMenu(ActionEvent actionEvent) {
|
|
|
+ if (eventActionsContextMenu.isShowing()) {
|
|
|
+ eventActionsContextMenu.hide();
|
|
|
+ } else {
|
|
|
+ eventActionsContextMenu.show(eventActionsButton, Side.BOTTOM, 0.0, 0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @FXML
|
|
|
+ public void remove() {
|
|
|
+ eventList.remove(event.getValue());
|
|
|
+ }
|
|
|
|
|
|
//-- property accessors --
|
|
|
public ObservableValue<String> messageProperty() {
|
|
@@ -78,5 +99,4 @@ public class EventListCellController implements FxController {
|
|
|
public FontAwesome5Icon getIcon() {
|
|
|
return icon.getValue();
|
|
|
}
|
|
|
-
|
|
|
}
|