Autopsy  4.19.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-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(), panel.getFileNameCondition(), panel.getMetaTypeCondition(), panel.getPathCondition(), panel.getMimeTypeCondition(), panel.getFileSizeCondition(), panel.getDateCondition());
520  rules.put(newRule.getUuid(), newRule);
521 
522  // Add the new/edited files set definition, replacing any previous
523  // definition with the same name and refreshing the display.
524  this.replaceFilesSet(selectedSet, selectedSet, rules);
525 
526  // Select the new/edited rule. Queue it up so it happens after the
527  // selection listeners react to the selection of the "new" files
528  // set.
529  EventQueue.invokeLater(() -> {
530  this.rulesList.setSelectedValue(newRule, true);
531  });
532  }
533  }
534 
546  private void replaceFilesSet(FilesSet oldSet, FilesSet newSet, Map<String, FilesSet.Rule> rules) {
547  if (oldSet != null) {
548  // Remove the set to be replaced from the working copy if the files
549  // set definitions.
550  this.filesSets.remove(oldSet.getName());
551  }
552 
553  FilesSet setToAdd = newSet;
554 
555  // Make the new/edited set definition and add it to the working copy of
556  // the files set definitions.
557  if (rules != null) {
558  setToAdd = new FilesSet(
559  newSet.getName(),
560  newSet.getDescription(),
561  newSet.ignoresKnownFiles(),
562  newSet.ingoresUnallocatedSpace(),
563  rules,
564  newSet.isStandardSet(),
565  newSet.getVersionNumber()
566  );
567  }
568 
569  this.filesSets.put(setToAdd.getName(), setToAdd);
570 
571  // Redo the list model for the files set list component, which will make
572  // everything stays sorted as in the working copy tree set.
573  FilesSetDefsPanel.this.setsListModel.clear();
574  this.filesSets.values().forEach((set) -> {
575  this.setsListModel.addElement(set);
576  });
577 
578  // Select the new/edited files set definition in the set definitions
579  // list. This will cause the selection listeners to repopulate the
580  // subordinate components.
581  this.setsList.setSelectedValue(setToAdd, true);
582  }
583 
589  @SuppressWarnings("unchecked")
590  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
591  private void initComponents() {
592 
593  fileNameButtonGroup = new javax.swing.ButtonGroup();
594  typeButtonGroup = new javax.swing.ButtonGroup();
595  jScrollPane1 = new javax.swing.JScrollPane();
596  jPanel1 = new javax.swing.JPanel();
597  setDetailsLabel = new javax.swing.JLabel();
598  newRuleButton = new javax.swing.JButton();
599  filesRadioButton = new javax.swing.JRadioButton();
600  editRuleButton = new javax.swing.JButton();
601  rulesListLabel = new javax.swing.JLabel();
602  rulesListScrollPane = new javax.swing.JScrollPane();
603  rulesList = new javax.swing.JList<>();
604  setDescScrollPanel = new javax.swing.JScrollPane();
605  setDescriptionTextArea = new javax.swing.JTextArea();
606  editSetButton = new javax.swing.JButton();
607  setsListScrollPane = new javax.swing.JScrollPane();
608  setsList = new javax.swing.JList<>();
609  fileNameExtensionRadioButton = new javax.swing.JRadioButton();
610  nameLabel = new javax.swing.JLabel();
611  fileNameTextField = new javax.swing.JTextField();
612  descriptionLabel = new javax.swing.JLabel();
613  fileNameRadioButton = new javax.swing.JRadioButton();
614  rulePathConditionTextField = new javax.swing.JTextField();
615  ignoreKnownFilesCheckbox = new javax.swing.JCheckBox();
616  fileNameRegexCheckbox = new javax.swing.JCheckBox();
617  separator = new javax.swing.JSeparator();
618  setsListLabel = new javax.swing.JLabel();
619  allRadioButton = new javax.swing.JRadioButton();
620  deleteSetButton = new javax.swing.JButton();
621  deleteRuleButton = new javax.swing.JButton();
622  newSetButton = new javax.swing.JButton();
623  fileTypeLabel = new javax.swing.JLabel();
624  dirsRadioButton = new javax.swing.JRadioButton();
625  ruleLabel = new javax.swing.JLabel();
626  pathLabel = new javax.swing.JLabel();
627  rulePathConditionRegexCheckBox = new javax.swing.JCheckBox();
628  descriptionScrollPane = new javax.swing.JScrollPane();
629  descriptionTextArea = new javax.swing.JTextArea();
630  mimeTypeLabel = new javax.swing.JLabel();
631  mimeTypeComboBox = new javax.swing.JComboBox<>();
632  fileSizeLabel = new javax.swing.JLabel();
633  equalitySignComboBox = new javax.swing.JComboBox<String>();
634  fileSizeSpinner = new javax.swing.JSpinner();
635  fileSizeUnitComboBox = new javax.swing.JComboBox<String>();
636  ingoreUnallocCheckbox = new javax.swing.JCheckBox();
637  ingestWarningLabel = new javax.swing.JLabel();
638  copySetButton = new javax.swing.JButton();
639  importSetButton = new javax.swing.JButton();
640  exportSetButton = new javax.swing.JButton();
641  modifiedDateLabel = new javax.swing.JLabel();
642  daysIncludedTextField = new javax.swing.JTextField();
643  daysIncludedLabel = new javax.swing.JLabel();
644 
645  org.openide.awt.Mnemonics.setLocalizedText(setDetailsLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.jLabel6.text")); // NOI18N
646 
647  newRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
648  org.openide.awt.Mnemonics.setLocalizedText(newRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.newRuleButton.text")); // NOI18N
649  newRuleButton.addActionListener(new java.awt.event.ActionListener() {
650  public void actionPerformed(java.awt.event.ActionEvent evt) {
651  newRuleButtonActionPerformed(evt);
652  }
653  });
654 
655  typeButtonGroup.add(filesRadioButton);
656  filesRadioButton.setSelected(true);
657  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.filesRadioButton.text")); // NOI18N
658  filesRadioButton.setEnabled(false);
659 
660  editRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
661  org.openide.awt.Mnemonics.setLocalizedText(editRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.editRuleButton.text")); // NOI18N
662  editRuleButton.setEnabled(false);
663  editRuleButton.addActionListener(new java.awt.event.ActionListener() {
664  public void actionPerformed(java.awt.event.ActionEvent evt) {
665  editRuleButtonActionPerformed(evt);
666  }
667  });
668 
669  org.openide.awt.Mnemonics.setLocalizedText(rulesListLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulesListLabel.text")); // NOI18N
670 
671  rulesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
672  rulesListScrollPane.setViewportView(rulesList);
673  rulesList.setCellRenderer(new SimpleListCellRenderer());
674 
675  setDescScrollPanel.setMinimumSize(new java.awt.Dimension(10, 22));
676  setDescScrollPanel.setPreferredSize(new java.awt.Dimension(14, 40));
677 
678  setDescriptionTextArea.setEditable(false);
679  setDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
680  setDescriptionTextArea.setColumns(20);
681  setDescriptionTextArea.setLineWrap(true);
682  setDescriptionTextArea.setRows(6);
683  setDescriptionTextArea.setMinimumSize(new java.awt.Dimension(10, 22));
684  setDescriptionTextArea.setOpaque(false);
685  setDescScrollPanel.setViewportView(setDescriptionTextArea);
686 
687  editSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
688  org.openide.awt.Mnemonics.setLocalizedText(editSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.editSetButton.text")); // NOI18N
689  editSetButton.setEnabled(false);
690  editSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
691  editSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
692  editSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
693  editSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
694  editSetButton.addActionListener(new java.awt.event.ActionListener() {
695  public void actionPerformed(java.awt.event.ActionEvent evt) {
696  editSetButtonActionPerformed(evt);
697  }
698  });
699 
700  setsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
701  setsListScrollPane.setViewportView(setsList);
702  setsList.setCellRenderer(new SimpleListCellRenderer());
703 
704  fileNameButtonGroup.add(fileNameExtensionRadioButton);
705  org.openide.awt.Mnemonics.setLocalizedText(fileNameExtensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameExtensionRadioButton.text")); // NOI18N
706  fileNameExtensionRadioButton.setEnabled(false);
707 
708  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.nameLabel.text")); // NOI18N
709 
710  fileNameTextField.setEditable(false);
711  fileNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameTextField.text")); // NOI18N
712 
713  org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.descriptionLabel.text")); // NOI18N
714 
715  fileNameButtonGroup.add(fileNameRadioButton);
716  org.openide.awt.Mnemonics.setLocalizedText(fileNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameRadioButton.text")); // NOI18N
717  fileNameRadioButton.setEnabled(false);
718 
719  rulePathConditionTextField.setEditable(false);
720  rulePathConditionTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulePathConditionTextField.text")); // NOI18N
721 
722  org.openide.awt.Mnemonics.setLocalizedText(ignoreKnownFilesCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ignoreKnownFilesCheckbox.text")); // NOI18N
723  ignoreKnownFilesCheckbox.setEnabled(false);
724 
725  org.openide.awt.Mnemonics.setLocalizedText(fileNameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileNameRegexCheckbox.text")); // NOI18N
726  fileNameRegexCheckbox.setEnabled(false);
727  fileNameRegexCheckbox.addActionListener(new java.awt.event.ActionListener() {
728  public void actionPerformed(java.awt.event.ActionEvent evt) {
729  fileNameRegexCheckboxActionPerformed(evt);
730  }
731  });
732 
733  separator.setOrientation(javax.swing.SwingConstants.VERTICAL);
734 
735  org.openide.awt.Mnemonics.setLocalizedText(setsListLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.setsListLabel.text")); // NOI18N
736 
737  typeButtonGroup.add(allRadioButton);
738  org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.allRadioButton.text")); // NOI18N
739  allRadioButton.setEnabled(false);
740 
741  deleteSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
742  org.openide.awt.Mnemonics.setLocalizedText(deleteSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.deleteSetButton.text")); // NOI18N
743  deleteSetButton.setEnabled(false);
744  deleteSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
745  deleteSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
746  deleteSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
747  deleteSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
748  deleteSetButton.addActionListener(new java.awt.event.ActionListener() {
749  public void actionPerformed(java.awt.event.ActionEvent evt) {
750  deleteSetButtonActionPerformed(evt);
751  }
752  });
753 
754  deleteRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
755  org.openide.awt.Mnemonics.setLocalizedText(deleteRuleButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.deleteRuleButton.text")); // NOI18N
756  deleteRuleButton.setEnabled(false);
757  deleteRuleButton.addActionListener(new java.awt.event.ActionListener() {
758  public void actionPerformed(java.awt.event.ActionEvent evt) {
759  deleteRuleButtonActionPerformed(evt);
760  }
761  });
762 
763  newSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
764  org.openide.awt.Mnemonics.setLocalizedText(newSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.newSetButton.text")); // NOI18N
765  newSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
766  newSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
767  newSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
768  newSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
769  newSetButton.addActionListener(new java.awt.event.ActionListener() {
770  public void actionPerformed(java.awt.event.ActionEvent evt) {
771  newSetButtonActionPerformed(evt);
772  }
773  });
774 
775  org.openide.awt.Mnemonics.setLocalizedText(fileTypeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileTypeLabel.text")); // NOI18N
776 
777  typeButtonGroup.add(dirsRadioButton);
778  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.dirsRadioButton.text")); // NOI18N
779  dirsRadioButton.setEnabled(false);
780 
781  org.openide.awt.Mnemonics.setLocalizedText(ruleLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ruleLabel.text")); // NOI18N
782 
783  org.openide.awt.Mnemonics.setLocalizedText(pathLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.pathLabel.text")); // NOI18N
784 
785  org.openide.awt.Mnemonics.setLocalizedText(rulePathConditionRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.rulePathConditionRegexCheckBox.text")); // NOI18N
786  rulePathConditionRegexCheckBox.setEnabled(false);
787 
788  descriptionTextArea.setEditable(false);
789  descriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
790  descriptionTextArea.setColumns(20);
791  descriptionTextArea.setLineWrap(true);
792  descriptionTextArea.setRows(3);
793  descriptionTextArea.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.jTextArea1.text")); // NOI18N
794  descriptionTextArea.setWrapStyleWord(true);
795  descriptionTextArea.setOpaque(false);
796  descriptionScrollPane.setViewportView(descriptionTextArea);
797 
798  org.openide.awt.Mnemonics.setLocalizedText(mimeTypeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.mimeTypeLabel.text")); // NOI18N
799 
800  mimeTypeComboBox.setBackground(new java.awt.Color(240, 240, 240));
801  mimeTypeComboBox.setEditable(true);
802  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
803  mimeTypeComboBox.setEnabled(false);
804  mimeTypeComboBox.setMinimumSize(new java.awt.Dimension(0, 20));
805  mimeTypeComboBox.setPreferredSize(new java.awt.Dimension(12, 20));
806 
807  org.openide.awt.Mnemonics.setLocalizedText(fileSizeLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.fileSizeLabel.text")); // NOI18N
808 
809  equalitySignComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { ">", "<" }));
810  equalitySignComboBox.setEnabled(false);
811 
812  fileSizeSpinner.setEnabled(false);
813  fileSizeSpinner.setMinimumSize(new java.awt.Dimension(2, 20));
814 
815  fileSizeUnitComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { Bundle.FilesSetDefsPanel_bytes(), Bundle.FilesSetDefsPanel_kiloBytes(), Bundle.FilesSetDefsPanel_megaBytes(), Bundle.FilesSetDefsPanel_gigaBytes() }));
816  fileSizeUnitComboBox.setEnabled(false);
817 
818  org.openide.awt.Mnemonics.setLocalizedText(ingoreUnallocCheckbox, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingoreUnallocCheckbox.text")); // NOI18N
819  ingoreUnallocCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingoreUnallocCheckbox.toolTipText")); // NOI18N
820  ingoreUnallocCheckbox.setEnabled(false);
821 
822  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
823  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.ingestWarningLabel.text")); // NOI18N
824 
825  copySetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/new16.png"))); // NOI18N
826  org.openide.awt.Mnemonics.setLocalizedText(copySetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.copySetButton.text")); // NOI18N
827  copySetButton.setEnabled(false);
828  copySetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
829  copySetButton.setMaximumSize(new java.awt.Dimension(111, 25));
830  copySetButton.setMinimumSize(new java.awt.Dimension(111, 25));
831  copySetButton.setPreferredSize(new java.awt.Dimension(111, 25));
832  copySetButton.addActionListener(new java.awt.event.ActionListener() {
833  public void actionPerformed(java.awt.event.ActionEvent evt) {
834  copySetButtonActionPerformed(evt);
835  }
836  });
837 
838  importSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/import16.png"))); // NOI18N
839  org.openide.awt.Mnemonics.setLocalizedText(importSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.importSetButton.text")); // NOI18N
840  importSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
841  importSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
842  importSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
843  importSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
844  importSetButton.addActionListener(new java.awt.event.ActionListener() {
845  public void actionPerformed(java.awt.event.ActionEvent evt) {
846  importSetButtonActionPerformed(evt);
847  }
848  });
849 
850  exportSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/export16.png"))); // NOI18N
851  org.openide.awt.Mnemonics.setLocalizedText(exportSetButton, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.interesting.exportSetButton.text")); // NOI18N
852  exportSetButton.setEnabled(false);
853  exportSetButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
854  exportSetButton.setMaximumSize(new java.awt.Dimension(111, 25));
855  exportSetButton.setMinimumSize(new java.awt.Dimension(111, 25));
856  exportSetButton.setPreferredSize(new java.awt.Dimension(111, 25));
857  exportSetButton.addActionListener(new java.awt.event.ActionListener() {
858  public void actionPerformed(java.awt.event.ActionEvent evt) {
859  exportSetButtonActionPerformed(evt);
860  }
861  });
862 
863  org.openide.awt.Mnemonics.setLocalizedText(modifiedDateLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.modifiedDateLabel.text")); // NOI18N
864 
865  daysIncludedTextField.setEditable(false);
866  daysIncludedTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
867  daysIncludedTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.daysIncludedTextField.text")); // NOI18N
868  daysIncludedTextField.setMinimumSize(new java.awt.Dimension(60, 20));
869  daysIncludedTextField.setPreferredSize(new java.awt.Dimension(60, 20));
870 
871  org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel, org.openide.util.NbBundle.getMessage(FilesSetDefsPanel.class, "FilesSetDefsPanel.daysIncludedLabel.text")); // NOI18N
872  daysIncludedLabel.setEnabled(false);
873 
874  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
875  jPanel1.setLayout(jPanel1Layout);
876  jPanel1Layout.setHorizontalGroup(
877  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
878  .addGroup(jPanel1Layout.createSequentialGroup()
879  .addContainerGap()
880  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
881  .addGroup(jPanel1Layout.createSequentialGroup()
882  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
883  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
884  .addComponent(copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
885  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
886  .addComponent(importSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
887  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
888  .addComponent(newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
889  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
890  .addComponent(editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
891  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
892  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
893  .addComponent(exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
894  .addComponent(deleteSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
895  .addComponent(setsListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
896  .addComponent(descriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
897  .addComponent(setsListLabel))
898  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
899  .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
900  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
901  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
902  .addGroup(jPanel1Layout.createSequentialGroup()
903  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
904  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
905  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
906  .addGroup(jPanel1Layout.createSequentialGroup()
907  .addGap(16, 16, 16)
908  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
909  .addComponent(mimeTypeLabel)
910  .addComponent(fileSizeLabel)
911  .addComponent(fileTypeLabel)
912  .addComponent(pathLabel)
913  .addComponent(modifiedDateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
914  .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
915  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
916  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
917  .addComponent(rulePathConditionTextField)
918  .addComponent(fileNameTextField, javax.swing.GroupLayout.Alignment.TRAILING)
919  .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
920  .addGroup(jPanel1Layout.createSequentialGroup()
921  .addComponent(equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
922  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
923  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
924  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
925  .addComponent(fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
926  .addGroup(jPanel1Layout.createSequentialGroup()
927  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
928  .addComponent(rulePathConditionRegexCheckBox)
929  .addGroup(jPanel1Layout.createSequentialGroup()
930  .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
931  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
932  .addComponent(daysIncludedLabel))
933  .addGroup(jPanel1Layout.createSequentialGroup()
934  .addComponent(filesRadioButton)
935  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
936  .addComponent(dirsRadioButton)
937  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
938  .addComponent(allRadioButton))
939  .addGroup(jPanel1Layout.createSequentialGroup()
940  .addComponent(fileNameRadioButton)
941  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
942  .addComponent(fileNameExtensionRadioButton)
943  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
944  .addComponent(fileNameRegexCheckbox)))
945  .addGap(0, 0, Short.MAX_VALUE)))))
946  .addGap(8, 8, 8))
947  .addGroup(jPanel1Layout.createSequentialGroup()
948  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
949  .addComponent(rulesListLabel)
950  .addGroup(jPanel1Layout.createSequentialGroup()
951  .addComponent(ignoreKnownFilesCheckbox)
952  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
953  .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
954  .addGroup(jPanel1Layout.createSequentialGroup()
955  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
956  .addComponent(descriptionLabel)
957  .addComponent(setDetailsLabel))
958  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
959  .addComponent(ingestWarningLabel))
960  .addComponent(ruleLabel)
961  .addGroup(jPanel1Layout.createSequentialGroup()
962  .addComponent(newRuleButton)
963  .addGap(18, 18, 18)
964  .addComponent(editRuleButton)
965  .addGap(18, 18, 18)
966  .addComponent(deleteRuleButton)))
967  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
968  );
969 
970  jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {copySetButton, deleteSetButton, editSetButton, exportSetButton, importSetButton, newSetButton});
971 
972  jPanel1Layout.setVerticalGroup(
973  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
974  .addGroup(jPanel1Layout.createSequentialGroup()
975  .addContainerGap()
976  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
977  .addComponent(separator)
978  .addGroup(jPanel1Layout.createSequentialGroup()
979  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
980  .addGroup(jPanel1Layout.createSequentialGroup()
981  .addComponent(setDetailsLabel)
982  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
983  .addComponent(descriptionLabel)
984  .addGap(1, 1, 1))
985  .addComponent(ingestWarningLabel, javax.swing.GroupLayout.Alignment.TRAILING))
986  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
987  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
988  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
989  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
990  .addComponent(ignoreKnownFilesCheckbox)
991  .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
992  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
993  .addComponent(rulesListLabel)
994  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
995  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
996  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
997  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
998  .addComponent(newRuleButton)
999  .addComponent(editRuleButton)
1000  .addComponent(deleteRuleButton))
1001  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1002  .addComponent(ruleLabel)
1003  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1004  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1005  .addComponent(fileTypeLabel)
1006  .addComponent(filesRadioButton)
1007  .addComponent(dirsRadioButton)
1008  .addComponent(allRadioButton))
1009  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1010  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1011  .addComponent(nameLabel)
1012  .addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
1013  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1014  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1015  .addComponent(fileNameRadioButton)
1016  .addComponent(fileNameExtensionRadioButton)
1017  .addComponent(fileNameRegexCheckbox))
1018  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1019  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1020  .addComponent(pathLabel)
1021  .addComponent(rulePathConditionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
1022  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1023  .addComponent(rulePathConditionRegexCheckBox)
1024  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1025  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1026  .addComponent(mimeTypeLabel)
1027  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1028  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1029  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1030  .addComponent(fileSizeLabel)
1031  .addComponent(equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1032  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1033  .addComponent(fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1034  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1035  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1036  .addComponent(modifiedDateLabel)
1037  .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1038  .addComponent(daysIncludedLabel))
1039  .addContainerGap())
1040  .addGroup(jPanel1Layout.createSequentialGroup()
1041  .addComponent(descriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1042  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1043  .addComponent(setsListLabel)
1044  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1045  .addComponent(setsListScrollPane)
1046  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1047  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1048  .addComponent(newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1049  .addComponent(editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1050  .addComponent(deleteSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1051  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1052  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
1053  .addComponent(copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1054  .addComponent(importSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1055  .addComponent(exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
1056  .addGap(6, 6, 6))))
1057  );
1058 
1059  jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {copySetButton, deleteRuleButton, deleteSetButton, editRuleButton, editSetButton, exportSetButton, importSetButton, newRuleButton, newSetButton});
1060 
1061  jScrollPane1.setViewportView(jPanel1);
1062 
1063  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
1064  this.setLayout(layout);
1065  layout.setHorizontalGroup(
1066  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
1067  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)
1068  );
1069  layout.setVerticalGroup(
1070  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
1071  .addComponent(jScrollPane1)
1072  );
1073  }// </editor-fold>//GEN-END:initComponents
1074 
1075  private void newSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newSetButtonActionPerformed
1076  this.doFileSetsDialog(null, true);
1077  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1078  }//GEN-LAST:event_newSetButtonActionPerformed
1079 
1080  private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteRuleButtonActionPerformed
1081  // Interesting file sets are immutable for thread safety,
1082  // so editing a files set rule definition is a replacement
1083  // operation. Preserve the existing rules from the set being
1084  // edited, except for the deleted rule.
1085  FilesSet oldSet = this.setsList.getSelectedValue();
1086  Map<String, FilesSet.Rule> rules = new HashMap<>(oldSet.getRules());
1087  FilesSet.Rule selectedRule = this.rulesList.getSelectedValue();
1088  rules.remove(selectedRule.getUuid());
1089  this.replaceFilesSet(oldSet, oldSet, rules);
1090  if (!this.rulesListModel.isEmpty()) {
1091  this.rulesList.setSelectedIndex(0);
1092  } else {
1093  this.resetRuleComponents();
1094  }
1095  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1096  }//GEN-LAST:event_deleteRuleButtonActionPerformed
1097 
1098  private void deleteSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSetButtonActionPerformed
1099  FilesSet selectedSet = this.setsList.getSelectedValue();
1100  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
1101  for (IngestProfile profile : IngestProfiles.getIngestProfiles()) {
1102  if (profile.getFileIngestFilter().equals(selectedSet.getName())) {
1103  MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
1104  "FilesSetDefsPanel.ingest.fileFilterInUseError",
1105  selectedSet.getName(), profile.toString()));
1106  return;
1107  }
1108  }
1109 
1110  }
1111  this.filesSets.remove(selectedSet.getName());
1112  this.setsListModel.removeElement(selectedSet);
1113  // Select the first of the remaining set definitions. This will cause
1114  // the selection listeners to repopulate the subordinate components.
1115  if (!this.filesSets.isEmpty()) {
1116  this.setsList.setSelectedIndex(0);
1117  } else {
1118  this.resetComponents();
1119  }
1120  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1121  }//GEN-LAST:event_deleteSetButtonActionPerformed
1122 
1123  private void editSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editSetButtonActionPerformed
1124  this.doFileSetsDialog(this.setsList.getSelectedValue(), false);
1125  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1126  }//GEN-LAST:event_editSetButtonActionPerformed
1127 
1128  private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editRuleButtonActionPerformed
1129  this.doFilesSetRuleDialog(this.rulesList.getSelectedValue());
1130  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1131  }//GEN-LAST:event_editRuleButtonActionPerformed
1132 
1133  private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newRuleButtonActionPerformed
1134  this.doFilesSetRuleDialog(null);
1135  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1136  }//GEN-LAST:event_newRuleButtonActionPerformed
1137 
1138  private void copySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copySetButtonActionPerformed
1139  this.doFileSetsDialog(this.setsList.getSelectedValue(), true);
1140  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1141  }//GEN-LAST:event_copySetButtonActionPerformed
1142 
1143  @NbBundle.Messages({
1144  "FilesSetDefsPanel.interesting.failImportMsg=Interesting files set not imported",
1145  "FilesSetDefsPanel.interesting.fileExtensionFilterLbl=Autopsy Interesting File Set File (xml)",
1146  "FilesSetDefsPanel.interesting.importButtonAction.featureName=Interesting Files Set Import",
1147  "FilesSetDefsPanel.importSetButtonActionPerformed.noFilesSelected=No files sets were selected.",
1148  "FilesSetDefsPanel.importSetButtonActionPerformed.noFiles=No files sets were found in the selected files.",
1149  "# {0} - fileName",
1150  "# {1} - errorMessage",
1151  "FilesSetDefsPanel.importSetButtonActionPerformed.importError=The rules file \"{0}\" could not be read:\n{1}.",})
1152  private void importSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSetButtonActionPerformed
1153  //save currently selected value as default value to select
1154  FilesSet selectedSet = this.setsList.getSelectedValue();
1155 
1156  File lastFolder = getLastUsedDirectory(LAST_IMPORT_PATH_KEY);
1157  importFileChooser.setCurrentDirectory(lastFolder);
1158 
1159  int returnVal = importFileChooser.showOpenDialog(this);
1160  if (returnVal == JFileChooser.APPROVE_OPTION) {
1161  File selFile = importFileChooser.getSelectedFile();
1162  if (selFile == null) {
1163  JOptionPane.showMessageDialog(this,
1164  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_noFilesSelected(),
1165  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1166  JOptionPane.WARNING_MESSAGE);
1167  logger.warning("Selected file was null, when trying to import interesting files set definitions");
1168  return;
1169  }
1170 
1171  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_IMPORT_PATH_KEY, selFile.getParent());
1172 
1173  Collection<FilesSet> importedSets;
1174  try {
1175  importedSets = InterestingItemsFilesSetSettings.readDefinitionsXML(selFile).values(); //read the xml from that path
1176  if (importedSets.isEmpty()) {
1177  JOptionPane.showMessageDialog(this,
1178  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_noFiles(),
1179  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1180  JOptionPane.WARNING_MESSAGE);
1181  logger.log(Level.WARNING, "No Interesting files set definitions were read from the selected file");
1182  return;
1183  }
1185  JOptionPane.showMessageDialog(this,
1186  Bundle.FilesSetDefsPanel_importSetButtonActionPerformed_importError(selFile.getName(), ex.getMessage()),
1187  Bundle.FilesSetDefsPanel_interesting_importButtonAction_featureName(),
1188  JOptionPane.WARNING_MESSAGE);
1189  logger.log(Level.WARNING, "No Interesting files set definitions were read from the selected file, exception", ex);
1190  return;
1191  }
1192 
1193  importedSets = importedSets
1194  .stream()
1195  .map((filesSet) -> StandardInterestingFilesSetsLoader.getAsStandardFilesSet(filesSet, false))
1196  .collect(Collectors.toList());
1197 
1198  FilesSet newSelected = determineFilesToImport(importedSets);
1199 
1200  // Redo the list model for the files set list component
1201  FilesSetDefsPanel.this.setsListModel.clear();
1202  this.filesSets.values().forEach((set) -> {
1203  this.setsListModel.addElement(set);
1204  });
1205  // Select the new/edited files set definition in the set definitions
1206  // list. This will cause the selection listeners to repopulate the
1207  // subordinate components.
1208  this.setsList.setSelectedValue(newSelected == null ? selectedSet : newSelected, true);
1209 
1210  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1211  }
1212 
1213  }//GEN-LAST:event_importSetButtonActionPerformed
1214 
1223  private File getLastUsedDirectory(String key) {
1224  File lastFolder = null;
1226  final String lastDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, key);
1227  File lastDirectoryFile = new File(lastDirectory);
1228  // Only select it if it exists.
1229  if (lastDirectoryFile.exists()) {
1230  lastFolder = lastDirectoryFile;
1231  }
1232  }
1233  return lastFolder;
1234  }
1235 
1244  private FilesSet determineFilesToImport(Collection<FilesSet> importedSets) {
1245  FilesSet selectedSet = null;
1246 
1247  for (FilesSet set : importedSets) {
1248  Pair<FilesSet, Integer> conflictResult = handleConflict(set, true);
1249  int choice = conflictResult.getRight();
1250  FilesSet resultingFilesSet = conflictResult.getLeft();
1251 
1252  if (choice == JOptionPane.OK_OPTION) {
1253  selectedSet = resultingFilesSet;
1254  this.filesSets.put(resultingFilesSet.getName(), resultingFilesSet);
1255  } else if (choice == JOptionPane.CANCEL_OPTION) {
1256  break;
1257  }
1258  }
1259 
1260  return selectedSet;
1261  }
1262 
1275  private Pair<FilesSet, Integer> handleConflict(FilesSet set, boolean isImport) {
1276  FilesSet conflict = this.filesSets.get(set.getName());
1277  // if no conflict, return the files set as is with the option to proceed
1278  if (conflict == null) {
1279  return Pair.of(set, JOptionPane.OK_OPTION);
1280  }
1281 
1282  if (isImport) {
1283  if (conflict.isStandardSet()) {
1284  return onImportStandardSetConflict(set);
1285  } else {
1286  return onImportConflict(set);
1287  }
1288  } else {
1289  if (conflict.isStandardSet()) {
1290  return onNewEditSetStandardSetConflict(set);
1291  } else {
1292  return onNewEditSetConflict(set);
1293  }
1294  }
1295 
1296  }
1297 
1308  @Messages({
1309  "FilesSetDefsPanel.yesOwMsg=Yes, overwrite",
1310  "FilesSetDefsPanel.noSkipMsg=No, skip",
1311  "FilesSetDefsPanel.cancelImportMsg=Cancel import",
1312  "# {0} - FilesSet name",
1313  "FilesSetDefsPanel.interesting.overwriteSetPrompt=Interesting files set \"{0}\" already exists locally, overwrite?",
1314  "FilesSetDefsPanel.interesting.importOwConflict=Import Interesting files set conflict",})
1315  private Pair<FilesSet, Integer> onImportConflict(FilesSet set) {
1316  // if there is a conflict, see if it is okay to overwrite.
1317  Object[] options = {
1318  Bundle.FilesSetDefsPanel_yesOwMsg(),
1319  Bundle.FilesSetDefsPanel_noSkipMsg(),
1320  Bundle.FilesSetDefsPanel_cancelImportMsg()
1321  };
1322  int conflictChoice = JOptionPane.showOptionDialog(this,
1323  Bundle.FilesSetDefsPanel_interesting_overwriteSetPrompt(set.getName()),
1324  Bundle.FilesSetDefsPanel_interesting_importOwConflict(),
1325  JOptionPane.YES_NO_CANCEL_OPTION,
1326  JOptionPane.QUESTION_MESSAGE,
1327  null,
1328  options,
1329  options[0]);
1330 
1331  if (conflictChoice == JOptionPane.OK_OPTION) {
1332  // if so, just return the files set to be placed in the map overwriting what is currently present.
1333  return Pair.of(set, conflictChoice);
1334  }
1335 
1336  return Pair.of(null, conflictChoice);
1337  }
1338 
1349  @Messages({
1350  "FilesSetDefsPanel.yesStandardFileConflictCreate=Yes, create",
1351  "# {0} - FilesSet name",
1352  "# {1} - New FilesSet name",
1353  "FilesSetDefsPanel.interesting.standardFileConflict=A standard interesting file set already exists with the name \"{0}.\" Would you like to rename your set to \"{1}?\"",})
1354  private Pair<FilesSet, Integer> onImportStandardSetConflict(FilesSet set) {
1355  // if there is a conflict and the conflicting files set is a standard files set,
1356  // see if allowing a custom files set is okay.
1357  Object[] options = {
1358  Bundle.FilesSetDefsPanel_yesStandardFileConflictCreate(),
1359  Bundle.FilesSetDefsPanel_noSkipMsg(),
1360  Bundle.FilesSetDefsPanel_cancelImportMsg()
1361  };
1362 
1363  String setName = set.getName();
1364  String customSetName = Bundle.StandardInterestingFileSetsLoader_customSuffixed(set.getName());
1365 
1366  int conflictChoice = JOptionPane.showOptionDialog(this,
1367  Bundle.FilesSetDefsPanel_interesting_standardFileConflict(setName, customSetName),
1368  Bundle.FilesSetDefsPanel_interesting_importOwConflict(),
1369  JOptionPane.YES_NO_CANCEL_OPTION,
1370  JOptionPane.QUESTION_MESSAGE,
1371  null,
1372  options,
1373  options[0]);
1374 
1375  // if it is okay to create with custom prefix, try again to see if there is a conflict.
1376  if (conflictChoice == JOptionPane.OK_OPTION) {
1377  return handleConflict(StandardInterestingFilesSetsLoader.getAsCustomFileSet(set), true);
1378  }
1379 
1380  return Pair.of(null, conflictChoice);
1381  }
1382 
1393  @Messages({
1394  "FilesSetDefsPanel.cancelNewSetMsg=Cancel",
1395  "FilesSetDefsPanel.interesting.newOwConflict=Interesting files set conflict",})
1396  private Pair<FilesSet, Integer> onNewEditSetConflict(FilesSet set) {
1397  // if there is a conflict, see if it is okay to overwrite.
1398  Object[] options = {
1399  Bundle.FilesSetDefsPanel_yesOwMsg(),
1400  Bundle.FilesSetDefsPanel_cancelNewSetMsg()
1401  };
1402  int conflictChoice = JOptionPane.showOptionDialog(this,
1403  Bundle.FilesSetDefsPanel_interesting_overwriteSetPrompt(set.getName()),
1404  Bundle.FilesSetDefsPanel_interesting_newOwConflict(),
1405  JOptionPane.OK_CANCEL_OPTION,
1406  JOptionPane.QUESTION_MESSAGE,
1407  null,
1408  options,
1409  options[0]);
1410 
1411  if (conflictChoice == JOptionPane.OK_OPTION) {
1412  // if so, just return the files set to be placed in the map overwriting what is currently present.
1413  return Pair.of(set, conflictChoice);
1414  }
1415 
1416  return Pair.of(null, conflictChoice);
1417  }
1418 
1429  private Pair<FilesSet, Integer> onNewEditSetStandardSetConflict(FilesSet set) {
1430  // if there is a conflict and the conflicting files set is a standard files set,
1431  // see if allowing a custom files set is okay.
1432  Object[] options = {
1433  Bundle.FilesSetDefsPanel_yesStandardFileConflictCreate(),
1434  Bundle.FilesSetDefsPanel_cancelNewSetMsg()
1435  };
1436 
1437  String setName = set.getName();
1438  String customSetName = Bundle.StandardInterestingFileSetsLoader_customSuffixed(set.getName());
1439 
1440  int conflictChoice = JOptionPane.showOptionDialog(this,
1441  Bundle.FilesSetDefsPanel_interesting_standardFileConflict(setName, customSetName),
1442  Bundle.FilesSetDefsPanel_interesting_newOwConflict(),
1443  JOptionPane.OK_CANCEL_OPTION,
1444  JOptionPane.QUESTION_MESSAGE,
1445  null,
1446  options,
1447  options[0]);
1448 
1449  // if it is okay to create with custom prefix, try again to see if there is a conflict.
1450  if (conflictChoice == JOptionPane.OK_OPTION) {
1451  return handleConflict(StandardInterestingFilesSetsLoader.getAsCustomFileSet(set), false);
1452  }
1453 
1454  return Pair.of(null, conflictChoice);
1455  }
1456 
1457  @NbBundle.Messages({"FilesSetDefsPanel.interesting.exportButtonAction.featureName=Interesting Files Set Export",
1458  "# {0} - file name",
1459  "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt=File {0} exists, overwrite?",
1460  "FilesSetDefsPanel.interesting.ExportedMsg=Interesting files set exported",
1461  "FilesSetDefsPanel.interesting.failExportMsg=Export of interesting files set failed"})
1462  private void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportSetButtonActionPerformed
1463  //display warning that existing filessets with duplicate names will be overwritten
1464  //create file chooser to get xml filefinal String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
1465  exportFileChooser.setSelectedFile(new File(this.setsList.getSelectedValue().getName()));
1466 
1467  final File lastDirectory = getLastUsedDirectory(LAST_EXPORT_PATH_KEY);
1468  exportFileChooser.setCurrentDirectory(lastDirectory);
1469 
1470  int returnVal = exportFileChooser.showSaveDialog(this);
1471  if (returnVal == JFileChooser.APPROVE_OPTION) {
1472  final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
1473  "FilesSetDefsPanel.interesting.exportButtonAction.featureName");
1474  File selFile = exportFileChooser.getSelectedFile();
1475  if (selFile == null) {
1476  JOptionPane.showMessageDialog(this,
1477  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.failExportMsg"),
1478  FEATURE_NAME,
1479  JOptionPane.WARNING_MESSAGE);
1480  logger.warning("Selected file was null, when trying to export interesting files set definitions");
1481  return;
1482  }
1483 
1484  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_EXPORT_PATH_KEY, selFile.getParent());
1485 
1486  //force append extension if not given
1487  String fileAbs = selFile.getAbsolutePath();
1488  if (!fileAbs.endsWith("." + XML_EXTENSION)) {
1489  fileAbs = fileAbs + "." + XML_EXTENSION;
1490  selFile = new File(fileAbs);
1491  }
1492  if (selFile.exists()) {
1493  //if the file already exists ask the user how to proceed
1494  final String FILE_EXISTS_MESSAGE = NbBundle.getMessage(this.getClass(),
1495  "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt", selFile.getName());
1496  boolean shouldWrite = JOptionPane.showConfirmDialog(this, FILE_EXISTS_MESSAGE, FEATURE_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION;
1497  if (!shouldWrite) {
1498  return;
1499  }
1500  }
1501  List<FilesSet> exportSets;
1502  exportSets = new ArrayList<>();
1503  //currently only exports selectedValue
1504  exportSets.add(this.setsList.getSelectedValue());
1505  boolean written = InterestingItemsFilesSetSettings.exportXmlDefinitionsFile(selFile, exportSets);
1506  if (written) {
1507  JOptionPane.showMessageDialog(
1508  WindowManager.getDefault().getMainWindow(),
1509  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.ExportedMsg"),
1510  FEATURE_NAME,
1511  JOptionPane.INFORMATION_MESSAGE);
1512  } else {
1513  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
1514  NbBundle.getMessage(this.getClass(), "FilesSetDefsPanel.interesting.failExportMsg"),
1515  FEATURE_NAME,
1516  JOptionPane.WARNING_MESSAGE);
1517  logger.warning("Export of interesting files set failed unable to write definitions xml file");
1518  }
1519  }
1520  }//GEN-LAST:event_exportSetButtonActionPerformed
1521 
1522  private void fileNameRegexCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileNameRegexCheckboxActionPerformed
1523  // TODO add your handling code here:
1524  }//GEN-LAST:event_fileNameRegexCheckboxActionPerformed
1525 
1526  // Variables declaration - do not modify//GEN-BEGIN:variables
1527  private javax.swing.JRadioButton allRadioButton;
1528  private javax.swing.JButton copySetButton;
1529  private javax.swing.JLabel daysIncludedLabel;
1530  private javax.swing.JTextField daysIncludedTextField;
1531  private javax.swing.JButton deleteRuleButton;
1532  private javax.swing.JButton deleteSetButton;
1533  private javax.swing.JLabel descriptionLabel;
1534  private javax.swing.JScrollPane descriptionScrollPane;
1535  private javax.swing.JTextArea descriptionTextArea;
1536  private javax.swing.JRadioButton dirsRadioButton;
1537  private javax.swing.JButton editRuleButton;
1538  private javax.swing.JButton editSetButton;
1539  private javax.swing.JComboBox<String> equalitySignComboBox;
1540  private javax.swing.JButton exportSetButton;
1541  private javax.swing.ButtonGroup fileNameButtonGroup;
1542  private javax.swing.JRadioButton fileNameExtensionRadioButton;
1543  private javax.swing.JRadioButton fileNameRadioButton;
1544  private javax.swing.JCheckBox fileNameRegexCheckbox;
1545  private javax.swing.JTextField fileNameTextField;
1546  private javax.swing.JLabel fileSizeLabel;
1547  private javax.swing.JSpinner fileSizeSpinner;
1548  private javax.swing.JComboBox<String> fileSizeUnitComboBox;
1549  private javax.swing.JLabel fileTypeLabel;
1550  private javax.swing.JRadioButton filesRadioButton;
1551  private javax.swing.JCheckBox ignoreKnownFilesCheckbox;
1552  private javax.swing.JButton importSetButton;
1553  private javax.swing.JLabel ingestWarningLabel;
1554  private javax.swing.JCheckBox ingoreUnallocCheckbox;
1555  private javax.swing.JPanel jPanel1;
1556  private javax.swing.JScrollPane jScrollPane1;
1557  private javax.swing.JComboBox<String> mimeTypeComboBox;
1558  private javax.swing.JLabel mimeTypeLabel;
1559  private javax.swing.JLabel modifiedDateLabel;
1560  private javax.swing.JLabel nameLabel;
1561  private javax.swing.JButton newRuleButton;
1562  private javax.swing.JButton newSetButton;
1563  private javax.swing.JLabel pathLabel;
1564  private javax.swing.JLabel ruleLabel;
1565  private javax.swing.JCheckBox rulePathConditionRegexCheckBox;
1566  private javax.swing.JTextField rulePathConditionTextField;
1567  private javax.swing.JList<FilesSet.Rule> rulesList;
1568  private javax.swing.JLabel rulesListLabel;
1569  private javax.swing.JScrollPane rulesListScrollPane;
1570  private javax.swing.JSeparator separator;
1571  private javax.swing.JScrollPane setDescScrollPanel;
1572  private javax.swing.JTextArea setDescriptionTextArea;
1573  private javax.swing.JLabel setDetailsLabel;
1574  private javax.swing.JList<FilesSet> setsList;
1575  private javax.swing.JLabel setsListLabel;
1576  private javax.swing.JScrollPane setsListScrollPane;
1577  private javax.swing.ButtonGroup typeButtonGroup;
1578  // End of variables declaration//GEN-END:variables
1579 
1580 }
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-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.