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.SwingWorker;
34 import javax.swing.event.ListSelectionEvent;
35 import javax.swing.table.AbstractTableModel;
36 import org.openide.util.NbBundle.Messages;
50 @SuppressWarnings(
"PMD.SingularField")
56 private static final int EXTRA_ROW_HEIGHT = 4;
57 private final List<IngestJobInfo> ingestJobs =
new ArrayList<>();
58 private final List<IngestJobInfo> ingestJobsForSelectedDataSource =
new ArrayList<>();
61 private final DateFormat datetimeFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
63 private static SwingWorker<Boolean, Void> refreshWorker = null;
70 customizeComponents();
73 @Messages({
"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
74 "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
77 this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
78 IngestJobInfo currJob = (ingestJobTable.getSelectedRow() < 0 ? null : this.ingestJobsForSelectedDataSource.get(ingestJobTable.getSelectedRow()));
80 this.ingestModuleTable.setModel(this.ingestModuleTableModel);
92 if (!(evt instanceof
AutopsyEvent) || (((AutopsyEvent) evt).getSourceType() != AutopsyEvent.SourceType.LOCAL)) {
97 if ((CURRENT_CASE ==
Case.
Events.valueOf(evt.getPropertyName()))) {
98 if (evt.getNewValue() != null) {
107 ingestJobTable.setRowHeight(ingestJobTable.getRowHeight() + EXTRA_ROW_HEIGHT);
108 ingestModuleTable.setRowHeight(ingestModuleTable.getRowHeight() + EXTRA_ROW_HEIGHT);
118 this.selectedDataSource = selectedDataSource;
119 ingestJobsForSelectedDataSource.clear();
120 if (selectedDataSource != null) {
121 for (IngestJobInfo jobInfo : ingestJobs) {
122 if (selectedDataSource.getId() == jobInfo.getObjectId()) {
123 ingestJobsForSelectedDataSource.add(jobInfo);
128 this.ingestJobTable.setModel(ingestJobTableModel);
130 if (!ingestJobsForSelectedDataSource.isEmpty()) {
131 ingestJobTable.setRowSelectionInterval(0, 0);
140 if (refreshWorker != null && !refreshWorker.isDone()) {
141 refreshWorker.cancel(
true);
143 refreshWorker =
new SwingWorker<Boolean, Void>() {
146 protected Boolean doInBackground()
throws Exception {
151 ingestJobs.addAll(skCase.getIngestJobs());
152 setDataSource(selectedDataSource);
158 logger.log(Level.SEVERE,
"Failed to load ingest jobs.", ex);
164 protected void done() {
167 JOptionPane.showMessageDialog(
IngestJobInfoPanel.this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
169 }
catch (InterruptedException | ExecutionException ex) {
170 logger.log(Level.WARNING,
"Error getting results from Ingest Job Info Panel's refresh worker", ex);
171 }
catch (CancellationException ignored){
172 logger.log(Level.INFO,
"The refreshing of the IngestJobInfoPanel was cancelled");
176 refreshWorker.execute();
183 if (refreshWorker != null) {
184 refreshWorker.cancel(
true);
186 this.ingestJobs.clear();
190 @Messages({
"IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
191 "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
192 "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
195 private final List<String> columnHeaders =
new ArrayList<>();
198 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
199 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
200 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
205 return ingestJobsForSelectedDataSource.size();
210 return columnHeaders.size();
215 IngestJobInfo currIngestJob = ingestJobsForSelectedDataSource.get(rowIndex);
216 if (columnIndex == 0) {
217 return datetimeFormat.format(currIngestJob.getStartDateTime());
218 }
else if (columnIndex == 1) {
219 Date endDate = currIngestJob.getEndDateTime();
220 if (endDate.getTime() == 0) {
223 return datetimeFormat.format(currIngestJob.getEndDateTime());
224 }
else if (columnIndex == 2) {
225 return currIngestJob.getStatus().getDisplayName();
232 return columnHeaders.get(column);
237 @Messages({
"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
238 "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
241 private final List<String> columnHeaders =
new ArrayList<>();
245 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
246 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
247 this.currJob = currJob;
252 if (currJob == null) {
255 return currJob.getIngestModuleInfo().size();
260 return columnHeaders.size();
265 if (currJob != null) {
266 IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
267 if (columnIndex == 0) {
268 return currIngestModule.getDisplayName();
269 }
else if (columnIndex == 1) {
270 return currIngestModule.getVersion();
279 return columnHeaders.get(column);
289 @SuppressWarnings(
"unchecked")
291 private
void initComponents() {
292 java.awt.GridBagConstraints gridBagConstraints;
294 javax.swing.JScrollPane mainScrollPane =
new javax.swing.JScrollPane();
295 javax.swing.JPanel contentPanel =
new javax.swing.JPanel();
296 javax.swing.JScrollPane ingestJobsScrollPane =
new javax.swing.JScrollPane();
297 ingestJobTable =
new javax.swing.JTable();
298 javax.swing.JLabel jLabel1 =
new javax.swing.JLabel();
299 javax.swing.JLabel jLabel2 =
new javax.swing.JLabel();
300 javax.swing.JScrollPane ingestModulesScrollPane =
new javax.swing.JScrollPane();
301 ingestModuleTable =
new javax.swing.JTable();
303 setLayout(
new java.awt.BorderLayout());
305 contentPanel.setMinimumSize(
new java.awt.Dimension(625, 150));
306 contentPanel.setPreferredSize(
new java.awt.Dimension(625, 150));
307 contentPanel.setLayout(
new java.awt.GridBagLayout());
309 ingestJobsScrollPane.setBorder(null);
310 ingestJobsScrollPane.setMinimumSize(
new java.awt.Dimension(16, 16));
312 ingestJobTable.setModel(ingestJobTableModel);
313 ingestJobTable.setGridColor(javax.swing.UIManager.getDefaults().getColor(
"InternalFrame.borderColor"));
314 ingestJobTable.setIntercellSpacing(
new java.awt.Dimension(4, 2));
315 ingestJobTable.getTableHeader().setReorderingAllowed(
false);
316 ingestJobsScrollPane.setViewportView(ingestJobTable);
317 ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
319 gridBagConstraints =
new java.awt.GridBagConstraints();
320 gridBagConstraints.gridx = 0;
321 gridBagConstraints.gridy = 1;
322 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
323 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
324 gridBagConstraints.weightx = 1.0;
325 gridBagConstraints.weighty = 1.0;
326 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 10, 0);
327 contentPanel.add(ingestJobsScrollPane, gridBagConstraints);
329 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel1.text"));
330 gridBagConstraints =
new java.awt.GridBagConstraints();
331 gridBagConstraints.gridx = 1;
332 gridBagConstraints.gridy = 0;
333 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
334 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 0, 0);
335 contentPanel.add(jLabel1, gridBagConstraints);
337 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel2.text"));
338 gridBagConstraints =
new java.awt.GridBagConstraints();
339 gridBagConstraints.gridx = 0;
340 gridBagConstraints.gridy = 0;
341 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
342 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 0, 0);
343 contentPanel.add(jLabel2, gridBagConstraints);
345 ingestModulesScrollPane.setMaximumSize(
new java.awt.Dimension(254, 32767));
346 ingestModulesScrollPane.setMinimumSize(
new java.awt.Dimension(254, 16));
347 ingestModulesScrollPane.setPreferredSize(
new java.awt.Dimension(254, 16));
349 ingestModuleTable.setModel(ingestModuleTableModel);
350 ingestModuleTable.setGridColor(javax.swing.UIManager.getDefaults().getColor(
"InternalFrame.borderColor"));
351 ingestModuleTable.setIntercellSpacing(
new java.awt.Dimension(4, 2));
352 ingestModulesScrollPane.setViewportView(ingestModuleTable);
354 gridBagConstraints =
new java.awt.GridBagConstraints();
355 gridBagConstraints.gridx = 1;
356 gridBagConstraints.gridy = 1;
357 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
358 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
359 gridBagConstraints.weighty = 1.0;
360 gridBagConstraints.insets =
new java.awt.Insets(2, 8, 10, 10);
361 contentPanel.add(ingestModulesScrollPane, gridBagConstraints);
363 mainScrollPane.setViewportView(contentPanel);
365 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()