19 package org.sleuthkit.autopsy.ingest;
21 import java.awt.Component;
22 import java.awt.Dimension;
23 import java.awt.Toolkit;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.WindowAdapter;
26 import java.awt.event.WindowEvent;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import javax.swing.Icon;
32 import javax.swing.ImageIcon;
33 import javax.swing.JDialog;
34 import javax.swing.JLabel;
35 import javax.swing.JTable;
36 import javax.swing.ListSelectionModel;
37 import javax.swing.SwingUtilities;
38 import javax.swing.event.ListSelectionEvent;
39 import javax.swing.table.AbstractTableModel;
40 import javax.swing.table.DefaultTableCellRenderer;
41 import javax.swing.table.TableColumn;
42 import org.openide.util.NbBundle.Messages;
62 private final List<IngestJobInfo>
ingestJobs =
new ArrayList<>();
63 private final List<IngestModuleModel>
modules =
new ArrayList<>();
75 for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
90 this.dataSources.addAll(dataSources);
93 ingestJobs.addAll(skCase.getIngestJobs());
94 }
catch (IllegalStateException ex) {
95 logger.log(Level.SEVERE,
"No open case", ex);
96 }
catch (TskCoreException ex) {
97 logger.log(Level.SEVERE,
"Failed to load ingest job information", ex);
99 for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
100 this.modules.add(
new IngestModuleModel(moduleTemplate));
112 List<IngestModuleTemplate> moduleTemplates =
new ArrayList<>();
114 IngestModuleTemplate moduleTemplate = module.getIngestModuleTemplate();
115 if (module.hasModuleSettingsPanel()) {
117 moduleTemplate.setModuleSettings(moduleSettings);
119 moduleTemplates.add(moduleTemplate);
121 this.settings.setIngestModuleTemplates(moduleTemplates);
125 @Messages({
"IngestJobSettingsPanel.noPerRunSettings=The selected module has no per-run settings."})
129 modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
136 for (
int i = 0; i <
modulesTable.getColumnCount(); ++i) {
137 TableColumn column =
modulesTable.getColumnModel().getColumn(i);
139 column.setPreferredWidth(((
int) (width * 0.15)));
141 column.setCellRenderer(renderer);
142 column.setPreferredWidth(((
int) (width * 0.84)));
149 modulesTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
150 ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
151 if (!listSelectionModel.isSelectionEmpty()) {
152 int index = listSelectionModel.getMinSelectionIndex();
153 selectedModule = modules.get(index);
155 if (null != selectedModule.getModuleSettingsPanel()) {
169 this.
modulesTable.getColumnModel().getColumn(0).setMaxWidth(22);
170 this.
modulesTable.getColumnModel().getColumn(1).setMaxWidth(20);
171 this.
modulesTable.getColumnModel().getColumn(1).setMinWidth(20);
178 pastJobsButton.setEnabled(!dataSources.isEmpty() && !ingestJobs.isEmpty());
186 @SuppressWarnings(
"unchecked")
190 timeGroup =
new javax.swing.ButtonGroup();
193 jPanel1 =
new javax.swing.JPanel();
204 setMaximumSize(
new java.awt.Dimension(5750, 3000));
205 setMinimumSize(
new java.awt.Dimension(0, 0));
206 setPreferredSize(
new java.awt.Dimension(625, 450));
208 modulesScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(
new java.awt.Color(160, 160, 160)));
212 modulesTable.setBackground(
new java.awt.Color(240, 240, 240));
213 modulesTable.setModel(
new javax.swing.table.DefaultTableModel(
225 jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(
new java.awt.Color(160, 160, 160)));
226 jPanel1.setPreferredSize(
new java.awt.Dimension(338, 257));
232 public void actionPerformed(java.awt.event.ActionEvent evt) {
237 descriptionLabel.setText(
"DO NOT REMOVE. This dummy text is used to anchor the inner panel's size to the outer panel, while still being expandable. Without this the expandability behavior doesn't work well. This text will never be shown, as it would only be shown when no module is selected (which is not possible).");
240 jScrollPane1.setPreferredSize(
new java.awt.Dimension(250, 180));
246 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(
jPanel1);
247 jPanel1.setLayout(jPanel1Layout);
248 jPanel1Layout.setHorizontalGroup(
249 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
250 .addComponent(
jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
251 .addGroup(jPanel1Layout.createSequentialGroup()
253 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
254 .addComponent(
descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
255 .addComponent(
jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
256 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
257 .addGap(0, 0, Short.MAX_VALUE)
261 jPanel1Layout.setVerticalGroup(
262 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
265 .addComponent(
jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
267 .addComponent(
jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
269 .addComponent(
descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
270 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
277 public void actionPerformed(java.awt.event.ActionEvent evt) {
284 public void actionPerformed(java.awt.event.ActionEvent evt) {
292 public void actionPerformed(java.awt.event.ActionEvent evt) {
298 pastJobsButton.addActionListener(
new java.awt.event.ActionListener() {
299 public void actionPerformed(java.awt.event.ActionEvent evt) {
304 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
305 this.setLayout(layout);
306 layout.setHorizontalGroup(
307 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addGroup(layout.createSequentialGroup()
310 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
311 .addComponent(
modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
312 .addGroup(layout.createSequentialGroup()
313 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
315 .addGroup(layout.createSequentialGroup()
316 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
317 .addComponent(
jButtonSelectAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
318 .addComponent(
pastJobsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
321 .addGap(0, 0, Short.MAX_VALUE)))
322 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
323 .addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
326 layout.setVerticalGroup(
327 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328 .addGroup(layout.createSequentialGroup()
330 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331 .addGroup(layout.createSequentialGroup()
332 .addComponent(
modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
333 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
337 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
339 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
340 .addComponent(
processUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
341 .addGroup(layout.createSequentialGroup()
342 .addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
343 .addContainerGap())))
351 if (selectedModule.hasGlobalSettingsPanel()) {
352 selectedModule.saveResourcesConfig();
357 dialog.addWindowListener(
new WindowAdapter() {
359 public void windowClosing(WindowEvent e) {
364 dialog.
display(selectedModule.getGlobalSettingsPanel());
378 @Messages({
"IngestJobSettingsPanel.pastJobsButton.action.frame.title=Ingest History"})
380 JDialog topFrame = (JDialog) SwingUtilities.getWindowAncestor(
this);
381 JDialog dialog =
new JDialog(topFrame, Bundle.IngestJobSettingsPanel_pastJobsButton_action_frame_title(),
false);
383 dialog.add(ingestInfo);
384 Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
385 double w = dialog.getSize().getWidth();
386 double h = dialog.getSize().getHeight();
387 dialog.setLocation((
int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
388 dialog.setResizable(
true);
390 dialog.setVisible(
true);
395 module.setEnabled(set);
429 if (moduleTemplate.hasModuleSettingsPanel()) {
430 moduleSettingsPanel = moduleTemplate.getModuleSettingsPanel();
432 if (moduleTemplate.hasGlobalSettingsPanel()) {
433 globalSettingsPanel = moduleTemplate.getGlobalSettingsPanel();
437 IngestModuleTemplate getIngestModuleTemplate() {
442 return moduleTemplate.getModuleName();
445 String getDescription() {
446 return moduleTemplate.getModuleDescription();
449 void setEnabled(
boolean enabled) {
450 moduleTemplate.setEnabled(enabled);
453 boolean isEnabled() {
454 return moduleTemplate.isEnabled();
457 boolean hasModuleSettingsPanel() {
458 return moduleTemplate.hasModuleSettingsPanel();
461 IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
465 boolean hasGlobalSettingsPanel() {
466 return moduleTemplate.hasGlobalSettingsPanel();
469 IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
473 void saveResourcesConfig() {
484 private static final long serialVersionUID = 1L;
488 return modules.size();
499 switch (columnIndex) {
501 return module.isEnabled();
505 return module.getName();
511 return columnIndex == 0;
515 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
516 if (columnIndex == 0) {
517 modules.get(rowIndex).setEnabled((
boolean) aValue);
527 if (dataSources.isEmpty() || ingestJobs.isEmpty()) {
530 boolean previousVersionRun =
false;
531 for (IngestJobInfo ingestJob : ingestJobs) {
532 if (ingestJob.getStatus() != IngestJobInfo.IngestJobStatusType.COMPLETED) {
535 long objectId = ingestJob.getObjectId();
536 boolean isSameDataSource =
false;
537 for (Content dataSource : dataSources) {
538 isSameDataSource = isSameDataSource || dataSource.getId() == objectId;
540 if (isSameDataSource) {
543 String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) +
"-"
545 + IngestModuleInfo.IngestModuleType.DATA_SOURCE_LEVEL.toString() +
"-"
547 for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
548 boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
550 if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
554 previousVersionRun = previousVersionRun || sameModule;
558 String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) +
"-"
560 + IngestModuleInfo.IngestModuleType.FILE_LEVEL.toString() +
"-"
562 for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
563 boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
565 if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
569 previousVersionRun = previousVersionRun || sameModule;
574 if (previousVersionRun) {
585 @Messages({
"IngestJobSettingsPanel.IngestModulesTableRenderer.warning.message=This ingest module has been run before on this data source.",
586 "IngestJobSettingsPanel.IngestModulesTableRenderer.info.message=A previous version of this ingest module has been run before on this data source."})
589 private static final long serialVersionUID = 1L;
591 List<String> tooltips =
new ArrayList<>();
595 tooltips.add(moduleTemplate.getDescription());
601 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
604 setToolTipText(tooltips.get(row));
605 }
else if (1 == column) {
606 setIcon((Icon) value);
608 if (warningIcon.equals(value)) {
609 setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_warning_message());
610 }
else if (infoIcon.equals(value)) {
611 setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_info_message());
IngestJobSettingsPanel(IngestJobSettings settings)
javax.swing.JSeparator jSeparator2
void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt)
String getModuleVersionNumber()
void display(JPanel panel)
final IngestModulesTableModel tableModel
boolean isFileIngestModuleFactory()
IngestModulesTableRenderer()
javax.swing.JCheckBox processUnallocCheckbox
void pastJobsButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel descriptionLabel
static final Logger logger
void SelectAllModules(boolean set)
void addApplyButtonListener(ActionListener l)
javax.swing.JTable modulesTable
final List< IngestModuleModel > modules
void jButtonSelectAllActionPerformed(java.awt.event.ActionEvent evt)
Class<?> getColumnClass(int c)
static final long serialVersionUID
void globalSettingsButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JButton pastJobsButton
static ImageIcon warningIcon
ImageIcon getIcon(IngestModuleModel module)
abstract void saveSettings()
javax.swing.JButton jButtonSelectAll
IngestModuleGlobalSettingsPanel globalSettingsPanel
IngestJobSettings getSettings()
IngestModuleIngestJobSettingsPanel moduleSettingsPanel
javax.swing.ButtonGroup timeGroup
SleuthkitCase getSleuthkitCase()
void setValueAt(Object aValue, int rowIndex, int columnIndex)
static ImageIcon infoIcon
javax.swing.JScrollPane modulesScrollPane
final IngestJobSettings settings
void jButtonDeselectAllActionPerformed(java.awt.event.ActionEvent evt)
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
javax.swing.JPanel jPanel1
Object getValueAt(int rowIndex, int columnIndex)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
boolean isCellEditable(int rowIndex, int columnIndex)
javax.swing.JScrollPane jScrollPane1
IngestModuleModel selectedModule
final List< IngestJobInfo > ingestJobs
String getModuleDisplayName()
javax.swing.JButton globalSettingsButton
final IngestModuleTemplate moduleTemplate
final List< Content > dataSources
javax.swing.JPanel ingestSettingsPanel
boolean isDataSourceIngestModuleFactory()
void customizeComponents()
javax.swing.JButton jButtonDeselectAll