mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Start work on progress bar for host merging
This commit is contained in:
parent
fa1b00d69b
commit
8ca54044ad
@ -31,6 +31,8 @@ AddEditHostDialog.okButton.text=OK
|
||||
AddEditHostDialog.cancelButton.text=Cancel
|
||||
AddEditHostDialog.inputTextField.text=jTextField1
|
||||
ManageHostsDialog_title_text=Manage Hosts
|
||||
MergeHostAction.progressIndicatorName=Merge Host Process
|
||||
MergeHostAction.startingMsg=Merging hosts...
|
||||
# {0} - sourceHostName
|
||||
# {1} - destHostName
|
||||
MergeHostAction_onError_description=There was an error merging host {0} into host {1}.
|
||||
|
@ -18,15 +18,21 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.datamodel.hosts;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.progress.ModalDialogProgressIndicator;
|
||||
import org.sleuthkit.autopsy.progress.ProgressIndicator;
|
||||
import org.sleuthkit.datamodel.Host;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
@ -58,19 +64,78 @@ public class MergeHostAction extends AbstractAction {
|
||||
this.destHost = destHost;
|
||||
}
|
||||
|
||||
@NbBundle.Messages({
|
||||
"MergeHostAction.progressIndicatorName=Merge Host Process",
|
||||
"MergeHostAction.startingMsg=Merging hosts..."
|
||||
})
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().mergeHosts(sourceHost, destHost);
|
||||
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||
logger.log(Level.WARNING, String.format("Unable to merge host: %s into host: %s", sourceHost.getName(), destHost.getName()), ex);
|
||||
|
||||
// TODO confirm
|
||||
|
||||
ModalDialogProgressIndicator progressDialog = new ModalDialogProgressIndicator(null,
|
||||
Bundle.MergeHostAction_progressIndicatorName());
|
||||
|
||||
MergeHostsBackgroundTask mergeTask = new MergeHostsBackgroundTask(sourceHost, destHost, progressDialog);
|
||||
progressDialog.start(NAME);
|
||||
mergeTask.execute();
|
||||
|
||||
/*
|
||||
new Thread(() -> {
|
||||
try {
|
||||
WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().mergeHosts(sourceHost, destHost);
|
||||
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||
logger.log(Level.WARNING, String.format("Unable to merge host: %s into host: %s", sourceHost.getName(), destHost.getName()), ex);
|
||||
|
||||
JOptionPane.showMessageDialog(
|
||||
WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.MergeHostAction_onError_description(sourceHost, destHost),
|
||||
Bundle.MergeHostAction_onError_title(),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
JOptionPane.showMessageDialog(
|
||||
WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.MergeHostAction_onError_description(sourceHost, destHost),
|
||||
Bundle.MergeHostAction_onError_title(),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
} finally {
|
||||
WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}).start();
|
||||
* */
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the host in a background worker.
|
||||
*/
|
||||
private class MergeHostsBackgroundTask extends SwingWorker<Void, Void> {
|
||||
|
||||
private final Host sourceHost;
|
||||
private final Host destHost;
|
||||
private final ProgressIndicator progress;
|
||||
|
||||
public MergeHostsBackgroundTask(Host sourceHost, Host destHost, ProgressIndicator progress) {
|
||||
this.sourceHost = sourceHost;
|
||||
this.destHost = destHost;
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().mergeHosts(sourceHost, destHost);
|
||||
} finally {
|
||||
progress.finish();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user