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.logging.Level;
30 import javax.swing.JOptionPane;
31 import javax.swing.event.ListSelectionEvent;
32 import javax.swing.table.AbstractTableModel;
33 import org.openide.util.NbBundle.Messages;
45 @SuppressWarnings(
"PMD.SingularField")
51 private final List<IngestJobInfo> ingestJobsForSelectedDataSource =
new ArrayList<>();
54 private final DateFormat datetimeFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
62 customizeComponents();
65 @Messages({
"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
66 "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
69 this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
70 IngestJobInfo currJob = (ingestJobTable.getSelectedRow() < 0 ? null : this.ingestJobsForSelectedDataSource.get(ingestJobTable.getSelectedRow()));
72 this.ingestModuleTable.setModel(this.ingestModuleTableModel);
90 this.selectedDataSource = selectedDataSource;
91 ingestJobsForSelectedDataSource.clear();
92 if (selectedDataSource != null) {
93 for (IngestJobInfo jobInfo : ingestJobs) {
94 if (selectedDataSource.getId() == jobInfo.getObjectId()) {
95 ingestJobsForSelectedDataSource.add(jobInfo);
100 this.ingestJobTable.setModel(ingestJobTableModel);
102 if (!ingestJobsForSelectedDataSource.isEmpty()) {
103 ingestJobTable.setRowSelectionInterval(0, 0);
114 this.ingestJobs = skCase.getIngestJobs();
115 setDataSource(selectedDataSource);
117 logger.log(Level.SEVERE,
"Failed to load ingest jobs.", ex);
118 JOptionPane.showMessageDialog(
this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
122 @Messages({
"IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
123 "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
124 "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
127 private final List<String> columnHeaders =
new ArrayList<>();
130 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
131 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
132 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
137 return ingestJobsForSelectedDataSource.size();
142 return columnHeaders.size();
147 IngestJobInfo currIngestJob = ingestJobsForSelectedDataSource.get(rowIndex);
148 if (columnIndex == 0) {
149 return datetimeFormat.format(currIngestJob.getStartDateTime());
150 }
else if (columnIndex == 1) {
151 Date endDate = currIngestJob.getEndDateTime();
152 if (endDate.getTime() == 0) {
155 return datetimeFormat.format(currIngestJob.getEndDateTime());
156 }
else if (columnIndex == 2) {
157 return currIngestJob.getStatus().getDisplayName();
164 return columnHeaders.get(column);
169 @Messages({
"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
170 "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
173 private final List<String> columnHeaders =
new ArrayList<>();
177 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
178 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
179 this.currJob = currJob;
184 if (currJob == null) {
187 return currJob.getIngestModuleInfo().size();
192 return columnHeaders.size();
197 if (currJob != null) {
198 IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
199 if (columnIndex == 0) {
200 return currIngestModule.getDisplayName();
201 }
else if (columnIndex == 1) {
202 return currIngestModule.getVersion();
211 return columnHeaders.get(column);
221 @SuppressWarnings(
"unchecked")
223 private
void initComponents() {
225 jScrollPane1 =
new javax.swing.JScrollPane();
226 ingestJobTable =
new javax.swing.JTable();
227 jLabel1 =
new javax.swing.JLabel();
228 jLabel2 =
new javax.swing.JLabel();
229 jScrollPane2 =
new javax.swing.JScrollPane();
230 ingestModuleTable =
new javax.swing.JTable();
232 jScrollPane1.setBorder(null);
234 ingestJobTable.setModel(ingestJobTableModel);
235 ingestJobTable.getTableHeader().setReorderingAllowed(
false);
236 jScrollPane1.setViewportView(ingestJobTable);
237 ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
239 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel1.text"));
241 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel2.text"));
243 ingestModuleTable.setModel(ingestModuleTableModel);
244 jScrollPane2.setViewportView(ingestModuleTable);
246 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
247 this.setLayout(layout);
248 layout.setHorizontalGroup(
249 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
250 .addGroup(layout.createSequentialGroup()
252 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
253 .addComponent(jLabel2)
254 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE))
256 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
257 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
258 .addComponent(jLabel1))
261 layout.setVerticalGroup(
262 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263 .addGroup(layout.createSequentialGroup()
265 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
266 .addComponent(jLabel1)
267 .addComponent(jLabel2))
268 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
270 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
271 .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
javax.swing.JScrollPane jScrollPane2
void setDataSource(DataSource selectedDataSource)
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