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.List;
27 import java.util.logging.Level;
28 import javax.swing.JOptionPane;
29 import javax.swing.event.ListSelectionEvent;
30 import javax.swing.table.AbstractTableModel;
31 import org.openide.util.NbBundle.Messages;
43 @SuppressWarnings(
"PMD.SingularField")
48 private final List<IngestJobInfo> ingestJobsForSelectedDataSource =
new ArrayList<>();
51 private final DateFormat datetimeFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
59 customizeComponents();
62 @Messages({
"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
63 "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
66 this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
67 IngestJobInfo currJob = (ingestJobTable.getSelectedRow() < 0 ? null : this.ingestJobsForSelectedDataSource.get(ingestJobTable.getSelectedRow()));
69 this.ingestModuleTable.setModel(this.ingestModuleTableModel);
87 this.selectedDataSource = selectedDataSource;
88 ingestJobsForSelectedDataSource.clear();
89 if (selectedDataSource != null) {
90 for (IngestJobInfo jobInfo : ingestJobs) {
91 if (selectedDataSource.getId() == jobInfo.getObjectId()) {
92 ingestJobsForSelectedDataSource.add(jobInfo);
97 this.ingestJobTable.setModel(ingestJobTableModel);
99 if (!ingestJobsForSelectedDataSource.isEmpty()) {
100 ingestJobTable.setRowSelectionInterval(0, 0);
111 this.ingestJobs = skCase.getIngestJobs();
112 updateIngestHistoryData(selectedDataSource);
114 logger.log(Level.SEVERE,
"Failed to load ingest jobs.", ex);
115 JOptionPane.showMessageDialog(
this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
119 @Messages({
"IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
120 "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
121 "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
124 private final List<String> columnHeaders =
new ArrayList<>();
127 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
128 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
129 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
134 return ingestJobsForSelectedDataSource.size();
139 return columnHeaders.size();
144 IngestJobInfo currIngestJob = ingestJobsForSelectedDataSource.get(rowIndex);
145 if (columnIndex == 0) {
146 return datetimeFormat.format(currIngestJob.getStartDateTime());
147 }
else if (columnIndex == 1) {
148 Date endDate = currIngestJob.getEndDateTime();
149 if (endDate.getTime() == 0) {
152 return datetimeFormat.format(currIngestJob.getEndDateTime());
153 }
else if (columnIndex == 2) {
154 return currIngestJob.getStatus().getDisplayName();
161 return columnHeaders.get(column);
166 @Messages({
"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
167 "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
170 private final List<String> columnHeaders =
new ArrayList<>();
174 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
175 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
176 this.currJob = currJob;
181 if (currJob == null) {
184 return currJob.getIngestModuleInfo().size();
189 return columnHeaders.size();
194 if (currJob != null) {
195 IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
196 if (columnIndex == 0) {
197 return currIngestModule.getDisplayName();
198 }
else if (columnIndex == 1) {
199 return currIngestModule.getVersion();
208 return columnHeaders.get(column);
218 @SuppressWarnings(
"unchecked")
220 private
void initComponents() {
222 jScrollPane1 =
new javax.swing.JScrollPane();
223 ingestJobTable =
new javax.swing.JTable();
224 jLabel1 =
new javax.swing.JLabel();
225 jLabel2 =
new javax.swing.JLabel();
226 jScrollPane2 =
new javax.swing.JScrollPane();
227 ingestModuleTable =
new javax.swing.JTable();
229 jScrollPane1.setBorder(null);
231 ingestJobTable.setModel(ingestJobTableModel);
232 ingestJobTable.getTableHeader().setReorderingAllowed(
false);
233 jScrollPane1.setViewportView(ingestJobTable);
234 ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
236 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel1.text"));
238 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel2.text"));
240 ingestModuleTable.setModel(ingestModuleTableModel);
241 jScrollPane2.setViewportView(ingestModuleTable);
243 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
244 this.setLayout(layout);
245 layout.setHorizontalGroup(
246 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247 .addGroup(layout.createSequentialGroup()
249 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
250 .addComponent(jLabel2)
251 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE))
253 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
254 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
255 .addComponent(jLabel1))
258 layout.setVerticalGroup(
259 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260 .addGroup(layout.createSequentialGroup()
262 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
263 .addComponent(jLabel1)
264 .addComponent(jLabel2))
265 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
266 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
267 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
268 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
Object getValueAt(int rowIndex, int columnIndex)
final IngestJobInfo currJob
static synchronized IngestManager getInstance()
javax.swing.JScrollPane jScrollPane1
void updateIngestHistoryData(DataSource selectedDataSource)
javax.swing.JScrollPane jScrollPane2
Object getValueAt(int rowIndex, int columnIndex)
DataSource selectedDataSource
javax.swing.JTable ingestModuleTable
List< IngestJobInfo > ingestJobs
void addIngestJobEventListener(final PropertyChangeListener listener)
SleuthkitCase getSleuthkitCase()
javax.swing.JLabel jLabel2
String getColumnName(int column)
javax.swing.JLabel jLabel1
String getColumnName(int column)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void customizeComponents()
javax.swing.JTable ingestJobTable