mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Merge remote-tracking branch 'upstream/develop' into 7895-cr-data-artifact-ingest-module
This commit is contained in:
commit
7a1d2e67fa
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2015-2017 Basis Technology Corp.
|
||||
* Copyright 2015-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -21,66 +21,76 @@ package org.sleuthkit.autopsy.guiutils;
|
||||
import java.awt.Component;
|
||||
import java.time.Duration;
|
||||
import javax.swing.JTable;
|
||||
import static javax.swing.SwingConstants.CENTER;
|
||||
|
||||
/**
|
||||
* A JTable cell renderer that renders a duration represented as a long as a
|
||||
* string with days, hours, minutes, and seconds components. It center-aligns
|
||||
* cell content and grays out the cell if the table is disabled.
|
||||
*/
|
||||
public class DurationCellRenderer extends GrayableCellRenderer {
|
||||
public final class DurationCellRenderer extends GrayableCellRenderer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final char UNIT_SEPARATOR_CHAR = ':';
|
||||
|
||||
public DurationCellRenderer() {
|
||||
setHorizontalAlignment(CENTER);
|
||||
setHorizontalAlignment(LEFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (value instanceof Long) {
|
||||
{
|
||||
setText(DurationCellRenderer.longToDurationString((long) value));
|
||||
}
|
||||
}
|
||||
grayCellIfTableNotEnabled(table, isSelected);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static char getUnitSeperator() {
|
||||
return UNIT_SEPARATOR_CHAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a duration represented by a long to a human readable string with
|
||||
* with days, hours, minutes, and seconds components.
|
||||
*
|
||||
* @param duration - the representation of the duration in long form
|
||||
* @param duration - The representation of the duration in long form.
|
||||
*
|
||||
* @return - the representation of the duration in String form.
|
||||
* @return - The representation of the duration in String form.
|
||||
*/
|
||||
public static String longToDurationString(long duration) {
|
||||
Duration d = Duration.ofMillis(duration);
|
||||
if (d.isNegative()) {
|
||||
d = Duration.ofMillis(-duration);
|
||||
d = Duration.ofMillis(0); //it being 0 for a few seconds seems preferable to it counting down to 0 then back up from 0
|
||||
}
|
||||
|
||||
String result;
|
||||
long days = d.toDays();
|
||||
long hours = d.minusDays(days).toHours();
|
||||
long minutes = d.minusDays(days).minusHours(hours).toMinutes();
|
||||
long seconds = d.minusDays(days).minusHours(hours).minusMinutes(minutes).getSeconds();
|
||||
|
||||
if (minutes > 0) {
|
||||
if (hours > 0) {
|
||||
if (days > 0) {
|
||||
result = days + " d " + hours + " h " + minutes + " m " + seconds + " s";
|
||||
} else {
|
||||
result = hours + " h " + minutes + " m " + seconds + " s";
|
||||
if (days < 0) {
|
||||
days = 0;
|
||||
}
|
||||
} else {
|
||||
result = minutes + " m " + seconds + " s";
|
||||
if (hours < 0) {
|
||||
hours = 0;
|
||||
}
|
||||
} else {
|
||||
result = seconds + " s";
|
||||
if (minutes < 0) {
|
||||
minutes = 0;
|
||||
}
|
||||
return result;
|
||||
if (seconds < 0) {
|
||||
seconds = 0;
|
||||
}
|
||||
StringBuilder results = new StringBuilder(12);
|
||||
if (days < 99) {
|
||||
results.append(String.format("%02d", days));
|
||||
} else {
|
||||
results.append(days); //in the off chance something has been running for over 99 days lets allow it to stand out a bit by having as many characters as it needs
|
||||
}
|
||||
results.append(UNIT_SEPARATOR_CHAR);
|
||||
results.append(String.format("%02d", hours));
|
||||
results.append(UNIT_SEPARATOR_CHAR);
|
||||
results.append(String.format("%02d", minutes));
|
||||
results.append(UNIT_SEPARATOR_CHAR);
|
||||
results.append(String.format("%02d", seconds));
|
||||
return results.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,7 +177,8 @@ public final class AutoIngestControlPanel extends JPanel implements Observer {
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.StartedTime=Stage Started",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.CompletedTime=Job Completed",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.Stage=Stage",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.StageTime=Time in Stage",
|
||||
"# {0} - unitSeparator",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.StageTime=Time in Stage (dd{0}hh{0}mm{0}ss)",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.Status=Status",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.CaseFolder=Case Folder",
|
||||
"AutoIngestControlPanel.JobsTableModel.ColumnHeader.LocalJob= Local Job?",
|
||||
@ -193,7 +194,7 @@ public final class AutoIngestControlPanel extends JPanel implements Observer {
|
||||
STARTED_TIME(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.StartedTime")),
|
||||
COMPLETED_TIME(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.CompletedTime")),
|
||||
STAGE(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.Stage")),
|
||||
STAGE_TIME(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.StageTime")),
|
||||
STAGE_TIME(Bundle.AutoIngestControlPanel_JobsTableModel_ColumnHeader_StageTime(DurationCellRenderer.getUnitSeperator())),
|
||||
STATUS(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.Status")),
|
||||
CASE_DIRECTORY_PATH(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.CaseFolder")),
|
||||
IS_LOCAL_JOB(NbBundle.getMessage(AutoIngestControlPanel.class, "AutoIngestControlPanel.JobsTableModel.ColumnHeader.LocalJob")),
|
||||
|
@ -53,7 +53,8 @@ final class AutoIngestJobsNode extends AbstractNode {
|
||||
"AutoIngestJobsNode.dataSource.text=Data Source",
|
||||
"AutoIngestJobsNode.hostName.text=Host Name",
|
||||
"AutoIngestJobsNode.stage.text=Stage",
|
||||
"AutoIngestJobsNode.stageTime.text=Time in Stage",
|
||||
"# {0} - unitSeparator",
|
||||
"AutoIngestJobsNode.stageTime.text=Time in Stage (dd{0}hh{0}mm{0}ss)",
|
||||
"AutoIngestJobsNode.jobCreated.text=Job Created",
|
||||
"AutoIngestJobsNode.jobCompleted.text=Job Completed",
|
||||
"AutoIngestJobsNode.priority.text=Prioritized",
|
||||
@ -345,8 +346,10 @@ final class AutoIngestJobsNode extends AbstractNode {
|
||||
jobWrapper.getProcessingHostName()));
|
||||
ss.put(new NodeProperty<>(Bundle.AutoIngestJobsNode_stage_text(), Bundle.AutoIngestJobsNode_stage_text(), Bundle.AutoIngestJobsNode_stage_text(),
|
||||
status.getDescription()));
|
||||
ss.put(new NodeProperty<>(Bundle.AutoIngestJobsNode_stageTime_text(), Bundle.AutoIngestJobsNode_stageTime_text(), Bundle.AutoIngestJobsNode_stageTime_text(),
|
||||
DurationCellRenderer.longToDurationString((Date.from(Instant.now()).getTime()) - (status.getStartDate().getTime()))));
|
||||
ss.put(new NodeProperty<>(Bundle.AutoIngestJobsNode_stageTime_text(DurationCellRenderer.getUnitSeperator()),
|
||||
Bundle.AutoIngestJobsNode_stageTime_text(DurationCellRenderer.getUnitSeperator()),
|
||||
Bundle.AutoIngestJobsNode_stageTime_text(DurationCellRenderer.getUnitSeperator()),
|
||||
DurationCellRenderer.longToDurationString(Date.from(Instant.now()).getTime() - status.getStartDate().getTime())));
|
||||
break;
|
||||
case COMPLETED_JOB:
|
||||
ss.put(new NodeProperty<>(Bundle.AutoIngestJobsNode_jobCreated_text(), Bundle.AutoIngestJobsNode_jobCreated_text(), Bundle.AutoIngestJobsNode_jobCreated_text(),
|
||||
|
@ -31,6 +31,7 @@ import org.sleuthkit.autopsy.datamodel.EmptyNode;
|
||||
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJobsNode.AutoIngestJobStatus;
|
||||
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJobsNode.JobNode;
|
||||
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent;
|
||||
import org.sleuthkit.autopsy.guiutils.DurationCellRenderer;
|
||||
import org.sleuthkit.autopsy.guiutils.StatusIconCellRenderer;
|
||||
|
||||
/**
|
||||
@ -64,6 +65,8 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
|
||||
customize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set up the AutoIngestJobsPanel's so that its outlineView is displaying
|
||||
* the correct columns for the specified AutoIngestJobStatus
|
||||
@ -99,7 +102,8 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
|
||||
outlineView.setPropertyColumns(Bundle.AutoIngestJobsNode_dataSource_text(), Bundle.AutoIngestJobsNode_dataSource_text(),
|
||||
Bundle.AutoIngestJobsNode_hostName_text(), Bundle.AutoIngestJobsNode_hostName_text(),
|
||||
Bundle.AutoIngestJobsNode_stage_text(), Bundle.AutoIngestJobsNode_stage_text(),
|
||||
Bundle.AutoIngestJobsNode_stageTime_text(), Bundle.AutoIngestJobsNode_stageTime_text());
|
||||
Bundle.AutoIngestJobsNode_stageTime_text(DurationCellRenderer.getUnitSeperator()),
|
||||
Bundle.AutoIngestJobsNode_stageTime_text(DurationCellRenderer.getUnitSeperator()));
|
||||
indexOfColumn = getColumnIndexByName(Bundle.AutoIngestJobsNode_caseName_text());
|
||||
if (indexOfColumn != INVALID_INDEX) {
|
||||
outline.setColumnSorted(indexOfColumn, true, 1);
|
||||
@ -177,8 +181,8 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
|
||||
* Update the contents of this AutoIngestJobsPanel while retaining currently
|
||||
* selected node.
|
||||
*
|
||||
* @param refreshEvent - the AutoIngestRefreshEvent which will provide the new
|
||||
* contents
|
||||
* @param refreshEvent - the AutoIngestRefreshEvent which will provide the
|
||||
* new contents
|
||||
*/
|
||||
void refresh(AutoIngestRefreshEvent refreshEvent) {
|
||||
synchronized (this) {
|
||||
@ -191,7 +195,6 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
|
||||
}
|
||||
outline.setRowSelectionAllowed(true);
|
||||
outline.setFocusable(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,8 @@ AutoIngestControlPanel.JobsTableModel.ColumnHeader.ManifestFilePath=\ Manifest F
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.OCR=OCR
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.Priority=Prioritized
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.Stage=Stage
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.StageTime=Time in Stage
|
||||
# {0} - unitSeparator
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.StageTime=Time in Stage (dd{0}hh{0}mm{0}ss)
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.StartedTime=Stage Started
|
||||
AutoIngestControlPanel.JobsTableModel.ColumnHeader.Status=Status
|
||||
AutoIngestControlPanel.OK=OK
|
||||
@ -140,7 +141,8 @@ AutoIngestJobsNode.prioritized.false=No
|
||||
AutoIngestJobsNode.prioritized.true=Yes
|
||||
AutoIngestJobsNode.priority.text=Prioritized
|
||||
AutoIngestJobsNode.stage.text=Stage
|
||||
AutoIngestJobsNode.stageTime.text=Time in Stage
|
||||
# {0} - unitSeparator
|
||||
AutoIngestJobsNode.stageTime.text=Time in Stage (dd{0}hh{0}mm{0}ss)
|
||||
AutoIngestJobsNode.status.text=Status
|
||||
AutoIngestJobsPanel.waitNode.text=Please Wait...
|
||||
AutoIngestMetricsDialog.initReportText=Select a date above and click the 'Generate Metrics Report' button to generate\na metrics report.
|
||||
|
Loading…
x
Reference in New Issue
Block a user