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

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.