Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilesSetRulePanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.interestingitems;
20 
21 import java.awt.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;
37 
41 final class FilesSetRulePanel extends javax.swing.JPanel {
42 
43  @Messages({
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)."
55  })
56 
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 = "/"; // NON-NLS
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;
64 
68  FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
69  initComponents();
70  if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { //Hide the mimetype settings when this is displaying a FileSet rule instead of a interesting item rule
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")); // NOI18N
82 
83  } else {
84  populateMimeTypesComboBox();
85  }
86  this.dateCheckActionPerformed(null);
87  populateComponentsWithDefaultValues();
88  this.setButtons(okButton, cancelButton);
89  }
90 
96  FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
97  initComponents();
98  if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { //Hide the mimetype settings when this is displaying a FileSet rule instead of a interesting item rule
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);
109  } else {
110  populateMimeTypesComboBox();
111  populateMimeConditionComponents(rule);
112  populateSizeConditionComponents(rule);
113 
114  }
115  populateMimeTypesComboBox();
116  populateRuleNameComponent(rule);
117  populateTypeConditionComponents(rule);
118  populateNameConditionComponents(rule);
119  populatePathConditionComponents(rule);
120  populateDateConditionComponents(rule);
121  this.setButtons(okButton, cancelButton);
122  }
123 
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);
133  }
134 
135  private void populateMimeTypesComboBox() {
136  try {
137  SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
138  detectableMimeTypes.forEach((type) -> {
139  mimeTypeComboBox.addItem(type);
140  });
141  } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
142  logger.log(Level.SEVERE, "Unable to get detectable file types", ex);
143  }
144  this.setOkButton();
145  }
146 
152  private void populateRuleNameComponent(FilesSet.Rule rule) {
153  this.ruleNameTextField.setText(rule.getName());
154  }
155 
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());
162  }
163  }
164 
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());
173  }
174  }
175 
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());
184  }
185  }
186 
194  private JOptionPane getOptionPane(JComponent parent) {
195  JOptionPane pane;
196  if (!(parent instanceof JOptionPane)) {
197  pane = getOptionPane((JComponent) parent.getParent());
198  } else {
199  pane = (JOptionPane) parent;
200  }
201  return pane;
202  }
203 
210  private void setButtons(JButton ok, JButton cancel) {
211  this.okButton = ok;
212  this.cancelButton = cancel;
213  okButton.addActionListener((ActionEvent e) -> {
214  JOptionPane pane = getOptionPane(okButton);
215  pane.setValue(okButton);
216  });
217  cancelButton.addActionListener((ActionEvent e) -> {
218  JOptionPane pane = getOptionPane(cancelButton);
219  pane.setValue(cancelButton);
220  });
221  this.setOkButton();
222  }
223 
230  private void populateTypeConditionComponents(FilesSet.Rule rule) {
231  FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
232  switch (typeCondition.getMetaType()) {
233  case FILES:
234  this.filesRadioButton.setSelected(true);
235  break;
236  case DIRECTORIES:
237  this.dirsRadioButton.setSelected(true);
238  break;
239  case ALL:
240  this.allRadioButton.setSelected(true);
241  break;
242  }
243  }
244 
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);
259  } else {
260  this.extensionRadioButton.setSelected(true);
261  }
262  }
263  }
264 
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());
278  }
279  }
280 
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()));
293  }
294  }
295 
303  boolean isValidRuleDefinition() {
304 
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);
310  return false;
311  }
312 
313  if (this.nameCheck.isSelected()) {
314  // The name condition must either be a regular expression that compiles or
315  // a string without illegal file name chars.
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);
321  return false;
322  }
323  if (this.nameRegexCheckbox.isSelected()) {
324  try {
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);
331  return false;
332  }
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);
338  return false;
339  }
340  }
341 
342  // The path condition, if specified, must either be a regular expression
343  // that compiles or a string without illegal file path chars.
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);
350  return false;
351  }
352  if (this.pathRegexCheckBox.isSelected()) {
353  try {
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);
360  return false;
361  }
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);
367  return false;
368  }
369  }
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);
376  return false;
377  }
378  }
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);
385  return false;
386  }
387  }
388 
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);
395  return false;
396  }
397  try {
398  int value = Integer.parseInt(daysIncludedTextField.getText());
399  if (value < 0) {
400  throw new NumberFormatException("Negative numbers are not allowed for the within N days condition");
401  }
402  } catch (NumberFormatException e) {
403  //field did not contain an integer
404  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
405  Bundle.FilesSetRulePanel_DaysIncludedInvalidError(),
406  NotifyDescriptor.WARNING_MESSAGE);
407  DialogDisplayer.getDefault().notify(notifyDesc);
408  return false;
409  }
410  }
411  return true;
412  }
413 
419  String getRuleName() {
420  return this.ruleNameTextField.getText();
421  }
422 
432  FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
433  FilesSet.Rule.FileNameCondition condition = null;
434  if (!this.nameTextField.getText().isEmpty()) {
435  if (this.nameRegexCheckbox.isSelected()) {
436  try {
437  Pattern pattern = Pattern.compile(this.nameTextField.getText());
438  if (this.fullNameRadioButton.isSelected()) {
439  condition = new FilesSet.Rule.FullNameCondition(pattern);
440  } else {
441  condition = new FilesSet.Rule.ExtensionCondition(pattern);
442  }
443  } catch (PatternSyntaxException ex) {
444  logger.log(Level.SEVERE, "Attempt to get regex name condition that does not compile", ex); // NON-NLS
445  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
446  }
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());
450  } else {
451  condition = new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
452  }
453  } else {
454  logger.log(Level.SEVERE, "Attempt to get name condition with illegal chars"); // NON-NLS
455  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
456  }
457  }
458  return condition;
459  }
460 
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());
470  }
471  return condition;
472  }
473 
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);
487  }
488  }
489  return condition;
490  }
491 
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);
503  } else {
504  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
505  }
506  }
507 
517  FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
518  FilesSet.Rule.ParentPathCondition condition = null;
519  if (!this.pathTextField.getText().isEmpty()) {
520  if (this.pathRegexCheckBox.isSelected()) {
521  try {
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); // NON-NLS
525  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
526  }
527  } else {
528  String path = this.pathTextField.getText();
529  if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
530  // Add a leading path separator if omitted.
531  if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
532  path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
533  }
534  // Add a trailing path separator if omitted.
535  if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
536  path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
537  }
538  condition = new FilesSet.Rule.ParentPathCondition(path);
539  } else {
540  logger.log(Level.SEVERE, "Attempt to get path condition with illegal chars"); // NON-NLS
541  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
542  }
543  }
544  }
545  return condition;
546  }
547 
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()));
561  }
562  return dateCondition;
563  }
564 
574  private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
575  for (String illegalChar : illegalChars) {
576  if (toBeChecked.contains(illegalChar)) {
577  return false;
578  }
579  }
580  return true;
581  }
582 
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);
601  } else {
602  if (this.nameCheck.isSelected()) {
603  this.extensionRadioButton.setEnabled(true);
604  }
605  this.fileSizeCheck.setEnabled(true);
606  this.mimeCheck.setEnabled(true);
607  }
608  }
609 
615  @SuppressWarnings("unchecked")
616  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
617  private void initComponents() {
618 
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();
646 
647  org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
648 
649  ruleNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameTextField.text")); // NOI18N
650 
651  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.jLabel1.text")); // NOI18N
652 
653  nameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameTextField.text")); // NOI18N
654  nameTextField.setEnabled(false);
655 
656  nameButtonGroup.add(fullNameRadioButton);
657  org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
658  fullNameRadioButton.setEnabled(false);
659 
660  nameButtonGroup.add(extensionRadioButton);
661  org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
662  extensionRadioButton.setEnabled(false);
663 
664  org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameRegexCheckbox.text")); // NOI18N
665  nameRegexCheckbox.setEnabled(false);
666 
667  pathTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathTextField.text")); // NOI18N
668  pathTextField.setEnabled(false);
669 
670  org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathRegexCheckBox.text")); // NOI18N
671  pathRegexCheckBox.setEnabled(false);
672 
673  pathSeparatorInfoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N
674  org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathSeparatorInfoLabel.text")); // NOI18N
675  pathSeparatorInfoLabel.setEnabled(false);
676 
677  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.interesting.jLabel5.text")); // NOI18N
678 
679  mimeTypeComboBox.setEditable(true);
680  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
681  mimeTypeComboBox.setEnabled(false);
682 
683  equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
684  equalitySymbolComboBox.setEnabled(false);
685 
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);
688 
689  fileSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
690  fileSizeSpinner.setEnabled(false);
691 
692  org.openide.awt.Mnemonics.setLocalizedText(nameCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameCheck.text")); // NOI18N
693  nameCheck.addActionListener(new java.awt.event.ActionListener() {
694  public void actionPerformed(java.awt.event.ActionEvent evt) {
695  nameCheckActionPerformed(evt);
696  }
697  });
698 
699  org.openide.awt.Mnemonics.setLocalizedText(pathCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathCheck.text")); // NOI18N
700  pathCheck.addActionListener(new java.awt.event.ActionListener() {
701  public void actionPerformed(java.awt.event.ActionEvent evt) {
702  pathCheckActionPerformed(evt);
703  }
704  });
705 
706  org.openide.awt.Mnemonics.setLocalizedText(mimeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.mimeCheck.text")); // NOI18N
707  mimeCheck.addActionListener(new java.awt.event.ActionListener() {
708  public void actionPerformed(java.awt.event.ActionEvent evt) {
709  mimeCheckActionPerformed(evt);
710  }
711  });
712 
713  org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fileSizeCheck.text")); // NOI18N
714  fileSizeCheck.addActionListener(new java.awt.event.ActionListener() {
715  public void actionPerformed(java.awt.event.ActionEvent evt) {
716  fileSizeCheckActionPerformed(evt);
717  }
718  });
719 
720  typeButtonGroup.add(filesRadioButton);
721  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N
722  filesRadioButton.addActionListener(new java.awt.event.ActionListener() {
723  public void actionPerformed(java.awt.event.ActionEvent evt) {
724  filesRadioButtonActionPerformed(evt);
725  }
726  });
727 
728  typeButtonGroup.add(dirsRadioButton);
729  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N
730  dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
731  public void actionPerformed(java.awt.event.ActionEvent evt) {
732  dirsRadioButtonActionPerformed(evt);
733  }
734  });
735 
736  typeButtonGroup.add(allRadioButton);
737  org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.allRadioButton.text")); // NOI18N
738  allRadioButton.addActionListener(new java.awt.event.ActionListener() {
739  public void actionPerformed(java.awt.event.ActionEvent evt) {
740  allRadioButtonActionPerformed(evt);
741  }
742  });
743 
744  daysIncludedTextField.setEnabled(false);
745  daysIncludedTextField.setMinimumSize(new java.awt.Dimension(60, 20));
746  daysIncludedTextField.setPreferredSize(new java.awt.Dimension(60, 20));
747 
748  org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.daysIncludedLabel.text")); // NOI18N
749 
750  org.openide.awt.Mnemonics.setLocalizedText(dateCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dateCheck.text")); // NOI18N
751  dateCheck.addActionListener(new java.awt.event.ActionListener() {
752  public void actionPerformed(java.awt.event.ActionEvent evt) {
753  dateCheckActionPerformed(evt);
754  }
755  });
756 
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()
764  .addGap(8, 8, 8)
765  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
766  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
767  .addComponent(ruleNameLabel)
768  .addGap(5, 5, 5)
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)))
795  .addGap(1, 1, 1))))
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))
801  .addGap(16, 16, 16)
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()
811  .addContainerGap()
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)))
818  .addContainerGap())
819  );
820  layout.setVerticalGroup(
821  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
822  .addGroup(layout.createSequentialGroup()
823  .addComponent(jLabel5)
824  .addGap(3, 3, 3)
825  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
826  .addGroup(layout.createSequentialGroup()
827  .addComponent(jLabel1)
828  .addGap(10, 10, 10)
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))
854  .addGap(11, 11, 11)
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))
869  .addContainerGap())
870  );
871  }// </editor-fold>//GEN-END:initComponents
872 
873  private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckActionPerformed
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);
880  } else {
881  this.nameTextField.setEnabled(true);
882  this.fullNameRadioButton.setEnabled(true);
883  if (this.filesRadioButton.isSelected()) {
884  this.extensionRadioButton.setEnabled(true);
885  }
886  this.nameRegexCheckbox.setEnabled(true);
887  }
888  this.setOkButton();
889  }//GEN-LAST:event_nameCheckActionPerformed
890 
891  private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathCheckActionPerformed
892  if (!this.pathCheck.isSelected()) {
893  this.pathTextField.setEnabled(false);
894  this.pathTextField.setText("");
895  this.pathRegexCheckBox.setEnabled(false);
896  this.pathSeparatorInfoLabel.setEnabled(false);
897  } else {
898  this.pathTextField.setEnabled(true);
899  this.pathRegexCheckBox.setEnabled(true);
900  this.pathSeparatorInfoLabel.setEnabled(true);
901  }
902  this.setOkButton();
903  }//GEN-LAST:event_pathCheckActionPerformed
904 
905  private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed
906 
907  this.setComponentsForSearchType();
908  }//GEN-LAST:event_filesRadioButtonActionPerformed
909 
910  private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
911  this.setComponentsForSearchType();
912  }//GEN-LAST:event_dirsRadioButtonActionPerformed
913 
914  private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allRadioButtonActionPerformed
915  this.setComponentsForSearchType();
916  }//GEN-LAST:event_allRadioButtonActionPerformed
917 
918  private void dateCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dateCheckActionPerformed
919  if (!this.dateCheck.isSelected()) {
920  this.daysIncludedTextField.setEnabled(false);
921  this.daysIncludedLabel.setEnabled(false);
922  this.daysIncludedTextField.setText("");
923  } else {
924  this.daysIncludedTextField.setEnabled(true);
925  this.daysIncludedLabel.setEnabled(true);
926  }
927  this.setOkButton();
928  }//GEN-LAST:event_dateCheckActionPerformed
929 
930  private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSizeCheckActionPerformed
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);
936  } else {
937  this.fileSizeComboBox.setEnabled(true);
938  this.fileSizeSpinner.setEnabled(true);
939  this.equalitySymbolComboBox.setEnabled(true);
940  }
941  this.setOkButton();
942  }//GEN-LAST:event_fileSizeCheckActionPerformed
943 
944  private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeCheckActionPerformed
945  if (!this.mimeCheck.isSelected()) {
946  this.mimeTypeComboBox.setEnabled(false);
947  this.mimeTypeComboBox.setSelectedIndex(0);
948  } else {
949  this.mimeTypeComboBox.setEnabled(true);
950  }
951  this.setOkButton();
952  }//GEN-LAST:event_mimeCheckActionPerformed
953 
954  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
982  // End of variables declaration//GEN-END:variables
983 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.