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;
47 @SuppressWarnings(
"PMD.SingularField")
55 private final List<IngestJobInfo> ingestJobsForSelectedDataSource =
new ArrayList<>();
58 private final DateFormat datetimeFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
66 customizeComponents();
69 @Messages({
"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
70 "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
73 this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
74 IngestJobInfo currJob = (ingestJobTable.getSelectedRow() < 0 ? null : this.ingestJobsForSelectedDataSource.get(ingestJobTable.getSelectedRow()));
76 this.ingestModuleTable.setModel(this.ingestModuleTableModel);
88 if (!(evt instanceof
AutopsyEvent) || (((AutopsyEvent) evt).getSourceType() != AutopsyEvent.SourceType.LOCAL)) {
92 if (CURRENT_CASE ==
Case.
Events.valueOf(evt.getPropertyName())) {
104 this.selectedDataSource = selectedDataSource;
105 ingestJobsForSelectedDataSource.clear();
106 if (selectedDataSource != null) {
107 for (IngestJobInfo jobInfo : ingestJobs) {
108 if (selectedDataSource.getId() == jobInfo.getObjectId()) {
109 ingestJobsForSelectedDataSource.add(jobInfo);
114 this.ingestJobTable.setModel(ingestJobTableModel);
116 if (!ingestJobsForSelectedDataSource.isEmpty()) {
117 ingestJobTable.setRowSelectionInterval(0, 0);
129 this.ingestJobs = skCase.getIngestJobs();
130 setDataSource(selectedDataSource);
132 this.ingestJobs =
new ArrayList<>();
137 logger.log(Level.SEVERE,
"Failed to load ingest jobs.", ex);
138 JOptionPane.showMessageDialog(
this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
142 @Messages({
"IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
143 "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
144 "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
147 private final List<String> columnHeaders =
new ArrayList<>();
150 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
151 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
152 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
157 return ingestJobsForSelectedDataSource.size();
162 return columnHeaders.size();
167 IngestJobInfo currIngestJob = ingestJobsForSelectedDataSource.get(rowIndex);
168 if (columnIndex == 0) {
169 return datetimeFormat.format(currIngestJob.getStartDateTime());
170 }
else if (columnIndex == 1) {
171 Date endDate = currIngestJob.getEndDateTime();
172 if (endDate.getTime() == 0) {
175 return datetimeFormat.format(currIngestJob.getEndDateTime());
176 }
else if (columnIndex == 2) {
177 return currIngestJob.getStatus().getDisplayName();
184 return columnHeaders.get(column);
189 @Messages({
"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
190 "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
193 private final List<String> columnHeaders =
new ArrayList<>();
197 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
198 columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
199 this.currJob = currJob;
204 if (currJob == null) {
207 return currJob.getIngestModuleInfo().size();
212 return columnHeaders.size();
217 if (currJob != null) {
218 IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
219 if (columnIndex == 0) {
220 return currIngestModule.getDisplayName();
221 }
else if (columnIndex == 1) {
222 return currIngestModule.getVersion();
231 return columnHeaders.get(column);
241 @SuppressWarnings(
"unchecked")
243 private
void initComponents() {
245 jScrollPane1 =
new javax.swing.JScrollPane();
246 ingestJobTable =
new javax.swing.JTable();
247 jLabel1 =
new javax.swing.JLabel();
248 jLabel2 =
new javax.swing.JLabel();
249 jScrollPane2 =
new javax.swing.JScrollPane();
250 ingestModuleTable =
new javax.swing.JTable();
252 jScrollPane1.setBorder(null);
254 ingestJobTable.setModel(ingestJobTableModel);
255 ingestJobTable.getTableHeader().setReorderingAllowed(
false);
256 jScrollPane1.setViewportView(ingestJobTable);
257 ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
259 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel1.text"));
261 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(
IngestJobInfoPanel.class,
"IngestJobInfoPanel.jLabel2.text"));
263 ingestModuleTable.setModel(ingestModuleTableModel);
264 jScrollPane2.setViewportView(ingestModuleTable);
266 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
267 this.setLayout(layout);
268 layout.setHorizontalGroup(
269 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
270 .addGroup(layout.createSequentialGroup()
272 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
273 .addComponent(jLabel2)
274 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE))
276 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
277 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
278 .addComponent(jLabel1))
281 layout.setVerticalGroup(
282 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
283 .addGroup(layout.createSequentialGroup()
285 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
286 .addComponent(jLabel1)
287 .addComponent(jLabel2))
288 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
289 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
290 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
291 .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()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
void customizeComponents()
javax.swing.JTable ingestJobTable
static boolean isCaseOpen()