19 package org.sleuthkit.autopsy.timeline;
21 import java.io.IOException;
23 import java.util.ArrayList;
24 import java.util.logging.Level;
25 import javafx.collections.FXCollections;
26 import javafx.scene.Node;
27 import javafx.scene.control.Alert;
28 import javafx.scene.control.ButtonBar;
29 import javafx.scene.control.ButtonType;
30 import javafx.scene.control.Dialog;
31 import javafx.scene.control.DialogPane;
32 import javafx.scene.control.ListView;
33 import javafx.scene.image.Image;
34 import javafx.stage.Modality;
35 import javafx.stage.Stage;
36 import org.controlsfx.dialog.ProgressDialog;
37 import org.controlsfx.tools.Borders;
38 import org.openide.util.NbBundle;
50 @NbBundle.Messages(
"PrompDialogManager.buttonType.showTimeline=Show Timeline")
51 private static final ButtonType
SHOW_TIMELINE =
new ButtonType(Bundle.PrompDialogManager_buttonType_showTimeline(), ButtonBar.ButtonData.OK_DONE);
53 @NbBundle.Messages(
"PrompDialogManager.buttonType.continueNoUpdate=Continue Without Updating")
54 private static final ButtonType
CONTINUE_NO_UPDATE =
new ButtonType(Bundle.PrompDialogManager_buttonType_continueNoUpdate(), ButtonBar.ButtonData.CANCEL_CLOSE);
56 @NbBundle.Messages(
"PrompDialogManager.buttonType.update=Update")
57 private static final ButtonType
UPDATE =
new ButtonType(Bundle.PrompDialogManager_buttonType_update(), ButtonBar.ButtonData.OK_DONE);
59 private static final Image
LOGO;
64 x =
new Image(
new URL(
"nbresloc:/org/netbeans/core/startup/frame.gif").openStream());
65 }
catch (IOException ex) {
66 LOGGER.log(Level.WARNING,
"Failed to load branded icon for progress dialog.", ex);
85 boolean bringCurrentDialogToFront() {
86 if (currentDialog != null && currentDialog.isShowing()) {
87 ((Stage) currentDialog.getDialogPane().getScene().getWindow()).toFront();
93 @NbBundle.Messages({
"PromptDialogManager.progressDialog.title=Populating Timeline Data"})
94 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
95 void showProgressDialog(CancellationProgressTask<?> task) {
96 currentDialog =
new ProgressDialog(task);
97 currentDialog.initModality(Modality.NONE);
98 currentDialog.setTitle(Bundle.PromptDialogManager_progressDialog_title());
100 currentDialog.headerTextProperty().bind(task.titleProperty());
102 DialogPane dialogPane = currentDialog.getDialogPane();
103 dialogPane.setPrefSize(400, 200);
106 task.setOnCancelled(cancelled -> currentDialog.close());
107 task.setOnSucceeded(succeeded -> currentDialog.close());
108 task.setOnFailed(failed -> currentDialog.close());
110 dialogPane.getButtonTypes().setAll(ButtonType.CANCEL);
111 final Node cancelButton = dialogPane.lookupButton(ButtonType.CANCEL);
112 cancelButton.disableProperty().bind(task.cancellableProperty().not());
113 currentDialog.setOnCloseRequest(closeRequest -> {
114 if (task.isRunning()) {
115 closeRequest.consume();
117 if (task.isCancellable() && task.isCancelRequested() ==
false) {
118 task.requestCancel();
122 currentDialog.show();
125 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
127 ((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons().setAll(LOGO);
136 @NbBundle.Messages({
"PromptDialogManager.confirmDuringIngest.headerText=You are trying to show a timeline before ingest has been completed.\nThe timeline may be incomplete.",
137 "PromptDialogManager.confirmDuringIngest.contentText=Do you want to continue?"})
138 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
139 boolean confirmDuringIngest() {
140 currentDialog =
new Alert(Alert.AlertType.CONFIRMATION, Bundle.PromptDialogManager_confirmDuringIngest_contentText(),
SHOW_TIMELINE, ButtonType.CANCEL);
141 currentDialog.initModality(Modality.APPLICATION_MODAL);
142 currentDialog.setHeaderText(Bundle.PromptDialogManager_confirmDuringIngest_headerText());
144 currentDialog.setTitle(Bundle.Timeline_confirmation_dialogs_title());
146 return currentDialog.showAndWait().map(SHOW_TIMELINE::equals).orElse(
false);
149 @NbBundle.Messages({
"PromptDialogManager.rebuildPrompt.headerText=The Timeline database is incomplete and/or out of date.\nSome events may be missing or inaccurate and some features may be unavailable.",
150 "PromptDialogManager.rebuildPrompt.details=Details:"})
151 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
152 boolean confirmRebuild(ArrayList<String> rebuildReasons) {
153 currentDialog =
new Alert(Alert.AlertType.CONFIRMATION, Bundle.TimeLinecontroller_updateNowQuestion(),
UPDATE,
CONTINUE_NO_UPDATE);
154 currentDialog.initModality(Modality.APPLICATION_MODAL);
155 currentDialog.setHeaderText(Bundle.PromptDialogManager_rebuildPrompt_headerText());
157 currentDialog.setTitle(Bundle.Timeline_confirmation_dialogs_title());
159 DialogPane dialogPane = currentDialog.getDialogPane();
160 ListView<String> listView =
new ListView<>(FXCollections.observableArrayList(rebuildReasons));
161 listView.setCellFactory(lstView ->
new WrappingListCell());
162 listView.setMaxHeight(75);
163 Node wrappedListView = Borders.wrap(listView).lineBorder().title(Bundle.PromptDialogManager_rebuildPrompt_details()).buildAll();
164 dialogPane.setExpandableContent(wrappedListView);
166 return currentDialog.showAndWait().map(UPDATE::equals).orElse(
false);
static final ButtonType SHOW_TIMELINE
static final ButtonType CONTINUE_NO_UPDATE
static final ButtonType UPDATE
final TimeLineController controller
synchronized static Logger getLogger(String name)
static void setDialogIcons(Dialog<?> dialog)
static final Logger LOGGER