19 package org.sleuthkit.autopsy.timeline.ui.filtering;
21 import javafx.application.Platform;
22 import javafx.geometry.Pos;
23 import javafx.scene.control.ContentDisplay;
24 import javafx.scene.control.TextField;
25 import javafx.scene.control.TreeTableCell;
26 import javafx.scene.image.ImageView;
27 import javafx.scene.layout.HBox;
28 import javafx.scene.paint.Color;
29 import javafx.scene.shape.Rectangle;
30 import org.openide.util.NbBundle;
36 import org.
sleuthkit.datamodel.TimelineFilter.TextFilter;
37 import org.
sleuthkit.datamodel.TimelineFilter.EventTypeFilter;
43 final class LegendCell
extends TreeTableCell<FilterState<?>, FilterState<?>> {
45 private static final Color CLEAR = Color.rgb(0, 0, 0, 0);
47 private final TimeLineController controller;
49 private final FilteredEventsModel filteredEvents;
52 LegendCell(TimeLineController controller) {
54 this.controller = controller;
55 this.filteredEvents = this.controller.getEventsModel();
59 @NbBundle.Messages(
"Timeline.ui.filtering.promptText=enter filter string")
60 public void updateItem(FilterState<?> item,
boolean empty) {
61 super.updateItem(item, empty);
63 Platform.runLater(() -> {
70 if (item.getFilter() instanceof EventTypeFilter) {
71 EventTypeFilter filter = (EventTypeFilter) item.getFilter();
72 Rectangle rect =
new Rectangle(20, 20);
76 rect.setStrokeWidth(3);
77 setLegendColor(filter, rect, this.filteredEvents.getEventTypeZoom());
78 this.filteredEvents.eventTypeZoomProperty().addListener((obs, oldZoomLevel, newZoomLevel) -> {
79 setLegendColor(filter, rect, newZoomLevel);
82 HBox hBox =
new HBox(
new Rectangle(filter.getEventType().getTypeLevel().ordinal() * 10, 5, CLEAR),
83 new ImageView(EventTypeUtils.getImagePath(filter.getEventType())), rect
85 hBox.setAlignment(Pos.CENTER);
86 Platform.runLater(() -> {
88 setContentDisplay(ContentDisplay.CENTER);
91 }
else if (item.getFilter() instanceof TextFilter) {
92 TextFilter filter = (TextFilter) item.getFilter();
93 TextField textField =
new TextField();
94 textField.setPromptText(Bundle.Timeline_ui_filtering_promptText());
95 textField.textProperty().bindBidirectional(filter.textProperty());
96 Platform.runLater(() -> setGraphic(textField));
99 Platform.runLater(() -> {
107 private void setLegendColor(EventTypeFilter filter, Rectangle rect, TimelineEventType.TypeLevel eventTypeZoom) {
109 if (eventTypeZoom.equals(filter.getEventType().getTypeLevel())) {
110 Platform.runLater(() -> {
111 rect.setStroke(EventTypeUtils.getColor(filter.getEventType().getSuperType()));
112 rect.setFill(EventTypeUtils.getColor(filter.getEventType()));
115 Platform.runLater(() -> {
116 rect.setStroke(CLEAR);