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.dsQueued")};
 
  193             jobSnapshots = snapshotProvider.getIngestJobSnapshots();
 
  194             fireTableDataChanged();
 
  199             return jobSnapshots.size();
 
  204             return columnNames.length;
 
  209             return columnNames[col];
 
  216             switch (columnIndex) {
 
  218                     cellValue = snapShot.getJobId();
 
  221                     cellValue = snapShot.getDataSource();
 
  224                     SimpleDateFormat dateFormat = 
new SimpleDateFormat(
"HH:mm:ss");
 
  225                     cellValue = dateFormat.format(
new Date(snapShot.getJobStartTime()));
 
  228                     cellValue = snapShot.getFilesProcessed();
 
  231                     cellValue = snapShot.getSpeed();
 
  234                     cellValue = snapShot.getRunningListSize();
 
  237                     cellValue = snapShot.getFileQueueSize();
 
  240                     cellValue = snapShot.getDirQueueSize();
 
  243                     cellValue = snapShot.getRootQueueSize();
 
  246                     cellValue = snapShot.getDsQueueSize();
 
  265                 this.duration = duration;
 
  294         private final String[] columnNames = {NbBundle.getMessage(this.getClass(), 
"ModuleTableModel.colName.module"),
 
  295             NbBundle.getMessage(this.getClass(),
 
  296             "ModuleTableModel.colName.duration")};
 
  297         private final List<ModuleStats> moduleStats = 
new ArrayList<>();
 
  305             Map<String, Long> moduleStatMap = snapshotProvider.getModuleRunTimes();
 
  308             for (String k : moduleStatMap.keySet()) {
 
  309                 moduleStats.add(
new ModuleStats(k, moduleStatMap.get(k)));
 
  310                 totalTime += moduleStatMap.get(k);
 
  312             Collections.sort(moduleStats);
 
  313             fireTableDataChanged();
 
  318             return moduleStats.size();
 
  323             return columnNames.length;
 
  328             return columnNames[col];
 
  333             ModuleStats moduleStat = moduleStats.get(rowIndex);
 
  335             switch (columnIndex) {
 
  337                     cellValue = moduleStat.
getName();
 
  340                     cellValue = DurationFormatUtils.formatDurationHMS(moduleStat.
getDuration()) + 
" (" + (moduleStat.
getDuration() * 100) / totalTime + 
"%)";
 
  356     @SuppressWarnings(
"unchecked")
 
  358     private 
void initComponents() {
 
  360         snapshotsScrollPane = 
new javax.swing.JScrollPane();
 
  361         threadActivitySnapshotsTable = 
new javax.swing.JTable();
 
  362         jobScrollPane = 
new javax.swing.JScrollPane();
 
  363         jobTable = 
new javax.swing.JTable();
 
  364         refreshButton = 
new javax.swing.JButton();
 
  365         closeButton = 
new javax.swing.JButton();
 
  366         moduleScrollPane = 
new javax.swing.JScrollPane();
 
  367         moduleTable = 
new javax.swing.JTable();
 
  369         threadActivitySnapshotsTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  377         snapshotsScrollPane.setViewportView(threadActivitySnapshotsTable);
 
  379         jobTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  387         jobScrollPane.setViewportView(jobTable);
 
  389         org.openide.awt.Mnemonics.setLocalizedText(refreshButton, 
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class, 
"IngestProgressSnapshotPanel.refreshButton.text")); 
 
  390         refreshButton.addActionListener(
new java.awt.event.ActionListener() {
 
  391             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  392                 refreshButtonActionPerformed(evt);
 
  396         org.openide.awt.Mnemonics.setLocalizedText(closeButton, 
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class, 
"IngestProgressSnapshotPanel.closeButton.text")); 
 
  397         closeButton.addActionListener(
new java.awt.event.ActionListener() {
 
  398             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  399                 closeButtonActionPerformed(evt);
 
  403         moduleTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  411         moduleScrollPane.setViewportView(moduleTable);
 
  413         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  414         this.setLayout(layout);
 
  415         layout.setHorizontalGroup(
 
  416             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  417             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
 
  419                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  420                     .addComponent(snapshotsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE)
 
  421                     .addGroup(layout.createSequentialGroup()
 
  422                         .addGap(0, 0, Short.MAX_VALUE)
 
  423                         .addComponent(refreshButton)
 
  424                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  425                         .addComponent(closeButton))
 
  426                     .addComponent(jobScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE)
 
  427                     .addComponent(moduleScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE))
 
  431         layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, 
new java.awt.Component[] {closeButton, refreshButton});
 
  433         layout.setVerticalGroup(
 
  434             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  435             .addGroup(layout.createSequentialGroup()
 
  437                 .addComponent(snapshotsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
 
  438                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  439                 .addComponent(jobScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
 
  440                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  441                 .addComponent(moduleScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
 
  442                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  443                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  444                     .addComponent(refreshButton)
 
  445                     .addComponent(closeButton))
 
  449         layout.linkSize(javax.swing.SwingConstants.VERTICAL, 
new java.awt.Component[] {closeButton, refreshButton});
 
  453     private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  457     private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  458         threadActivityTableModel.refresh();
 
  459         jobTableModel.refresh();
 
  460         moduleTableModel.refresh();
 
  463     private javax.swing.JButton closeButton;
 
  464     private javax.swing.JScrollPane jobScrollPane;
 
  465     private javax.swing.JTable jobTable;
 
  466     private javax.swing.JScrollPane moduleScrollPane;
 
  467     private javax.swing.JTable moduleTable;
 
  468     private javax.swing.JButton refreshButton;
 
  469     private javax.swing.JScrollPane snapshotsScrollPane;
 
  470     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< DataSourceIngestJob.Snapshot > jobSnapshots
List< IngestManager.IngestThreadActivitySnapshot > snapshots
Object getValueAt(int rowIndex, int columnIndex)