Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilesSetDefsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.interestingitems;
20 
21 import java.awt.EventQueue;
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.Comparator;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.SortedSet;
31 import java.util.TreeMap;
32 import java.util.logging.Level;
33 import java.util.stream.Collectors;
34 import javax.swing.DefaultListModel;
35 import javax.swing.JButton;
36 import javax.swing.JFileChooser;
37 import javax.swing.JOptionPane;
38 import javax.swing.event.ListSelectionEvent;
39 import javax.swing.event.ListSelectionListener;
40 import javax.swing.filechooser.FileNameExtensionFilter;
41 import org.apache.commons.lang3.tuple.Pair;
42 import org.netbeans.spi.options.OptionsPanelController;
43 import org.openide.util.NbBundle;
44 import org.openide.util.NbBundle.Messages;
45 import org.openide.windows.WindowManager;
55 
59 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
60 public final class FilesSetDefsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
61 
62  private static final long serialVersionUID = 1L;
63 
64  @NbBundle.Messages({"# {0} - filter name",
65  "# {1} - profile name",
66  "FilesSetDefsPanel.ingest.fileFilterInUseError=The selected file filter, {0}, is being used by a profile, {1}, and cannot be deleted while any profile uses it.",
67  "FilesSetDefsPanel.bytes=Bytes",
68  "FilesSetDefsPanel.kiloBytes=Kilobytes",
69  "FilesSetDefsPanel.megaBytes=Megabytes",
70  "FilesSetDefsPanel.gigaBytes=Gigabytes",
71  "FilesSetDefsPanel.loadError=Error loading interesting files sets from file.",
72  "FilesSetDefsPanel.saveError=Error saving interesting files sets to file.",
73  "FilesSetDefsPanel.interesting.copySetButton.text=Copy Set",
74  "FilesSetDefsPanel.interesting.importSetButton.text=Import Set",
75  "FilesSetDefsPanel.interesting.exportSetButton.text=Export Set"
76  })
77  public static enum PANEL_TYPE {
79  INTERESTING_FILE_SETS
80 
81  }
82  private final DefaultListModel<FilesSet> setsListModel = new DefaultListModel<>();
83  private final DefaultListModel<FilesSet.Rule> rulesListModel = new DefaultListModel<>();
84  private final Logger logger = Logger.getLogger(FilesSetDefsPanel.class.getName());
85  private final JButton okButton = new JButton("OK");
86  private final JButton cancelButton = new JButton("Cancel");
87  private final PANEL_TYPE panelType;
88  private final String filterDialogTitle;
89  private final String ruleDialogTitle;
90  private boolean canBeEnabled = true;
91 
92  // The following is a map of interesting files set names to interesting
93  // files set definitions. It is a snapshot of the files set definitions
94  // obtained from the interesting item definitions manager at the time the
95  // the panel is loaded. When the panel saves or stores its settings, these
96  // definitions, possibly changed, are submitted back to the interesting item
97  // definitions manager. Note that it is a tree map to aid in displaying
98  // files sets in sorted order by name.
99  private TreeMap<String, FilesSet> filesSets;
100 
104  public FilesSetDefsPanel(PANEL_TYPE panelType) {
105  this.panelType = panelType;
106  this.initComponents();
107  this.customInit();
108 
109  this.setsList.setModel(setsListModel);
110  this.setsList.addListSelectionListener(new FilesSetDefsPanel.SetsListSelectionListener());
111  this.rulesList.setModel(rulesListModel);
112  this.rulesList.addListSelectionListener(new FilesSetDefsPanel.RulesListSelectionListener());
113  this.ingestWarningLabel.setVisible(false);
114  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) { //Hide the mimetype settings when this is displaying FileSet rules instead of interesting item rules
115  this.copySetButton.setVisible(false);
116  this.importSetButton.setVisible(false);
117  this.exportSetButton.setVisible(false);
118  this.mimeTypeComboBox.setVisible(false);
119  this.mimeTypeLabel.setVisible(false);
120  this.fileSizeUnitComboBox.setVisible(false);
121  this.fileSizeSpinner.setVisible(false);
122  this.filterDialogTitle = "FilesSetPanel.filter.title";
123  this.ruleDialogTitle = "FilesSetPanel.rule.title";
124  this.fileSizeLabel.setVisible(false);
125  this.equalitySignComboBox.setVisible(false);
126  this.ignoreKnownFilesCheckbox.setVisible(false);
127  this.fileTypeLabel.setVisible(false);
128  this.filesRadioButton.setVisible(false);
129  this.dirsRadioButton.setVisible(false);
130  this.allRadioButton.setVisible(false);
131  this.descriptionTextArea.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.jTextArea1.text")); // NOI18N
132  org.openide.awt.Mnemonics.setLocalizedText(setsListLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.setsListLabel.text")); // NOI18N
133  org.openide.awt.Mnemonics.setLocalizedText(editSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.editSetButton.text")); // NOI18N
134  org.openide.awt.Mnemonics.setLocalizedText(newSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.newSetButton.text")); // NOI18N
135  org.openide.awt.Mnemonics.setLocalizedText(deleteSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.deleteSetButton.text")); // NOI18N
136  org.openide.awt.Mnemonics.setLocalizedText(setDetailsLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingest.jLabel6.text")); // NOI18N
137  } else {
138  this.filterDialogTitle = "FilesSetPanel.interesting.title";
139  this.ruleDialogTitle = "FilesSetPanel.interesting.title";
140  this.ingoreUnallocCheckbox.setVisible(false);
141  }
142 
144  canBeEnabled
146  enableButtons();
147  });
148  canBeEnabled = !IngestManager.getInstance().isIngestRunning();
149  }
150 
151  @NbBundle.Messages({"FilesSetDefsPanel.Interesting.Title=Global Interesting Items Settings",
152  "FilesSetDefsPanel.Ingest.Title=File Filter Settings"})
153  private void customInit() {
154  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
155  setName(Bundle.FilesSetDefsPanel_Ingest_Title());
156  } else {
157  setName(Bundle.FilesSetDefsPanel_Interesting_Title());
158  }
159 
160  try {
161  SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
162  detectableMimeTypes.forEach((type) -> {
163  mimeTypeComboBox.addItem(type);
164  });
166  logger.log(Level.SEVERE, "Unable to get detectable file types", ex);
167  }
168 
169  this.fileSizeUnitComboBox.setSelectedIndex(1);
170  this.equalitySignComboBox.setSelectedIndex(2);
171  }
172 
173  @Override
174  public void saveSettings() {
175  try {
176  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
177  FilesSetsManager.getInstance().setCustomFileIngestFilters(this.filesSets);
178  } else {
179  FilesSetsManager.getInstance().setInterestingFilesSets(this.filesSets);
180  }
181 
183  MessageNotifyUtil.Message.error(Bundle.FilesSetDefsPanel_saveError());
184  logger.log(Level.WARNING, Bundle.FilesSetDefsPanel_saveError(), ex);
185  }
186  }
187 
188  public void enableButtons() {
189  FilesSet selectedFilesSet = this.setsList.getSelectedValue();
190  boolean setSelected = (selectedFilesSet != null);
191  boolean isStandardSet = (selectedFilesSet != null && selectedFilesSet.isStandardSet());
192 
193  boolean ruleSelected = (FilesSetDefsPanel.this.rulesList.getSelectedValue() != null);
194 
195  newRuleButton.setEnabled(canBeEnabled && !isStandardSet);
196  copySetButton.setEnabled(canBeEnabled && setSelected);
197  newSetButton.setEnabled(canBeEnabled);
198  editRuleButton.setEnabled(canBeEnabled && ruleSelected && !isStandardSet);
199  editSetButton.setEnabled(canBeEnabled && setSelected && !isStandardSet);
200  exportSetButton.setEnabled(setSelected);
201  importSetButton.setEnabled(canBeEnabled);
202  deleteRuleButton.setEnabled(canBeEnabled && ruleSelected && !isStandardSet);
203  deleteSetButton.setEnabled(canBeEnabled && setSelected && !isStandardSet);
204  ingestWarningLabel.setVisible(!canBeEnabled);
205  }
206 
207  @Override
208  public void store() {
209  this.saveSettings();
210  }
211 
212  @Override
213  public void load() {
214  this.resetComponents();
215 
216  try {
217  // Get a working copy of the interesting files set definitions and sort
218  // by set name.
219  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
220  this.filesSets = new TreeMap<>(FilesSetsManager.getInstance().getCustomFileIngestFilters());
221  } else {
222  this.filesSets = new TreeMap<>(FilesSetsManager.getInstance().getInterestingFilesSets());
223  }
224 
226  MessageNotifyUtil.Message.error(Bundle.FilesSetDefsPanel_loadError());
227  logger.log(Level.WARNING, Bundle.FilesSetDefsPanel_loadError(), ex);
228  this.filesSets = new TreeMap<>();
229  }
230 
231  // Populate the list model for the interesting files sets list
232  // component.
233  this.filesSets.values().forEach((set) -> {
234  this.setsListModel.addElement(set);
235  });
236 
237  if (!this.filesSets.isEmpty()) {
238  // Select the first files set by default. The list selections
239  // listeners will then populate the other components.
240  EventQueue.invokeLater(() -> {
241  FilesSetDefsPanel.this.setsList.setSelectedIndex(0);
242  });
243  }
244  }
245 
249  private void resetComponents() {
250  this.setsListModel.clear();
251  this.setDescriptionTextArea.setText("");
252  this.ignoreKnownFilesCheckbox.setSelected(true);
253  this.ingoreUnallocCheckbox.setSelected(true);
254  this.resetRuleComponents();
255  }
256 
261  private void resetRuleComponents() {
262  this.fileNameTextField.setText("");
263  this.fileNameRadioButton.setSelected(true);
264  this.fileNameRegexCheckbox.setSelected(false);
265  this.filesRadioButton.setSelected(true);
266  this.rulePathConditionTextField.setText("");
267  this.daysIncludedTextField.setText("");
268  this.rulePathConditionRegexCheckBox.setSelected(false);
269  this.mimeTypeComboBox.setSelectedIndex(0);
270  this.equalitySignComboBox.setSelectedIndex(2);
271  this.fileSizeUnitComboBox.setSelectedIndex(1);
272  this.fileSizeSpinner.setValue(0);
273  enableButtons();
274  }
275 
279  private final class SetsListSelectionListener implements ListSelectionListener {
280 
281  @Override
282  public void valueChanged(ListSelectionEvent e) {
283  if (e.getValueIsAdjusting()) {
284  return;
285  }
286 
287  FilesSetDefsPanel.this.rulesListModel.clear();
289 
290  // Get the selected interesting files set and populate the set
291  // components.
292  FilesSet selectedSet = FilesSetDefsPanel.this.setsList.getSelectedValue();
293 
294  if (selectedSet != null) {
295  // Populate the components that display the properties of the
296  // selected files set.
297  FilesSetDefsPanel.this.setDescriptionTextArea.setText(selectedSet.getDescription());
298  FilesSetDefsPanel.this.ignoreKnownFilesCheckbox.setSelected(selectedSet.ignoresKnownFiles());
299  FilesSetDefsPanel.this.ingoreUnallocCheckbox.setSelected(selectedSet.ingoresUnallocatedSpace());
300  // Populate the rule definitions list, sorted by name.
301  List<FilesSet.Rule> rules = new ArrayList<>(selectedSet.getRules().values());
302  Collections.sort(rules, new Comparator<FilesSet.Rule>() {
303  @Override
304  public int compare(FilesSet.Rule rule1, FilesSet.Rule rule2) {
305  return rule1.toString().compareTo(rule2.toString());
306  }
307  });
308  rules.forEach((rule) -> {
309  FilesSetDefsPanel.this.rulesListModel.addElement(rule);
310  });
311  // Select the first rule by default.
312  if (!FilesSetDefsPanel.this.rulesListModel.isEmpty()) {
313  FilesSetDefsPanel.this.rulesList.setSelectedIndex(0);
314  }
315  }
316  }
317  }
318 
323  private final class RulesListSelectionListener implements ListSelectionListener {
324 
325  @Override
326  public void valueChanged(ListSelectionEvent e) {
327  if (e.getValueIsAdjusting()) {
328  return;
329  }
330 
331  // Get the selected rule and populate the rule components.
332  FilesSet.Rule rule = FilesSetDefsPanel.this.rulesList.getSelectedValue();
333  if (rule != null) {
334  // Get the conditions that make up the rule.
335  FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
336  FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
337  FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
338  FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
339  FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
340  FilesSet.Rule.DateCondition dateCondition = rule.getDateCondition();
341  // Populate the components that display the properties of the
342  // selected rule.
343  if (nameCondition != null) {
344  FilesSetDefsPanel.this.fileNameTextField.setText(nameCondition.getTextToMatch());
345  FilesSetDefsPanel.this.fileNameRadioButton.setSelected(nameCondition instanceof FilesSet.Rule.FullNameCondition);
346  FilesSetDefsPanel.this.fileNameExtensionRadioButton.setSelected(nameCondition instanceof FilesSet.Rule.ExtensionCondition);
347  FilesSetDefsPanel.this.fileNameRegexCheckbox.setSelected(nameCondition.isRegex());
348  } else {
349  FilesSetDefsPanel.this.fileNameTextField.setText("");
350  FilesSetDefsPanel.this.fileNameRadioButton.setSelected(true);
351  FilesSetDefsPanel.this.fileNameExtensionRadioButton.setSelected(false);
352  FilesSetDefsPanel.this.fileNameRegexCheckbox.setSelected(false);
353  }
354  switch (typeCondition.getMetaType()) {
355  case FILES:
356  FilesSetDefsPanel.this.filesRadioButton.setSelected(true);
357  break;
358  case DIRECTORIES:
359  FilesSetDefsPanel.this.dirsRadioButton.setSelected(true);
360  break;
361  case FILES_AND_DIRECTORIES:
362  FilesSetDefsPanel.this.allRadioButton.setSelected(true);
363  break;
364  }
365  if (pathCondition != null) {
366  FilesSetDefsPanel.this.rulePathConditionTextField.setText(pathCondition.getTextToMatch());
367  FilesSetDefsPanel.this.rulePathConditionRegexCheckBox.setSelected(pathCondition.isRegex());
368  } else {
370  FilesSetDefsPanel.this.rulePathConditionRegexCheckBox.setSelected(false);
371  }
372  if (mimeTypeCondition != null) {
373  FilesSetDefsPanel.this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
374  } else {
375  FilesSetDefsPanel.this.mimeTypeComboBox.setSelectedIndex(0);
376  }
377  if (fileSizeCondition != null) {
378  FilesSetDefsPanel.this.fileSizeUnitComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
379  FilesSetDefsPanel.this.equalitySignComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
380  FilesSetDefsPanel.this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
381  } else {
382  FilesSetDefsPanel.this.fileSizeUnitComboBox.setSelectedIndex(1);
383  FilesSetDefsPanel.this.equalitySignComboBox.setSelectedIndex(2);
384  FilesSetDefsPanel.this.fileSizeSpinner.setValue(0);
385  }
386  if (dateCondition != null) {
387  FilesSetDefsPanel.this.daysIncludedTextField.setText(Integer.toString(dateCondition.getDaysIncluded()));
388  } else {
389  FilesSetDefsPanel.this.daysIncludedTextField.setText("");
390  }
391  enableButtons();
392  } else {
393  resetRuleComponents();
394  }
395  }
396 
397  }
398 
410  private void doFileSetsDialog(FilesSet selectedSet, boolean shouldCreateNew) {
411  // Create a files set defintion panle.
412  FilesSetPanel panel;
413  if (selectedSet != null) {
414  // Editing an existing set definition.
415  panel = new FilesSetPanel(selectedSet, panelType);
416  } else {
417  // Creating a new set definition.
418  panel = new FilesSetPanel(panelType);
419  }
420 
421  // Do a dialog box with the files set panel until the user either enters
422  // a valid definition or cancels. Note that the panel gives the user
423  // feedback when isValidDefinition() is called.
424  int option = JOptionPane.OK_OPTION;
425  do {
426  option = JOptionPane.showConfirmDialog(this, panel, NbBundle.getMessage(FilesSetPanel.class, filterDialogTitle), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
427  } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
428 
429  if (option == JOptionPane.OK_OPTION) {
430  Map<String, FilesSet.Rule> rules = new HashMap<>();
431  if (selectedSet != null) {
432  // Interesting file sets are immutable for thread safety,
433  // so editing a files set definition is a replacement operation.
434  // Preserve the existing rules from the set being edited.
435  rules.putAll(selectedSet.getRules());
436  }
437 
438  FilesSet filesSet = new FilesSet(
439  panel.getFilesSetName(),
440  panel.getFilesSetDescription(),
441  panel.getFileSetIgnoresKnownFiles(),
442  panel.getFileSetIgnoresUnallocatedSpace(),
443  rules
444  );
445 
446  Pair<FilesSet, Integer> result = handleConflict(filesSet, false);
447  option = result.getRight();
448  FilesSet toAddOrUpdate = result.getLeft();
449 
450  if (result.getRight() == JOptionPane.OK_OPTION) {
451  if (shouldCreateNew) {
452  this.replaceFilesSet(null, toAddOrUpdate, null);
453  } else {
454  this.replaceFilesSet(selectedSet, toAddOrUpdate, null);
455  }
456  }
457  }
458  }
459 
467  private void doFilesSetRuleDialog(FilesSet.Rule selectedRule) {
468  // Create a files set rule panel.
469  FilesSetRulePanel panel;
470  if (selectedRule != null) {
471  // Editing an existing rule definition.
472  panel = new FilesSetRulePanel(selectedRule, okButton, cancelButton, panelType);
473  } else {
474  // Creating a new rule definition.
475  panel = new FilesSetRulePanel(okButton, cancelButton, panelType);
476  }
477  // Do a dialog box with the files set panel until the user either enters
478  // a valid definition or cancels. Note that the panel gives the user
479  // feedback when isValidDefinition() is called.
480  int option = JOptionPane.OK_OPTION;
481  do {
482  option = JOptionPane.showOptionDialog(this, panel, NbBundle.getMessage(FilesSetPanel.class, ruleDialogTitle), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{okButton, cancelButton}, okButton);
483 
484  } while (option == JOptionPane.OK_OPTION && !panel.isValidRuleDefinition());
485 
486  if (option == JOptionPane.OK_OPTION) {
487  // Interesting file sets are immutable for thread safety,
488  // so editing a files set rule definition is a replacement
489  // operation. Preserve the existing rules from the set being edited.
490  FilesSet selectedSet = this.setsList.getSelectedValue();
491  Map<String, FilesSet.Rule> rules = new HashMap<>(selectedSet.getRules());
492 
493  // Remove the "old" rule definition and add the new/edited
494  // definition.
495  if (selectedRule != null) {
496  rules.remove(selectedRule.getUuid());
497  }
498  FilesSet.Rule newRule = new FilesSet.Rule(panel.getRuleName(), panel.getFileNameCondition(), panel.getMetaTypeCondition(), panel.getPathCondition(), panel.getMimeTypeCondition(), panel.getFileSizeCondition(), panel.getDateCondition());
499  rules.put(newRule.getUuid(), newRule);
500 
501  // Add the new/edited files set definition, replacing any previous
502  // definition with the same name and refreshing the display.
503  this.replaceFilesSet(selectedSet, selectedSet, rules);
504 
505  // Select the new/edited rule. Queue it up so it happens after the
506  // selection listeners react to the selection of the "new" files
507  // set.
508  EventQueue.invokeLater(() -> {
509  this.rulesList.setSelectedValue(newRule, true);
510  });
511  }
512  }
513 
525  private void replaceFilesSet(FilesSet oldSet, FilesSet newSet, Map<String, FilesSet.Rule> rules) {
526  if (oldSet != null) {
527  // Remove the set to be replaced from the working copy if the files
528  // set definitions.
529  this.filesSets.remove(oldSet.getName());
530  }
531 
532  FilesSet setToAdd = newSet;
533 
534  // Make the new/edited set definition and add it to the working copy of
535  // the files set definitions.
536  if (rules != null) {
537  setToAdd = new FilesSet(
538  newSet.getName(),
539  newSet.getDescription(),
540  newSet.ignoresKnownFiles(),
541  newSet.ingoresUnallocatedSpace(),
542  rules,
543  newSet.isStandardSet(),
544  newSet.getVersionNumber()
545  );
546  }
547 
548  this.filesSets.put(setToAdd.getName(), setToAdd);
549 
550  // Redo the list model for the files set list component, which will make
551  // everything stays sorted as in the working copy tree set.
552  FilesSetDefsPanel.this.setsListModel.clear();
553  this.filesSets.values().forEach((set) -> {
554  this.setsListModel.addElement(set);
555  });
556 
557  // Select the new/edited files set definition in the set definitions
558  // list. This will cause the selection listeners to repopulate the
559  // subordinate components.
560  this.setsList.setSelectedValue(setToAdd, true);
561  }
562 
568  @SuppressWarnings("unchecked")
569  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
570  private void initComponents() {
571 
572  fileNameButtonGroup = new javax.swing.ButtonGroup();
573  typeButtonGroup = new javax.swing.ButtonGroup();
574  jScrollPane1 = new javax.swing.JScrollPane();
575  jPanel1 = new javax.swing.JPanel();
576  setDetailsLabel = new javax.swing.JLabel();
577  newRuleButton = new javax.swing.JButton();
578  filesRadioButton = new javax.swing.JRadioButton();
579  editRuleButton = new javax.swing.JButton();
580  rulesListLabel = new javax.swing.JLabel();
581  rulesListScrollPane = new javax.swing.JScrollPane();
582  rulesList = new javax.swing.JList<>();
583  setDescScrollPanel = new javax.swing.JScrollPane();
584  setDescriptionTextArea = new javax.swing.JTextArea();
585  editSetButton = new javax.swing.JButton();
586  setsListScrollPane = new javax.swing.JScrollPane();
587  setsList = new javax.swing.JList<>();
588  fileNameExtensionRadioButton = new javax.swing.JRadioButton();
589  nameLabel = new javax.swing.JLabel();
590  fileNameTextField = new javax.swing.JTextField();
591  descriptionLabel = new javax.swing.JLabel();
592  fileNameRadioButton = new javax.swing.JRadioButton();
593  rulePathConditionTextField = new javax.swing.JTextField();
594  ignoreKnownFilesCheckbox = new javax.swing.JCheckBox();
595  fileNameRegexCheckbox = new javax.swing.JCheckBox();
596  separator = new javax.swing.JSeparator();
597  setsListLabel = new javax.swing.JLabel();
598  allRadioButton = new javax.swing.JRadioButton();
599  deleteSetButton = new javax.swing.JButton();
600  deleteRuleButton = new javax.swing.JButton();
601  newSetButton = new javax.swing.JButton();
602  fileTypeLabel = new javax.swing.JLabel();
603  dirsRadioButton = new javax.swing.JRadioButton();
604  ruleLabel = new javax.swing.JLabel();
605  pathLabel = new javax.swing.JLabel();
606  rulePathConditionRegexCheckBox = new javax.swing.JCheckBox();
607  descriptionScrollPane = new javax.swing.JScrollPane();
608  descriptionTextArea = new javax.swing.JTextArea();
609  mimeTypeLabel = new javax.swing.JLabel();
610  mimeTypeComboBox = new javax.swing.JComboBox<>();
611  fileSizeLabel = new javax.swing.JLabel();
612  equalitySignComboBox = new javax.swing.JComboBox<String>();
613  fileSizeSpinner = new javax.swing.JSpinner();
614  fileSizeUnitComboBox = new javax.swing.JComboBox<String>();
615  ingoreUnallocCheckbox = new javax.swing.JCheckBox();
616  ingestWarningLabel = new javax.swing.JLabel();
617  copySetButton = new javax.swing.JButton();
618  importSetButton = new javax.swing.JButton();
619  exportSetButton = new javax.swing.JButton();
620  modifiedDateLabel = new javax.swing.JLabel();
621  daysIncludedTextField = new javax.swing.JTextField();
622  daysIncludedLabel = new javax.swing.JLabel();
623 
624  org.openide.awt.Mnemonics.setLocalizedText(setDetailsLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.jLabel6.text")); // NOI18N
625 
626  newRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
627  org.openide.awt.Mnemonics.setLocalizedText(newRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.newRuleButton.text")); // NOI18N
628  newRuleButton.addActionListener(new java.awt.event.ActionListener() {
629  public void actionPerformed(java.awt.event.ActionEvent evt) {
630  newRuleButtonActionPerformed(evt);
631  }
632  });
633 
634  typeButtonGroup.add(filesRadioButton);
635  filesRadioButton.setSelected(true);
636  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.filesRadioButton.text")); // NOI18N
637  filesRadioButton.setEnabled(false);
638 
639  editRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
640  org.openide.awt.Mnemonics.setLocalizedText(editRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.editRuleButton.text")); // NOI18N
641  editRuleButton.setEnabled(false);
642  editRuleButton.addActionListener(new java.awt.event.ActionListener() {
643  public void actionPerformed(java.awt.event.ActionEvent evt) {
644  editRuleButtonActionPerformed(evt);
645  }
646  });
647 
648  org.openide.awt.Mnemonics.setLocalizedText(rulesListLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulesListLabel.text")); // NOI18N
649 
650  rulesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
651  rulesListScrollPane.setViewportView(rulesList);
652  rulesList.setCellRenderer(new SimpleListCellRenderer());
653 
654  setDescScrollPanel.setMinimumSize(new java.awt.Dimension(10, 22));
655  setDescScrollPanel.setPreferredSize(new java.awt.Dimension(14, 40));
656 
657  setDescriptionTextArea.setEditable(false);
658  setDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
659  setDescriptionTextArea.setColumns(20);
660  setDescriptionTextArea.setLineWrap(true);
661  setDescriptionTextArea.setRows(6);
662  setDescriptionTextArea.setMinimumSize(new java.awt.Dimension(10, 22));
663  setDescriptionTextArea.setOpaque(false);
664  setDescScrollPanel.setViewportView(setDescriptionTextArea);
665 
666  editSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
667  org.openide.awt.Mnemonics.setLocalizedText(editSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.editSetButton.text")); // NOI18N
668  editSetButton.setEnabled(false);
669  editSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
670  editSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
671  editSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
672  editSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
673  editSetButton.addActionListener(new java.awt.event.ActionListener() {
674  public void actionPerformed(java.awt.event.ActionEvent evt) {
675  editSetButtonActionPerformed(evt);
676  }
677  });
678 
679  setsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
680  setsListScrollPane.setViewportView(setsList);
681  setsList.setCellRenderer(new SimpleListCellRenderer());
682 
683  fileNameButtonGroup.add(fileNameExtensionRadioButton);
684  org.openide.awt.Mnemonics.setLocalizedText(fileNameExtensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameExtensionRadioButton.text")); // NOI18N
685  fileNameExtensionRadioButton.setEnabled(false);
686 
687  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.nameLabel.text")); // NOI18N
688 
689  fileNameTextField.setEditable(false);
690  fileNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameTextField.text")); // NOI18N
691 
692  org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.descriptionLabel.text")); // NOI18N
693 
694  fileNameButtonGroup.add(fileNameRadioButton);
695  org.openide.awt.Mnemonics.setLocalizedText(fileNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameRadioButton.text")); // NOI18N
696  fileNameRadioButton.setEnabled(false);
697 
698  rulePathConditionTextField.setEditable(false);
699  rulePathConditionTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulePathConditionTextField.text")); // NOI18N
700 
701  org.openide.awt.Mnemonics.setLocalizedText(ignoreKnownFilesCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ignoreKnownFilesCheckbox.text")); // NOI18N
702  ignoreKnownFilesCheckbox.setEnabled(false);
703 
704  org.openide.awt.Mnemonics.setLocalizedText(fileNameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameRegexCheckbox.text")); // NOI18N
705  fileNameRegexCheckbox.setEnabled(false);
706  fileNameRegexCheckbox.addActionListener(new java.awt.event.ActionListener() {
707  public void actionPerformed(java.awt.event.ActionEvent evt) {
708  fileNameRegexCheckboxActionPerformed(evt);
709  }
710  });
711 
712  separator.setOrientation(javax.swing.SwingConstants.VERTICAL);
713 
714  org.openide.awt.Mnemonics.setLocalizedText(setsListLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.setsListLabel.text")); // NOI18N
715 
716  typeButtonGroup.add(allRadioButton);
717  org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.allRadioButton.text")); // NOI18N
718  allRadioButton.setEnabled(false);
719 
720  deleteSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
721  org.openide.awt.Mnemonics.setLocalizedText(deleteSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.deleteSetButton.text")); // NOI18N
722  deleteSetButton.setEnabled(false);
723  deleteSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
724  deleteSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
725  deleteSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
726  deleteSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
727  deleteSetButton.addActionListener(new java.awt.event.ActionListener() {
728  public void actionPerformed(java.awt.event.ActionEvent evt) {
729  deleteSetButtonActionPerformed(evt);
730  }
731  });
732 
733  deleteRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
734  org.openide.awt.Mnemonics.setLocalizedText(deleteRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.deleteRuleButton.text")); // NOI18N
735  deleteRuleButton.setEnabled(false);
736  deleteRuleButton.addActionListener(new java.awt.event.ActionListener() {
737  public void actionPerformed(java.awt.event.ActionEvent evt) {
738  deleteRuleButtonActionPerformed(evt);
739  }
740  });
741 
742  newSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
743  org.openide.awt.Mnemonics.setLocalizedText(newSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.newSetButton.text")); // NOI18N
744  newSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
745  newSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
746  newSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
747  newSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
748  newSetButton.addActionListener(new java.awt.event.ActionListener() {
749  public void actionPerformed(java.awt.event.ActionEvent evt) {
750  newSetButtonActionPerformed(evt);
751  }
752  });
753 
754  org.openide.awt.Mnemonics.setLocalizedText(fileTypeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileTypeLabel.text")); // NOI18N
755 
756  typeButtonGroup.add(dirsRadioButton);
757  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.dirsRadioButton.text")); // NOI18N
758  dirsRadioButton.setEnabled(false);
759 
760  org.openide.awt.Mnemonics.setLocalizedText(ruleLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ruleLabel.text")); // NOI18N
761 
762  org.openide.awt.Mnemonics.setLocalizedText(pathLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.pathLabel.text")); // NOI18N
763 
764  org.openide.awt.Mnemonics.setLocalizedText(rulePathConditionRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulePathConditionRegexCheckBox.text")); // NOI18N
765  rulePathConditionRegexCheckBox.setEnabled(false);
766 
767  descriptionTextArea.setEditable(false);
768  descriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
769  descriptionTextArea.setColumns(20);
770  descriptionTextArea.setLineWrap(true);
771  descriptionTextArea.setRows(3);
772  descriptionTextArea.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.jTextArea1.text")); // NOI18N
773  descriptionTextArea.setWrapStyleWord(true);
774  descriptionTextArea.setOpaque(false);
775  descriptionScrollPane.setViewportView(descriptionTextArea);
776 
777  org.openide.awt.Mnemonics.setLocalizedText(mimeTypeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.mimeTypeLabel.text")); // NOI18N
778 
779  mimeTypeComboBox.setBackground(new java.awt.Color(240, 240, 240));
780  mimeTypeComboBox.setEditable(true);
781  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
782  mimeTypeComboBox.setEnabled(false);
783  mimeTypeComboBox.setMinimumSize(new java.awt.Dimension(0, 20));
784  mimeTypeComboBox.setPreferredSize(new java.awt.Dimension(12, 20));
785 
786  org.openide.awt.Mnemonics.setLocalizedText(fileSizeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileSizeLabel.text")); // NOI18N
787 
788  equalitySignComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
789  equalitySignComboBox.setEnabled(false);
790 
791  fileSizeSpinner.setEnabled(false);
792  fileSizeSpinner.setMinimumSize(new java.awt.Dimension(2, 20));
793 
794  fileSizeUnitComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { Bundle.FilesSetDefsPanel_bytes(), Bundle.FilesSetDefsPanel_kiloBytes(), Bundle.FilesSetDefsPanel_megaBytes(), Bundle.FilesSetDefsPanel_gigaBytes() }));
795  fileSizeUnitComboBox.setEnabled(false);
796 
797  org.openide.awt.Mnemonics.setLocalizedText(ingoreUnallocCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingoreUnallocCheckbox.text")); // NOI18N
798  ingoreUnallocCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingoreUnallocCheckbox.toolTipText")); // NOI18N
799  ingoreUnallocCheckbox.setEnabled(false);
800 
801  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
802  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingestWarningLabel.text")); // NOI18N
803 
804  copySetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/new16.png"))); // NOI18N
805  org.openide.awt.Mnemonics.setLocalizedText(copySetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.copySetButton.text")); // NOI18N
806  copySetButton.setEnabled(false);
807  copySetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
808  copySetButton.setMaximumSize(new java.awt.Dimension(111, 25));
809  copySetButton.setMinimumSize(new java.awt.Dimension(111, 25));
810  copySetButton.setPreferredSize(new java.awt.Dimension(111, 25));
811  copySetButton.addActionListener(new java.awt.event.ActionListener() {
812  public void actionPerformed(java.awt.event.ActionEvent evt) {
813  copySetButtonActionPerformed(evt);
814  }
815  });
816 
817  importSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/import16.png"))); // NOI18N
818  org.openide.awt.Mnemonics.setLocalizedText(importSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.importSetButton.text")); // NOI18N
819  importSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
820  importSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
821  importSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
822  importSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
823  importSetButton.addActionListener(new java.awt.event.ActionListener() {
824  public void actionPerformed(java.awt.event.ActionEvent evt) {
825  importSetButtonActionPerformed(evt);
826  }
827  });
828 
829  exportSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/export16.png"))); // NOI18N
830  org.openide.awt.Mnemonics.setLocalizedText(exportSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.exportSetButton.text")); // NOI18N
831  exportSetButton.setEnabled(false);
832  exportSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
833  exportSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
834  exportSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
835  exportSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
836  exportSetButton.addActionListener(new java.awt.event.ActionListener() {
837  public void actionPerformed(java.awt.event.ActionEvent evt) {
838  exportSetButtonActionPerformed(evt);
839  }
840  });
841 
842  org.openide.awt.Mnemonics.setLocalizedText(modifiedDateLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.modifiedDateLabel.text")); // NOI18N
843 
844  daysIncludedTextField.setEditable(false);
845  daysIncludedTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
846  daysIncludedTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.daysIncludedTextField.text")); // NOI18N
847  daysIncludedTextField.setMinimumSize(new java.awt.Dimension(60, 20));
848  daysIncludedTextField.setPreferredSize(new java.awt.Dimension(60, 20));
849 
850  org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.daysIncludedLabel.text")); // NOI18N
851  daysIncludedLabel.setEnabled(false);
852 
853  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
854  jPanel1.setLayout(jPanel1Layout);
855  jPanel1Layout.setHorizontalGroup(
856  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
857  .addGroup(jPanel1Layout.createSequentialGroup()
858  .addContainerGap()
859  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
860  .addGroup(jPanel1Layout.createSequentialGroup()
861  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
862  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
863  .addComponent(copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
864  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
865  .addComponent(importSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
866  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
867  .addComponent(newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
868  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
869  .addComponent(editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
870  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
871  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
872  .addComponent(exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
873  .addComponent(deleteSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
874  .addComponent(setsListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
875  .addComponent(descriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
876  .addComponent(setsListLabel))
877  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
878  .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
879  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
880  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
881  .addGroup(jPanel1Layout.createSequentialGroup()
882  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
883  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
884  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
885  .addGroup(jPanel1Layout.createSequentialGroup()
886  .addGap(16, 16, 16)
887  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
888  .addComponent(mimeTypeLabel)
889  .addComponent(fileSizeLabel)
890  .addComponent(fileTypeLabel)
891  .addComponent(pathLabel)
892  .addComponent(modifiedDateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
893  .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
894  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
895  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
896  .addComponent(rulePathConditionTextField)
897  .addComponent(fileNameTextField, javax.swing.GroupLayout.Alignment.TRAILING)
898  .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
899  .addGroup(jPanel1Layout.createSequentialGroup()
900  .addComponent(equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
901  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
902  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
903  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
904  .addComponent(fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
905  .addGroup(jPanel1Layout.createSequentialGroup()
906  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
907  .addComponent(rulePathConditionRegexCheckBox)
908  .addGroup(jPanel1Layout.createSequentialGroup()
909  .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
910  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
911  .addComponent(daysIncludedLabel))
912  .addGroup(jPanel1Layout.createSequentialGroup()
913  .addComponent(filesRadioButton)
914  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
915  .addComponent(dirsRadioButton)
916  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
917  .addComponent(allRadioButton))
918  .addGroup(jPanel1Layout.createSequentialGroup()
919  .addComponent(fileNameRadioButton)
920  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
921  .addComponent(fileNameExtensionRadioButton)
922  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
923  .addComponent(fileNameRegexCheckbox)))
924  .addGap(0, 0, Short.MAX_VALUE)))))
925  .addGap(8, 8, 8))
926  .addGroup(jPanel1Layout.createSequentialGroup()
927  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
928  .addComponent(rulesListLabel)
929  .addGroup(jPanel1Layout.createSequentialGroup()
930  .addComponent(ignoreKnownFilesCheckbox)
931  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
932  .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
933  .addGroup(jPanel1Layout.createSequentialGroup()
934  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
935  .addComponent(descriptionLabel)
936  .addComponent(setDetailsLabel))
937  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
938  .addComponent(ingestWarningLabel))
939  .addComponent(ruleLabel)
940  .addGroup(jPanel1Layout.createSequentialGroup()
941  .addComponent(newRuleButton)
942  .addGap(18, 18, 18)
943  .addComponent(editRuleButton)
944  .addGap(18, 18, 18)
945  .addComponent(deleteRuleButton)))
946  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
947  );
948 
949  jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {copySetButton, deleteSetButton, editSetButton, exportSetButton, importSetButton, newSetButton});
950 
951  jPanel1Layout.setVerticalGroup(
952  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
953  .addGroup(jPanel1Layout.createSequentialGroup()
954  .addContainerGap()
955  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
956  .addComponent(separator)
957  .addGroup(jPanel1Layout.createSequentialGroup()
958  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
959  .addGroup(jPanel1Layout.createSequentialGroup()
960  .addComponent(setDetailsLabel)
961  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
962  .addComponent(descriptionLabel)
963  .addGap(1, 1, 1))
964  .addComponent(ingestWarningLabel, javax.swing.GroupLayout.Alignment.TRAILING))
965  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
966  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
967  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
968  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
969  .addComponent(ignoreKnownFilesCheckbox)
970  .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
971  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
972  .addComponent(rulesListLabel)
973  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
974  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
975  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
976  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
977  .addComponent(newRuleButton)
978  .addComponent(editRuleButton)
979  .addComponent(deleteRuleButton))
980  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
981  .addComponent(ruleLabel)
982  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
983  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
984  .addComponent(fileTypeLabel)
985  .addComponent(filesRadioButton)
986  .addComponent(dirsRadioButton)
987  .addComponent(allRadioButton))
988  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
989  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
990  .addComponent(nameLabel)
991  .addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
992  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
993  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
994  .addComponent(fileNameRadioButton)
995  .addComponent(fileNameExtensionRadioButton)
996  .addComponent(fileNameRegexCheckbox))
997  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
998  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
999  .addComponent(pathLabel)
1000  .addComponent(rulePathConditionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
1001  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1002  .addComponent(rulePathConditionRegexCheckBox)
1003  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1004  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1005  .addComponent(mimeTypeLabel)
1006  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1007  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1008  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1009  .addComponent(fileSizeLabel)
1010  .addComponent(equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1011  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1012  .addComponent(fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1013  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1014  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1015  .addComponent(modifiedDateLabel)
1016  .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1017  .addComponent(daysIncludedLabel))
1018  .addContainerGap())
1019  .addGroup(jPanel1Layout.createSequentialGroup()
1020  .addComponent(descriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1021  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1022  .addComponent(setsListLabel)
1023  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1024  .addComponent(setsListScrollPane)
1025  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1026  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1027  .addComponent(newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1028  .addComponent(editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1029  .addComponent(deleteSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1030  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1031  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1032  .addComponent(copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1033  .addComponent(importSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1034  .addComponent(exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1035  .addGap(6, 6, 6))))
1036  );
1037 
1038  jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {copySetButton, deleteRuleButton, deleteSetButton, editRuleButton, editSetButton, exportSetButton, importSetButton, newRuleButton, newSetButton});
1039 
1040  jScrollPane1.setViewportView(jPanel1);
1041 
1042  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
1043  this.setLayout(layout);
1044  layout.setHorizontalGroup(
1045  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
1046  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)
1047  );
1048  layout.setVerticalGroup(
1049  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
1050  .addComponent(jScrollPane1)
1051  );
1052  }// </editor-fold>//GEN-END:initComponents
1053 
1054  private void newSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newSetButtonActionPerformed
1055  this.doFileSetsDialog(null, true);
1056  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1057  }//GEN-LAST:event_newSetButtonActionPerformed
1058 
1059  private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteRuleButtonActionPerformed
1060  // Interesting file sets are immutable for thread safety,
1061  // so editing a files set rule definition is a replacement
1062  // operation. Preserve the existing rules from the set being
1063  // edited, except for the deleted rule.
1064  FilesSet oldSet = this.setsList.getSelectedValue();
1065  Map<String, FilesSet.Rule> rules = new HashMap<>(oldSet.getRules());
1066  FilesSet.Rule selectedRule = this.rulesList.getSelectedValue();
1067  rules.remove(selectedRule.getUuid());
1068  this.replaceFilesSet(oldSet, oldSet, rules);
1069  if (!this.rulesListModel.isEmpty()) {
1070  this.rulesList.setSelectedIndex(0);
1071  } else {
1072  this.resetRuleComponents();
1073  }
1074  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1075  }//GEN-LAST:event_deleteRuleButtonActionPerformed
1076 
1077  private void deleteSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSetButtonActionPerformed
1078  FilesSet selectedSet = this.setsList.getSelectedValue();
1079  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
1080  for (IngestProfile profile : IngestProfiles.getIngestProfiles()) {
1081  if (profile.getFileIngestFilter().equals(selectedSet.getName())) {
1082  MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
1083  "FilesSetDefsPanel.ingest.fileFilterInUseError",
1084  selectedSet.getName(), profile.toString()));
1085  return;
1086  }
1087  }
1088 
1089  }
1090  this.filesSets.remove(selectedSet.getName());
1091  this.setsListModel.removeElement(selectedSet);
1092  // Select the first of the remaining set definitions. This will cause
1093  // the selection listeners to repopulate the subordinate components.
1094  if (!this.filesSets.isEmpty()) {
1095  this.setsList.setSelectedIndex(0);
1096  } else {
1097  this.resetComponents();
1098  }
1099  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1100  }//GEN-LAST:event_deleteSetButtonActionPerformed
1101 
1102  private void editSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editSetButtonActionPerformed
1103  this.doFileSetsDialog(this.setsList.getSelectedValue(), false);
1104  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1105  }//GEN-LAST:event_editSetButtonActionPerformed
1106 
1107  private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editRuleButtonActionPerformed
1108  this.doFilesSetRuleDialog(this.rulesList.getSelectedValue());
1109  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1110  }//GEN-LAST:event_editRuleButtonActionPerformed
1111 
1112  private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newRuleButtonActionPerformed
1113  this.doFilesSetRuleDialog(null);
1114  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1115  }//GEN-LAST:event_newRuleButtonActionPerformed
1116 
1117  private void copySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copySetButtonActionPerformed
1118  this.doFileSetsDialog(this.setsList.getSelectedValue(), true);
1119  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1120  }//GEN-LAST:event_copySetButtonActionPerformed
1121 
1122  @NbBundle.Messages({
1123  "FilesSetDefsPanel.interesting.failImportMsg=Interesting files set not imported",
1124  "FilesSetDefsPanel.interesting.fileExtensionFilterLbl=Autopsy Interesting File Set File (xml)",
1125  "FilesSetDefsPanel.interesting.importButtonAction.featureName=Interesting Files Set Import",
1126  "FilesSetDefsPanel.importSetButtonActionPerformed.noFilesSelected=No files sets were selected.",
1127  "FilesSetDefsPanel.importSetButtonActionPerformed.noFiles=No files sets were found in the selected files.",
1128  "# {0} - fileName",
1129  "# {1} - errorMessage",
1130  "FilesSetDefsPanel.importSetButtonActionPerformed.importError=The rules file \"{0}\" could not be read:\n{1}.",})
1131  private void importSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSetButtonActionPerformed
1132  //save currently selected value as default value to select
1133  FilesSet selectedSet = this.setsList.getSelectedValue();
1134  JFileChooser chooser = new JFileChooser();
1135  final String EXTENSION = "xml"; //NON-NLS
1136  FileNameExtensionFilter autopsyFilter = new FileNameExtensionFilter(
1137  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.fileExtensionFilterLbl"), EXTENSION);
1138  chooser.addChoosableFileFilter(autopsyFilter);
1139  chooser.setAcceptAllFileFilterUsed(false);
1140  chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
1141  int returnVal = chooser.showOpenDialog(this);
1142  if (returnVal == JFileChooser.APPROVE_OPTION) {
1143  File selFile = chooser.getSelectedFile();
1144  if (selFile == null) {
1145  JOptionPane.showMessageDialog(this,
1146  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_noFilesSelected(),
1147  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1148  JOptionPane.WARNING_MESSAGE);
1149  logger.warning("Selected file was null, when trying to import interesting files set definitions");
1150  return;
1151  }
1152  Collection<FilesSet> importedSets;
1153  try {
1154  importedSets = InterestingItemsFilesSetSettings.readDefinitionsXML(selFile).values(); //read the xml from that path
1155  if (importedSets.isEmpty()) {
1156  JOptionPane.showMessageDialog(this,
1157  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_noFiles(),
1158  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1159  JOptionPane.WARNING_MESSAGE);
1160  logger.log(Level.WARNING, "No Interesting files set definitions were read from the selected file");
1161  return;
1162  }
1164  JOptionPane.showMessageDialog(this,
1165  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_importError(selFile.getName(), ex.getMessage()),
1166  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1167  JOptionPane.WARNING_MESSAGE);
1168  logger.log(Level.WARNING, "No Interesting files set definitions were read from the selected file, exception", ex);
1169  return;
1170  }
1171 
1172  importedSets = importedSets
1173  .stream()
1174  .map((filesSet) -> StandardInterestingFilesSetsLoader.getAsStandardFilesSet(filesSet, false))
1175  .collect(Collectors.toList());
1176 
1177  FilesSet newSelected = determineFilesToImport(importedSets);
1178 
1179  // Redo the list model for the files set list component
1180  FilesSetDefsPanel.this.setsListModel.clear();
1181  this.filesSets.values().forEach((set) -> {
1182  this.setsListModel.addElement(set);
1183  });
1184  // Select the new/edited files set definition in the set definitions
1185  // list. This will cause the selection listeners to repopulate the
1186  // subordinate components.
1187  this.setsList.setSelectedValue(newSelected == null ? selectedSet : newSelected, true);
1188 
1189  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1190  }
1191 
1192  }//GEN-LAST:event_importSetButtonActionPerformed
1193 
1202  private FilesSet determineFilesToImport(Collection<FilesSet> importedSets) {
1203  FilesSet selectedSet = null;
1204 
1205  for (FilesSet set : importedSets) {
1206  Pair<FilesSet, Integer> conflictResult = handleConflict(set, true);
1207  int choice = conflictResult.getRight();
1208  FilesSet resultingFilesSet = conflictResult.getLeft();
1209 
1210  if (choice == JOptionPane.OK_OPTION) {
1211  selectedSet = resultingFilesSet;
1212  this.filesSets.put(resultingFilesSet.getName(), resultingFilesSet);
1213  } else if (choice == JOptionPane.CANCEL_OPTION) {
1214  break;
1215  }
1216  }
1217 
1218  return selectedSet;
1219  }
1220 
1233  private Pair<FilesSet, Integer> handleConflict(FilesSet set, boolean isImport) {
1234  FilesSet conflict = this.filesSets.get(set.getName());
1235  // if no conflict, return the files set as is with the option to proceed
1236  if (conflict == null) {
1237  return Pair.of(set, JOptionPane.OK_OPTION);
1238  }
1239 
1240  if (isImport) {
1241  if (conflict.isStandardSet()) {
1242  return onImportStandardSetConflict(set);
1243  } else {
1244  return onImportConflict(set);
1245  }
1246  } else {
1247  if (conflict.isStandardSet()) {
1248  return onNewEditSetStandardSetConflict(set);
1249  } else {
1250  return onNewEditSetConflict(set);
1251  }
1252  }
1253 
1254  }
1255 
1266  @Messages({
1267  "FilesSetDefsPanel.yesOwMsg=Yes, overwrite",
1268  "FilesSetDefsPanel.noSkipMsg=No, skip",
1269  "FilesSetDefsPanel.cancelImportMsg=Cancel import",
1270  "# {0} - FilesSet name",
1271  "FilesSetDefsPanel.interesting.overwriteSetPrompt=Interesting files set \"{0}\" already exists locally, overwrite?",
1272  "FilesSetDefsPanel.interesting.importOwConflict=Import Interesting files set conflict",})
1273  private Pair<FilesSet, Integer> onImportConflict(FilesSet set) {
1274  // if there is a conflict, see if it is okay to overwrite.
1275  Object[] options = {
1276  Bundle.FilesSetDefsPanel_yesOwMsg(),
1277  Bundle.FilesSetDefsPanel_noSkipMsg(),
1278  Bundle.FilesSetDefsPanel_cancelImportMsg()
1279  };
1280  int conflictChoice = JOptionPane.showOptionDialog(this,
1281  Bundle.FilesSetDefsPanel_interesting_overwriteSetPrompt(set.getName()),
1282  Bundle.FilesSetDefsPanel_interesting_importOwConflict(),
1283  JOptionPane.YES_NO_CANCEL_OPTION,
1284  JOptionPane.QUESTION_MESSAGE,
1285  null,
1286  options,
1287  options[0]);
1288 
1289  if (conflictChoice == JOptionPane.OK_OPTION) {
1290  // if so, just return the files set to be placed in the map overwriting what is currently present.
1291  return Pair.of(set, conflictChoice);
1292  }
1293 
1294  return Pair.of(null, conflictChoice);
1295  }
1296 
1307  @Messages({
1308  "FilesSetDefsPanel.yesStandardFileConflictCreate=Yes, create",
1309  "# {0} - FilesSet name",
1310  "# {1} - New FilesSet name",
1311  "FilesSetDefsPanel.interesting.standardFileConflict=A standard interesting file set already exists with the name \"{0}.\" Would you like to rename your set to \"{1}?\"",})
1312  private Pair<FilesSet, Integer> onImportStandardSetConflict(FilesSet set) {
1313  // if there is a conflict and the conflicting files set is a standard files set,
1314  // see if allowing a custom files set is okay.
1315  Object[] options = {
1316  Bundle.FilesSetDefsPanel_yesStandardFileConflictCreate(),
1317  Bundle.FilesSetDefsPanel_noSkipMsg(),
1318  Bundle.FilesSetDefsPanel_cancelImportMsg()
1319  };
1320 
1321  String setName = set.getName();
1322  String customSetName = Bundle.StandardInterestingFileSetsLoader_customSuffixed(set.getName());
1323 
1324  int conflictChoice = JOptionPane.showOptionDialog(this,
1325  Bundle.FilesSetDefsPanel_interesting_standardFileConflict(setName, customSetName),
1326  Bundle.FilesSetDefsPanel_interesting_importOwConflict(),
1327  JOptionPane.YES_NO_CANCEL_OPTION,
1328  JOptionPane.QUESTION_MESSAGE,
1329  null,
1330  options,
1331  options[0]);
1332 
1333  // if it is okay to create with custom prefix, try again to see if there is a conflict.
1334  if (conflictChoice == JOptionPane.OK_OPTION) {
1335  return handleConflict(StandardInterestingFilesSetsLoader.getAsCustomFileSet(set), true);
1336  }
1337 
1338  return Pair.of(null, conflictChoice);
1339  }
1340 
1351  @Messages({
1352  "FilesSetDefsPanel.cancelNewSetMsg=Cancel",
1353  "FilesSetDefsPanel.interesting.newOwConflict=Interesting files set conflict",})
1354  private Pair<FilesSet, Integer> onNewEditSetConflict(FilesSet set) {
1355  // if there is a conflict, see if it is okay to overwrite.
1356  Object[] options = {
1357  Bundle.FilesSetDefsPanel_yesOwMsg(),
1358  Bundle.FilesSetDefsPanel_cancelNewSetMsg()
1359  };
1360  int conflictChoice = JOptionPane.showOptionDialog(this,
1361  Bundle.FilesSetDefsPanel_interesting_overwriteSetPrompt(set.getName()),
1362  Bundle.FilesSetDefsPanel_interesting_newOwConflict(),
1363  JOptionPane.OK_CANCEL_OPTION,
1364  JOptionPane.QUESTION_MESSAGE,
1365  null,
1366  options,
1367  options[0]);
1368 
1369  if (conflictChoice == JOptionPane.OK_OPTION) {
1370  // if so, just return the files set to be placed in the map overwriting what is currently present.
1371  return Pair.of(set, conflictChoice);
1372  }
1373 
1374  return Pair.of(null, conflictChoice);
1375  }
1376 
1387  private Pair<FilesSet, Integer> onNewEditSetStandardSetConflict(FilesSet set) {
1388  // if there is a conflict and the conflicting files set is a standard files set,
1389  // see if allowing a custom files set is okay.
1390  Object[] options = {
1391  Bundle.FilesSetDefsPanel_yesStandardFileConflictCreate(),
1392  Bundle.FilesSetDefsPanel_cancelNewSetMsg()
1393  };
1394 
1395  String setName = set.getName();
1396  String customSetName = Bundle.StandardInterestingFileSetsLoader_customSuffixed(set.getName());
1397 
1398  int conflictChoice = JOptionPane.showOptionDialog(this,
1399  Bundle.FilesSetDefsPanel_interesting_standardFileConflict(setName, customSetName),
1400  Bundle.FilesSetDefsPanel_interesting_newOwConflict(),
1401  JOptionPane.OK_CANCEL_OPTION,
1402  JOptionPane.QUESTION_MESSAGE,
1403  null,
1404  options,
1405  options[0]);
1406 
1407  // if it is okay to create with custom prefix, try again to see if there is a conflict.
1408  if (conflictChoice == JOptionPane.OK_OPTION) {
1409  return handleConflict(StandardInterestingFilesSetsLoader.getAsCustomFileSet(set), false);
1410  }
1411 
1412  return Pair.of(null, conflictChoice);
1413  }
1414 
1415  @NbBundle.Messages({"FilesSetDefsPanel.interesting.exportButtonAction.featureName=Interesting Files Set Export",
1416  "# {0} - file name",
1417  "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt=File {0} exists, overwrite?",
1418  "FilesSetDefsPanel.interesting.ExportedMsg=Interesting files set exported",
1419  "FilesSetDefsPanel.interesting.failExportMsg=Export of interesting files set failed"})
1420  private void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportSetButtonActionPerformed
1421  //display warning that existing filessets with duplicate names will be overwritten
1422  //create file chooser to get xml filefinal String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
1423  JFileChooser chooser = new JFileChooser();
1424  final String EXTENSION = "xml"; //NON-NLS
1425  FileNameExtensionFilter autopsyFilter = new FileNameExtensionFilter(
1426  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.fileExtensionFilterLbl"), EXTENSION);
1427  chooser.addChoosableFileFilter(autopsyFilter);
1428  chooser.setSelectedFile(new File(this.setsList.getSelectedValue().getName()));
1429  chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
1430  int returnVal = chooser.showSaveDialog(this);
1431  if (returnVal == JFileChooser.APPROVE_OPTION) {
1432  final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
1433  "FilesSetDefsPanel.interesting.exportButtonAction.featureName");
1434  File selFile = chooser.getSelectedFile();
1435  if (selFile == null) {
1436  JOptionPane.showMessageDialog(this,
1437  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.failExportMsg"),
1438  FEATURE_NAME,
1439  JOptionPane.WARNING_MESSAGE);
1440  logger.warning("Selected file was null, when trying to export interesting files set definitions");
1441  return;
1442  }
1443  //force append extension if not given
1444  String fileAbs = selFile.getAbsolutePath();
1445  if (!fileAbs.endsWith("." + EXTENSION)) {
1446  fileAbs = fileAbs + "." + EXTENSION;
1447  selFile = new File(fileAbs);
1448  }
1449  if (selFile.exists()) {
1450  //if the file already exists ask the user how to proceed
1451  final String FILE_EXISTS_MESSAGE = NbBundle.getMessage(this.getClass(),
1452  "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt", selFile.getName());
1453  boolean shouldWrite = JOptionPane.showConfirmDialog(this, FILE_EXISTS_MESSAGE, FEATURE_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION;
1454  if (!shouldWrite) {
1455  return;
1456  }
1457  }
1458  List<FilesSet> exportSets;
1459  exportSets = new ArrayList<>();
1460  //currently only exports selectedValue
1461  exportSets.add(this.setsList.getSelectedValue());
1462  boolean written = InterestingItemsFilesSetSettings.exportXmlDefinitionsFile(selFile, exportSets);
1463  if (written) {
1464  JOptionPane.showMessageDialog(
1465  WindowManager.getDefault().getMainWindow(),
1466  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.ExportedMsg"),
1467  FEATURE_NAME,
1468  JOptionPane.INFORMATION_MESSAGE);
1469  } else {
1470  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
1471  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.failExportMsg"),
1472  FEATURE_NAME,
1473  JOptionPane.WARNING_MESSAGE);
1474  logger.warning("Export of interesting files set failed unable to write definitions xml file");
1475  }
1476  }
1477  }//GEN-LAST:event_exportSetButtonActionPerformed
1478 
1479  private void fileNameRegexCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileNameRegexCheckboxActionPerformed
1480  // TODO add your handling code here:
1481  }//GEN-LAST:event_fileNameRegexCheckboxActionPerformed
1482 
1483  // Variables declaration - do not modify//GEN-BEGIN:variables
1484  private javax.swing.JRadioButton allRadioButton;
1485  private javax.swing.JButton copySetButton;
1486  private javax.swing.JLabel daysIncludedLabel;
1487  private javax.swing.JTextField daysIncludedTextField;
1488  private javax.swing.JButton deleteRuleButton;
1489  private javax.swing.JButton deleteSetButton;
1490  private javax.swing.JLabel descriptionLabel;
1491  private javax.swing.JScrollPane descriptionScrollPane;
1492  private javax.swing.JTextArea descriptionTextArea;
1493  private javax.swing.JRadioButton dirsRadioButton;
1494  private javax.swing.JButton editRuleButton;
1495  private javax.swing.JButton editSetButton;
1496  private javax.swing.JComboBox<String> equalitySignComboBox;
1497  private javax.swing.JButton exportSetButton;
1498  private javax.swing.ButtonGroup fileNameButtonGroup;
1499  private javax.swing.JRadioButton fileNameExtensionRadioButton;
1500  private javax.swing.JRadioButton fileNameRadioButton;
1501  private javax.swing.JCheckBox fileNameRegexCheckbox;
1502  private javax.swing.JTextField fileNameTextField;
1503  private javax.swing.JLabel fileSizeLabel;
1504  private javax.swing.JSpinner fileSizeSpinner;
1505  private javax.swing.JComboBox<String> fileSizeUnitComboBox;
1506  private javax.swing.JLabel fileTypeLabel;
1507  private javax.swing.JRadioButton filesRadioButton;
1508  private javax.swing.JCheckBox ignoreKnownFilesCheckbox;
1509  private javax.swing.JButton importSetButton;
1510  private javax.swing.JLabel ingestWarningLabel;
1511  private javax.swing.JCheckBox ingoreUnallocCheckbox;
1512  private javax.swing.JPanel jPanel1;
1513  private javax.swing.JScrollPane jScrollPane1;
1514  private javax.swing.JComboBox<String> mimeTypeComboBox;
1515  private javax.swing.JLabel mimeTypeLabel;
1516  private javax.swing.JLabel modifiedDateLabel;
1517  private javax.swing.JLabel nameLabel;
1518  private javax.swing.JButton newRuleButton;
1519  private javax.swing.JButton newSetButton;
1520  private javax.swing.JLabel pathLabel;
1521  private javax.swing.JLabel ruleLabel;
1522  private javax.swing.JCheckBox rulePathConditionRegexCheckBox;
1523  private javax.swing.JTextField rulePathConditionTextField;
1524  private javax.swing.JList<FilesSet.Rule> rulesList;
1525  private javax.swing.JLabel rulesListLabel;
1526  private javax.swing.JScrollPane rulesListScrollPane;
1527  private javax.swing.JSeparator separator;
1528  private javax.swing.JScrollPane setDescScrollPanel;
1529  private javax.swing.JTextArea setDescriptionTextArea;
1530  private javax.swing.JLabel setDetailsLabel;
1531  private javax.swing.JList<FilesSet> setsList;
1532  private javax.swing.JLabel setsListLabel;
1533  private javax.swing.JScrollPane setsListScrollPane;
1534  private javax.swing.ButtonGroup typeButtonGroup;
1535  // End of variables declaration//GEN-END:variables
1536 
1537 }
void replaceFilesSet(FilesSet oldSet, FilesSet newSet, Map< String, FilesSet.Rule > rules)
static synchronized IngestManager getInstance()
Pair< FilesSet, Integer > handleConflict(FilesSet set, boolean isImport)
FilesSet determineFilesToImport(Collection< FilesSet > importedSets)
Pair< FilesSet, Integer > onNewEditSetStandardSetConflict(FilesSet set)
void addIngestJobEventListener(final PropertyChangeListener listener)
static synchronized List< IngestProfile > getIngestProfiles()
void doFileSetsDialog(FilesSet selectedSet, boolean shouldCreateNew)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized SortedSet< String > getDetectedTypes()

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.