19 package org.sleuthkit.autopsy.ingest;
21 import java.text.SimpleDateFormat;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Date;
25 import java.util.List;
27 import javax.swing.JDialog;
28 import javax.swing.table.AbstractTableModel;
29 import javax.swing.table.TableColumn;
30 import org.apache.commons.lang3.time.DurationFormatUtils;
31 import org.openide.util.NbBundle;
36 @SuppressWarnings(
"PMD.SingularField")
37 class IngestProgressSnapshotPanel extends javax.swing.JPanel {
39 private final JDialog parent;
40 private final IngestProgressSnapshotProvider snapshotProvider;
41 private final IngestThreadActivitySnapshotsTableModel threadActivityTableModel;
42 private final IngestJobTableModel jobTableModel;
43 private final ModuleTableModel moduleTableModel;
45 IngestProgressSnapshotPanel(JDialog parent, IngestProgressSnapshotProvider snapshotProvider) {
47 this.snapshotProvider = snapshotProvider;
48 threadActivityTableModel =
new IngestThreadActivitySnapshotsTableModel();
49 jobTableModel =
new IngestJobTableModel();
50 moduleTableModel =
new ModuleTableModel();
52 customizeComponents();
55 private void customizeComponents() {
56 threadActivitySnapshotsTable.setModel(threadActivityTableModel);
57 jobTable.setModel(jobTableModel);
58 moduleTable.setModel(moduleTableModel);
60 int width = snapshotsScrollPane.getPreferredSize().width;
61 for (
int i = 0; i < threadActivitySnapshotsTable.getColumnCount(); ++i) {
62 TableColumn column = threadActivitySnapshotsTable.getColumnModel().getColumn(i);
65 column.setPreferredWidth(((
int) (width * 0.02)));
68 column.setPreferredWidth(((
int) (width * 0.20)));
71 column.setPreferredWidth(((
int) (width * 0.15)));
74 column.setPreferredWidth(((
int) (width * 0.35)));
77 column.setPreferredWidth(((
int) (width * 0.18)));
80 column.setPreferredWidth(((
int) (width * 0.10)));
85 threadActivitySnapshotsTable.setFillsViewportHeight(
true);
90 private final String[] columnNames = {NbBundle.getMessage(this.getClass(),
91 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.threadID"),
92 NbBundle.getMessage(this.getClass(),
93 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.activity"),
94 NbBundle.getMessage(this.getClass(),
95 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.dataSource"),
96 NbBundle.getMessage(this.getClass(),
97 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.file"),
98 NbBundle.getMessage(this.getClass(),
99 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.startTime"),
100 NbBundle.getMessage(this.getClass(),
101 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.elapsedTime"),
102 NbBundle.getMessage(this.getClass(),
103 "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.jobID")};
111 snapshots = snapshotProvider.getIngestThreadActivitySnapshots();
112 fireTableDataChanged();
117 return snapshots.size();
122 return columnNames.length;
127 return columnNames[col];
134 switch (columnIndex) {
136 cellValue = snapshot.getThreadId();
139 cellValue = snapshot.getActivity();
142 cellValue = snapshot.getDataSourceName();
145 cellValue = snapshot.getFileName();
148 cellValue = snapshot.getStartTime();
151 Date now =
new Date();
152 long elapsedTime = now.getTime() - snapshot.getStartTime().getTime();
153 cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime);
156 cellValue = snapshot.getIngestJobId();
168 private static final long serialVersionUID = 1L;
170 private final String[] columnNames = {
171 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.jobID"),
172 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.dataSource"),
173 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.start"),
174 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.numProcessed"),
175 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.filesPerSec"),
176 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.inProgress"),
177 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.filesQueued"),
178 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.dirQueued"),
179 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.rootQueued"),
180 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.streamingQueued"),
181 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.dsQueued"),
182 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.artifactsQueued")};
191 jobSnapshots = snapshotProvider.getIngestJobSnapshots();
192 fireTableDataChanged();
197 return jobSnapshots.size();
202 return columnNames.length;
207 return columnNames[col];
212 Snapshot snapShot = jobSnapshots.get(rowIndex);
214 switch (columnIndex) {
216 cellValue = snapShot.getJobId();
219 cellValue = snapShot.getDataSource();
222 SimpleDateFormat dateFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
223 cellValue = dateFormat.format(
new Date(snapShot.getJobStartTime()));
226 cellValue = snapShot.getFilesProcessed();
229 cellValue = snapShot.getSpeed();
232 cellValue = snapShot.getRunningListSize();
235 cellValue = snapShot.getFileQueueSize();
238 cellValue = snapShot.getDirQueueSize();
241 cellValue = snapShot.getRootQueueSize();
244 cellValue = snapShot.getStreamingQueueSize();
247 cellValue = snapShot.getDsQueueSize();
250 cellValue = snapShot.getArtifactTasksQueueSize();
262 private static final long serialVersionUID = 1L;
271 this.duration = duration;
300 private final String[] columnNames = {NbBundle.getMessage(this.getClass(),
"ModuleTableModel.colName.module"),
301 NbBundle.getMessage(this.getClass(),
302 "ModuleTableModel.colName.duration")};
303 private final List<ModuleStats> moduleStats =
new ArrayList<>();
311 Map<String, Long> moduleStatMap = snapshotProvider.getModuleRunTimes();
314 for (String k : moduleStatMap.keySet()) {
315 moduleStats.add(
new ModuleStats(k, moduleStatMap.get(k)));
316 totalTime += moduleStatMap.get(k);
318 Collections.sort(moduleStats);
319 fireTableDataChanged();
324 return moduleStats.size();
329 return columnNames.length;
334 return columnNames[col];
339 ModuleStats moduleStat = moduleStats.get(rowIndex);
341 switch (columnIndex) {
343 cellValue = moduleStat.
getName();
346 cellValue = DurationFormatUtils.formatDurationHMS(moduleStat.
getDuration()) +
" (" + (moduleStat.
getDuration() * 100) / totalTime +
"%)";
362 @SuppressWarnings(
"unchecked")
364 private
void initComponents() {
365 java.awt.GridBagConstraints gridBagConstraints;
367 snapshotsScrollPane =
new javax.swing.JScrollPane();
368 threadActivitySnapshotsTable =
new javax.swing.JTable();
369 jobScrollPane =
new javax.swing.JScrollPane();
370 jobTable =
new javax.swing.JTable();
371 refreshButton =
new javax.swing.JButton();
372 closeButton =
new javax.swing.JButton();
373 moduleScrollPane =
new javax.swing.JScrollPane();
374 moduleTable =
new javax.swing.JTable();
376 setMinimumSize(
new java.awt.Dimension(500, 500));
377 setPreferredSize(
new java.awt.Dimension(1100, 500));
378 setLayout(
new java.awt.GridBagLayout());
380 threadActivitySnapshotsTable.setModel(
new javax.swing.table.DefaultTableModel(
388 snapshotsScrollPane.setViewportView(threadActivitySnapshotsTable);
390 gridBagConstraints =
new java.awt.GridBagConstraints();
391 gridBagConstraints.gridx = 0;
392 gridBagConstraints.gridy = 0;
393 gridBagConstraints.gridwidth = 2;
394 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
395 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
396 gridBagConstraints.weightx = 1.0;
397 gridBagConstraints.weighty = 1.0;
398 gridBagConstraints.insets =
new java.awt.Insets(11, 10, 0, 10);
399 add(snapshotsScrollPane, gridBagConstraints);
401 jobTable.setModel(
new javax.swing.table.DefaultTableModel(
409 jobScrollPane.setViewportView(jobTable);
411 gridBagConstraints =
new java.awt.GridBagConstraints();
412 gridBagConstraints.gridx = 0;
413 gridBagConstraints.gridy = 1;
414 gridBagConstraints.gridwidth = 2;
415 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
416 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
417 gridBagConstraints.weightx = 1.0;
418 gridBagConstraints.weighty = 1.0;
419 gridBagConstraints.insets =
new java.awt.Insets(6, 10, 0, 10);
420 add(jobScrollPane, gridBagConstraints);
422 org.openide.awt.Mnemonics.setLocalizedText(refreshButton,
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class,
"IngestProgressSnapshotPanel.refreshButton.text"));
423 refreshButton.addActionListener(
new java.awt.event.ActionListener() {
424 public void actionPerformed(java.awt.event.ActionEvent evt) {
425 refreshButtonActionPerformed(evt);
428 gridBagConstraints =
new java.awt.GridBagConstraints();
429 gridBagConstraints.gridx = 0;
430 gridBagConstraints.gridy = 3;
431 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
432 gridBagConstraints.weightx = 1.0;
433 add(refreshButton, gridBagConstraints);
435 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class,
"IngestProgressSnapshotPanel.closeButton.text"));
436 closeButton.addActionListener(
new java.awt.event.ActionListener() {
437 public void actionPerformed(java.awt.event.ActionEvent evt) {
438 closeButtonActionPerformed(evt);
441 gridBagConstraints =
new java.awt.GridBagConstraints();
442 gridBagConstraints.gridx = 1;
443 gridBagConstraints.gridy = 3;
444 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
445 gridBagConstraints.insets =
new java.awt.Insets(6, 6, 11, 10);
446 add(closeButton, gridBagConstraints);
448 moduleTable.setModel(
new javax.swing.table.DefaultTableModel(
456 moduleScrollPane.setViewportView(moduleTable);
458 gridBagConstraints =
new java.awt.GridBagConstraints();
459 gridBagConstraints.gridx = 0;
460 gridBagConstraints.gridy = 2;
461 gridBagConstraints.gridwidth = 2;
462 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
463 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
464 gridBagConstraints.weightx = 1.0;
465 gridBagConstraints.weighty = 1.0;
466 gridBagConstraints.insets =
new java.awt.Insets(6, 10, 0, 10);
467 add(moduleScrollPane, gridBagConstraints);
470 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
474 private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
475 threadActivityTableModel.refresh();
476 jobTableModel.refresh();
477 moduleTableModel.refresh();
480 private javax.swing.JButton closeButton;
481 private javax.swing.JScrollPane jobScrollPane;
482 private javax.swing.JTable jobTable;
483 private javax.swing.JScrollPane moduleScrollPane;
484 private javax.swing.JTable moduleTable;
485 private javax.swing.JButton refreshButton;
486 private javax.swing.JScrollPane snapshotsScrollPane;
487 private javax.swing.JTable threadActivitySnapshotsTable;
Object getValueAt(int rowIndex, int columnIndex)
Object getValueAt(int rowIndex, int columnIndex)
String getColumnName(int col)
String getColumnName(int col)
IngestThreadActivitySnapshotsTableModel()
int compareTo(ModuleStats o)
String getColumnName(int col)
List< Snapshot > jobSnapshots
List< IngestManager.IngestThreadActivitySnapshot > snapshots
Object getValueAt(int rowIndex, int columnIndex)