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