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;
112 private static final Image
INFORMATION =
new Image(
"org/sleuthkit/autopsy/timeline/images/information.png", 16, 16,
true,
true);
113 private static final Image
WARNING =
new Image(
"org/sleuthkit/autopsy/timeline/images/warning_triangle.png", 16, 16,
true,
true);
114 private static final Image
REFRESH =
new Image(
"org/sleuthkit/autopsy/timeline/images/arrow-circle-double-135.png");
115 private static final Background
GRAY_BACKGROUND =
new Background(
new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY));
124 setBackground(GRAY_BACKGROUND);
161 private final RangeSlider
rangeSlider = new RangeSlider(0, 1.0, .25, .75);
226 private final ObservableList<Node>
settingsNodes = FXCollections.observableArrayList();
249 public void invalidated(Observable observable) {
253 if (
false == controller.pushTimeRange(
new Interval(
255 (
long) (
rangeSlider.getHighValue() + minTime + 1000)))) {
318 "ViewFrame.viewModeLabel.text=View Mode:",
319 "ViewFrame.startLabel.text=Start:",
320 "ViewFrame.endLabel.text=End:",
321 "ViewFrame.countsToggle.text=Counts",
322 "ViewFrame.detailsToggle.text=Details",
323 "ViewFrame.listToggle.text=List",
324 "ViewFrame.zoomMenuButton.text=Zoom in/out to",
325 "ViewFrame.tagsAddedOrDeleted=Tags have been created and/or deleted. The view may not be up to date."
328 assert
endPicker != null :
"fx:id=\"endPicker\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
329 assert
histogramBox != null :
"fx:id=\"histogramBox\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
330 assert
startPicker != null :
"fx:id=\"startPicker\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
331 assert
rangeHistogramStack != null :
"fx:id=\"rangeHistogramStack\" was not injected: check your FXML file 'ViewWrapper.fxml'.";
332 assert
countsToggle != null :
"fx:id=\"countsToggle\" was not injected: check your FXML file 'VisToggle.fxml'.";
333 assert
detailsToggle != null :
"fx:id=\"eventsToggle\" was not injected: check your FXML file 'VisToggle.fxml'.";
343 viewModeLabel.setText(Bundle.ViewFrame_viewModeLabel_text());
344 countsToggle.setText(Bundle.ViewFrame_countsToggle_text());
345 detailsToggle.setText(Bundle.ViewFrame_detailsToggle_text());
346 listToggle.setText(Bundle.ViewFrame_listToggle_text());
363 startLabel.setText(Bundle.ViewFrame_startLabel_text());
364 endLabel.setText(Bundle.ViewFrame_endLabel_text());
368 startPicker.setParseErrorCallback(throwable -> null);
369 endPicker.setParseErrorCallback(throwable -> null);
372 LocalDateDisabler localDateDisabler =
new LocalDateDisabler();
373 startPicker.setLocalDateTimeRangeCallback(localDateDisabler);
374 endPicker.setLocalDateTimeRangeCallback(localDateDisabler);
391 histogramBox.setStyle(
" -fx-padding: 0,0.5em,0,.5em; ");
395 for (ZoomRanges zoomRange : ZoomRanges.values()) {
408 TimeLineController.getTimeZone().addListener(timeZoneProp ->
refreshTimeUI());
428 Platform.runLater(() -> {
431 notificationPane.show(Bundle.ViewFrame_tagsAddedOrDeleted(),
new ImageView(INFORMATION));
447 Platform.runLater(() -> {
448 if (Bundle.ViewFrame_tagsAddedOrDeleted().equals(
notificationPane.getText())) {
466 Platform.runLater(notificationPane::hide);
480 "# {0} - datasource name",
481 "ViewFrame.notification.newDataSource={0} has been added as a new datasource. The Timeline DB may be out of date."})
483 Platform.runLater(() -> {
500 "# {0} - datasource name",
501 "ViewFrame.notification.analysisComplete=Analysis has finished for {0}. The Timeline DB may be out of date."})
503 Platform.runLater(() -> {
512 @NbBundle.Messages({
"ViewFrame.histogramTask.title=Rebuilding Histogram",
513 "ViewFrame.histogramTask.preparing=Preparing",
514 "ViewFrame.histogramTask.resetUI=Resetting UI",
515 "ViewFrame.histogramTask.queryDb=Querying FB",
516 "ViewFrame.histogramTask.updateUI2=Updating UI"})
523 private final Lighting lighting =
new Lighting();
526 protected Void call()
throws Exception {
528 updateMessage(ViewFrame_histogramTask_preparing());
540 Platform.runLater(() -> {
541 updateMessage(ViewFrame_histogramTask_resetUI());
545 ArrayList<Long> bins =
new ArrayList<>();
547 DateTime start = timeRange.getStart();
548 while (timeRange.contains(start)) {
553 final Interval interval =
new Interval(start, end);
558 updateMessage(ViewFrame_histogramTask_queryDb());
563 max = Math.max(count, max);
565 final double fMax = Math.log(max);
566 final ArrayList<Long> fbins =
new ArrayList<>(bins);
567 Platform.runLater(() -> {
568 updateMessage(ViewFrame_histogramTask_updateUI2());
572 for (Long bin : fbins) {
576 Region bar =
new Region();
578 bar.prefHeightProperty().bind(
histogramBox.heightProperty().multiply(Math.log(bin)).divide(fMax));
579 bar.setMaxHeight(USE_PREF_SIZE);
580 bar.setMinHeight(USE_PREF_SIZE);
581 bar.setBackground(GRAY_BACKGROUND);
582 bar.setOnMouseEntered((MouseEvent event) -> {
583 Tooltip.install(bar,
new Tooltip(bin.toString()));
585 bar.setEffect(lighting);
587 HBox.setHgrow(bar, Priority.ALWAYS);
611 if (minTime > 0 && maxTime > minTime) {
612 Platform.runLater(() -> {
613 startPicker.localDateTimeProperty().removeListener(startListener);
614 endPicker.localDateTimeProperty().removeListener(endListener);
627 startPicker.localDateTimeProperty().addListener(startListener);
628 endPicker.localDateTimeProperty().addListener(endListener);
647 switch (newViewMode) {
664 throw new IllegalArgumentException(
"Unknown ViewMode: " + newViewMode.toString());
681 hostedView.hasVisibleEventsProperty().addListener(hasEvents -> {
685 NO_EVENTS_BACKGROUND,
714 this.timeNavigationNodes.setAll(timeNavigationNodes);
715 timeRangeToolBar.getItems().addAll(TIME_TOOLBAR_INSERTION_INDEX, timeNavigationNodes);
718 @NbBundle.Messages(
"NoEventsDialog.titledPane.text=No Visible Events")
742 @NbBundle.Messages(
"ViewFrame.noEventsDialogLabel.text=There are no events visible with the current zoom / filter settings.")
744 assert resetFiltersButton != null :
"fx:id=\"resetFiltersButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
745 assert dismissButton != null :
"fx:id=\"dismissButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
746 assert zoomButton != null :
"fx:id=\"zoomButton\" was not injected: check your FXML file 'NoEventsDialog.fxml'.";
748 titledPane.setText(Bundle.NoEventsDialog_titledPane_text());
749 noEventsDialogLabel.setText(Bundle.ViewFrame_noEventsDialogLabel_text());
751 dismissButton.setOnAction(actionEvent -> closeCallback.run());
768 PickerListener(Supplier<LocalDateTimeTextField> pickerSupplier, BiFunction<Interval, Long, Interval> intervalMapper) {
775 LocalDateTime pickerTime = pickerSupplier.get().getLocalDateTime();
776 if (pickerTime != null) {
778 Platform.runLater(
ViewFrame.this::refreshTimeUI);
786 private class LocalDateDisabler implements Callback<LocalDateTimePicker.LocalDateTimeRange, Void> {
789 public Void
call(LocalDateTimePicker.LocalDateTimeRange viewedRange) {
791 endPicker.disabledLocalDateTimes().clear();
795 long spanStartMillis = spanningInterval.getStartMillis();
796 long spaneEndMillis = spanningInterval.getEndMillis();
798 LocalDate rangeStartLocalDate = viewedRange.getStartLocalDateTime().toLocalDate();
799 LocalDate rangeEndLocalDate = viewedRange.getEndLocalDateTime().toLocalDate().plusDays(1);
801 for (LocalDate dt = rangeStartLocalDate;
false == dt.isAfter(rangeEndLocalDate); dt = dt.plusDays(1)) {
802 long startOfDay = dt.atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
803 long endOfDay = dt.plusDays(1).atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
805 if (endOfDay < spanStartMillis || startOfDay > spaneEndMillis) {
806 startPicker.disabledLocalDateTimes().add(dt.atStartOfDay());
807 endPicker.disabledLocalDateTimes().add(dt.atStartOfDay());
824 private final LocalDateTimeTextField
picker;
831 public Boolean
call(LocalDateTime param) {
836 if (picker.isPickerShowing() ==
false) {
838 picker.setDisplayedLocalDateTime(picker.getLocalDateTime());
851 "ViewFrame.refresh.text=Refresh View",
852 "ViewFrame.refresh.longText=Refresh the view to include information that is in the DB but not displayed, such as newly updated tags."})
854 super(Bundle.ViewFrame_refresh_text());
855 setLongText(Bundle.ViewFrame_refresh_longText());
856 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)