19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.awt.Color;
22 import java.awt.event.ActionEvent;
23 import java.util.Arrays;
24 import java.util.List;
25 import java.util.SortedSet;
26 import java.util.logging.Level;
27 import java.util.regex.Pattern;
28 import java.util.regex.PatternSyntaxException;
29 import javax.swing.JButton;
30 import javax.swing.JComponent;
31 import javax.swing.JOptionPane;
32 import org.openide.DialogDisplayer;
33 import org.openide.NotifyDescriptor;
34 import org.openide.util.NbBundle;
35 import org.openide.util.NbBundle.Messages;
44 @SuppressWarnings(
"PMD.SingularField")
45 final class FilesSetRulePanel extends javax.swing.JPanel {
48 "FilesSetRulePanel.bytes=Bytes",
49 "FilesSetRulePanel.kiloBytes=Kilobytes",
50 "FilesSetRulePanel.megaBytes=Megabytes",
51 "FilesSetRulePanel.gigaBytes=Gigabytes",
52 "FilesSetRulePanel.nameTextField.fullNameExample=Example: \"file.exe\"",
53 "FilesSetRulePanel.nameTextField.extensionExample=Examples: \"jpg\" or \"jpg,jpeg,gif\"",
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.DaysIncludedEmptyError=Number of days included cannot be empty.",
59 "FilesSetRulePanel.DaysIncludedInvalidError=Number of days included must be a positive integer.",
60 "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected).",
62 "FilesSetRulePanel.CommaInRegexWarning=Warning: Comma(s) in the file extension field will be interpreted as part of a regex and will not split the entry into multiple extensions (Entered: \"{0}\")",
65 private static final long serialVersionUID = 1L;
66 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
67 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
68 private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
69 private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
70 private JButton okButton;
71 private JButton cancelButton;
72 private TextPrompt nameTextFieldPrompt;
77 FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
79 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
80 mimeTypeComboBox.setVisible(
false);
81 mimeCheck.setVisible(
false);
82 jLabel1.setVisible(
false);
83 filesRadioButton.setVisible(
false);
84 dirsRadioButton.setVisible(
false);
85 allRadioButton.setVisible(
false);
86 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ingest.jLabel5.text"));
89 populateMimeTypesComboBox();
91 this.dateCheckActionPerformed(null);
92 populateComponentsWithDefaultValues();
93 this.setButtons(okButton, cancelButton);
95 updateNameTextFieldPrompt();
103 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
105 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
106 mimeTypeComboBox.setVisible(
false);
107 mimeCheck.setVisible(
false);
108 jLabel1.setVisible(
false);
109 filesRadioButton.setVisible(
false);
110 dirsRadioButton.setVisible(
false);
111 allRadioButton.setVisible(
false);
113 populateMimeTypesComboBox();
114 populateMimeConditionComponents(rule);
116 populateMimeTypesComboBox();
117 populateRuleNameComponent(rule);
118 populateTypeConditionComponents(rule);
119 populateNameConditionComponents(rule);
120 populatePathConditionComponents(rule);
121 populateDateConditionComponents(rule);
122 populateSizeConditionComponents(rule);
123 this.setButtons(okButton, cancelButton);
125 updateNameTextFieldPrompt();
126 setComponentsForSearchType();
133 private void updateNameTextFieldPrompt() {
138 if (fullNameRadioButton.isSelected()) {
139 text = Bundle.FilesSetRulePanel_nameTextField_fullNameExample();
141 text = Bundle.FilesSetRulePanel_nameTextField_extensionExample();
143 nameTextFieldPrompt =
new TextPrompt(text, nameTextField);
148 nameTextFieldPrompt.setForeground(Color.LIGHT_GRAY);
149 nameTextFieldPrompt.changeAlpha(0.9f);
158 private void populateComponentsWithDefaultValues() {
159 this.filesRadioButton.setSelected(
true);
160 this.fullNameRadioButton.setSelected(
true);
161 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
162 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
163 this.mimeTypeComboBox.setSelectedIndex(0);
166 private void populateMimeTypesComboBox() {
168 SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
169 detectableMimeTypes.forEach((type) -> {
170 mimeTypeComboBox.addItem(type);
172 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
173 logger.log(Level.SEVERE,
"Unable to get detectable file types", ex);
183 private void populateRuleNameComponent(FilesSet.Rule rule) {
184 this.ruleNameTextField.setText(rule.getName());
187 private void populateMimeConditionComponents(FilesSet.Rule rule) {
188 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
189 if (mimeTypeCondition != null) {
190 this.mimeCheck.setSelected(
true);
191 this.mimeCheckActionPerformed(null);
192 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
196 private void populateSizeConditionComponents(FilesSet.Rule rule) {
197 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
198 if (fileSizeCondition != null) {
199 this.fileSizeCheck.setSelected(
true);
200 this.fileSizeCheckActionPerformed(null);
201 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
202 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
203 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
211 private void setOkButton() {
212 if (this.okButton != null) {
213 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
214 || this.nameCheck.isSelected() || this.pathCheck.isSelected() || this.dateCheck.isSelected());
225 private JOptionPane getOptionPane(JComponent parent) {
227 if (!(parent instanceof JOptionPane)) {
228 pane = getOptionPane((JComponent) parent.getParent());
230 pane = (JOptionPane) parent;
241 private void setButtons(JButton ok, JButton cancel) {
243 this.cancelButton = cancel;
244 okButton.addActionListener((ActionEvent e) -> {
245 JOptionPane pane = getOptionPane(okButton);
246 pane.setValue(okButton);
248 cancelButton.addActionListener((ActionEvent e) -> {
249 JOptionPane pane = getOptionPane(cancelButton);
250 pane.setValue(cancelButton);
261 private void populateTypeConditionComponents(FilesSet.Rule rule) {
262 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
263 switch (typeCondition.getMetaType()) {
265 this.filesRadioButton.setSelected(
true);
268 this.dirsRadioButton.setSelected(
true);
271 this.allRadioButton.setSelected(
true);
281 private void populateNameConditionComponents(FilesSet.Rule rule) {
282 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
283 if (nameCondition != null) {
284 this.nameCheck.setSelected(
true);
285 this.nameCheckActionPerformed(null);
286 this.nameTextField.setText(nameCondition.getTextToMatch());
287 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
288 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
289 this.fullNameRadioButton.setSelected(
true);
291 this.extensionRadioButton.setSelected(
true);
302 private void populatePathConditionComponents(FilesSet.Rule rule) {
303 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
304 if (pathCondition != null) {
305 this.pathCheck.setSelected(
true);
306 this.pathCheckActionPerformed(null);
307 this.pathTextField.setText(pathCondition.getTextToMatch());
308 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
318 private void populateDateConditionComponents(FilesSet.Rule rule) {
319 FilesSet.Rule.DateCondition dateCondition = rule.getDateCondition();
320 if (dateCondition != null) {
321 this.dateCheck.setSelected(
true);
322 this.dateCheckActionPerformed(null);
323 this.daysIncludedTextField.setText(Integer.toString(dateCondition.getDaysIncluded()));
334 boolean isValidRuleDefinition() {
336 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected() || this.dateCheck.isSelected())) {
337 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
338 Bundle.FilesSetRulePanel_NoConditionError(),
339 NotifyDescriptor.WARNING_MESSAGE);
340 DialogDisplayer.getDefault().notify(notifyDesc);
344 if (this.nameCheck.isSelected()) {
347 if (this.nameTextField.getText().isEmpty()) {
348 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
349 Bundle.FilesSetRulePanel_NoNameError(),
350 NotifyDescriptor.WARNING_MESSAGE);
351 DialogDisplayer.getDefault().notify(notifyDesc);
354 if (this.nameRegexCheckbox.isSelected()) {
358 if (this.extensionRadioButton.isSelected() && this.nameTextField.getText().contains(
",")) {
359 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
360 Bundle.FilesSetRulePanel_CommaInRegexWarning(
this.nameTextField.getText()),
361 NotifyDescriptor.WARNING_MESSAGE);
362 DialogDisplayer.getDefault().notify(notifyDesc);
366 Pattern.compile(this.nameTextField.getText());
367 }
catch (PatternSyntaxException ex) {
368 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
369 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
370 NotifyDescriptor.WARNING_MESSAGE);
371 DialogDisplayer.getDefault().notify(notifyDesc);
374 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
375 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
376 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
377 NotifyDescriptor.WARNING_MESSAGE);
378 DialogDisplayer.getDefault().notify(notifyDesc);
385 if (this.pathCheck.isSelected()) {
386 if (this.pathTextField.getText().isEmpty()) {
387 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
388 Bundle.FilesSetRulePanel_NoPathError(),
389 NotifyDescriptor.WARNING_MESSAGE);
390 DialogDisplayer.getDefault().notify(notifyDesc);
393 if (this.pathRegexCheckBox.isSelected()) {
395 Pattern.compile(this.pathTextField.getText());
396 }
catch (PatternSyntaxException ex) {
397 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
398 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
399 NotifyDescriptor.WARNING_MESSAGE);
400 DialogDisplayer.getDefault().notify(notifyDesc);
403 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
404 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
405 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
406 NotifyDescriptor.WARNING_MESSAGE);
407 DialogDisplayer.getDefault().notify(notifyDesc);
411 if (this.mimeCheck.isSelected()) {
412 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
413 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
414 Bundle.FilesSetRulePanel_NoMimeTypeError(),
415 NotifyDescriptor.WARNING_MESSAGE);
416 DialogDisplayer.getDefault().notify(notifyDesc);
420 if (this.fileSizeCheck.isSelected()) {
421 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
422 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
423 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
424 NotifyDescriptor.WARNING_MESSAGE);
425 DialogDisplayer.getDefault().notify(notifyDesc);
430 if (this.dateCheck.isSelected()) {
431 if (this.daysIncludedTextField.getText().isEmpty()) {
432 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
433 Bundle.FilesSetRulePanel_DaysIncludedEmptyError(),
434 NotifyDescriptor.WARNING_MESSAGE);
435 DialogDisplayer.getDefault().notify(notifyDesc);
439 int value = Integer.parseInt(daysIncludedTextField.getText());
441 throw new NumberFormatException(
"Negative numbers are not allowed for the within N days condition");
443 }
catch (NumberFormatException e) {
445 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
446 Bundle.FilesSetRulePanel_DaysIncludedInvalidError(),
447 NotifyDescriptor.WARNING_MESSAGE);
448 DialogDisplayer.getDefault().notify(notifyDesc);
460 String getRuleName() {
461 return this.ruleNameTextField.getText();
473 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
474 FilesSet.Rule.FileNameCondition condition = null;
475 if (!this.nameTextField.getText().isEmpty()) {
476 if (this.nameRegexCheckbox.isSelected()) {
478 Pattern pattern = Pattern.compile(this.nameTextField.getText(), Pattern.CASE_INSENSITIVE);
479 if (this.fullNameRadioButton.isSelected()) {
480 condition =
new FilesSet.Rule.FullNameCondition(pattern);
482 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
484 }
catch (PatternSyntaxException ex) {
485 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
486 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
488 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
489 if (this.fullNameRadioButton.isSelected()) {
490 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
492 List<String> extensions = Arrays.asList(this.nameTextField.getText().split(
","));
493 for (
int i=0; i < extensions.size(); i++) {
495 extensions.set(i, extensions.get(i).trim());
497 condition =
new FilesSet.Rule.ExtensionCondition(extensions);
500 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
501 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
512 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
513 FilesSet.Rule.MimeTypeCondition condition = null;
514 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
515 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
525 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
526 FilesSet.Rule.FileSizeCondition condition = null;
527 if (this.fileSizeCheck.isSelected()) {
528 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
529 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
530 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
531 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
532 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
544 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
545 if (this.filesRadioButton.isSelected()) {
546 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
547 }
else if (this.dirsRadioButton.isSelected()) {
548 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
550 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
563 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
564 FilesSet.Rule.ParentPathCondition condition = null;
565 if (!this.pathTextField.getText().isEmpty()) {
566 if (this.pathRegexCheckBox.isSelected()) {
568 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText(), Pattern.CASE_INSENSITIVE));
569 }
catch (PatternSyntaxException ex) {
570 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
571 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
574 String path = this.pathTextField.getText();
575 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
577 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
578 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
581 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
582 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
584 condition =
new FilesSet.Rule.ParentPathCondition(path);
586 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
587 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
603 FilesSet.Rule.DateCondition getDateCondition() {
604 FilesSet.Rule.DateCondition dateCondition = null;
605 if (!daysIncludedTextField.getText().isEmpty()) {
606 dateCondition =
new FilesSet.Rule.DateCondition(Integer.parseInt(daysIncludedTextField.getText()));
608 return dateCondition;
620 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
621 for (String illegalChar : illegalChars) {
622 if (toBeChecked.contains(illegalChar)) {
633 private void setComponentsForSearchType() {
634 if (!this.filesRadioButton.isSelected()) {
635 this.fullNameRadioButton.setSelected(
true);
636 this.extensionRadioButton.setEnabled(
false);
637 this.mimeTypeComboBox.setEnabled(
false);
638 this.mimeTypeComboBox.setSelectedIndex(0);
639 this.equalitySymbolComboBox.setEnabled(
false);
640 this.fileSizeComboBox.setEnabled(
false);
641 this.fileSizeSpinner.setEnabled(
false);
642 this.fileSizeSpinner.setValue(0);
643 this.fileSizeCheck.setEnabled(
false);
644 this.fileSizeCheck.setSelected(
false);
645 this.mimeCheck.setEnabled(
false);
646 this.mimeCheck.setSelected(
false);
648 if (this.nameCheck.isSelected()) {
649 this.extensionRadioButton.setEnabled(
true);
651 this.fileSizeCheck.setEnabled(
true);
652 this.mimeCheck.setEnabled(
true);
661 @SuppressWarnings(
"unchecked")
663 private
void initComponents() {
665 nameButtonGroup =
new javax.swing.ButtonGroup();
666 typeButtonGroup =
new javax.swing.ButtonGroup();
667 ruleNameLabel =
new javax.swing.JLabel();
668 ruleNameTextField =
new javax.swing.JTextField();
669 jLabel1 =
new javax.swing.JLabel();
670 nameTextField =
new javax.swing.JTextField();
671 fullNameRadioButton =
new javax.swing.JRadioButton();
672 extensionRadioButton =
new javax.swing.JRadioButton();
673 nameRegexCheckbox =
new javax.swing.JCheckBox();
674 pathTextField =
new javax.swing.JTextField();
675 pathRegexCheckBox =
new javax.swing.JCheckBox();
676 pathSeparatorInfoLabel =
new javax.swing.JLabel();
677 jLabel5 =
new javax.swing.JLabel();
678 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
679 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
680 fileSizeComboBox =
new javax.swing.JComboBox<String>();
681 fileSizeSpinner =
new javax.swing.JSpinner();
682 nameCheck =
new javax.swing.JCheckBox();
683 pathCheck =
new javax.swing.JCheckBox();
684 mimeCheck =
new javax.swing.JCheckBox();
685 fileSizeCheck =
new javax.swing.JCheckBox();
686 filesRadioButton =
new javax.swing.JRadioButton();
687 dirsRadioButton =
new javax.swing.JRadioButton();
688 allRadioButton =
new javax.swing.JRadioButton();
689 daysIncludedTextField =
new javax.swing.JTextField();
690 daysIncludedLabel =
new javax.swing.JLabel();
691 dateCheck =
new javax.swing.JCheckBox();
693 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
695 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
697 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
699 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
700 nameTextField.setEnabled(
false);
702 nameButtonGroup.add(fullNameRadioButton);
703 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
704 fullNameRadioButton.setEnabled(
false);
705 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
706 public void actionPerformed(java.awt.event.ActionEvent evt) {
707 fullNameRadioButtonActionPerformed(evt);
711 nameButtonGroup.add(extensionRadioButton);
712 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
713 extensionRadioButton.setEnabled(
false);
714 extensionRadioButton.addActionListener(
new java.awt.event.ActionListener() {
715 public void actionPerformed(java.awt.event.ActionEvent evt) {
716 extensionRadioButtonActionPerformed(evt);
720 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
721 nameRegexCheckbox.setEnabled(
false);
723 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
724 pathTextField.setEnabled(
false);
726 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
727 pathRegexCheckBox.setEnabled(
false);
729 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
730 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
731 pathSeparatorInfoLabel.setEnabled(
false);
733 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.interesting.jLabel5.text"));
735 mimeTypeComboBox.setEditable(
true);
736 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
737 mimeTypeComboBox.setEnabled(
false);
739 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
">",
"<" }));
740 equalitySymbolComboBox.setEnabled(
false);
742 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
743 fileSizeComboBox.setEnabled(
false);
745 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
746 fileSizeSpinner.setEnabled(
false);
748 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
749 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
750 public void actionPerformed(java.awt.event.ActionEvent evt) {
751 nameCheckActionPerformed(evt);
755 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
756 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
757 public void actionPerformed(java.awt.event.ActionEvent evt) {
758 pathCheckActionPerformed(evt);
762 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
763 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
764 public void actionPerformed(java.awt.event.ActionEvent evt) {
765 mimeCheckActionPerformed(evt);
769 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
770 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
771 public void actionPerformed(java.awt.event.ActionEvent evt) {
772 fileSizeCheckActionPerformed(evt);
776 typeButtonGroup.add(filesRadioButton);
777 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
778 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
779 public void actionPerformed(java.awt.event.ActionEvent evt) {
780 filesRadioButtonActionPerformed(evt);
784 typeButtonGroup.add(dirsRadioButton);
785 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
786 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
787 public void actionPerformed(java.awt.event.ActionEvent evt) {
788 dirsRadioButtonActionPerformed(evt);
792 typeButtonGroup.add(allRadioButton);
793 org.openide.awt.Mnemonics.setLocalizedText(allRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.allRadioButton.text"));
794 allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
795 public void actionPerformed(java.awt.event.ActionEvent evt) {
796 allRadioButtonActionPerformed(evt);
800 daysIncludedTextField.setEnabled(
false);
801 daysIncludedTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
802 daysIncludedTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
804 org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.daysIncludedLabel.text"));
806 org.openide.awt.Mnemonics.setLocalizedText(dateCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dateCheck.text"));
807 dateCheck.addActionListener(
new java.awt.event.ActionListener() {
808 public void actionPerformed(java.awt.event.ActionEvent evt) {
809 dateCheckActionPerformed(evt);
813 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
814 this.setLayout(layout);
815 layout.setHorizontalGroup(
816 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
817 .addGroup(layout.createSequentialGroup()
818 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
819 .addGroup(layout.createSequentialGroup()
821 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
822 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
823 .addComponent(ruleNameLabel)
825 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
826 .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
827 .addComponent(pathTextField)
828 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
829 .addComponent(equalitySymbolComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
830 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
831 .addComponent(fileSizeSpinner)
832 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
833 .addComponent(fileSizeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
834 .addGroup(layout.createSequentialGroup()
835 .addComponent(pathRegexCheckBox)
836 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
837 .addComponent(pathSeparatorInfoLabel))
838 .addGroup(layout.createSequentialGroup()
839 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
840 .addComponent(ruleNameTextField)
841 .addGroup(layout.createSequentialGroup()
842 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
843 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
844 .addComponent(daysIncludedLabel)
845 .addGap(0, 0, Short.MAX_VALUE)))
847 .addGroup(layout.createSequentialGroup()
848 .addComponent(fullNameRadioButton)
849 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
850 .addComponent(extensionRadioButton)
851 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
852 .addComponent(nameRegexCheckbox))))
853 .addComponent(jLabel5)
854 .addGroup(layout.createSequentialGroup()
855 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
856 .addComponent(nameCheck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
857 .addComponent(jLabel1))
859 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
860 .addGroup(layout.createSequentialGroup()
861 .addComponent(filesRadioButton)
862 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
863 .addComponent(dirsRadioButton)
864 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
865 .addComponent(allRadioButton))
866 .addComponent(nameTextField)))))
867 .addGroup(layout.createSequentialGroup()
869 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
870 .addComponent(pathCheck)
871 .addComponent(mimeCheck)
872 .addComponent(fileSizeCheck)
873 .addComponent(dateCheck))
874 .addGap(0, 0, Short.MAX_VALUE)))
877 layout.setVerticalGroup(
878 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
879 .addGroup(layout.createSequentialGroup()
880 .addComponent(jLabel5)
882 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
883 .addGroup(layout.createSequentialGroup()
884 .addComponent(jLabel1)
886 .addComponent(nameCheck))
887 .addGroup(layout.createSequentialGroup()
888 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
889 .addComponent(filesRadioButton)
890 .addComponent(dirsRadioButton)
891 .addComponent(allRadioButton))
892 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
893 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
894 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
895 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
896 .addComponent(fullNameRadioButton)
897 .addComponent(extensionRadioButton)
898 .addComponent(nameRegexCheckbox))
899 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
900 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
901 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
902 .addComponent(pathCheck))
903 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
904 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
905 .addComponent(pathRegexCheckBox)
906 .addComponent(pathSeparatorInfoLabel))
907 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
908 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
909 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
910 .addComponent(mimeCheck))
912 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
913 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
914 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
915 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
916 .addComponent(fileSizeCheck))
917 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
918 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
919 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
920 .addComponent(daysIncludedLabel)
921 .addComponent(dateCheck))
922 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
923 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
924 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
925 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
930 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
931 if (!this.nameCheck.isSelected()) {
932 this.nameTextField.setEnabled(
false);
933 this.nameTextField.setText(
"");
934 this.fullNameRadioButton.setEnabled(
false);
935 this.extensionRadioButton.setEnabled(
false);
936 this.nameRegexCheckbox.setEnabled(
false);
938 this.nameTextField.setEnabled(
true);
939 this.fullNameRadioButton.setEnabled(
true);
940 if (this.filesRadioButton.isSelected()) {
941 this.extensionRadioButton.setEnabled(
true);
943 this.nameRegexCheckbox.setEnabled(
true);
948 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
949 if (!this.pathCheck.isSelected()) {
950 this.pathTextField.setEnabled(
false);
951 this.pathTextField.setText(
"");
952 this.pathRegexCheckBox.setEnabled(
false);
953 this.pathSeparatorInfoLabel.setEnabled(
false);
955 this.pathTextField.setEnabled(
true);
956 this.pathRegexCheckBox.setEnabled(
true);
957 this.pathSeparatorInfoLabel.setEnabled(
true);
962 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
964 this.setComponentsForSearchType();
967 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
968 this.setComponentsForSearchType();
971 private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
972 this.setComponentsForSearchType();
975 private void dateCheckActionPerformed(java.awt.event.ActionEvent evt) {
976 if (!this.dateCheck.isSelected()) {
977 this.daysIncludedTextField.setEnabled(
false);
978 this.daysIncludedLabel.setEnabled(
false);
979 this.daysIncludedTextField.setText(
"");
981 this.daysIncludedTextField.setEnabled(
true);
982 this.daysIncludedLabel.setEnabled(
true);
987 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
988 if (!this.fileSizeCheck.isSelected()) {
989 this.fileSizeComboBox.setEnabled(
false);
990 this.fileSizeSpinner.setEnabled(
false);
991 this.fileSizeSpinner.setValue(0);
992 this.equalitySymbolComboBox.setEnabled(
false);
994 this.fileSizeComboBox.setEnabled(
true);
995 this.fileSizeSpinner.setEnabled(
true);
996 this.equalitySymbolComboBox.setEnabled(
true);
1001 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
1002 if (!this.mimeCheck.isSelected()) {
1003 this.mimeTypeComboBox.setEnabled(
false);
1004 this.mimeTypeComboBox.setSelectedIndex(0);
1006 this.mimeTypeComboBox.setEnabled(
true);
1011 private void extensionRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1012 updateNameTextFieldPrompt();
1015 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1016 updateNameTextFieldPrompt();
1020 private javax.swing.JRadioButton allRadioButton;
1021 private javax.swing.JCheckBox dateCheck;
1022 private javax.swing.JLabel daysIncludedLabel;
1023 private javax.swing.JTextField daysIncludedTextField;
1024 private javax.swing.JRadioButton dirsRadioButton;
1025 private javax.swing.JComboBox<String> equalitySymbolComboBox;
1026 private javax.swing.JRadioButton extensionRadioButton;
1027 private javax.swing.JCheckBox fileSizeCheck;
1028 private javax.swing.JComboBox<String> fileSizeComboBox;
1029 private javax.swing.JSpinner fileSizeSpinner;
1030 private javax.swing.JRadioButton filesRadioButton;
1031 private javax.swing.JRadioButton fullNameRadioButton;
1032 private javax.swing.JLabel jLabel1;
1033 private javax.swing.JLabel jLabel5;
1034 private javax.swing.JCheckBox mimeCheck;
1035 private javax.swing.JComboBox<String> mimeTypeComboBox;
1036 private javax.swing.ButtonGroup nameButtonGroup;
1037 private javax.swing.JCheckBox nameCheck;
1038 private javax.swing.JCheckBox nameRegexCheckbox;
1039 private javax.swing.JTextField nameTextField;
1040 private javax.swing.JCheckBox pathCheck;
1041 private javax.swing.JCheckBox pathRegexCheckBox;
1042 private javax.swing.JLabel pathSeparatorInfoLabel;
1043 private javax.swing.JTextField pathTextField;
1044 private javax.swing.JLabel ruleNameLabel;
1045 private javax.swing.JTextField ruleNameTextField;
1046 private javax.swing.ButtonGroup typeButtonGroup;