19 package org.sleuthkit.autopsy.timeline.ui;
21 import com.google.common.collect.ImmutableList;
22 import com.google.common.eventbus.Subscribe;
23 import java.time.Instant;
24 import java.time.LocalDate;
25 import java.time.LocalDateTime;
26 import java.time.ZoneOffset;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.function.BiFunction;
30 import java.util.function.Supplier;
31 import javafx.application.Platform;
32 import javafx.beans.InvalidationListener;
33 import javafx.beans.Observable;
34 import javafx.collections.FXCollections;
35 import javafx.collections.ObservableList;
36 import javafx.fxml.FXML;
37 import javafx.geometry.Insets;
38 import javafx.scene.Node;
39 import javafx.scene.control.Button;
40 import javafx.scene.control.Label;
41 import javafx.scene.control.MenuButton;
42 import javafx.scene.control.TitledPane;
43 import javafx.scene.control.ToggleButton;
44 import javafx.scene.control.ToolBar;
45 import javafx.scene.control.Tooltip;
46 import javafx.scene.effect.Lighting;
47 import javafx.scene.image.Image;
48 import javafx.scene.image.ImageView;
49 import javafx.scene.input.MouseEvent;
50 import javafx.scene.layout.Background;
51 import javafx.scene.layout.BackgroundFill;
52 import javafx.scene.layout.BorderPane;
53 import javafx.scene.layout.CornerRadii;
54 import javafx.scene.layout.HBox;
55 import javafx.scene.layout.Priority;
56 import javafx.scene.layout.Region;
57 import static javafx.scene.layout.Region.USE_PREF_SIZE;
58 import javafx.scene.layout.StackPane;
59 import javafx.scene.paint.Color;
60 import javafx.util.Callback;
61 import javax.annotation.Nonnull;
62 import javax.annotation.concurrent.GuardedBy;
63 import jfxtras.scene.control.LocalDateTimePicker;
64 import jfxtras.scene.control.LocalDateTimeTextField;
65 import jfxtras.scene.control.ToggleGroupValue;
66 import org.controlsfx.control.NotificationPane;
67 import org.controlsfx.control.RangeSlider;
68 import org.controlsfx.control.SegmentedButton;
69 import org.controlsfx.control.action.Action;
70 import org.controlsfx.control.action.ActionUtils;
71 import org.joda.time.DateTime;
72 import org.joda.time.Interval;
73 import org.openide.util.NbBundle;
113 private static final Image
INFORMATION =
new Image(
"org/sleuthkit/autopsy/timeline/images/information.png", 16, 16,
true,
true);
114 private static final Image
WARNING =
new Image(
"org/sleuthkit/autopsy/timeline/images/warning_triangle.png", 16, 16,
true,
true);
115 private static final Image
REFRESH =
new Image(
"org/sleuthkit/autopsy/timeline/images/arrow-circle-double-135.png");
116 private static final Background
GRAY_BACKGROUND =
new Background(
new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY));
125 setBackground(GRAY_BACKGROUND);
162 private final RangeSlider
rangeSlider = new RangeSlider(0, 1.0, .25, .75);
227 private final ObservableList<Node>
settingsNodes = FXCollections.observableArrayList();
250 public void invalidated(Observable observable) {
254 if (
false == controller.pushTimeRange(
new Interval(
256 (
long) (
rangeSlider.getHighValue() + minTime + 1000)))) {
319 "ViewFrame.viewModeLabel.text=View Mode:",
320 "ViewFrame.startLabel.text=Start:",
321 "ViewFrame.endLabel.text=End:",
322 "ViewFrame.countsToggle.text=Counts",
323 "ViewFrame.detailsToggle.text=Details",
324 "ViewFrame.listToggle.text=List",
325 "ViewFrame.zoomMenuButton.text=Zoom in/out to",
326 "ViewFrame.tagsAddedOrDeleted=Tags have been created and/or deleted. The view may not be up to date."
329 assert
endPicker != null :
"fx:id=\"endPicker\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
330 assert
histogramBox != null :
"fx:id=\"histogramBox\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
331 assert
startPicker != null :
"fx:id=\"startPicker\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
332 assert
rangeHistogramStack != null :
"fx:id=\"rangeHistogramStack\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
333 assert
countsToggle != null :
"fx:id=\"countsToggle\" was not injected: check your FXML file 'VisToggle.fxml'.";
334 assert
detailsToggle != null :
"fx:id=\"eventsToggle\" was not injected: check your FXML file 'VisToggle.fxml'.";
344 viewModeLabel.setText(Bundle.ViewFrame_viewModeLabel_text());
345 countsToggle.setText(Bundle.ViewFrame_countsToggle_text());
346 detailsToggle.setText(Bundle.ViewFrame_detailsToggle_text());
347 listToggle.setText(Bundle.ViewFrame_listToggle_text());
364 startLabel.setText(Bundle.ViewFrame_startLabel_text());
365 endLabel.setText(Bundle.ViewFrame_endLabel_text());
369 startPicker.setParseErrorCallback(throwable -> null);
370 endPicker.setParseErrorCallback(throwable -> null);
373 LocalDateDisabler localDateDisabler =
new LocalDateDisabler();
374 startPicker.setLocalDateTimeRangeCallback(localDateDisabler);
375 endPicker.setLocalDateTimeRangeCallback(localDateDisabler);
392 histogramBox.setStyle(
" -fx-padding: 0,0.5em,0,.5em; ");
396 for (ZoomRanges zoomRange : ZoomRanges.values()) {
409 TimeLineController.getTimeZone().addListener(timeZoneProp ->
refreshTimeUI());
429 Platform.runLater(() -> {
432 notificationPane.show(Bundle.ViewFrame_tagsAddedOrDeleted(),
new ImageView(INFORMATION));
448 Platform.runLater(() -> {
449 if (Bundle.ViewFrame_tagsAddedOrDeleted().equals(
notificationPane.getText())) {
467 Platform.runLater(notificationPane::hide);
481 "# {0} - datasource name",
482 "ViewFrame.notification.newDataSource={0} has been added as a new datasource. The Timeline DB may be out of date."})
484 Platform.runLater(() -> {
501 "# {0} - datasource name",
502 "ViewFrame.notification.analysisComplete=Analysis has finished for {0}. The Timeline DB may be out of date."})
504 Platform.runLater(() -> {
505 Content dataSource =
event.getDataSource();
506 if (dataSource != null) {
508 notificationPane.show(Bundle.ViewFrame_notification_analysisComplete(dataSource.getName()),
new ImageView(WARNING));
516 @NbBundle.Messages({
"ViewFrame.histogramTask.title=Rebuilding Histogram",
517 "ViewFrame.histogramTask.preparing=Preparing",
518 "ViewFrame.histogramTask.resetUI=Resetting UI",
519 "ViewFrame.histogramTask.queryDb=Querying FB",
520 "ViewFrame.histogramTask.updateUI2=Updating UI"})
527 private final Lighting lighting =
new Lighting();
530 protected Void call()
throws Exception {
532 updateMessage(ViewFrame_histogramTask_preparing());
544 Platform.runLater(() -> {
545 updateMessage(ViewFrame_histogramTask_resetUI());
549 ArrayList<Long> bins =
new ArrayList<>();
551 DateTime start = timeRange.getStart();
552 while (timeRange.contains(start)) {
557 final Interval interval =
new Interval(start, end);
562 updateMessage(ViewFrame_histogramTask_queryDb());
567 max = Math.max(count, max);
569 final double fMax = Math.log(max);
570 final ArrayList<Long> fbins =
new ArrayList<>(bins);
571 Platform.runLater(() -> {
572 updateMessage(ViewFrame_histogramTask_updateUI2());
576 for (Long bin : fbins) {
580 Region bar =
new Region();
582 bar.prefHeightProperty().bind(
histogramBox.heightProperty().multiply(Math.log(bin)).divide(fMax));
583 bar.setMaxHeight(USE_PREF_SIZE);
584 bar.setMinHeight(USE_PREF_SIZE);
585 bar.setBackground(GRAY_BACKGROUND);
586 bar.setOnMouseEntered((MouseEvent event) -> {
587 Tooltip.install(bar,
new Tooltip(bin.toString()));
589 bar.setEffect(lighting);
591 HBox.setHgrow(bar, Priority.ALWAYS);
615 if (minTime > 0 && maxTime > minTime) {
616 Platform.runLater(() -> {
617 startPicker.localDateTimeProperty().removeListener(startListener);
618 endPicker.localDateTimeProperty().removeListener(endListener);
631 startPicker.localDateTimeProperty().addListener(startListener);
632 endPicker.localDateTimeProperty().addListener(endListener);
651 switch (newViewMode) {
668 throw new IllegalArgumentException(
"Unknown ViewMode: " + newViewMode.toString());
685 hostedView.hasVisibleEventsProperty().addListener(hasEvents -> {
689 NO_EVENTS_BACKGROUND,
718 this.timeNavigationNodes.setAll(timeNavigationNodes);
719 timeRangeToolBar.getItems().addAll(TIME_TOOLBAR_INSERTION_INDEX, timeNavigationNodes);
722 @NbBundle.Messages(
"NoEventsDialog.titledPane.text=No Visible Events")
746 @NbBundle.Messages(
"ViewFrame.noEventsDialogLabel.text=There are no events visible with the current zoom / filter settings.")
748 assert resetFiltersButton != null :
"fx:id=\"resetFiltersButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
749 assert dismissButton != null :
"fx:id=\"dismissButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
750 assert zoomButton != null :
"fx:id=\"zoomButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
752 titledPane.setText(Bundle.NoEventsDialog_titledPane_text());
753 noEventsDialogLabel.setText(Bundle.ViewFrame_noEventsDialogLabel_text());
755 dismissButton.setOnAction(actionEvent -> closeCallback.run());
772 PickerListener(Supplier<LocalDateTimeTextField> pickerSupplier, BiFunction<Interval, Long, Interval> intervalMapper) {
779 LocalDateTime pickerTime = pickerSupplier.get().getLocalDateTime();
780 if (pickerTime != null) {
782 Platform.runLater(
ViewFrame.this::refreshTimeUI);
790 private class LocalDateDisabler implements Callback<LocalDateTimePicker.LocalDateTimeRange, Void> {
793 public Void
call(LocalDateTimePicker.LocalDateTimeRange viewedRange) {
795 endPicker.disabledLocalDateTimes().clear();
799 long spanStartMillis = spanningInterval.getStartMillis();
800 long spaneEndMillis = spanningInterval.getEndMillis();
802 LocalDate rangeStartLocalDate = viewedRange.getStartLocalDateTime().toLocalDate();
803 LocalDate rangeEndLocalDate = viewedRange.getEndLocalDateTime().toLocalDate().plusDays(1);
805 for (LocalDate dt = rangeStartLocalDate;
false == dt.isAfter(rangeEndLocalDate); dt = dt.plusDays(1)) {
806 long startOfDay = dt.atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
807 long endOfDay = dt.plusDays(1).atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
809 if (endOfDay < spanStartMillis || startOfDay > spaneEndMillis) {
810 startPicker.disabledLocalDateTimes().add(dt.atStartOfDay());
811 endPicker.disabledLocalDateTimes().add(dt.atStartOfDay());
828 private final LocalDateTimeTextField
picker;
835 public Boolean
call(LocalDateTime param) {
840 if (picker.isPickerShowing() ==
false) {
842 picker.setDisplayedLocalDateTime(picker.getLocalDateTime());
855 "ViewFrame.refresh.text=Refresh View",
856 "ViewFrame.refresh.longText=Refresh the view to include information that is in the DB but not displayed, such as newly updated tags."})
858 super(Bundle.ViewFrame_refresh_text());
859 setLongText(Bundle.ViewFrame_refresh_longText());
860 setGraphic(
new ImageView(REFRESH));
synchronized void registerForEvents(Object o)
static final Image WARNING
final EventsTree eventsTree
final Runnable closeCallback
Void call(LocalDateTimePicker.LocalDateTimeRange viewedRange)
void postRefreshRequest()
abstract boolean hasCustomTimeNavigationControls()
final InvalidationListener zoomListener
void setViewSettingsControls(List< Node > newSettingsNodes)
synchronized ViewMode getViewMode()
void handleDBUpdated(DBUpdatedEvent event)
synchronized Interval getTimeRange()
final NotificationPane notificationPane
abstract ImmutableList< Node > getTimeNavigationControls()
synchronized void refreshHistorgram()
final ObservableList< Node > settingsNodes
synchronized void setViewMode(ViewMode viewMode)
final FilteredEventsModel filteredEvents
ObservableList< TimeLineEvent > getSelectedEvents()
static final Image INFORMATION
Map< EventType, Long > getEventCounts(Interval timeRange)
ReadOnlyBooleanProperty outOfDateProperty()
final synchronized void refresh()
synchronized ReadOnlyObjectProperty< ZoomParams > zoomParametersProperty()
ToggleButton countsToggle
Interval getSpanningInterval()
Boolean call(LocalDateTime param)
LoggedTask< Void > histogramTask
final ObservableList< Node > timeNavigationNodes
abstract ImmutableList< Node > getSettingsControls()
void handleTimeLineTagUpdate(TagsUpdatedEvent event)
synchronized boolean pushTimeRange(Interval timeRange)
void setTimeNavigationControls(List< Node > timeNavigationNodes)
final ReadOnlyBooleanWrapper hasVisibleEvents
final RangeSlider rangeSlider
static RangeDivisionInfo getRangeDivisionInfo(Interval timeRange)
final TimeLineController controller
final InvalidationListener endListener
static final Background GRAY_BACKGROUND
static final Region NO_EVENTS_BACKGROUND
final InvalidationListener rangeSliderListener
static ZoneId getTimeZoneID()
void invalidated(Observable observable)
static final int SETTINGS_TOOLBAR_INSERTION_INDEX
synchronized void monitorTask(final Task<?> task)
synchronized void pushPeriod(ReadablePeriod period)
StackPane rangeHistogramStack
synchronized void registerForEvents(Object o)
final InvalidationListener startListener
void setHighLightedEvents(ObservableList< TimeLineEvent > highlightedEvents)
ViewFrame(@Nonnull TimeLineController controller,@Nonnull EventsTree eventsTree)
static LocalDateTime epochMillisToLocalDateTime(long millis)
NoEventsDialog(Runnable closeCallback)
Label noEventsDialogLabel
void handleAnalysisCompleted(DataSourceAnalysisCompletedEvent event)
void handleRefreshRequested(RefreshRequestedEvent event)
ToggleGroupValue< ViewMode > viewModeToggleGroup
final BiFunction< Interval, Long, Interval > intervalMapper
static final Logger LOGGER
static DateTimeZone getJodaTimeZone()
LocalDateTimeTextField startPicker
static final int TIME_TOOLBAR_INSERTION_INDEX
AbstractTimeLineView hostedView
Button resetFiltersButton
synchronized ReadOnlyObjectProperty< ViewMode > viewModeProperty()
synchronized static Logger getLogger(String name)
void setDetailViewPane(DetailViewPane detailViewPane)
static final Image REFRESH
TimeUnits getPeriodSize()
LocalDateTimeTextField endPicker
final Supplier< LocalDateTimeTextField > pickerSupplier
static void construct(Node node, String fxmlFileName)
ToggleButton detailsToggle
synchronized ReadOnlyObjectProperty< Interval > timeRangeProperty()
ImmutableList< Node > defaultTimeNavigationNodes
SegmentedButton modeSegButton
MenuButton zoomMenuButton
final LocalDateTimeTextField picker
static long localDateTimeToEpochMilli(LocalDateTime localDateTime)
void handlDataSourceAdded(DataSourceAddedEvent event)