Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilesSetRulePanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 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  private void populateSizeConditionComponents(FilesSet.Rule rule) {
156  FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
157  if (fileSizeCondition != null) {
158  this.fileSizeCheck.setSelected(true);
159  this.fileSizeCheckActionPerformed(null);
160  this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
161  this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
162  this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
163  }
164  }
165 
170  private void setOkButton() {
171  if (this.okButton != null) {
172  this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
173  || this.nameCheck.isSelected() || this.pathCheck.isSelected());
174  }
175  }
176 
184  private JOptionPane getOptionPane(JComponent parent) {
185  JOptionPane pane = null;
186  if (!(parent instanceof JOptionPane)) {
187  pane = getOptionPane((JComponent) parent.getParent());
188  } else {
189  pane = (JOptionPane) parent;
190  }
191  return pane;
192  }
193 
200  private void setButtons(JButton ok, JButton cancel) {
201  this.okButton = ok;
202  this.cancelButton = cancel;
203  okButton.addActionListener(new ActionListener() {
204  @Override
205  public void actionPerformed(ActionEvent e) {
206  JOptionPane pane = getOptionPane(okButton);
207  pane.setValue(okButton);
208  }
209  });
210  cancelButton.addActionListener(new ActionListener() {
211  @Override
212  public void actionPerformed(ActionEvent e) {
213  JOptionPane pane = getOptionPane(cancelButton);
214  pane.setValue(cancelButton);
215  }
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 FILES_AND_DIRECTORIES:
236  this.filesAndDirsRadioButton.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 {
315  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 
325  // The path condition, if specified, must either be a regular expression
326  // that compiles or a string without illegal file path chars.
327  if (this.pathCheck.isSelected()) {
328  if (this.pathTextField.getText().isEmpty()) {
329  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
330  Bundle.FilesSetRulePanel_NoPathError(),
331  NotifyDescriptor.WARNING_MESSAGE);
332  DialogDisplayer.getDefault().notify(notifyDesc);
333  return false;
334  }
335  if (this.pathRegexCheckBox.isSelected()) {
336  try {
337  Pattern.compile(this.pathTextField.getText());
338  } catch (PatternSyntaxException ex) {
339  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
340  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
341  NotifyDescriptor.WARNING_MESSAGE);
342  DialogDisplayer.getDefault().notify(notifyDesc);
343  return false;
344  }
345  } else {
346  if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
347  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
348  NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.invalidCharInPath"),
349  NotifyDescriptor.WARNING_MESSAGE);
350  DialogDisplayer.getDefault().notify(notifyDesc);
351  return false;
352  }
353  }
354  }
355  if (this.mimeCheck.isSelected()) {
356  if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
357  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
358  Bundle.FilesSetRulePanel_NoMimeTypeError(),
359  NotifyDescriptor.WARNING_MESSAGE);
360  DialogDisplayer.getDefault().notify(notifyDesc);
361  return false;
362  }
363  }
364  if (this.fileSizeCheck.isSelected()) {
365  if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String)this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
366  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
367  Bundle.FilesSetRulePanel_ZeroFileSizeError(),
368  NotifyDescriptor.WARNING_MESSAGE);
369  DialogDisplayer.getDefault().notify(notifyDesc);
370  return false;
371  }
372  }
373 
374  return true;
375  }
376 
382  String getRuleName() {
383  return this.ruleNameTextField.getText();
384  }
385 
395  FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
396  FilesSet.Rule.FileNameCondition condition = null;
397  if (!this.nameTextField.getText().isEmpty()) {
398  if (this.nameRegexCheckbox.isSelected()) {
399  try {
400  Pattern pattern = Pattern.compile(this.nameTextField.getText());
401  if (this.fullNameRadioButton.isSelected()) {
402  condition = new FilesSet.Rule.FullNameCondition(pattern);
403  } else {
404  condition = new FilesSet.Rule.ExtensionCondition(pattern);
405  }
406  } catch (PatternSyntaxException ex) {
407  logger.log(Level.SEVERE, "Attempt to get regex name condition that does not compile", ex); // NON-NLS
408  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
409  }
410  } else {
411  if (FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
412  if (this.fullNameRadioButton.isSelected()) {
413  condition = new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
414  } else {
415  condition = new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
416  }
417  } else {
418  logger.log(Level.SEVERE, "Attempt to get name condition with illegal chars"); // NON-NLS
419  throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
420  }
421  }
422  }
423  return condition;
424  }
425 
431  FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
432  FilesSet.Rule.MimeTypeCondition condition = null;
433  if (!this.mimeTypeComboBox.getSelectedItem().equals("")) {
434  condition = new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
435  }
436  return condition;
437  }
438 
444  FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
445  FilesSet.Rule.FileSizeCondition condition = null;
446  if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String)this.equalitySymbolComboBox.getSelectedItem()).equals("=")) {
447  FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
448  FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
449  int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
450  condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
451  }
452  return condition;
453  }
454 
461  FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
462  if (this.filesRadioButton.isSelected()) {
463  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
464  } else if (this.dirsRadioButton.isSelected()) {
465  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
466  } else {
467  return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
468  }
469  }
470 
480  FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
481  FilesSet.Rule.ParentPathCondition condition = null;
482  if (!this.pathTextField.getText().isEmpty()) {
483  if (this.pathRegexCheckBox.isSelected()) {
484  try {
485  condition = new FilesSet.Rule.ParentPathCondition(Pattern.compile(this.pathTextField.getText()));
486  } catch (PatternSyntaxException ex) {
487  logger.log(Level.SEVERE, "Attempt to get malformed path condition", ex); // NON-NLS
488  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
489  }
490  } else {
491  String path = this.pathTextField.getText();
492  if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
493  // Add a leading path separator if omitted.
494  if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
495  path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
496  }
497  // Add a trailing path separator if omitted.
498  if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
499  path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
500  }
501  condition = new FilesSet.Rule.ParentPathCondition(path);
502  } else {
503  logger.log(Level.SEVERE, "Attempt to get path condition with illegal chars"); // NON-NLS
504  throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
505  }
506  }
507  }
508  return condition;
509  }
510 
520  private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
521  for (String illegalChar : illegalChars) {
522  if (toBeChecked.contains(illegalChar)) {
523  return false;
524  }
525  }
526  return true;
527  }
528 
533  private void setComponentsForSearchType() {
534  if (!this.filesRadioButton.isSelected()) {
535  this.fullNameRadioButton.setSelected(true);
536  this.extensionRadioButton.setEnabled(false);
537  this.mimeTypeComboBox.setEnabled(false);
538  this.mimeTypeComboBox.setSelectedIndex(0);
539  this.equalitySymbolComboBox.setEnabled(false);
540  this.fileSizeComboBox.setEnabled(false);
541  this.fileSizeSpinner.setEnabled(false);
542  this.fileSizeSpinner.setValue(0);
543  this.fileSizeCheck.setEnabled(false);
544  this.fileSizeCheck.setSelected(false);
545  this.mimeCheck.setEnabled(false);
546  this.mimeCheck.setSelected(false);
547 
548  } else {
549  this.extensionRadioButton.setEnabled(true);
550  this.fileSizeCheck.setEnabled(true);
551  this.mimeCheck.setEnabled(true);
552  }
553  }
554 
560  @SuppressWarnings("unchecked")
561  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
562  private void initComponents() {
563 
564  nameButtonGroup = new javax.swing.ButtonGroup();
565  typeButtonGroup = new javax.swing.ButtonGroup();
566  ruleNameLabel = new javax.swing.JLabel();
567  ruleNameTextField = new javax.swing.JTextField();
568  jLabel1 = new javax.swing.JLabel();
569  nameTextField = new javax.swing.JTextField();
570  fullNameRadioButton = new javax.swing.JRadioButton();
571  extensionRadioButton = new javax.swing.JRadioButton();
572  nameRegexCheckbox = new javax.swing.JCheckBox();
573  pathTextField = new javax.swing.JTextField();
574  pathRegexCheckBox = new javax.swing.JCheckBox();
575  pathSeparatorInfoLabel = new javax.swing.JLabel();
576  jLabel5 = new javax.swing.JLabel();
577  mimeTypeComboBox = new javax.swing.JComboBox<String>();
578  equalitySymbolComboBox = new javax.swing.JComboBox<String>();
579  fileSizeComboBox = new javax.swing.JComboBox<String>();
580  fileSizeSpinner = new javax.swing.JSpinner();
581  nameCheck = new javax.swing.JCheckBox();
582  pathCheck = new javax.swing.JCheckBox();
583  mimeCheck = new javax.swing.JCheckBox();
584  fileSizeCheck = new javax.swing.JCheckBox();
585  filesRadioButton = new javax.swing.JRadioButton();
586  dirsRadioButton = new javax.swing.JRadioButton();
587  filesAndDirsRadioButton = new javax.swing.JRadioButton();
588 
589  org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
590 
591  ruleNameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameTextField.text")); // NOI18N
592  ruleNameTextField.addActionListener(new java.awt.event.ActionListener() {
593  public void actionPerformed(java.awt.event.ActionEvent evt) {
594  ruleNameTextFieldActionPerformed(evt);
595  }
596  });
597 
598  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.jLabel1.text")); // NOI18N
599 
600  nameTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameTextField.text")); // NOI18N
601  nameTextField.setEnabled(false);
602 
603  nameButtonGroup.add(fullNameRadioButton);
604  org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
605  fullNameRadioButton.setEnabled(false);
606  fullNameRadioButton.addActionListener(new java.awt.event.ActionListener() {
607  public void actionPerformed(java.awt.event.ActionEvent evt) {
608  fullNameRadioButtonActionPerformed(evt);
609  }
610  });
611 
612  nameButtonGroup.add(extensionRadioButton);
613  org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
614  extensionRadioButton.setEnabled(false);
615 
616  org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameRegexCheckbox.text")); // NOI18N
617  nameRegexCheckbox.setEnabled(false);
618 
619  pathTextField.setText(org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathTextField.text")); // NOI18N
620  pathTextField.setEnabled(false);
621 
622  org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathRegexCheckBox.text")); // NOI18N
623  pathRegexCheckBox.setEnabled(false);
624 
625  pathSeparatorInfoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N
626  org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathSeparatorInfoLabel.text")); // NOI18N
627  pathSeparatorInfoLabel.setEnabled(false);
628 
629  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.jLabel5.text")); // NOI18N
630 
631  mimeTypeComboBox.setEditable(true);
632  mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
633  mimeTypeComboBox.setEnabled(false);
634 
635  equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
636  equalitySymbolComboBox.setEnabled(false);
637 
638  fileSizeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
639  fileSizeComboBox.setEnabled(false);
640 
641  fileSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
642  fileSizeSpinner.setEnabled(false);
643 
644  org.openide.awt.Mnemonics.setLocalizedText(nameCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.nameCheck.text")); // NOI18N
645  nameCheck.addActionListener(new java.awt.event.ActionListener() {
646  public void actionPerformed(java.awt.event.ActionEvent evt) {
647  nameCheckActionPerformed(evt);
648  }
649  });
650 
651  org.openide.awt.Mnemonics.setLocalizedText(pathCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.pathCheck.text")); // NOI18N
652  pathCheck.addActionListener(new java.awt.event.ActionListener() {
653  public void actionPerformed(java.awt.event.ActionEvent evt) {
654  pathCheckActionPerformed(evt);
655  }
656  });
657 
658  org.openide.awt.Mnemonics.setLocalizedText(mimeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.mimeCheck.text")); // NOI18N
659  mimeCheck.addActionListener(new java.awt.event.ActionListener() {
660  public void actionPerformed(java.awt.event.ActionEvent evt) {
661  mimeCheckActionPerformed(evt);
662  }
663  });
664 
665  org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fileSizeCheck.text")); // NOI18N
666  fileSizeCheck.addActionListener(new java.awt.event.ActionListener() {
667  public void actionPerformed(java.awt.event.ActionEvent evt) {
668  fileSizeCheckActionPerformed(evt);
669  }
670  });
671 
672  typeButtonGroup.add(filesRadioButton);
673  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N
674  filesRadioButton.addActionListener(new java.awt.event.ActionListener() {
675  public void actionPerformed(java.awt.event.ActionEvent evt) {
676  filesRadioButtonActionPerformed(evt);
677  }
678  });
679 
680  typeButtonGroup.add(dirsRadioButton);
681  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N
682  dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
683  public void actionPerformed(java.awt.event.ActionEvent evt) {
684  dirsRadioButtonActionPerformed(evt);
685  }
686  });
687 
688  typeButtonGroup.add(filesAndDirsRadioButton);
689  org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesAndDirsRadioButton.text")); // NOI18N
690  filesAndDirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
691  public void actionPerformed(java.awt.event.ActionEvent evt) {
692  filesAndDirsRadioButtonActionPerformed(evt);
693  }
694  });
695 
696  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
697  this.setLayout(layout);
698  layout.setHorizontalGroup(
699  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
700  .addGroup(layout.createSequentialGroup()
701  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
702  .addGroup(layout.createSequentialGroup()
703  .addGap(8, 8, 8)
704  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
705  .addGroup(layout.createSequentialGroup()
706  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
707  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
708  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
709  .addGroup(layout.createSequentialGroup()
710  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
711  .addComponent(jLabel5)
712  .addGroup(layout.createSequentialGroup()
713  .addComponent(jLabel1)
714  .addGap(65, 65, 65)
715  .addComponent(filesRadioButton)
716  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
717  .addComponent(dirsRadioButton)
718  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
719  .addComponent(filesAndDirsRadioButton)))
720  .addGap(0, 0, Short.MAX_VALUE))))
721  .addGroup(layout.createSequentialGroup()
722  .addContainerGap()
723  .addComponent(nameCheck)
724  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
725  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
726  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
727  .addContainerGap()
728  .addComponent(pathCheck)
729  .addGap(4, 4, 4)
730  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
731  .addGroup(layout.createSequentialGroup()
732  .addComponent(pathRegexCheckBox)
733  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
734  .addComponent(pathSeparatorInfoLabel))
735  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
736  .addGap(0, 0, Short.MAX_VALUE)
737  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
738  .addGroup(layout.createSequentialGroup()
739  .addComponent(fullNameRadioButton)
740  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
741  .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
742  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
743  .addComponent(nameRegexCheckbox)
744  .addGap(0, 0, Short.MAX_VALUE))))
745  .addGroup(layout.createSequentialGroup()
746  .addContainerGap()
747  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
748  .addComponent(mimeCheck)
749  .addComponent(fileSizeCheck))
750  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
751  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
752  .addGroup(layout.createSequentialGroup()
753  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
754  .addGap(18, 18, 18)
755  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
756  .addGap(18, 18, 18)
757  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
758  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
759  .addContainerGap())
760  );
761  layout.setVerticalGroup(
762  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
763  .addGroup(layout.createSequentialGroup()
764  .addComponent(jLabel5)
765  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
766  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
767  .addComponent(jLabel1)
768  .addComponent(filesRadioButton)
769  .addComponent(dirsRadioButton)
770  .addComponent(filesAndDirsRadioButton))
771  .addGap(5, 5, 5)
772  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
773  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
774  .addComponent(nameCheck))
775  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
776  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
777  .addComponent(fullNameRadioButton)
778  .addComponent(extensionRadioButton)
779  .addComponent(nameRegexCheckbox))
780  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
781  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
782  .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
783  .addComponent(pathCheck))
784  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
785  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
786  .addComponent(pathRegexCheckBox)
787  .addComponent(pathSeparatorInfoLabel))
788  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
789  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
790  .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
791  .addComponent(mimeCheck))
792  .addGap(11, 11, 11)
793  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
794  .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
795  .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
796  .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
797  .addComponent(fileSizeCheck))
798  .addGap(15, 15, 15)
799  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
800  .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
801  .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
802  .addContainerGap())
803  );
804  }// </editor-fold>//GEN-END:initComponents
805 
806  private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ruleNameTextFieldActionPerformed
807  // TODO add your handling code here:
808  }//GEN-LAST:event_ruleNameTextFieldActionPerformed
809 
810  private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckActionPerformed
811  if (!this.nameCheck.isSelected()) {
812  this.nameTextField.setEnabled(false);
813  this.nameTextField.setText("");
814  this.fullNameRadioButton.setEnabled(false);
815  this.extensionRadioButton.setEnabled(false);
816  this.nameRegexCheckbox.setEnabled(false);
817  } else {
818  this.nameTextField.setEnabled(true);
819  this.fullNameRadioButton.setEnabled(true);
820  this.extensionRadioButton.setEnabled(true);
821  this.nameRegexCheckbox.setEnabled(true);
822  }
823  this.setOkButton();
824  }//GEN-LAST:event_nameCheckActionPerformed
825 
826  private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathCheckActionPerformed
827  if (!this.pathCheck.isSelected()) {
828  this.pathTextField.setEnabled(false);
829  this.pathTextField.setText("");
830  this.pathRegexCheckBox.setEnabled(false);
831  this.pathSeparatorInfoLabel.setEnabled(false);
832  } else {
833  this.pathTextField.setEnabled(true);
834  this.pathRegexCheckBox.setEnabled(true);
835  this.pathSeparatorInfoLabel.setEnabled(true);
836  }
837  this.setOkButton();
838  }//GEN-LAST:event_pathCheckActionPerformed
839 
840  private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeCheckActionPerformed
841  if (!this.mimeCheck.isSelected()) {
842  this.mimeTypeComboBox.setEnabled(false);
843  this.mimeTypeComboBox.setSelectedIndex(0);
844  } else {
845  this.mimeTypeComboBox.setEnabled(true);
846  }
847  this.setOkButton();
848  }//GEN-LAST:event_mimeCheckActionPerformed
849 
850  private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSizeCheckActionPerformed
851  if (!this.fileSizeCheck.isSelected()) {
852  this.fileSizeComboBox.setEnabled(false);
853  this.fileSizeSpinner.setEnabled(false);
854  this.fileSizeSpinner.setValue(0);
855  this.equalitySymbolComboBox.setEnabled(false);
856  } else {
857  this.fileSizeComboBox.setEnabled(true);
858  this.fileSizeSpinner.setEnabled(true);
859  this.equalitySymbolComboBox.setEnabled(true);
860  }
861  this.setOkButton();
862  }//GEN-LAST:event_fileSizeCheckActionPerformed
863 
864  private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed
865 
866  this.setComponentsForSearchType();
867  }//GEN-LAST:event_filesRadioButtonActionPerformed
868 
869  private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
870  this.setComponentsForSearchType();
871  }//GEN-LAST:event_dirsRadioButtonActionPerformed
872 
873  private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesAndDirsRadioButtonActionPerformed
874  this.setComponentsForSearchType();
875  }//GEN-LAST:event_filesAndDirsRadioButtonActionPerformed
876 
877  private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fullNameRadioButtonActionPerformed
878  // TODO add your handling code here:
879  }//GEN-LAST:event_fullNameRadioButtonActionPerformed
880 
881  // Variables declaration - do not modify//GEN-BEGIN:variables
882  private javax.swing.JRadioButton dirsRadioButton;
883  private javax.swing.JComboBox<String> equalitySymbolComboBox;
884  private javax.swing.JRadioButton extensionRadioButton;
885  private javax.swing.JCheckBox fileSizeCheck;
886  private javax.swing.JComboBox<String> fileSizeComboBox;
887  private javax.swing.JSpinner fileSizeSpinner;
888  private javax.swing.JRadioButton filesAndDirsRadioButton;
889  private javax.swing.JRadioButton filesRadioButton;
890  private javax.swing.JRadioButton fullNameRadioButton;
891  private javax.swing.JLabel jLabel1;
892  private javax.swing.JLabel jLabel5;
893  private javax.swing.JCheckBox mimeCheck;
894  private javax.swing.JComboBox<String> mimeTypeComboBox;
895  private javax.swing.ButtonGroup nameButtonGroup;
896  private javax.swing.JCheckBox nameCheck;
897  private javax.swing.JCheckBox nameRegexCheckbox;
898  private javax.swing.JTextField nameTextField;
899  private javax.swing.JCheckBox pathCheck;
900  private javax.swing.JCheckBox pathRegexCheckBox;
901  private javax.swing.JLabel pathSeparatorInfoLabel;
902  private javax.swing.JTextField pathTextField;
903  private javax.swing.JLabel ruleNameLabel;
904  private javax.swing.JTextField ruleNameTextField;
905  private javax.swing.ButtonGroup typeButtonGroup;
906  // End of variables declaration//GEN-END:variables
907 }

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