19 package org.sleuthkit.autopsy.modules.interestingitems;
 
   21 import java.awt.event.ActionEvent;
 
   22 import java.util.List;
 
   23 import java.util.SortedSet;
 
   24 import java.util.logging.Level;
 
   25 import java.util.regex.Pattern;
 
   26 import java.util.regex.PatternSyntaxException;
 
   27 import javax.swing.JButton;
 
   28 import javax.swing.JComponent;
 
   29 import javax.swing.JOptionPane;
 
   30 import org.openide.DialogDisplayer;
 
   31 import org.openide.NotifyDescriptor;
 
   32 import org.openide.util.NbBundle;
 
   33 import org.openide.util.NbBundle.Messages;
 
   41 final class FilesSetRulePanel 
extends javax.swing.JPanel {
 
   44         "FilesSetRulePanel.bytes=Bytes",
 
   45         "FilesSetRulePanel.kiloBytes=Kilobytes",
 
   46         "FilesSetRulePanel.megaBytes=Megabytes",
 
   47         "FilesSetRulePanel.gigaBytes=Gigabytes",
 
   48         "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
 
   49         "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
 
   50         "FilesSetRulePanel.NoNameError=Name cannot be empty",
 
   51         "FilesSetRulePanel.NoPathError=Path cannot be empty",
 
   52         "FilesSetRulePanel.DaysIncludedEmptyError=Number of days included cannot be empty.",
 
   53         "FilesSetRulePanel.DaysIncludedInvalidError=Number of days included must be a positive integer.",
 
   54         "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)." 
   57     private static final long serialVersionUID = 1L;
 
   58     private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
 
   59     private static final String SLEUTHKIT_PATH_SEPARATOR = 
"/"; 
 
   60     private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
 
   61     private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
 
   62     private JButton okButton;
 
   63     private JButton cancelButton;
 
   68     FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
 
   70         if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { 
 
   71             mimeTypeComboBox.setVisible(
false);
 
   72             mimeCheck.setVisible(
false);
 
   73             fileSizeComboBox.setVisible(
false);
 
   74             fileSizeCheck.setVisible(
false);
 
   75             equalitySymbolComboBox.setVisible(
false);
 
   76             fileSizeSpinner.setVisible(
false);
 
   77             jLabel1.setVisible(
false);
 
   78             filesRadioButton.setVisible(
false);
 
   79             dirsRadioButton.setVisible(
false);
 
   80             allRadioButton.setVisible(
false);
 
   81             org.openide.awt.Mnemonics.setLocalizedText(jLabel5, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.ingest.jLabel5.text")); 
 
   84             populateMimeTypesComboBox();
 
   86         this.dateCheckActionPerformed(null);
 
   87         populateComponentsWithDefaultValues();
 
   88         this.setButtons(okButton, cancelButton);
 
   96     FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
 
   98         if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { 
 
   99             mimeTypeComboBox.setVisible(
false);
 
  100             mimeCheck.setVisible(
false);
 
  101             fileSizeComboBox.setVisible(
false);
 
  102             fileSizeCheck.setVisible(
false);
 
  103             equalitySymbolComboBox.setVisible(
false);
 
  104             fileSizeSpinner.setVisible(
false);
 
  105             jLabel1.setVisible(
false);
 
  106             filesRadioButton.setVisible(
false);
 
  107             dirsRadioButton.setVisible(
false);
 
  108             allRadioButton.setVisible(
false);
 
  110             populateMimeTypesComboBox();
 
  111             populateMimeConditionComponents(rule);
 
  112             populateSizeConditionComponents(rule);
 
  115         populateMimeTypesComboBox();
 
  116         populateRuleNameComponent(rule);
 
  117         populateTypeConditionComponents(rule);
 
  118         populateNameConditionComponents(rule);
 
  119         populatePathConditionComponents(rule);
 
  120         populateDateConditionComponents(rule);
 
  121         this.setButtons(okButton, cancelButton);
 
  127     private void populateComponentsWithDefaultValues() {
 
  128         this.filesRadioButton.setSelected(
true);
 
  129         this.fullNameRadioButton.setSelected(
true);
 
  130         this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
 
  131         this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
 
  132         this.mimeTypeComboBox.setSelectedIndex(0);
 
  135     private void populateMimeTypesComboBox() {
 
  137             SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
 
  138             detectableMimeTypes.forEach((type) -> {
 
  139                 mimeTypeComboBox.addItem(type);
 
  141         } 
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
 
  142             logger.log(Level.SEVERE, 
"Unable to get detectable file types", ex);
 
  152     private void populateRuleNameComponent(FilesSet.Rule rule) {
 
  153         this.ruleNameTextField.setText(rule.getName());
 
  156     private void populateMimeConditionComponents(FilesSet.Rule rule) {
 
  157         FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
 
  158         if (mimeTypeCondition != null) {
 
  159             this.mimeCheck.setSelected(
true);
 
  160             this.mimeCheckActionPerformed(null);
 
  161             this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
 
  165     private void populateSizeConditionComponents(FilesSet.Rule rule) {
 
  166         FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
 
  167         if (fileSizeCondition != null) {
 
  168             this.fileSizeCheck.setSelected(
true);
 
  169             this.fileSizeCheckActionPerformed(null);
 
  170             this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
 
  171             this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
 
  172             this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
 
  180     private void setOkButton() {
 
  181         if (this.okButton != null) {
 
  182             this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
 
  183                     || this.nameCheck.isSelected() || this.pathCheck.isSelected() || this.dateCheck.isSelected());
 
  194     private JOptionPane getOptionPane(JComponent parent) {
 
  196         if (!(parent instanceof JOptionPane)) {
 
  197             pane = getOptionPane((JComponent) parent.getParent());
 
  199             pane = (JOptionPane) parent;
 
  210     private void setButtons(JButton ok, JButton cancel) {
 
  212         this.cancelButton = cancel;
 
  213         okButton.addActionListener((ActionEvent e) -> {
 
  214             JOptionPane pane = getOptionPane(okButton);
 
  215             pane.setValue(okButton);
 
  217         cancelButton.addActionListener((ActionEvent e) -> {
 
  218             JOptionPane pane = getOptionPane(cancelButton);
 
  219             pane.setValue(cancelButton);
 
  230     private void populateTypeConditionComponents(FilesSet.Rule rule) {
 
  231         FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
 
  232         switch (typeCondition.getMetaType()) {
 
  234                 this.filesRadioButton.setSelected(
true);
 
  237                 this.dirsRadioButton.setSelected(
true);
 
  240                 this.allRadioButton.setSelected(
true);
 
  250     private void populateNameConditionComponents(FilesSet.Rule rule) {
 
  251         FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
 
  252         if (nameCondition != null) {
 
  253             this.nameCheck.setSelected(
true);
 
  254             this.nameCheckActionPerformed(null);
 
  255             this.nameTextField.setText(nameCondition.getTextToMatch());
 
  256             this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
 
  257             if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
 
  258                 this.fullNameRadioButton.setSelected(
true);
 
  260                 this.extensionRadioButton.setSelected(
true);
 
  271     private void populatePathConditionComponents(FilesSet.Rule rule) {
 
  272         FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
 
  273         if (pathCondition != null) {
 
  274             this.pathCheck.setSelected(
true);
 
  275             this.pathCheckActionPerformed(null);
 
  276             this.pathTextField.setText(pathCondition.getTextToMatch());
 
  277             this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
 
  287     private void populateDateConditionComponents(FilesSet.Rule rule) {
 
  288         FilesSet.Rule.DateCondition dateCondition = rule.getDateCondition();
 
  289         if (dateCondition != null) {
 
  290             this.dateCheck.setSelected(
true);
 
  291             this.dateCheckActionPerformed(null);
 
  292             this.daysIncludedTextField.setText(Integer.toString(dateCondition.getDaysIncluded()));
 
  303     boolean isValidRuleDefinition() {
 
  305         if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected() || this.dateCheck.isSelected())) {
 
  306             NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  307                     Bundle.FilesSetRulePanel_NoConditionError(),
 
  308                     NotifyDescriptor.WARNING_MESSAGE);
 
  309             DialogDisplayer.getDefault().notify(notifyDesc);
 
  313         if (this.nameCheck.isSelected()) {
 
  316             if (this.nameTextField.getText().isEmpty()) {
 
  317                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  318                         Bundle.FilesSetRulePanel_NoNameError(),
 
  319                         NotifyDescriptor.WARNING_MESSAGE);
 
  320                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  323             if (this.nameRegexCheckbox.isSelected()) {
 
  325                     Pattern.compile(this.nameTextField.getText());
 
  326                 } 
catch (PatternSyntaxException ex) {
 
  327                     NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  328                             NbBundle.getMessage(FilesSetPanel.class, 
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
 
  329                             NotifyDescriptor.WARNING_MESSAGE);
 
  330                     DialogDisplayer.getDefault().notify(notifyDesc);
 
  333             } 
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
 
  334                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  335                         NbBundle.getMessage(FilesSetPanel.class, 
"FilesSetRulePanel.messages.invalidCharInName"),
 
  336                         NotifyDescriptor.WARNING_MESSAGE);
 
  337                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  344         if (this.pathCheck.isSelected()) {
 
  345             if (this.pathTextField.getText().isEmpty()) {
 
  346                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  347                         Bundle.FilesSetRulePanel_NoPathError(),
 
  348                         NotifyDescriptor.WARNING_MESSAGE);
 
  349                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  352             if (this.pathRegexCheckBox.isSelected()) {
 
  354                     Pattern.compile(this.pathTextField.getText());
 
  355                 } 
catch (PatternSyntaxException ex) {
 
  356                     NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  357                             NbBundle.getMessage(FilesSetPanel.class, 
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
 
  358                             NotifyDescriptor.WARNING_MESSAGE);
 
  359                     DialogDisplayer.getDefault().notify(notifyDesc);
 
  362             } 
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
 
  363                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  364                         NbBundle.getMessage(FilesSetPanel.class, 
"FilesSetRulePanel.messages.invalidCharInPath"),
 
  365                         NotifyDescriptor.WARNING_MESSAGE);
 
  366                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  370         if (this.mimeCheck.isSelected()) {
 
  371             if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
 
  372                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  373                         Bundle.FilesSetRulePanel_NoMimeTypeError(),
 
  374                         NotifyDescriptor.WARNING_MESSAGE);
 
  375                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  379         if (this.fileSizeCheck.isSelected()) {
 
  380             if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
 
  381                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  382                         Bundle.FilesSetRulePanel_ZeroFileSizeError(),
 
  383                         NotifyDescriptor.WARNING_MESSAGE);
 
  384                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  389         if (this.dateCheck.isSelected()) {
 
  390             if (this.daysIncludedTextField.getText().isEmpty()) {
 
  391                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  392                         Bundle.FilesSetRulePanel_DaysIncludedEmptyError(),
 
  393                         NotifyDescriptor.WARNING_MESSAGE);
 
  394                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  398                 int value = Integer.parseInt(daysIncludedTextField.getText());
 
  400                     throw new NumberFormatException(
"Negative numbers are not allowed for the within N days condition");
 
  402             } 
catch (NumberFormatException e) {
 
  404                 NotifyDescriptor notifyDesc = 
new NotifyDescriptor.Message(
 
  405                         Bundle.FilesSetRulePanel_DaysIncludedInvalidError(),
 
  406                         NotifyDescriptor.WARNING_MESSAGE);
 
  407                 DialogDisplayer.getDefault().notify(notifyDesc);
 
  419     String getRuleName() {
 
  420         return this.ruleNameTextField.getText();
 
  432     FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
 
  433         FilesSet.Rule.FileNameCondition condition = null;
 
  434         if (!this.nameTextField.getText().isEmpty()) {
 
  435             if (this.nameRegexCheckbox.isSelected()) {
 
  437                     Pattern pattern = Pattern.compile(this.nameTextField.getText());
 
  438                     if (this.fullNameRadioButton.isSelected()) {
 
  439                         condition = 
new FilesSet.Rule.FullNameCondition(pattern);
 
  441                         condition = 
new FilesSet.Rule.ExtensionCondition(pattern);
 
  443                 } 
catch (PatternSyntaxException ex) {
 
  444                     logger.log(Level.SEVERE, 
"Attempt to get regex name condition that does not compile", ex); 
 
  445                     throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state"); 
 
  447             } 
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
 
  448                 if (this.fullNameRadioButton.isSelected()) {
 
  449                     condition = 
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
 
  451                     condition = 
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
 
  454                 logger.log(Level.SEVERE, 
"Attempt to get name condition with illegal chars"); 
 
  455                 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state"); 
 
  466     FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
 
  467         FilesSet.Rule.MimeTypeCondition condition = null;
 
  468         if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
 
  469             condition = 
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
 
  479     FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
 
  480         FilesSet.Rule.FileSizeCondition condition = null;
 
  481         if (this.fileSizeCheck.isSelected()) {
 
  482             if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
 
  483                 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
 
  484                 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
 
  485                 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
 
  486                 condition = 
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
 
  498     FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
 
  499         if (this.filesRadioButton.isSelected()) {
 
  500             return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
 
  501         } 
else if (this.dirsRadioButton.isSelected()) {
 
  502             return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
 
  504             return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
 
  517     FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
 
  518         FilesSet.Rule.ParentPathCondition condition = null;
 
  519         if (!this.pathTextField.getText().isEmpty()) {
 
  520             if (this.pathRegexCheckBox.isSelected()) {
 
  522                     condition = 
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
 
  523                 } 
catch (PatternSyntaxException ex) {
 
  524                     logger.log(Level.SEVERE, 
"Attempt to get malformed path condition", ex); 
 
  525                     throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state"); 
 
  528                 String path = this.pathTextField.getText();
 
  529                 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
 
  531                     if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
 
  532                         path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
 
  535                     if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
 
  536                         path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
 
  538                     condition = 
new FilesSet.Rule.ParentPathCondition(path);
 
  540                     logger.log(Level.SEVERE, 
"Attempt to get path condition with illegal chars"); 
 
  541                     throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state"); 
 
  557     FilesSet.Rule.DateCondition getDateCondition() {
 
  558         FilesSet.Rule.DateCondition dateCondition = null;
 
  559         if (!daysIncludedTextField.getText().isEmpty()) {
 
  560             dateCondition = 
new FilesSet.Rule.DateCondition(Integer.parseInt(daysIncludedTextField.getText()));
 
  562         return dateCondition;
 
  574     private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
 
  575         for (String illegalChar : illegalChars) {
 
  576             if (toBeChecked.contains(illegalChar)) {
 
  587     private void setComponentsForSearchType() {
 
  588         if (!this.filesRadioButton.isSelected()) {
 
  589             this.fullNameRadioButton.setSelected(
true);
 
  590             this.extensionRadioButton.setEnabled(
false);
 
  591             this.mimeTypeComboBox.setEnabled(
false);
 
  592             this.mimeTypeComboBox.setSelectedIndex(0);
 
  593             this.equalitySymbolComboBox.setEnabled(
false);
 
  594             this.fileSizeComboBox.setEnabled(
false);
 
  595             this.fileSizeSpinner.setEnabled(
false);
 
  596             this.fileSizeSpinner.setValue(0);
 
  597             this.fileSizeCheck.setEnabled(
false);
 
  598             this.fileSizeCheck.setSelected(
false);
 
  599             this.mimeCheck.setEnabled(
false);
 
  600             this.mimeCheck.setSelected(
false);
 
  602             if (this.nameCheck.isSelected()) {
 
  603                 this.extensionRadioButton.setEnabled(
true);
 
  605             this.fileSizeCheck.setEnabled(
true);
 
  606             this.mimeCheck.setEnabled(
true);
 
  615     @SuppressWarnings(
"unchecked")
 
  617     private 
void initComponents() {
 
  619         nameButtonGroup = 
new javax.swing.ButtonGroup();
 
  620         typeButtonGroup = 
new javax.swing.ButtonGroup();
 
  621         ruleNameLabel = 
new javax.swing.JLabel();
 
  622         ruleNameTextField = 
new javax.swing.JTextField();
 
  623         jLabel1 = 
new javax.swing.JLabel();
 
  624         nameTextField = 
new javax.swing.JTextField();
 
  625         fullNameRadioButton = 
new javax.swing.JRadioButton();
 
  626         extensionRadioButton = 
new javax.swing.JRadioButton();
 
  627         nameRegexCheckbox = 
new javax.swing.JCheckBox();
 
  628         pathTextField = 
new javax.swing.JTextField();
 
  629         pathRegexCheckBox = 
new javax.swing.JCheckBox();
 
  630         pathSeparatorInfoLabel = 
new javax.swing.JLabel();
 
  631         jLabel5 = 
new javax.swing.JLabel();
 
  632         mimeTypeComboBox = 
new javax.swing.JComboBox<String>();
 
  633         equalitySymbolComboBox = 
new javax.swing.JComboBox<String>();
 
  634         fileSizeComboBox = 
new javax.swing.JComboBox<String>();
 
  635         fileSizeSpinner = 
new javax.swing.JSpinner();
 
  636         nameCheck = 
new javax.swing.JCheckBox();
 
  637         pathCheck = 
new javax.swing.JCheckBox();
 
  638         mimeCheck = 
new javax.swing.JCheckBox();
 
  639         fileSizeCheck = 
new javax.swing.JCheckBox();
 
  640         filesRadioButton = 
new javax.swing.JRadioButton();
 
  641         dirsRadioButton = 
new javax.swing.JRadioButton();
 
  642         allRadioButton = 
new javax.swing.JRadioButton();
 
  643         daysIncludedTextField = 
new javax.swing.JTextField();
 
  644         daysIncludedLabel = 
new javax.swing.JLabel();
 
  645         dateCheck = 
new javax.swing.JCheckBox();
 
  647         org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.ruleNameLabel.text")); 
 
  649         ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.ruleNameTextField.text")); 
 
  651         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.jLabel1.text")); 
 
  653         nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.nameTextField.text")); 
 
  654         nameTextField.setEnabled(
false);
 
  656         nameButtonGroup.add(fullNameRadioButton);
 
  657         org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.fullNameRadioButton.text")); 
 
  658         fullNameRadioButton.setEnabled(
false);
 
  660         nameButtonGroup.add(extensionRadioButton);
 
  661         org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.extensionRadioButton.text")); 
 
  662         extensionRadioButton.setEnabled(
false);
 
  664         org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.nameRegexCheckbox.text")); 
 
  665         nameRegexCheckbox.setEnabled(
false);
 
  667         pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.pathTextField.text")); 
 
  668         pathTextField.setEnabled(
false);
 
  670         org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.pathRegexCheckBox.text")); 
 
  671         pathRegexCheckBox.setEnabled(
false);
 
  673         pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png"))); 
 
  674         org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.pathSeparatorInfoLabel.text")); 
 
  675         pathSeparatorInfoLabel.setEnabled(
false);
 
  677         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.interesting.jLabel5.text")); 
 
  679         mimeTypeComboBox.setEditable(
true);
 
  680         mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
 
  681         mimeTypeComboBox.setEnabled(
false);
 
  683         equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { 
"=", 
">", 
"≥", 
"<", 
"≤" }));
 
  684         equalitySymbolComboBox.setEnabled(
false);
 
  686         fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
 
  687         fileSizeComboBox.setEnabled(
false);
 
  689         fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
 
  690         fileSizeSpinner.setEnabled(
false);
 
  692         org.openide.awt.Mnemonics.setLocalizedText(nameCheck, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.nameCheck.text")); 
 
  693         nameCheck.addActionListener(
new java.awt.event.ActionListener() {
 
  694             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  695                 nameCheckActionPerformed(evt);
 
  699         org.openide.awt.Mnemonics.setLocalizedText(pathCheck, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.pathCheck.text")); 
 
  700         pathCheck.addActionListener(
new java.awt.event.ActionListener() {
 
  701             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  702                 pathCheckActionPerformed(evt);
 
  706         org.openide.awt.Mnemonics.setLocalizedText(mimeCheck, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.mimeCheck.text")); 
 
  707         mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
 
  708             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  709                 mimeCheckActionPerformed(evt);
 
  713         org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.fileSizeCheck.text")); 
 
  714         fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
 
  715             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  716                 fileSizeCheckActionPerformed(evt);
 
  720         typeButtonGroup.add(filesRadioButton);
 
  721         org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.filesRadioButton.text")); 
 
  722         filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
 
  723             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  724                 filesRadioButtonActionPerformed(evt);
 
  728         typeButtonGroup.add(dirsRadioButton);
 
  729         org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.dirsRadioButton.text")); 
 
  730         dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
 
  731             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  732                 dirsRadioButtonActionPerformed(evt);
 
  736         typeButtonGroup.add(allRadioButton);
 
  737         org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.allRadioButton.text")); 
 
  738         allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
 
  739             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  740                 allRadioButtonActionPerformed(evt);
 
  744         daysIncludedTextField.setEnabled(
false);
 
  745         daysIncludedTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
 
  746         daysIncludedTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
 
  748         org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.daysIncludedLabel.text")); 
 
  750         org.openide.awt.Mnemonics.setLocalizedText(dateCheck, 
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, 
"FilesSetRulePanel.dateCheck.text")); 
 
  751         dateCheck.addActionListener(
new java.awt.event.ActionListener() {
 
  752             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  753                 dateCheckActionPerformed(evt);
 
  757         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  758         this.setLayout(layout);
 
  759         layout.setHorizontalGroup(
 
  760             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  761             .addGroup(layout.createSequentialGroup()
 
  762                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  763                     .addGroup(layout.createSequentialGroup()
 
  765                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  766                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
 
  767                                 .addComponent(ruleNameLabel)
 
  769                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  770                                     .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  771                                     .addComponent(pathTextField)
 
  772                                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
 
  773                                         .addComponent(equalitySymbolComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  774                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  775                                         .addComponent(fileSizeSpinner)
 
  776                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  777                                         .addComponent(fileSizeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  778                                     .addGroup(layout.createSequentialGroup()
 
  779                                         .addComponent(pathRegexCheckBox)
 
  780                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  781                                         .addComponent(pathSeparatorInfoLabel))
 
  782                                     .addGroup(layout.createSequentialGroup()
 
  783                                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  784                                             .addGroup(layout.createSequentialGroup()
 
  785                                                 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  786                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  787                                                 .addComponent(daysIncludedLabel))
 
  788                                             .addComponent(ruleNameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
 
  789                                             .addGroup(layout.createSequentialGroup()
 
  790                                                 .addComponent(fullNameRadioButton)
 
  791                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  792                                                 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  793                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  794                                                 .addComponent(nameRegexCheckbox)))
 
  796                             .addComponent(jLabel5)
 
  797                             .addGroup(layout.createSequentialGroup()
 
  798                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  799                                     .addComponent(nameCheck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  800                                     .addComponent(jLabel1))
 
  802                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  803                                     .addGroup(layout.createSequentialGroup()
 
  804                                         .addComponent(filesRadioButton)
 
  805                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  806                                         .addComponent(dirsRadioButton)
 
  807                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  808                                         .addComponent(allRadioButton))
 
  809                                     .addComponent(nameTextField)))))
 
  810                     .addGroup(layout.createSequentialGroup()
 
  812                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  813                             .addComponent(pathCheck)
 
  814                             .addComponent(mimeCheck)
 
  815                             .addComponent(fileSizeCheck)
 
  816                             .addComponent(dateCheck))
 
  817                         .addGap(0, 0, Short.MAX_VALUE)))
 
  820         layout.setVerticalGroup(
 
  821             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  822             .addGroup(layout.createSequentialGroup()
 
  823                 .addComponent(jLabel5)
 
  825                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  826                     .addGroup(layout.createSequentialGroup()
 
  827                         .addComponent(jLabel1)
 
  829                         .addComponent(nameCheck))
 
  830                     .addGroup(layout.createSequentialGroup()
 
  831                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  832                             .addComponent(filesRadioButton)
 
  833                             .addComponent(dirsRadioButton)
 
  834                             .addComponent(allRadioButton))
 
  835                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  836                         .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  837                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  838                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  839                     .addComponent(fullNameRadioButton)
 
  840                     .addComponent(extensionRadioButton)
 
  841                     .addComponent(nameRegexCheckbox))
 
  842                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  843                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  844                     .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  845                     .addComponent(pathCheck))
 
  846                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  847                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  848                     .addComponent(pathRegexCheckBox)
 
  849                     .addComponent(pathSeparatorInfoLabel))
 
  850                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  851                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  852                     .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  853                     .addComponent(mimeCheck))
 
  855                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  856                     .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  857                     .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  858                     .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  859                     .addComponent(fileSizeCheck))
 
  860                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  861                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  862                     .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  863                     .addComponent(daysIncludedLabel)
 
  864                     .addComponent(dateCheck))
 
  865                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  866                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  867                     .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  868                     .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  873     private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
 
  874         if (!this.nameCheck.isSelected()) {
 
  875             this.nameTextField.setEnabled(
false);
 
  876             this.nameTextField.setText(
"");
 
  877             this.fullNameRadioButton.setEnabled(
false);
 
  878             this.extensionRadioButton.setEnabled(
false);
 
  879             this.nameRegexCheckbox.setEnabled(
false);
 
  881             this.nameTextField.setEnabled(
true);
 
  882             this.fullNameRadioButton.setEnabled(
true);
 
  883             if (this.filesRadioButton.isSelected()) {
 
  884                 this.extensionRadioButton.setEnabled(
true);
 
  886             this.nameRegexCheckbox.setEnabled(
true);
 
  891     private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
 
  892         if (!this.pathCheck.isSelected()) {
 
  893             this.pathTextField.setEnabled(
false);
 
  894             this.pathTextField.setText(
"");
 
  895             this.pathRegexCheckBox.setEnabled(
false);
 
  896             this.pathSeparatorInfoLabel.setEnabled(
false);
 
  898             this.pathTextField.setEnabled(
true);
 
  899             this.pathRegexCheckBox.setEnabled(
true);
 
  900             this.pathSeparatorInfoLabel.setEnabled(
true);
 
  905     private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  907         this.setComponentsForSearchType();
 
  910     private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  911         this.setComponentsForSearchType();
 
  914     private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  915         this.setComponentsForSearchType();
 
  918     private void dateCheckActionPerformed(java.awt.event.ActionEvent evt) {
 
  919         if (!this.dateCheck.isSelected()) {
 
  920             this.daysIncludedTextField.setEnabled(
false);
 
  921             this.daysIncludedLabel.setEnabled(
false);
 
  922             this.daysIncludedTextField.setText(
"");
 
  924             this.daysIncludedTextField.setEnabled(
true);
 
  925             this.daysIncludedLabel.setEnabled(
true);
 
  930     private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
 
  931         if (!this.fileSizeCheck.isSelected()) {
 
  932             this.fileSizeComboBox.setEnabled(
false);
 
  933             this.fileSizeSpinner.setEnabled(
false);
 
  934             this.fileSizeSpinner.setValue(0);
 
  935             this.equalitySymbolComboBox.setEnabled(
false);
 
  937             this.fileSizeComboBox.setEnabled(
true);
 
  938             this.fileSizeSpinner.setEnabled(
true);
 
  939             this.equalitySymbolComboBox.setEnabled(
true);
 
  944     private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
 
  945         if (!this.mimeCheck.isSelected()) {
 
  946             this.mimeTypeComboBox.setEnabled(
false);
 
  947             this.mimeTypeComboBox.setSelectedIndex(0);
 
  949             this.mimeTypeComboBox.setEnabled(
true);
 
  955     private javax.swing.JRadioButton allRadioButton;
 
  956     private javax.swing.JCheckBox dateCheck;
 
  957     private javax.swing.JLabel daysIncludedLabel;
 
  958     private javax.swing.JTextField daysIncludedTextField;
 
  959     private javax.swing.JRadioButton dirsRadioButton;
 
  960     private javax.swing.JComboBox<String> equalitySymbolComboBox;
 
  961     private javax.swing.JRadioButton extensionRadioButton;
 
  962     private javax.swing.JCheckBox fileSizeCheck;
 
  963     private javax.swing.JComboBox<String> fileSizeComboBox;
 
  964     private javax.swing.JSpinner fileSizeSpinner;
 
  965     private javax.swing.JRadioButton filesRadioButton;
 
  966     private javax.swing.JRadioButton fullNameRadioButton;
 
  967     private javax.swing.JLabel jLabel1;
 
  968     private javax.swing.JLabel jLabel5;
 
  969     private javax.swing.JCheckBox mimeCheck;
 
  970     private javax.swing.JComboBox<String> mimeTypeComboBox;
 
  971     private javax.swing.ButtonGroup nameButtonGroup;
 
  972     private javax.swing.JCheckBox nameCheck;
 
  973     private javax.swing.JCheckBox nameRegexCheckbox;
 
  974     private javax.swing.JTextField nameTextField;
 
  975     private javax.swing.JCheckBox pathCheck;
 
  976     private javax.swing.JCheckBox pathRegexCheckBox;
 
  977     private javax.swing.JLabel pathSeparatorInfoLabel;
 
  978     private javax.swing.JTextField pathTextField;
 
  979     private javax.swing.JLabel ruleNameLabel;
 
  980     private javax.swing.JTextField ruleNameTextField;
 
  981     private javax.swing.ButtonGroup typeButtonGroup;