Autopsy  4.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-2017 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.List;
24 import java.util.SortedSet;
25 import java.util.logging.Level;
26 import java.util.regex.Pattern;
27 import java.util.regex.PatternSyntaxException;
28 import javax.swing.JButton;
29 import javax.swing.JComponent;
30 import javax.swing.JOptionPane;
31 import org.openide.DialogDisplayer;
32 import org.openide.NotifyDescriptor;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
38 
42 final class FilesSetRulePanel extends javax.swing.JPanel {
43 
44  @Messages({
45  "FilesSetRulePanel.bytes=Bytes",
46  "FilesSetRulePanel.kiloBytes=Kilobytes",
47  "FilesSetRulePanel.megaBytes=Megabytes",
48  "FilesSetRulePanel.gigaBytes=Gigabytes",
49  "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
50  "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
51  "FilesSetRulePanel.NoNameError=Name cannot be empty",
52  "FilesSetRulePanel.NoPathError=Path cannot be empty",
53  "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
54  })
55 
56  private static final long serialVersionUID = 1L;
57  private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
58  private static final String SLEUTHKIT_PATH_SEPARATOR = "/"; // NON-NLS
59  private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
60  private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
61  private JButton okButton;
62  private JButton cancelButton;
63 
67  FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
68  initComponents();
69  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
70  mimeTypeComboBox.setVisible(false);
71  mimeCheck.setVisible(false);
72  fileSizeComboBox.setVisible(false);
73  fileSizeCheck.setVisible(false);
74  equalitySymbolComboBox.setVisible(false);
75  fileSizeSpinner.setVisible(false);
76  jLabel1.setVisible(false);
77  filesRadioButton.setVisible(false);
78  dirsRadioButton.setVisible(false);
79  allRadioButton.setVisible(false);
80  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ingest.jLabel5.text")); // NOI18N
81 
82  } else {
83  populateMimeTypesComboBox();
84  }
85  populateComponentsWithDefaultValues();
86  this.setButtons(okButton, cancelButton);
87  }
88 
94  FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
95  initComponents();
96  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
97  mimeTypeComboBox.setVisible(false);
98  mimeCheck.setVisible(false);
99  fileSizeComboBox.setVisible(false);
100  fileSizeCheck.setVisible(false);
101  equalitySymbolComboBox.setVisible(false);
102  fileSizeSpinner.setVisible(false);
103  jLabel1.setVisible(false);
104  filesRadioButton.setVisible(false);
105  dirsRadioButton.setVisible(false);
106  allRadioButton.setVisible(false);
107  } else {
108  populateMimeTypesComboBox();
109  populateMimeConditionComponents(rule);
110  populateSizeConditionComponents(rule);
111  }
112  populateMimeTypesComboBox();
113  populateRuleNameComponent(rule);
114  populateTypeConditionComponents(rule);
115  populateNameConditionComponents(rule);
116  populatePathConditionComponents(rule);
117  this.setButtons(okButton, cancelButton);
118  }
119 
123  private void populateComponentsWithDefaultValues() {
124  this.filesRadioButton.setSelected(true);
125  this.fullNameRadioButton.setSelected(true);
126  this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
127  this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
128  this.mimeTypeComboBox.setSelectedIndex(0);
129  }
130 
131  private void populateMimeTypesComboBox() {
132  try {
133  SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
134  detectableMimeTypes.forEach((type) -> {
135  mimeTypeComboBox.addItem(type);
136  });
137  } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
138  logger.log(Level.SEVERE, "Unable to get detectable file types", ex);
139  }
140  this.setOkButton();
141  }
142 
148  private void populateRuleNameComponent(FilesSet.Rule rule) {
149  this.ruleNameTextField.setText(rule.getName());
150  }
151 
152  private void populateMimeConditionComponents(FilesSet.Rule rule) {
153  FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
154  if (mimeTypeCondition != null) {
155  this.mimeCheck.setSelected(true);
156  this.mimeCheckActionPerformed(null);
157  this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
158  }
159  }
160 
161  private void populateSizeConditionComponents(FilesSet.Rule rule) {
162  FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
163  if (fileSizeCondition != null) {
164  this.fileSizeCheck.setSelected(true);
165  this.fileSizeCheckActionPerformed(null);
166  this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
167  this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
168  this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
169  }
170  }
171 
176  private void setOkButton() {
177  if (this.okButton != null) {
178  this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
179  || this.nameCheck.isSelected() || this.pathCheck.isSelected());
180  }
181  }
182 
190  private JOptionPane getOptionPane(JComponent parent) {
191  JOptionPane pane;
192  if (!(parent instanceof JOptionPane)) {
193  pane = getOptionPane((JComponent) parent.getParent());
194  } else {
195  pane = (JOptionPane) parent;
196  }
197  return pane;
198  }
199 
206  private void setButtons(JButton ok, JButton cancel) {
207  this.okButton = ok;
208  this.cancelButton = cancel;
209  okButton.addActionListener((ActionEvent e) -> {
210  JOptionPane pane = getOptionPane(okButton);
211  pane.setValue(okButton);
212  });
213  cancelButton.addActionListener((ActionEvent e) -> {
214  JOptionPane pane = getOptionPane(cancelButton);
215  pane.setValue(cancelButton);
216  });
217  this.setOkButton();
218  }
219 
226  private void populateTypeConditionComponents(FilesSet.Rule rule) {
227  FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
228  switch (typeCondition.getMetaType()) {
229  case FILES:
230  this.filesRadioButton.setSelected(true);
231  break;
232  case DIRECTORIES:
233  this.dirsRadioButton.setSelected(true);
234  break;
235  case ALL:
236  this.allRadioButton.setSelected(true);
237  break;
238  }
239  }
240 
246  private void populateNameConditionComponents(FilesSet.Rule rule) {
247  FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
248  if (nameCondition != null) {
249  this.nameCheck.setSelected(true);
250  this.nameCheckActionPerformed(null);
251  this.nameTextField.setText(nameCondition.getTextToMatch());
252  this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
253  if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
254  this.fullNameRadioButton.setSelected(true);
255  } else {
256  this.extensionRadioButton.setSelected(true);
257  }
258  }
259  }
260 
267  private void populatePathConditionComponents(FilesSet.Rule rule) {
268  FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
269  if (pathCondition != null) {
270  this.pathCheck.setSelected(true);
271  this.pathCheckActionPerformed(null);
272  this.pathTextField.setText(pathCondition.getTextToMatch());
273  this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
274  }
275  }
276 
284  boolean isValidRuleDefinition() {
285 
286  if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
287  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
288  Bundle.FilesSetRulePanel_NoConditionError(),
289  NotifyDescriptor.WARNING_MESSAGE);
290  DialogDisplayer.getDefault().notify(notifyDesc);
291  return false;
292  }
293 
294  if (this.nameCheck.isSelected()) {
295  // The name condition must either be a regular expression that compiles or
296  // a string without illegal file name chars.
297  if (this.nameTextField.getText().isEmpty()) {
298  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
299  Bundle.FilesSetRulePanel_NoNameError(),
300  NotifyDescriptor.WARNING_MESSAGE);
301  DialogDisplayer.getDefault().notify(notifyDesc);
302  return false;
303  }
304  if (this.nameRegexCheckbox.isSelected()) {
305  try {
306  Pattern.compile(this.nameTextField.getText());
307  } catch (PatternSyntaxException ex) {
308  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
309  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
310  NotifyDescriptor.WARNING_MESSAGE);
311  DialogDisplayer.getDefault().notify(notifyDesc);
312  return false;
313  }
314  } else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
315  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
316  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidCharInName"),
317  NotifyDescriptor.WARNING_MESSAGE);
318  DialogDisplayer.getDefault().notify(notifyDesc);
319  return false;
320  }
321  }
322 
323  // The path condition, if specified, must either be a regular expression
324  // that compiles or a string without illegal file path chars.
325  if (this.pathCheck.isSelected()) {
326  if (this.pathTextField.getText().isEmpty()) {
327  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
328  Bundle.FilesSetRulePanel_NoPathError(),
329  NotifyDescriptor.WARNING_MESSAGE);
330  DialogDisplayer.getDefault().notify(notifyDesc);
331  return false;
332  }
333  if (this.pathRegexCheckBox.isSelected()) {
334  try {
335  Pattern.compile(this.pathTextField.getText());
336  } catch (PatternSyntaxException ex) {
337  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
338  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
339  NotifyDescriptor.WARNING_MESSAGE);
340  DialogDisplayer.getDefault().notify(notifyDesc);
341  return false;
342  }
343  } else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
344  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
345  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidCharInPath"),
346  NotifyDescriptor.WARNING_MESSAGE);
347  DialogDisplayer.getDefault().notify(notifyDesc);
348  return false;
349  }
350  }
351  if (this.mimeCheck.isSelected()) {
352  if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
353  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
354  Bundle.FilesSetRulePanel_NoMimeTypeError(),
355  NotifyDescriptor.WARNING_MESSAGE);
356  DialogDisplayer.getDefault().notify(notifyDesc);
357  return false;
358  }
359  }
360  if (this.fileSizeCheck.isSelected()) {
361  if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
362  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
363  Bundle.FilesSetRulePanel_ZeroFileSizeError(),
364  NotifyDescriptor.WARNING_MESSAGE);
365  DialogDisplayer.getDefault().notify(notifyDesc);
366  return false;
367  }
368  }
369 
370  return true;
371  }
372 
378  String getRuleName() {
379  return this.ruleNameTextField.getText();
380  }
381 
391  FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
392  FilesSet.Rule.FileNameCondition condition = null;
393  if (!this.nameTextField.getText().isEmpty()) {
394  if (this.nameRegexCheckbox.isSelected()) {
395  try {
396  Pattern pattern = Pattern.compile(this.nameTextField.getText());
397  if (this.fullNameRadioButton.isSelected()) {
398  condition = new FilesSet.Rule.FullNameCondition(pattern);
399  } else {
400  condition = new FilesSet.Rule.ExtensionCondition(pattern);
401  }
402  } catch (PatternSyntaxException ex) {
403  logger.log(Level.SEVERE, "Attempt to get regex name condition that does not compile", ex); // NON-NLS
404  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
405  }
406  } else if (FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
407  if (this.fullNameRadioButton.isSelected()) {
408  condition = new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
409  } else {
410  condition = new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
411  }
412  } else {
413  logger.log(Level.SEVERE, "Attempt to get name condition with illegal chars"); // NON-NLS
414  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
415  }
416  }
417  return condition;
418  }
419 
425  FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
426  FilesSet.Rule.MimeTypeCondition condition = null;
427  if (!this.mimeTypeComboBox.getSelectedItem().equals("")) {
428  condition = new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
429  }
430  return condition;
431  }
432 
438  FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
439  FilesSet.Rule.FileSizeCondition condition = null;
440  if (this.fileSizeCheck.isSelected()) {
441  if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
442  FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
443  FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
444  int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
445  condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
446  }
447  }
448  return condition;
449  }
450 
457  FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
458  if (this.filesRadioButton.isSelected()) {
459  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
460  } else if (this.dirsRadioButton.isSelected()) {
461  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
462  } else {
463  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
464  }
465  }
466 
476  FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
477  FilesSet.Rule.ParentPathCondition condition = null;
478  if (!this.pathTextField.getText().isEmpty()) {
479  if (this.pathRegexCheckBox.isSelected()) {
480  try {
481  condition = new FilesSet.Rule.ParentPathCondition(Pattern.compile(this.pathTextField.getText()));
482  } catch (PatternSyntaxException ex) {
483  logger.log(Level.SEVERE, "Attempt to get malformed path condition", ex); // NON-NLS
484  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
485  }
486  } else {
487  String path = this.pathTextField.getText();
488  if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
489  // Add a leading path separator if omitted.
490  if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
491  path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
492  }
493  // Add a trailing path separator if omitted.
494  if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
495  path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
496  }
497  condition = new FilesSet.Rule.ParentPathCondition(path);
498  } else {
499  logger.log(Level.SEVERE, "Attempt to get path condition with illegal chars"); // NON-NLS
500  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
501  }
502  }
503  }
504  return condition;
505  }
506 
516  private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
517  for (String illegalChar : illegalChars) {
518  if (toBeChecked.contains(illegalChar)) {
519  return false;
520  }
521  }
522  return true;
523  }
524 
529  private void setComponentsForSearchType() {
530  if (!this.filesRadioButton.isSelected()) {
531  this.fullNameRadioButton.setSelected(true);
532  this.extensionRadioButton.setEnabled(false);
533  this.mimeTypeComboBox.setEnabled(false);
534  this.mimeTypeComboBox.setSelectedIndex(0);
535  this.equalitySymbolComboBox.setEnabled(false);
536  this.fileSizeComboBox.setEnabled(false);
537  this.fileSizeSpinner.setEnabled(false);
538  this.fileSizeSpinner.setValue(0);
539  this.fileSizeCheck.setEnabled(false);
540  this.fileSizeCheck.setSelected(false);
541  this.mimeCheck.setEnabled(false);
542  this.mimeCheck.setSelected(false);
543  } else {
544  if (this.nameCheck.isSelected()) {
545  this.extensionRadioButton.setEnabled(true);
546  }
547  this.fileSizeCheck.setEnabled(true);
548  this.mimeCheck.setEnabled(true);
549  }
550  }
551 
557  @SuppressWarnings("unchecked")
558  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
559  private void initComponents() {
560 
561  nameButtonGroup = new javax.swing.ButtonGroup();
562  typeButtonGroup = new javax.swing.ButtonGroup();
563  ruleNameLabel = new javax.swing.JLabel();
564  ruleNameTextField = new javax.swing.JTextField();
565  jLabel1 = new javax.swing.JLabel();
566  nameTextField = new javax.swing.JTextField();
567  fullNameRadioButton = new javax.swing.JRadioButton();
568  extensionRadioButton = new javax.swing.JRadioButton();
569  nameRegexCheckbox = new javax.swing.JCheckBox();
570  pathTextField = new javax.swing.JTextField();
571  pathRegexCheckBox = new javax.swing.JCheckBox();
572  pathSeparatorInfoLabel = new javax.swing.JLabel();
573  jLabel5 = new javax.swing.JLabel();
574  mimeTypeComboBox = new javax.swing.JComboBox<String>();
575  equalitySymbolComboBox = new javax.swing.JComboBox<String>();
576  fileSizeComboBox = new javax.swing.JComboBox<String>();
577  fileSizeSpinner = new javax.swing.JSpinner();
578  nameCheck = new javax.swing.JCheckBox();
579  pathCheck = new javax.swing.JCheckBox();
580  mimeCheck = new javax.swing.JCheckBox();
581  fileSizeCheck = new javax.swing.JCheckBox();
582  filesRadioButton = new javax.swing.JRadioButton();
583  dirsRadioButton = new javax.swing.JRadioButton();
584  allRadioButton = new javax.swing.JRadioButton();
585 
586  org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
587 
588  ruleNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameTextField.text")); // NOI18N
589  ruleNameTextField.addActionListener(new java.awt.event.ActionListener() {
590  public void actionPerformed(java.awt.event.ActionEvent evt) {
591  ruleNameTextFieldActionPerformed(evt);
592  }
593  });
594 
595  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.jLabel1.text")); // NOI18N
596 
597  nameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameTextField.text")); // NOI18N
598  nameTextField.setEnabled(false);
599 
600  nameButtonGroup.add(fullNameRadioButton);
601  org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
602  fullNameRadioButton.setEnabled(false);
603 
604  nameButtonGroup.add(extensionRadioButton);
605  org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
606  extensionRadioButton.setEnabled(false);
607 
608  org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameRegexCheckbox.text")); // NOI18N
609  nameRegexCheckbox.setEnabled(false);
610 
611  pathTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathTextField.text")); // NOI18N
612  pathTextField.setEnabled(false);
613 
614  org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathRegexCheckBox.text")); // NOI18N
615  pathRegexCheckBox.setEnabled(false);
616 
617  pathSeparatorInfoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N
618  org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathSeparatorInfoLabel.text")); // NOI18N
619  pathSeparatorInfoLabel.setEnabled(false);
620 
621  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.interesting.jLabel5.text")); // NOI18N
622 
623  mimeTypeComboBox.setEditable(true);
624  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
625  mimeTypeComboBox.setEnabled(false);
626 
627  equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
628  equalitySymbolComboBox.setEnabled(false);
629 
630  fileSizeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
631  fileSizeComboBox.setEnabled(false);
632 
633  fileSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
634  fileSizeSpinner.setEnabled(false);
635 
636  org.openide.awt.Mnemonics.setLocalizedText(nameCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameCheck.text")); // NOI18N
637  nameCheck.addActionListener(new java.awt.event.ActionListener() {
638  public void actionPerformed(java.awt.event.ActionEvent evt) {
639  nameCheckActionPerformed(evt);
640  }
641  });
642 
643  org.openide.awt.Mnemonics.setLocalizedText(pathCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathCheck.text")); // NOI18N
644  pathCheck.addActionListener(new java.awt.event.ActionListener() {
645  public void actionPerformed(java.awt.event.ActionEvent evt) {
646  pathCheckActionPerformed(evt);
647  }
648  });
649 
650  org.openide.awt.Mnemonics.setLocalizedText(mimeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.mimeCheck.text")); // NOI18N
651  mimeCheck.addActionListener(new java.awt.event.ActionListener() {
652  public void actionPerformed(java.awt.event.ActionEvent evt) {
653  mimeCheckActionPerformed(evt);
654  }
655  });
656 
657  org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fileSizeCheck.text")); // NOI18N
658  fileSizeCheck.addActionListener(new java.awt.event.ActionListener() {
659  public void actionPerformed(java.awt.event.ActionEvent evt) {
660  fileSizeCheckActionPerformed(evt);
661  }
662  });
663 
664  typeButtonGroup.add(filesRadioButton);
665  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N
666  filesRadioButton.addActionListener(new java.awt.event.ActionListener() {
667  public void actionPerformed(java.awt.event.ActionEvent evt) {
668  filesRadioButtonActionPerformed(evt);
669  }
670  });
671 
672  typeButtonGroup.add(dirsRadioButton);
673  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N
674  dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
675  public void actionPerformed(java.awt.event.ActionEvent evt) {
676  dirsRadioButtonActionPerformed(evt);
677  }
678  });
679 
680  typeButtonGroup.add(allRadioButton);
681  org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.allRadioButton.text")); // NOI18N
682  allRadioButton.addActionListener(new java.awt.event.ActionListener() {
683  public void actionPerformed(java.awt.event.ActionEvent evt) {
684  allRadioButtonActionPerformed(evt);
685  }
686  });
687 
688  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
689  this.setLayout(layout);
690  layout.setHorizontalGroup(
691  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
692  .addGroup(layout.createSequentialGroup()
693  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
694  .addGroup(layout.createSequentialGroup()
695  .addGap(8, 8, 8)
696  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
697  .addGroup(layout.createSequentialGroup()
698  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
699  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
700  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
701  .addGroup(layout.createSequentialGroup()
702  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
703  .addComponent(jLabel5)
704  .addGroup(layout.createSequentialGroup()
705  .addComponent(jLabel1)
706  .addGap(65, 65, 65)
707  .addComponent(filesRadioButton)
708  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
709  .addComponent(dirsRadioButton)
710  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
711  .addComponent(allRadioButton)))
712  .addGap(0, 0, Short.MAX_VALUE))))
713  .addGroup(layout.createSequentialGroup()
714  .addContainerGap()
715  .addComponent(nameCheck)
716  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
717  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
718  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
719  .addContainerGap()
720  .addComponent(pathCheck)
721  .addGap(4, 4, 4)
722  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
723  .addGroup(layout.createSequentialGroup()
724  .addComponent(pathRegexCheckBox)
725  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
726  .addComponent(pathSeparatorInfoLabel))
727  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
728  .addGap(0, 0, Short.MAX_VALUE)
729  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
730  .addGroup(layout.createSequentialGroup()
731  .addComponent(fullNameRadioButton)
732  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
733  .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
734  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
735  .addComponent(nameRegexCheckbox)
736  .addGap(0, 0, Short.MAX_VALUE))))
737  .addGroup(layout.createSequentialGroup()
738  .addContainerGap()
739  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
740  .addComponent(mimeCheck)
741  .addComponent(fileSizeCheck))
742  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
743  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
744  .addGroup(layout.createSequentialGroup()
745  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
746  .addGap(18, 18, 18)
747  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
748  .addGap(18, 18, 18)
749  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
750  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
751  .addContainerGap())
752  );
753  layout.setVerticalGroup(
754  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
755  .addGroup(layout.createSequentialGroup()
756  .addComponent(jLabel5)
757  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
758  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
759  .addComponent(jLabel1)
760  .addComponent(filesRadioButton)
761  .addComponent(dirsRadioButton)
762  .addComponent(allRadioButton))
763  .addGap(5, 5, 5)
764  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
765  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
766  .addComponent(nameCheck))
767  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
768  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
769  .addComponent(fullNameRadioButton)
770  .addComponent(extensionRadioButton)
771  .addComponent(nameRegexCheckbox))
772  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
773  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
774  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
775  .addComponent(pathCheck))
776  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
777  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
778  .addComponent(pathRegexCheckBox)
779  .addComponent(pathSeparatorInfoLabel))
780  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
781  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
782  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
783  .addComponent(mimeCheck))
784  .addGap(11, 11, 11)
785  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
786  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
787  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
788  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
789  .addComponent(fileSizeCheck))
790  .addGap(15, 15, 15)
791  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
792  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
793  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
794  .addContainerGap())
795  );
796  }// </editor-fold>//GEN-END:initComponents
797 
798  private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ruleNameTextFieldActionPerformed
799  // TODO add your handling code here:
800  }//GEN-LAST:event_ruleNameTextFieldActionPerformed
801 
802  private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckActionPerformed
803  if (!this.nameCheck.isSelected()) {
804  this.nameTextField.setEnabled(false);
805  this.nameTextField.setText("");
806  this.fullNameRadioButton.setEnabled(false);
807  this.extensionRadioButton.setEnabled(false);
808  this.nameRegexCheckbox.setEnabled(false);
809  } else {
810  this.nameTextField.setEnabled(true);
811  this.fullNameRadioButton.setEnabled(true);
812  if (this.filesRadioButton.isSelected()) {
813  this.extensionRadioButton.setEnabled(true);
814  }
815  this.nameRegexCheckbox.setEnabled(true);
816  }
817  this.setOkButton();
818  }//GEN-LAST:event_nameCheckActionPerformed
819 
820  private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathCheckActionPerformed
821  if (!this.pathCheck.isSelected()) {
822  this.pathTextField.setEnabled(false);
823  this.pathTextField.setText("");
824  this.pathRegexCheckBox.setEnabled(false);
825  this.pathSeparatorInfoLabel.setEnabled(false);
826  } else {
827  this.pathTextField.setEnabled(true);
828  this.pathRegexCheckBox.setEnabled(true);
829  this.pathSeparatorInfoLabel.setEnabled(true);
830  }
831  this.setOkButton();
832  }//GEN-LAST:event_pathCheckActionPerformed
833 
834  private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeCheckActionPerformed
835  if (!this.mimeCheck.isSelected()) {
836  this.mimeTypeComboBox.setEnabled(false);
837  this.mimeTypeComboBox.setSelectedIndex(0);
838  } else {
839  this.mimeTypeComboBox.setEnabled(true);
840  }
841  this.setOkButton();
842  }//GEN-LAST:event_mimeCheckActionPerformed
843 
844  private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSizeCheckActionPerformed
845  if (!this.fileSizeCheck.isSelected()) {
846  this.fileSizeComboBox.setEnabled(false);
847  this.fileSizeSpinner.setEnabled(false);
848  this.fileSizeSpinner.setValue(0);
849  this.equalitySymbolComboBox.setEnabled(false);
850  } else {
851  this.fileSizeComboBox.setEnabled(true);
852  this.fileSizeSpinner.setEnabled(true);
853  this.equalitySymbolComboBox.setEnabled(true);
854  }
855  this.setOkButton();
856  }//GEN-LAST:event_fileSizeCheckActionPerformed
857 
858  private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed
859 
860  this.setComponentsForSearchType();
861  }//GEN-LAST:event_filesRadioButtonActionPerformed
862 
863  private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
864  this.setComponentsForSearchType();
865  }//GEN-LAST:event_dirsRadioButtonActionPerformed
866 
867  private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allRadioButtonActionPerformed
868  this.setComponentsForSearchType();
869  }//GEN-LAST:event_allRadioButtonActionPerformed
870 
871  // Variables declaration - do not modify//GEN-BEGIN:variables
872  private javax.swing.JRadioButton allRadioButton;
873  private javax.swing.JRadioButton dirsRadioButton;
874  private javax.swing.JComboBox<String> equalitySymbolComboBox;
875  private javax.swing.JRadioButton extensionRadioButton;
876  private javax.swing.JCheckBox fileSizeCheck;
877  private javax.swing.JComboBox<String> fileSizeComboBox;
878  private javax.swing.JSpinner fileSizeSpinner;
879  private javax.swing.JRadioButton filesRadioButton;
880  private javax.swing.JRadioButton fullNameRadioButton;
881  private javax.swing.JLabel jLabel1;
882  private javax.swing.JLabel jLabel5;
883  private javax.swing.JCheckBox mimeCheck;
884  private javax.swing.JComboBox<String> mimeTypeComboBox;
885  private javax.swing.ButtonGroup nameButtonGroup;
886  private javax.swing.JCheckBox nameCheck;
887  private javax.swing.JCheckBox nameRegexCheckbox;
888  private javax.swing.JTextField nameTextField;
889  private javax.swing.JCheckBox pathCheck;
890  private javax.swing.JCheckBox pathRegexCheckBox;
891  private javax.swing.JLabel pathSeparatorInfoLabel;
892  private javax.swing.JTextField pathTextField;
893  private javax.swing.JLabel ruleNameLabel;
894  private javax.swing.JTextField ruleNameTextField;
895  private javax.swing.ButtonGroup typeButtonGroup;
896  // End of variables declaration//GEN-END:variables
897 }

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