Autopsy  4.1
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-2016 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.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Set;
27 import java.util.logging.Level;
28 import java.util.regex.Pattern;
29 import java.util.regex.PatternSyntaxException;
30 import javax.swing.JButton;
31 import javax.swing.JComponent;
32 import javax.swing.JOptionPane;
33 import org.openide.DialogDisplayer;
34 import org.openide.NotifyDescriptor;
35 import org.openide.util.NbBundle;
36 import org.openide.util.NbBundle.Messages;
40 
44 final class FilesSetRulePanel extends javax.swing.JPanel {
45 
46  @Messages({
47  "FilesSetRulePanel.bytes=Bytes",
48  "FilesSetRulePanel.kiloBytes=Kilobytes",
49  "FilesSetRulePanel.megaBytes=Megabytes",
50  "FilesSetRulePanel.gigaBytes=Gigabytes",
51  "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
52  "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
53  "FilesSetRulePanel.NoNameError=Name cannot be empty",
54  "FilesSetRulePanel.NoPathError=Path cannot be empty",
55  "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
56  })
57 
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  populateComponentsWithDefaultValues();
87  this.setButtons(okButton, cancelButton);
88  }
89 
95  FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
96  initComponents();
97  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
98  mimeTypeComboBox.setVisible(false);
99  mimeCheck.setVisible(false);
100  fileSizeComboBox.setVisible(false);
101  fileSizeCheck.setVisible(false);
102  equalitySymbolComboBox.setVisible(false);
103  fileSizeSpinner.setVisible(false);
104  jLabel1.setVisible(false);
105  filesRadioButton.setVisible(false);
106  dirsRadioButton.setVisible(false);
107  allRadioButton.setVisible(false);
108  } else {
109  populateMimeTypesComboBox();
110  populateMimeConditionComponents(rule);
111  populateSizeConditionComponents(rule);
112  }
113  populateMimeTypesComboBox();
114  populateRuleNameComponent(rule);
115  populateTypeConditionComponents(rule);
116  populateNameConditionComponents(rule);
117  populatePathConditionComponents(rule);
118  this.setButtons(okButton, cancelButton);
119  }
120 
124  private void populateComponentsWithDefaultValues() {
125  this.filesRadioButton.setSelected(true);
126  this.fullNameRadioButton.setSelected(true);
127  this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
128  this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
129  this.mimeTypeComboBox.setSelectedIndex(0);
130  }
131 
132  private void populateMimeTypesComboBox() {
133  Set<String> fileTypesCollated = new HashSet<>();
134  for (String mediaType : FileTypeDetector.getStandardDetectedTypes()) {
135  fileTypesCollated.add(mediaType);
136  }
137 
138  FileTypeDetector fileTypeDetector;
139  try {
140  fileTypeDetector = new FileTypeDetector();
141  List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
142  fileTypesCollated.addAll(userDefinedFileTypes);
143 
144  } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
145  logger.log(Level.SEVERE, "Unable to get user defined file types", ex);
146  }
147 
148  List<String> toSort = new ArrayList<>(fileTypesCollated);
149  toSort.sort((String string1, String string2) -> {
150  int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
151  if (result == 0) {
152  result = string1.compareTo(string2);
153  }
154  return result;
155  });
156 
157  for (String file : toSort) {
158  mimeTypeComboBox.addItem(file);
159  }
160  this.setOkButton();
161  }
162 
168  private void populateRuleNameComponent(FilesSet.Rule rule) {
169  this.ruleNameTextField.setText(rule.getName());
170  }
171 
172  private void populateMimeConditionComponents(FilesSet.Rule rule) {
173  FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
174  if (mimeTypeCondition != null) {
175  this.mimeCheck.setSelected(true);
176  this.mimeCheckActionPerformed(null);
177  this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
178  }
179  }
180 
181  private void populateSizeConditionComponents(FilesSet.Rule rule) {
182  FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
183  if (fileSizeCondition != null) {
184  this.fileSizeCheck.setSelected(true);
185  this.fileSizeCheckActionPerformed(null);
186  this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
187  this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
188  this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
189  }
190  }
191 
196  private void setOkButton() {
197  if (this.okButton != null) {
198  this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
199  || this.nameCheck.isSelected() || this.pathCheck.isSelected());
200  }
201  }
202 
210  private JOptionPane getOptionPane(JComponent parent) {
211  JOptionPane pane = null;
212  if (!(parent instanceof JOptionPane)) {
213  pane = getOptionPane((JComponent) parent.getParent());
214  } else {
215  pane = (JOptionPane) parent;
216  }
217  return pane;
218  }
219 
226  private void setButtons(JButton ok, JButton cancel) {
227  this.okButton = ok;
228  this.cancelButton = cancel;
229  okButton.addActionListener(new ActionListener() {
230  @Override
231  public void actionPerformed(ActionEvent e) {
232  JOptionPane pane = getOptionPane(okButton);
233  pane.setValue(okButton);
234  }
235  });
236  cancelButton.addActionListener(new ActionListener() {
237  @Override
238  public void actionPerformed(ActionEvent e) {
239  JOptionPane pane = getOptionPane(cancelButton);
240  pane.setValue(cancelButton);
241  }
242  });
243  this.setOkButton();
244  }
245 
252  private void populateTypeConditionComponents(FilesSet.Rule rule) {
253  FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
254  switch (typeCondition.getMetaType()) {
255  case FILES:
256  this.filesRadioButton.setSelected(true);
257  break;
258  case DIRECTORIES:
259  this.dirsRadioButton.setSelected(true);
260  break;
261  case ALL:
262  this.allRadioButton.setSelected(true);
263  break;
264  }
265  }
266 
272  private void populateNameConditionComponents(FilesSet.Rule rule) {
273  FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
274  if (nameCondition != null) {
275  this.nameCheck.setSelected(true);
276  this.nameCheckActionPerformed(null);
277  this.nameTextField.setText(nameCondition.getTextToMatch());
278  this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
279  if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
280  this.fullNameRadioButton.setSelected(true);
281  } else {
282  this.extensionRadioButton.setSelected(true);
283  }
284  }
285  }
286 
293  private void populatePathConditionComponents(FilesSet.Rule rule) {
294  FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
295  if (pathCondition != null) {
296  this.pathCheck.setSelected(true);
297  this.pathCheckActionPerformed(null);
298  this.pathTextField.setText(pathCondition.getTextToMatch());
299  this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
300  }
301  }
302 
310  boolean isValidRuleDefinition() {
311 
312  if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
313  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
314  Bundle.FilesSetRulePanel_NoConditionError(),
315  NotifyDescriptor.WARNING_MESSAGE);
316  DialogDisplayer.getDefault().notify(notifyDesc);
317  return false;
318  }
319 
320  if (this.nameCheck.isSelected()) {
321  // The name condition must either be a regular expression that compiles or
322  // a string without illegal file name chars.
323  if (this.nameTextField.getText().isEmpty()) {
324  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
325  Bundle.FilesSetRulePanel_NoNameError(),
326  NotifyDescriptor.WARNING_MESSAGE);
327  DialogDisplayer.getDefault().notify(notifyDesc);
328  return false;
329  }
330  if (this.nameRegexCheckbox.isSelected()) {
331  try {
332  Pattern.compile(this.nameTextField.getText());
333  } catch (PatternSyntaxException ex) {
334  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
335  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
336  NotifyDescriptor.WARNING_MESSAGE);
337  DialogDisplayer.getDefault().notify(notifyDesc);
338  return false;
339  }
340  } else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
341  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
342  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidCharInName"),
343  NotifyDescriptor.WARNING_MESSAGE);
344  DialogDisplayer.getDefault().notify(notifyDesc);
345  return false;
346  }
347  }
348 
349  // The path condition, if specified, must either be a regular expression
350  // that compiles or a string without illegal file path chars.
351  if (this.pathCheck.isSelected()) {
352  if (this.pathTextField.getText().isEmpty()) {
353  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
354  Bundle.FilesSetRulePanel_NoPathError(),
355  NotifyDescriptor.WARNING_MESSAGE);
356  DialogDisplayer.getDefault().notify(notifyDesc);
357  return false;
358  }
359  if (this.pathRegexCheckBox.isSelected()) {
360  try {
361  Pattern.compile(this.pathTextField.getText());
362  } catch (PatternSyntaxException ex) {
363  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
364  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
365  NotifyDescriptor.WARNING_MESSAGE);
366  DialogDisplayer.getDefault().notify(notifyDesc);
367  return false;
368  }
369  } else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
370  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
371  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidCharInPath"),
372  NotifyDescriptor.WARNING_MESSAGE);
373  DialogDisplayer.getDefault().notify(notifyDesc);
374  return false;
375  }
376  }
377  if (this.mimeCheck.isSelected()) {
378  if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
379  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
380  Bundle.FilesSetRulePanel_NoMimeTypeError(),
381  NotifyDescriptor.WARNING_MESSAGE);
382  DialogDisplayer.getDefault().notify(notifyDesc);
383  return false;
384  }
385  }
386  if (this.fileSizeCheck.isSelected()) {
387  if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
388  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
389  Bundle.FilesSetRulePanel_ZeroFileSizeError(),
390  NotifyDescriptor.WARNING_MESSAGE);
391  DialogDisplayer.getDefault().notify(notifyDesc);
392  return false;
393  }
394  }
395 
396  return true;
397  }
398 
404  String getRuleName() {
405  return this.ruleNameTextField.getText();
406  }
407 
417  FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
418  FilesSet.Rule.FileNameCondition condition = null;
419  if (!this.nameTextField.getText().isEmpty()) {
420  if (this.nameRegexCheckbox.isSelected()) {
421  try {
422  Pattern pattern = Pattern.compile(this.nameTextField.getText());
423  if (this.fullNameRadioButton.isSelected()) {
424  condition = new FilesSet.Rule.FullNameCondition(pattern);
425  } else {
426  condition = new FilesSet.Rule.ExtensionCondition(pattern);
427  }
428  } catch (PatternSyntaxException ex) {
429  logger.log(Level.SEVERE, "Attempt to get regex name condition that does not compile", ex); // NON-NLS
430  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
431  }
432  } else if (FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
433  if (this.fullNameRadioButton.isSelected()) {
434  condition = new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
435  } else {
436  condition = new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
437  }
438  } else {
439  logger.log(Level.SEVERE, "Attempt to get name condition with illegal chars"); // NON-NLS
440  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
441  }
442  }
443  return condition;
444  }
445 
451  FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
452  FilesSet.Rule.MimeTypeCondition condition = null;
453  if (!this.mimeTypeComboBox.getSelectedItem().equals("")) {
454  condition = new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
455  }
456  return condition;
457  }
458 
464  FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
465  FilesSet.Rule.FileSizeCondition condition = null;
466  if (this.fileSizeCheck.isSelected()) {
467  if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
468  FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
469  FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
470  int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
471  condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
472  }
473  }
474  return condition;
475  }
476 
483  FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
484  if (this.filesRadioButton.isSelected()) {
485  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
486  } else if (this.dirsRadioButton.isSelected()) {
487  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
488  } else {
489  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
490  }
491  }
492 
502  FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
503  FilesSet.Rule.ParentPathCondition condition = null;
504  if (!this.pathTextField.getText().isEmpty()) {
505  if (this.pathRegexCheckBox.isSelected()) {
506  try {
507  condition = new FilesSet.Rule.ParentPathCondition(Pattern.compile(this.pathTextField.getText()));
508  } catch (PatternSyntaxException ex) {
509  logger.log(Level.SEVERE, "Attempt to get malformed path condition", ex); // NON-NLS
510  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
511  }
512  } else {
513  String path = this.pathTextField.getText();
514  if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
515  // Add a leading path separator if omitted.
516  if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
517  path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
518  }
519  // Add a trailing path separator if omitted.
520  if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
521  path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
522  }
523  condition = new FilesSet.Rule.ParentPathCondition(path);
524  } else {
525  logger.log(Level.SEVERE, "Attempt to get path condition with illegal chars"); // NON-NLS
526  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
527  }
528  }
529  }
530  return condition;
531  }
532 
542  private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
543  for (String illegalChar : illegalChars) {
544  if (toBeChecked.contains(illegalChar)) {
545  return false;
546  }
547  }
548  return true;
549  }
550 
555  private void setComponentsForSearchType() {
556  if (!this.filesRadioButton.isSelected()) {
557  this.fullNameRadioButton.setSelected(true);
558  this.extensionRadioButton.setEnabled(false);
559  this.mimeTypeComboBox.setEnabled(false);
560  this.mimeTypeComboBox.setSelectedIndex(0);
561  this.equalitySymbolComboBox.setEnabled(false);
562  this.fileSizeComboBox.setEnabled(false);
563  this.fileSizeSpinner.setEnabled(false);
564  this.fileSizeSpinner.setValue(0);
565  this.fileSizeCheck.setEnabled(false);
566  this.fileSizeCheck.setSelected(false);
567  this.mimeCheck.setEnabled(false);
568  this.mimeCheck.setSelected(false);
569  } else {
570  if (this.nameCheck.isSelected()) {
571  this.extensionRadioButton.setEnabled(true);
572  }
573  this.fileSizeCheck.setEnabled(true);
574  this.mimeCheck.setEnabled(true);
575  }
576  }
577 
583  @SuppressWarnings("unchecked")
584  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
585  private void initComponents() {
586 
587  nameButtonGroup = new javax.swing.ButtonGroup();
588  typeButtonGroup = new javax.swing.ButtonGroup();
589  ruleNameLabel = new javax.swing.JLabel();
590  ruleNameTextField = new javax.swing.JTextField();
591  jLabel1 = new javax.swing.JLabel();
592  nameTextField = new javax.swing.JTextField();
593  fullNameRadioButton = new javax.swing.JRadioButton();
594  extensionRadioButton = new javax.swing.JRadioButton();
595  nameRegexCheckbox = new javax.swing.JCheckBox();
596  pathTextField = new javax.swing.JTextField();
597  pathRegexCheckBox = new javax.swing.JCheckBox();
598  pathSeparatorInfoLabel = new javax.swing.JLabel();
599  jLabel5 = new javax.swing.JLabel();
600  mimeTypeComboBox = new javax.swing.JComboBox<String>();
601  equalitySymbolComboBox = new javax.swing.JComboBox<String>();
602  fileSizeComboBox = new javax.swing.JComboBox<String>();
603  fileSizeSpinner = new javax.swing.JSpinner();
604  nameCheck = new javax.swing.JCheckBox();
605  pathCheck = new javax.swing.JCheckBox();
606  mimeCheck = new javax.swing.JCheckBox();
607  fileSizeCheck = new javax.swing.JCheckBox();
608  filesRadioButton = new javax.swing.JRadioButton();
609  dirsRadioButton = new javax.swing.JRadioButton();
610  allRadioButton = new javax.swing.JRadioButton();
611 
612  org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
613 
614  ruleNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameTextField.text")); // NOI18N
615  ruleNameTextField.addActionListener(new java.awt.event.ActionListener() {
616  public void actionPerformed(java.awt.event.ActionEvent evt) {
617  ruleNameTextFieldActionPerformed(evt);
618  }
619  });
620 
621  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.jLabel1.text")); // NOI18N
622 
623  nameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameTextField.text")); // NOI18N
624  nameTextField.setEnabled(false);
625 
626  nameButtonGroup.add(fullNameRadioButton);
627  org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
628  fullNameRadioButton.setEnabled(false);
629 
630  nameButtonGroup.add(extensionRadioButton);
631  org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
632  extensionRadioButton.setEnabled(false);
633 
634  org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameRegexCheckbox.text")); // NOI18N
635  nameRegexCheckbox.setEnabled(false);
636 
637  pathTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathTextField.text")); // NOI18N
638  pathTextField.setEnabled(false);
639 
640  org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathRegexCheckBox.text")); // NOI18N
641  pathRegexCheckBox.setEnabled(false);
642 
643  pathSeparatorInfoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N
644  org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathSeparatorInfoLabel.text")); // NOI18N
645  pathSeparatorInfoLabel.setEnabled(false);
646 
647  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.interesting.jLabel5.text")); // NOI18N
648 
649  mimeTypeComboBox.setEditable(true);
650  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
651  mimeTypeComboBox.setEnabled(false);
652 
653  equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
654  equalitySymbolComboBox.setEnabled(false);
655 
656  fileSizeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
657  fileSizeComboBox.setEnabled(false);
658 
659  fileSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
660  fileSizeSpinner.setEnabled(false);
661 
662  org.openide.awt.Mnemonics.setLocalizedText(nameCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameCheck.text")); // NOI18N
663  nameCheck.addActionListener(new java.awt.event.ActionListener() {
664  public void actionPerformed(java.awt.event.ActionEvent evt) {
665  nameCheckActionPerformed(evt);
666  }
667  });
668 
669  org.openide.awt.Mnemonics.setLocalizedText(pathCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathCheck.text")); // NOI18N
670  pathCheck.addActionListener(new java.awt.event.ActionListener() {
671  public void actionPerformed(java.awt.event.ActionEvent evt) {
672  pathCheckActionPerformed(evt);
673  }
674  });
675 
676  org.openide.awt.Mnemonics.setLocalizedText(mimeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.mimeCheck.text")); // NOI18N
677  mimeCheck.addActionListener(new java.awt.event.ActionListener() {
678  public void actionPerformed(java.awt.event.ActionEvent evt) {
679  mimeCheckActionPerformed(evt);
680  }
681  });
682 
683  org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fileSizeCheck.text")); // NOI18N
684  fileSizeCheck.addActionListener(new java.awt.event.ActionListener() {
685  public void actionPerformed(java.awt.event.ActionEvent evt) {
686  fileSizeCheckActionPerformed(evt);
687  }
688  });
689 
690  typeButtonGroup.add(filesRadioButton);
691  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N
692  filesRadioButton.addActionListener(new java.awt.event.ActionListener() {
693  public void actionPerformed(java.awt.event.ActionEvent evt) {
694  filesRadioButtonActionPerformed(evt);
695  }
696  });
697 
698  typeButtonGroup.add(dirsRadioButton);
699  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N
700  dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
701  public void actionPerformed(java.awt.event.ActionEvent evt) {
702  dirsRadioButtonActionPerformed(evt);
703  }
704  });
705 
706  typeButtonGroup.add(allRadioButton);
707  org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.allRadioButton.text")); // NOI18N
708  allRadioButton.addActionListener(new java.awt.event.ActionListener() {
709  public void actionPerformed(java.awt.event.ActionEvent evt) {
710  allRadioButtonActionPerformed(evt);
711  }
712  });
713 
714  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
715  this.setLayout(layout);
716  layout.setHorizontalGroup(
717  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
718  .addGroup(layout.createSequentialGroup()
719  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
720  .addGroup(layout.createSequentialGroup()
721  .addGap(8, 8, 8)
722  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
723  .addGroup(layout.createSequentialGroup()
724  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
725  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
726  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
727  .addGroup(layout.createSequentialGroup()
728  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
729  .addComponent(jLabel5)
730  .addGroup(layout.createSequentialGroup()
731  .addComponent(jLabel1)
732  .addGap(65, 65, 65)
733  .addComponent(filesRadioButton)
734  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
735  .addComponent(dirsRadioButton)
736  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
737  .addComponent(allRadioButton)))
738  .addGap(0, 0, Short.MAX_VALUE))))
739  .addGroup(layout.createSequentialGroup()
740  .addContainerGap()
741  .addComponent(nameCheck)
742  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
743  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
744  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
745  .addContainerGap()
746  .addComponent(pathCheck)
747  .addGap(4, 4, 4)
748  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
749  .addGroup(layout.createSequentialGroup()
750  .addComponent(pathRegexCheckBox)
751  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
752  .addComponent(pathSeparatorInfoLabel))
753  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
754  .addGap(0, 0, Short.MAX_VALUE)
755  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
756  .addGroup(layout.createSequentialGroup()
757  .addComponent(fullNameRadioButton)
758  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
759  .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
760  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
761  .addComponent(nameRegexCheckbox)
762  .addGap(0, 0, Short.MAX_VALUE))))
763  .addGroup(layout.createSequentialGroup()
764  .addContainerGap()
765  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
766  .addComponent(mimeCheck)
767  .addComponent(fileSizeCheck))
768  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
769  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
770  .addGroup(layout.createSequentialGroup()
771  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
772  .addGap(18, 18, 18)
773  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
774  .addGap(18, 18, 18)
775  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
776  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
777  .addContainerGap())
778  );
779  layout.setVerticalGroup(
780  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
781  .addGroup(layout.createSequentialGroup()
782  .addComponent(jLabel5)
783  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
784  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
785  .addComponent(jLabel1)
786  .addComponent(filesRadioButton)
787  .addComponent(dirsRadioButton)
788  .addComponent(allRadioButton))
789  .addGap(5, 5, 5)
790  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
791  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
792  .addComponent(nameCheck))
793  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
794  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
795  .addComponent(fullNameRadioButton)
796  .addComponent(extensionRadioButton)
797  .addComponent(nameRegexCheckbox))
798  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
799  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
800  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
801  .addComponent(pathCheck))
802  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
803  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
804  .addComponent(pathRegexCheckBox)
805  .addComponent(pathSeparatorInfoLabel))
806  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
807  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
808  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
809  .addComponent(mimeCheck))
810  .addGap(11, 11, 11)
811  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
812  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
813  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
814  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
815  .addComponent(fileSizeCheck))
816  .addGap(15, 15, 15)
817  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
818  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
819  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
820  .addContainerGap())
821  );
822  }// </editor-fold>//GEN-END:initComponents
823 
824  private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ruleNameTextFieldActionPerformed
825  // TODO add your handling code here:
826  }//GEN-LAST:event_ruleNameTextFieldActionPerformed
827 
828  private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckActionPerformed
829  if (!this.nameCheck.isSelected()) {
830  this.nameTextField.setEnabled(false);
831  this.nameTextField.setText("");
832  this.fullNameRadioButton.setEnabled(false);
833  this.extensionRadioButton.setEnabled(false);
834  this.nameRegexCheckbox.setEnabled(false);
835  } else {
836  this.nameTextField.setEnabled(true);
837  this.fullNameRadioButton.setEnabled(true);
838  if (this.filesRadioButton.isSelected()) {
839  this.extensionRadioButton.setEnabled(true);
840  }
841  this.nameRegexCheckbox.setEnabled(true);
842  }
843  this.setOkButton();
844  }//GEN-LAST:event_nameCheckActionPerformed
845 
846  private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathCheckActionPerformed
847  if (!this.pathCheck.isSelected()) {
848  this.pathTextField.setEnabled(false);
849  this.pathTextField.setText("");
850  this.pathRegexCheckBox.setEnabled(false);
851  this.pathSeparatorInfoLabel.setEnabled(false);
852  } else {
853  this.pathTextField.setEnabled(true);
854  this.pathRegexCheckBox.setEnabled(true);
855  this.pathSeparatorInfoLabel.setEnabled(true);
856  }
857  this.setOkButton();
858  }//GEN-LAST:event_pathCheckActionPerformed
859 
860  private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeCheckActionPerformed
861  if (!this.mimeCheck.isSelected()) {
862  this.mimeTypeComboBox.setEnabled(false);
863  this.mimeTypeComboBox.setSelectedIndex(0);
864  } else {
865  this.mimeTypeComboBox.setEnabled(true);
866  }
867  this.setOkButton();
868  }//GEN-LAST:event_mimeCheckActionPerformed
869 
870  private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSizeCheckActionPerformed
871  if (!this.fileSizeCheck.isSelected()) {
872  this.fileSizeComboBox.setEnabled(false);
873  this.fileSizeSpinner.setEnabled(false);
874  this.fileSizeSpinner.setValue(0);
875  this.equalitySymbolComboBox.setEnabled(false);
876  } else {
877  this.fileSizeComboBox.setEnabled(true);
878  this.fileSizeSpinner.setEnabled(true);
879  this.equalitySymbolComboBox.setEnabled(true);
880  }
881  this.setOkButton();
882  }//GEN-LAST:event_fileSizeCheckActionPerformed
883 
884  private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed
885 
886  this.setComponentsForSearchType();
887  }//GEN-LAST:event_filesRadioButtonActionPerformed
888 
889  private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
890  this.setComponentsForSearchType();
891  }//GEN-LAST:event_dirsRadioButtonActionPerformed
892 
893  private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allRadioButtonActionPerformed
894  this.setComponentsForSearchType();
895  }//GEN-LAST:event_allRadioButtonActionPerformed
896 
897  // Variables declaration - do not modify//GEN-BEGIN:variables
898  private javax.swing.JRadioButton allRadioButton;
899  private javax.swing.JRadioButton dirsRadioButton;
900  private javax.swing.JComboBox<String> equalitySymbolComboBox;
901  private javax.swing.JRadioButton extensionRadioButton;
902  private javax.swing.JCheckBox fileSizeCheck;
903  private javax.swing.JComboBox<String> fileSizeComboBox;
904  private javax.swing.JSpinner fileSizeSpinner;
905  private javax.swing.JRadioButton filesRadioButton;
906  private javax.swing.JRadioButton fullNameRadioButton;
907  private javax.swing.JLabel jLabel1;
908  private javax.swing.JLabel jLabel5;
909  private javax.swing.JCheckBox mimeCheck;
910  private javax.swing.JComboBox<String> mimeTypeComboBox;
911  private javax.swing.ButtonGroup nameButtonGroup;
912  private javax.swing.JCheckBox nameCheck;
913  private javax.swing.JCheckBox nameRegexCheckbox;
914  private javax.swing.JTextField nameTextField;
915  private javax.swing.JCheckBox pathCheck;
916  private javax.swing.JCheckBox pathRegexCheckBox;
917  private javax.swing.JLabel pathSeparatorInfoLabel;
918  private javax.swing.JTextField pathTextField;
919  private javax.swing.JLabel ruleNameLabel;
920  private javax.swing.JTextField ruleNameTextField;
921  private javax.swing.ButtonGroup typeButtonGroup;
922  // End of variables declaration//GEN-END:variables
923 }

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