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 final String[] columnNames = {NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.jobID"),
169 NbBundle.getMessage(this.getClass(),
170 "IngestJobTableModel.colName.dataSource"),
171 NbBundle.getMessage(this.getClass(),
"IngestJobTableModel.colName.start"),
172 NbBundle.getMessage(this.getClass(),
173 "IngestJobTableModel.colName.numProcessed"),
174 NbBundle.getMessage(this.getClass(),
175 "IngestJobTableModel.colName.filesPerSec"),
176 NbBundle.getMessage(this.getClass(),
177 "IngestJobTableModel.colName.inProgress"),
178 NbBundle.getMessage(this.getClass(),
179 "IngestJobTableModel.colName.filesQueued"),
180 NbBundle.getMessage(this.getClass(),
181 "IngestJobTableModel.colName.dirQueued"),
182 NbBundle.getMessage(this.getClass(),
183 "IngestJobTableModel.colName.rootQueued"),
184 NbBundle.getMessage(this.getClass(),
185 "IngestJobTableModel.colName.streamingQueued"),
186 NbBundle.getMessage(this.getClass(),
187 "IngestJobTableModel.colName.dsQueued")};
195 jobSnapshots = snapshotProvider.getIngestJobSnapshots();
196 fireTableDataChanged();
201 return jobSnapshots.size();
206 return columnNames.length;
211 return columnNames[col];
216 Snapshot snapShot = jobSnapshots.get(rowIndex);
218 switch (columnIndex) {
220 cellValue = snapShot.getJobId();
223 cellValue = snapShot.getDataSource();
226 SimpleDateFormat dateFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
227 cellValue = dateFormat.format(
new Date(snapShot.getJobStartTime()));
230 cellValue = snapShot.getFilesProcessed();
233 cellValue = snapShot.getSpeed();
236 cellValue = snapShot.getRunningListSize();
239 cellValue = snapShot.getFileQueueSize();
242 cellValue = snapShot.getDirQueueSize();
245 cellValue = snapShot.getRootQueueSize();
248 cellValue = snapShot.getStreamingQueueSize();
251 cellValue = snapShot.getDsQueueSize();
270 this.duration = duration;
299 private final String[] columnNames = {NbBundle.getMessage(this.getClass(),
"ModuleTableModel.colName.module"),
300 NbBundle.getMessage(this.getClass(),
301 "ModuleTableModel.colName.duration")};
302 private final List<ModuleStats> moduleStats =
new ArrayList<>();
310 Map<String, Long> moduleStatMap = snapshotProvider.getModuleRunTimes();
313 for (String k : moduleStatMap.keySet()) {
314 moduleStats.add(
new ModuleStats(k, moduleStatMap.get(k)));
315 totalTime += moduleStatMap.get(k);
317 Collections.sort(moduleStats);
318 fireTableDataChanged();
323 return moduleStats.size();
328 return columnNames.length;
333 return columnNames[col];
338 ModuleStats moduleStat = moduleStats.get(rowIndex);
340 switch (columnIndex) {
342 cellValue = moduleStat.
getName();
345 cellValue = DurationFormatUtils.formatDurationHMS(moduleStat.
getDuration()) +
" (" + (moduleStat.
getDuration() * 100) / totalTime +
"%)";
361 @SuppressWarnings(
"unchecked")
363 private
void initComponents() {
364 java.awt.GridBagConstraints gridBagConstraints;
366 snapshotsScrollPane =
new javax.swing.JScrollPane();
367 threadActivitySnapshotsTable =
new javax.swing.JTable();
368 jobScrollPane =
new javax.swing.JScrollPane();
369 jobTable =
new javax.swing.JTable();
370 refreshButton =
new javax.swing.JButton();
371 closeButton =
new javax.swing.JButton();
372 moduleScrollPane =
new javax.swing.JScrollPane();
373 moduleTable =
new javax.swing.JTable();
375 setMinimumSize(
new java.awt.Dimension(500, 500));
376 setPreferredSize(
new java.awt.Dimension(1100, 500));
377 setLayout(
new java.awt.GridBagLayout());
379 threadActivitySnapshotsTable.setModel(
new javax.swing.table.DefaultTableModel(
387 snapshotsScrollPane.setViewportView(threadActivitySnapshotsTable);
389 gridBagConstraints =
new java.awt.GridBagConstraints();
390 gridBagConstraints.gridx = 0;
391 gridBagConstraints.gridy = 0;
392 gridBagConstraints.gridwidth = 2;
393 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
394 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
395 gridBagConstraints.weightx = 1.0;
396 gridBagConstraints.weighty = 1.0;
397 gridBagConstraints.insets =
new java.awt.Insets(11, 10, 0, 10);
398 add(snapshotsScrollPane, gridBagConstraints);
400 jobTable.setModel(
new javax.swing.table.DefaultTableModel(
408 jobScrollPane.setViewportView(jobTable);
410 gridBagConstraints =
new java.awt.GridBagConstraints();
411 gridBagConstraints.gridx = 0;
412 gridBagConstraints.gridy = 1;
413 gridBagConstraints.gridwidth = 2;
414 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
415 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
416 gridBagConstraints.weightx = 1.0;
417 gridBagConstraints.weighty = 1.0;
418 gridBagConstraints.insets =
new java.awt.Insets(6, 10, 0, 10);
419 add(jobScrollPane, gridBagConstraints);
421 org.openide.awt.Mnemonics.setLocalizedText(refreshButton,
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class,
"IngestProgressSnapshotPanel.refreshButton.text"));
422 refreshButton.addActionListener(
new java.awt.event.ActionListener() {
423 public void actionPerformed(java.awt.event.ActionEvent evt) {
424 refreshButtonActionPerformed(evt);
427 gridBagConstraints =
new java.awt.GridBagConstraints();
428 gridBagConstraints.gridx = 0;
429 gridBagConstraints.gridy = 3;
430 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
431 gridBagConstraints.weightx = 1.0;
432 add(refreshButton, gridBagConstraints);
434 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class,
"IngestProgressSnapshotPanel.closeButton.text"));
435 closeButton.addActionListener(
new java.awt.event.ActionListener() {
436 public void actionPerformed(java.awt.event.ActionEvent evt) {
437 closeButtonActionPerformed(evt);
440 gridBagConstraints =
new java.awt.GridBagConstraints();
441 gridBagConstraints.gridx = 1;
442 gridBagConstraints.gridy = 3;
443 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
444 gridBagConstraints.insets =
new java.awt.Insets(6, 6, 11, 10);
445 add(closeButton, gridBagConstraints);
447 moduleTable.setModel(
new javax.swing.table.DefaultTableModel(
455 moduleScrollPane.setViewportView(moduleTable);
457 gridBagConstraints =
new java.awt.GridBagConstraints();
458 gridBagConstraints.gridx = 0;
459 gridBagConstraints.gridy = 2;
460 gridBagConstraints.gridwidth = 2;
461 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
462 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
463 gridBagConstraints.weightx = 1.0;
464 gridBagConstraints.weighty = 1.0;
465 gridBagConstraints.insets =
new java.awt.Insets(6, 10, 0, 10);
466 add(moduleScrollPane, gridBagConstraints);
469 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
473 private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
474 threadActivityTableModel.refresh();
475 jobTableModel.refresh();
476 moduleTableModel.refresh();
479 private javax.swing.JButton closeButton;
480 private javax.swing.JScrollPane jobScrollPane;
481 private javax.swing.JTable jobTable;
482 private javax.swing.JScrollPane moduleScrollPane;
483 private javax.swing.JTable moduleTable;
484 private javax.swing.JButton refreshButton;
485 private javax.swing.JScrollPane snapshotsScrollPane;
486 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)