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