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