19 package org.sleuthkit.autopsy.casemodule;
21 import java.beans.PropertyChangeEvent;
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.ArrayList;
25 import java.util.Date;
26 import java.util.EnumSet;
27 import java.util.List;
29 import java.util.concurrent.CancellationException;
30 import java.util.concurrent.ExecutionException;
31 import java.util.logging.Level;
32 import javax.swing.JOptionPane;
33 import javax.swing.SwingUtilities;
34 import javax.swing.SwingWorker;
35 import javax.swing.event.ListSelectionEvent;
36 import javax.swing.table.AbstractTableModel;
37 import org.openide.util.NbBundle.Messages;
51 @SuppressWarnings(
"PMD.SingularField")
57 private static final int EXTRA_ROW_HEIGHT = 4;
58 private final List<IngestJobInfo> ingestJobs =
new ArrayList<>();
59 private final List<IngestJobInfo> ingestJobsForSelectedDataSource =
new ArrayList<>();
62 private final DateFormat datetimeFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
64 private static SwingWorker<Boolean, Void> refreshWorker = null;
71 customizeComponents();
74 @Messages({
"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
75 "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
78 this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
79 IngestJobInfo currJob = (ingestJobTable.getSelectedRow() < 0 ? null : this.ingestJobsForSelectedDataSource.get(ingestJobTable.getSelectedRow()));
81 this.ingestModuleTable.setModel(this.ingestModuleTableModel);
93 if (!(evt instanceof
AutopsyEvent) || (((AutopsyEvent) evt).getSourceType() != AutopsyEvent.SourceType.LOCAL)) {
98 if ((CURRENT_CASE ==
Case.
Events.valueOf(evt.getPropertyName()))) {
99 if (evt.getNewValue() != null) {
108 ingestJobTable.setRowHeight(ingestJobTable.getRowHeight() + EXTRA_ROW_HEIGHT);
109 ingestModuleTable.setRowHeight(ingestModuleTable.getRowHeight() + EXTRA_ROW_HEIGHT);
119 this.selectedDataSource = selectedDataSource;
120 ingestJobsForSelectedDataSource.clear();
121 if (selectedDataSource != null) {
122 for (IngestJobInfo jobInfo : ingestJobs) {
123 if (selectedDataSource.getId() == jobInfo.getObjectId()) {
124 ingestJobsForSelectedDataSource.add(jobInfo);
130 SwingUtilities.invokeLater(() -> {
131 this.ingestJobTable.setModel(ingestJobTableModel);
133 if (!ingestJobsForSelectedDataSource.isEmpty()) {
134 ingestJobTable.setRowSelectionInterval(0, 0);
144 if (refreshWorker != null && !refreshWorker.isDone()) {
145 refreshWorker.cancel(
true);
147 refreshWorker =
new SwingWorker<Boolean, Void>() {
150 protected Boolean doInBackground()
throws Exception {
155 ingestJobs.addAll(skCase.getIngestJobs());
156 setDataSource(selectedDataSource);
162 logger.log(Level.SEVERE,
"Failed to load ingest jobs.", ex);
168 protected void done() {
171 JOptionPane.showMessageDialog(
IngestJobInfoPanel.this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
173 }
catch (InterruptedException | ExecutionException ex) {
174 logger.log(Level.WARNING,
"Error getting results from Ingest Job Info Panel's refresh worker", ex);
175 }
catch (CancellationException ignored) {
176 logger.log(Level.INFO,
"The refreshing of the IngestJobInfoPanel was cancelled");
180 refreshWorker.execute();
187 if (refreshWorker != null) {
188 refreshWorker.cancel(
true);
190 this.ingestJobs.clear();
194 @Messages({
"IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
195 "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
196 "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
199 private final List<String> columnHeaders =
new ArrayList<>();
202 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
203 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
204 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
209 return ingestJobsForSelectedDataSource.size();
214 return columnHeaders.size();
219 IngestJobInfo currIngestJob = ingestJobsForSelectedDataSource.get(rowIndex);
220 if (columnIndex == 0) {
221 return datetimeFormat.format(currIngestJob.getStartDateTime());
222 }
else if (columnIndex == 1) {
223 Date endDate = currIngestJob.getEndDateTime();
224 if (endDate.getTime() == 0) {
227 return datetimeFormat.format(currIngestJob.getEndDateTime());
228 }
else if (columnIndex == 2) {
229 return currIngestJob.getStatus().getDisplayName();
236 return columnHeaders.get(column);
241 @Messages({
"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
242 "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
245 private final List<String> columnHeaders =
new ArrayList<>();
249 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
250 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
251 this.currJob = currJob;
256 if (currJob == null) {
259 return currJob.getIngestModuleInfo().size();
264 return columnHeaders.size();
269 if (currJob != null) {
270 IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
271 if (columnIndex == 0) {
272 return currIngestModule.getDisplayName();
273 }
else if (columnIndex == 1) {
274 return currIngestModule.getVersion();
283 return columnHeaders.get(column);
293 @SuppressWarnings(
"unchecked")
295 private
void initComponents() {
296 java.awt.GridBagConstraints gridBagConstraints;
298 javax.swing.JScrollPane mainScrollPane =
new javax.swing.JScrollPane();
299 javax.swing.JPanel contentPanel =
new javax.swing.JPanel();
300 javax.swing.JScrollPane ingestJobsScrollPane =
new javax.swing.JScrollPane();
301 ingestJobTable =
new javax.swing.JTable();
302 javax.swing.JLabel jLabel1 =
new javax.swing.JLabel();
303 javax.swing.JLabel jLabel2 =
new javax.swing.JLabel();
304 javax.swing.JScrollPane ingestModulesScrollPane =
new javax.swing.JScrollPane();
305 ingestModuleTable =
new javax.swing.JTable();
307 setLayout(
new java.awt.BorderLayout());
309 contentPanel.setMinimumSize(
new java.awt.Dimension(625, 150));
310 contentPanel.setPreferredSize(
new java.awt.Dimension(625, 150));
311 contentPanel.setLayout(
new java.awt.GridBagLayout());
313 ingestJobsScrollPane.setBorder(null);
314 ingestJobsScrollPane.setMinimumSize(
new java.awt.Dimension(16, 16));
316 ingestJobTable.setModel(ingestJobTableModel);
317 ingestJobTable.setGridColor(javax.swing.UIManager.getDefaults().getColor(
"InternalFrame.borderColor"));
318 ingestJobTable.setIntercellSpacing(
new java.awt.Dimension(4, 2));
319 ingestJobTable.getTableHeader().setReorderingAllowed(
false);
320 ingestJobsScrollPane.setViewportView(ingestJobTable);
321 ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
323 gridBagConstraints =
new java.awt.GridBagConstraints();
324 gridBagConstraints.gridx = 0;
325 gridBagConstraints.gridy = 1;
326 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
327 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
328 gridBagConstraints.weightx = 1.0;
329 gridBagConstraints.weighty = 1.0;
330 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 10, 0);
331 contentPanel.add(ingestJobsScrollPane, gridBagConstraints);
333 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel1.text"));
334 gridBagConstraints =
new java.awt.GridBagConstraints();
335 gridBagConstraints.gridx = 1;
336 gridBagConstraints.gridy = 0;
337 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
338 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 0, 0);
339 contentPanel.add(jLabel1, gridBagConstraints);
341 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel2.text"));
342 gridBagConstraints =
new java.awt.GridBagConstraints();
343 gridBagConstraints.gridx = 0;
344 gridBagConstraints.gridy = 0;
345 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
346 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 0, 0);
347 contentPanel.add(jLabel2, gridBagConstraints);
349 ingestModulesScrollPane.setMaximumSize(
new java.awt.Dimension(254, 32767));
350 ingestModulesScrollPane.setMinimumSize(
new java.awt.Dimension(254, 16));
351 ingestModulesScrollPane.setPreferredSize(
new java.awt.Dimension(254, 16));
353 ingestModuleTable.setModel(ingestModuleTableModel);
354 ingestModuleTable.setGridColor(javax.swing.UIManager.getDefaults().getColor(
"InternalFrame.borderColor"));
355 ingestModuleTable.setIntercellSpacing(
new java.awt.Dimension(4, 2));
356 ingestModulesScrollPane.setViewportView(ingestModuleTable);
358 gridBagConstraints =
new java.awt.GridBagConstraints();
359 gridBagConstraints.gridx = 1;
360 gridBagConstraints.gridy = 1;
361 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
362 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
363 gridBagConstraints.weighty = 1.0;
364 gridBagConstraints.insets =
new java.awt.Insets(2, 8, 10, 10);
365 contentPanel.add(ingestModulesScrollPane, gridBagConstraints);
367 mainScrollPane.setViewportView(contentPanel);
369 add(mainScrollPane, java.awt.BorderLayout.CENTER);
Object getValueAt(int rowIndex, int columnIndex)
final IngestJobInfo currJob
static synchronized IngestManager getInstance()
void setDataSource(DataSource selectedDataSource)
Object getValueAt(int rowIndex, int columnIndex)
DataSource selectedDataSource
javax.swing.JTable ingestModuleTable
void addIngestJobEventListener(final PropertyChangeListener listener)
SleuthkitCase getSleuthkitCase()
String getColumnName(int column)
String getColumnName(int column)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
void customizeComponents()
javax.swing.JTable ingestJobTable
static boolean isCaseOpen()