mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
cleanup PromptDialogManager, EventsRepository and TimeLineController
This commit is contained in:
parent
843fefac25
commit
767a169d77
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2015 Basis Technology Corp.
|
* Copyright 2015-16 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -61,9 +61,9 @@ public class PromptDialogManager {
|
|||||||
static {
|
static {
|
||||||
Image x = null;
|
Image x = null;
|
||||||
try {
|
try {
|
||||||
x = new Image(new URL("nbresloc:/org/netbeans/core/startup/frame.gif").openStream()); //NOI18N
|
x = new Image(new URL("nbresloc:/org/netbeans/core/startup/frame.gif").openStream()); //NON-NLS
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.WARNING, "Failed to load branded icon for progress dialog.", ex); //NOI18N NON-NLS
|
LOGGER.log(Level.WARNING, "Failed to load branded icon for progress dialog.", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
LOGO = x;
|
LOGO = x;
|
||||||
}
|
}
|
||||||
@ -75,6 +75,12 @@ public class PromptDialogManager {
|
|||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bring the currently managed dialog (if there is one) to the front
|
||||||
|
*
|
||||||
|
* @return true if a dialog was brought to the front, or false of there is
|
||||||
|
* no currently managed open dialog
|
||||||
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
boolean bringCurrentDialogToFront() {
|
boolean bringCurrentDialogToFront() {
|
||||||
if (currentDialog != null && currentDialog.isShowing()) {
|
if (currentDialog != null && currentDialog.isShowing()) {
|
||||||
@ -86,12 +92,12 @@ public class PromptDialogManager {
|
|||||||
|
|
||||||
@NbBundle.Messages({"PromptDialogManager.progressDialog.title=Populating Timeline Data"})
|
@NbBundle.Messages({"PromptDialogManager.progressDialog.title=Populating Timeline Data"})
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
public void showProgressDialog(CancellationProgressTask<?> task) {
|
void showProgressDialog(CancellationProgressTask<?> task) {
|
||||||
currentDialog = new ProgressDialog(task);
|
currentDialog = new ProgressDialog(task);
|
||||||
currentDialog.initModality(Modality.NONE);
|
currentDialog.initModality(Modality.NONE);
|
||||||
currentDialog.headerTextProperty().bind(task.titleProperty());
|
|
||||||
setDialogIcons(currentDialog);
|
|
||||||
currentDialog.setTitle(Bundle.PromptDialogManager_progressDialog_title());
|
currentDialog.setTitle(Bundle.PromptDialogManager_progressDialog_title());
|
||||||
|
setDialogIcons(currentDialog);
|
||||||
|
currentDialog.headerTextProperty().bind(task.titleProperty());
|
||||||
|
|
||||||
DialogPane dialogPane = currentDialog.getDialogPane();
|
DialogPane dialogPane = currentDialog.getDialogPane();
|
||||||
dialogPane.setPrefSize(400, 200); //override autosizing which fails for some reason
|
dialogPane.setPrefSize(400, 200); //override autosizing which fails for some reason
|
||||||
@ -100,6 +106,7 @@ public class PromptDialogManager {
|
|||||||
task.setOnCancelled(cancelled -> currentDialog.close());
|
task.setOnCancelled(cancelled -> currentDialog.close());
|
||||||
task.setOnSucceeded(succeeded -> currentDialog.close());
|
task.setOnSucceeded(succeeded -> currentDialog.close());
|
||||||
task.setOnFailed(failed -> currentDialog.close());
|
task.setOnFailed(failed -> currentDialog.close());
|
||||||
|
|
||||||
dialogPane.getButtonTypes().setAll(ButtonType.CANCEL);
|
dialogPane.getButtonTypes().setAll(ButtonType.CANCEL);
|
||||||
final Node cancelButton = dialogPane.lookupButton(ButtonType.CANCEL);
|
final Node cancelButton = dialogPane.lookupButton(ButtonType.CANCEL);
|
||||||
cancelButton.disableProperty().bind(task.cancellableProperty().not());
|
cancelButton.disableProperty().bind(task.cancellableProperty().not());
|
||||||
@ -117,14 +124,7 @@ public class PromptDialogManager {
|
|||||||
|
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
static private void setDialogIcons(Dialog<?> dialog) {
|
static private void setDialogIcons(Dialog<?> dialog) {
|
||||||
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons().setAll(LOGO);
|
||||||
stage.getIcons().setAll(LOGO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
|
||||||
static private void setDialogTitle(Dialog<?> dialog) {
|
|
||||||
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
|
||||||
stage.setTitle(Bundle.Timeline_confirmation_dialogs_title());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +141,7 @@ public class PromptDialogManager {
|
|||||||
currentDialog.initModality(Modality.APPLICATION_MODAL);
|
currentDialog.initModality(Modality.APPLICATION_MODAL);
|
||||||
currentDialog.setHeaderText(Bundle.PromptDialogManager_confirmDuringIngest_headerText());
|
currentDialog.setHeaderText(Bundle.PromptDialogManager_confirmDuringIngest_headerText());
|
||||||
setDialogIcons(currentDialog);
|
setDialogIcons(currentDialog);
|
||||||
setDialogTitle(currentDialog);
|
currentDialog.setTitle(Bundle.Timeline_confirmation_dialogs_title());
|
||||||
|
|
||||||
return currentDialog.showAndWait().map(SHOW_TIMELINE::equals).orElse(false);
|
return currentDialog.showAndWait().map(SHOW_TIMELINE::equals).orElse(false);
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public class PromptDialogManager {
|
|||||||
currentDialog.initModality(Modality.APPLICATION_MODAL);
|
currentDialog.initModality(Modality.APPLICATION_MODAL);
|
||||||
currentDialog.setHeaderText(Bundle.PromptDialogManager_rebuildPrompt_headerText());
|
currentDialog.setHeaderText(Bundle.PromptDialogManager_rebuildPrompt_headerText());
|
||||||
setDialogIcons(currentDialog);
|
setDialogIcons(currentDialog);
|
||||||
setDialogTitle(currentDialog);
|
currentDialog.setTitle(Bundle.Timeline_confirmation_dialogs_title());
|
||||||
|
|
||||||
DialogPane dialogPane = currentDialog.getDialogPane();
|
DialogPane dialogPane = currentDialog.getDialogPane();
|
||||||
ListView<String> listView = new ListView<>(FXCollections.observableArrayList(rebuildReasons));
|
ListView<String> listView = new ListView<>(FXCollections.observableArrayList(rebuildReasons));
|
||||||
|
@ -290,6 +290,14 @@ public class TimeLineController {
|
|||||||
advance(filteredEvents.zoomParametersProperty().get().withTimeRange(boundingEventsInterval));
|
advance(filteredEvents.zoomParametersProperty().get().withTimeRange(boundingEventsInterval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rebuild the repo using the given repo builder (expected to be a member
|
||||||
|
* reference to {@link EventsRepository#rebuildRepository(java.util.function.Consumer)
|
||||||
|
* } or {@link EventsRepository#rebuildTags(java.util.function.Consumer) })
|
||||||
|
* and display the ui when it is done.
|
||||||
|
*
|
||||||
|
* @param repoBuilder
|
||||||
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
private void rebuildRepoHelper(Function<Consumer<Worker.State>, CancellationProgressTask<?>> repoBuilder) {
|
private void rebuildRepoHelper(Function<Consumer<Worker.State>, CancellationProgressTask<?>> repoBuilder) {
|
||||||
SwingUtilities.invokeLater(this::closeTimelineWindow);
|
SwingUtilities.invokeLater(this::closeTimelineWindow);
|
||||||
@ -314,11 +322,7 @@ public class TimeLineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rebuld the repo.
|
* rebuld the entire repo.
|
||||||
*
|
|
||||||
* @return False if the repo was not rebuilt because because the user
|
|
||||||
* aborted after prompt about ingest running. True if the repo was
|
|
||||||
* rebuilt.
|
|
||||||
*/
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
void rebuildRepo() {
|
void rebuildRepo() {
|
||||||
@ -329,7 +333,6 @@ public class TimeLineController {
|
|||||||
* Since tags might have changed while TimeLine wasn't listening, drop the
|
* Since tags might have changed while TimeLine wasn't listening, drop the
|
||||||
* tags table and rebuild it by querying for all the tags and inserting them
|
* tags table and rebuild it by querying for all the tags and inserting them
|
||||||
* in to the TimeLine DB.
|
* in to the TimeLine DB.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
void rebuildTagsTable() {
|
void rebuildTagsTable() {
|
||||||
|
@ -320,19 +320,48 @@ public class EventsRepository {
|
|||||||
return dbWorker.isRunning();
|
return dbWorker.isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rebuild the entire repo.
|
||||||
|
*
|
||||||
|
* @param onStateChange called when he background task changes state.
|
||||||
|
* Clients can use this to handle failure, or cleanup
|
||||||
|
* operations for example.
|
||||||
|
*
|
||||||
|
* @return the task that will rebuild the repo in a background thread. The
|
||||||
|
* task has already been started.
|
||||||
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
public CancellationProgressTask<Void> rebuildRepository(Consumer<Worker.State> onStateChange) {
|
public CancellationProgressTask<Void> rebuildRepository(Consumer<Worker.State> onStateChange) {
|
||||||
return rebuildRepository(DBPopulationMode.FULL, onStateChange);
|
return rebuildRepository(DBPopulationMode.FULL, onStateChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* drop and rebuild the tags in the repo.
|
||||||
|
*
|
||||||
|
* @param onStateChange called when he background task changes state.
|
||||||
|
* Clients can use this to handle failure, or cleanup
|
||||||
|
* operations for example.
|
||||||
|
*
|
||||||
|
* @return the task that will rebuild the repo in a background thread. The
|
||||||
|
* task has already been started.
|
||||||
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
public CancellationProgressTask<Void> rebuildTags(Consumer<Worker.State> onStateChange) {
|
public CancellationProgressTask<Void> rebuildTags(Consumer<Worker.State> onStateChange) {
|
||||||
return rebuildRepository(DBPopulationMode.TAGS_ONLY, onStateChange);
|
return rebuildRepository(DBPopulationMode.TAGS_ONLY, onStateChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* rebuild the repo.
|
||||||
*
|
*
|
||||||
* @param mode the value of mode
|
* @param mode the rebuild mode to use.
|
||||||
|
* @param onStateChange called when he background task changes state.
|
||||||
|
* Clients can use this to handle failure, or cleanup
|
||||||
|
* operations for example.
|
||||||
|
*
|
||||||
|
* @return the task that will rebuild the repo in a background thread. The
|
||||||
|
* task has already been started.
|
||||||
*/
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
|
||||||
private CancellationProgressTask<Void> rebuildRepository(final DBPopulationMode mode, Consumer<Worker.State> onStateChange) {
|
private CancellationProgressTask<Void> rebuildRepository(final DBPopulationMode mode, Consumer<Worker.State> onStateChange) {
|
||||||
@ -409,7 +438,7 @@ public class EventsRepository {
|
|||||||
skCase = autoCase.getSleuthkitCase();
|
skCase = autoCase.getSleuthkitCase();
|
||||||
tagsManager = autoCase.getServices().getTagsManager();
|
tagsManager = autoCase.getServices().getTagsManager();
|
||||||
this.dbPopulationMode = mode;
|
this.dbPopulationMode = mode;
|
||||||
this.stateProperty().addListener(observable -> onStateChange.accept(getState()));
|
this.stateProperty().addListener(stateObservable -> onStateChange.accept(getState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartProgressHandle(String title, String message, Double workDone, double total, Boolean cancellable) {
|
void restartProgressHandle(String title, String message, Double workDone, double total, Boolean cancellable) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user