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

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