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)."
63 private static final long serialVersionUID = 1L;
64 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
65 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
66 private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
67 private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
68 private JButton okButton;
69 private JButton cancelButton;
70 private TextPrompt nameTextFieldPrompt;
75 FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
77 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
78 mimeTypeComboBox.setVisible(
false);
79 mimeCheck.setVisible(
false);
80 fileSizeComboBox.setVisible(
false);
81 fileSizeCheck.setVisible(
false);
82 equalitySymbolComboBox.setVisible(
false);
83 fileSizeSpinner.setVisible(
false);
84 jLabel1.setVisible(
false);
85 filesRadioButton.setVisible(
false);
86 dirsRadioButton.setVisible(
false);
87 allRadioButton.setVisible(
false);
88 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ingest.jLabel5.text"));
91 populateMimeTypesComboBox();
93 this.dateCheckActionPerformed(null);
94 populateComponentsWithDefaultValues();
95 this.setButtons(okButton, cancelButton);
97 updateNameTextFieldPrompt();
105 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
107 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
108 mimeTypeComboBox.setVisible(
false);
109 mimeCheck.setVisible(
false);
110 fileSizeComboBox.setVisible(
false);
111 fileSizeCheck.setVisible(
false);
112 equalitySymbolComboBox.setVisible(
false);
113 fileSizeSpinner.setVisible(
false);
114 jLabel1.setVisible(
false);
115 filesRadioButton.setVisible(
false);
116 dirsRadioButton.setVisible(
false);
117 allRadioButton.setVisible(
false);
119 populateMimeTypesComboBox();
120 populateMimeConditionComponents(rule);
121 populateSizeConditionComponents(rule);
124 populateMimeTypesComboBox();
125 populateRuleNameComponent(rule);
126 populateTypeConditionComponents(rule);
127 populateNameConditionComponents(rule);
128 populatePathConditionComponents(rule);
129 populateDateConditionComponents(rule);
130 this.setButtons(okButton, cancelButton);
132 updateNameTextFieldPrompt();
139 private void updateNameTextFieldPrompt() {
144 if (fullNameRadioButton.isSelected()) {
145 text = Bundle.FilesSetRulePanel_nameTextField_fullNameExample();
147 text = Bundle.FilesSetRulePanel_nameTextField_extensionExample();
149 nameTextFieldPrompt =
new TextPrompt(text, nameTextField);
154 nameTextFieldPrompt.setForeground(Color.LIGHT_GRAY);
155 nameTextFieldPrompt.changeAlpha(0.9f);
164 private void populateComponentsWithDefaultValues() {
165 this.filesRadioButton.setSelected(
true);
166 this.fullNameRadioButton.setSelected(
true);
167 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
168 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
169 this.mimeTypeComboBox.setSelectedIndex(0);
172 private void populateMimeTypesComboBox() {
174 SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
175 detectableMimeTypes.forEach((type) -> {
176 mimeTypeComboBox.addItem(type);
178 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
179 logger.log(Level.SEVERE,
"Unable to get detectable file types", ex);
189 private void populateRuleNameComponent(FilesSet.Rule rule) {
190 this.ruleNameTextField.setText(rule.getName());
193 private void populateMimeConditionComponents(FilesSet.Rule rule) {
194 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
195 if (mimeTypeCondition != null) {
196 this.mimeCheck.setSelected(
true);
197 this.mimeCheckActionPerformed(null);
198 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
202 private void populateSizeConditionComponents(FilesSet.Rule rule) {
203 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
204 if (fileSizeCondition != null) {
205 this.fileSizeCheck.setSelected(
true);
206 this.fileSizeCheckActionPerformed(null);
207 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
208 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
209 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
217 private void setOkButton() {
218 if (this.okButton != null) {
219 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
220 || this.nameCheck.isSelected() || this.pathCheck.isSelected() || this.dateCheck.isSelected());
231 private JOptionPane getOptionPane(JComponent parent) {
233 if (!(parent instanceof JOptionPane)) {
234 pane = getOptionPane((JComponent) parent.getParent());
236 pane = (JOptionPane) parent;
247 private void setButtons(JButton ok, JButton cancel) {
249 this.cancelButton = cancel;
250 okButton.addActionListener((ActionEvent e) -> {
251 JOptionPane pane = getOptionPane(okButton);
252 pane.setValue(okButton);
254 cancelButton.addActionListener((ActionEvent e) -> {
255 JOptionPane pane = getOptionPane(cancelButton);
256 pane.setValue(cancelButton);
267 private void populateTypeConditionComponents(FilesSet.Rule rule) {
268 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
269 switch (typeCondition.getMetaType()) {
271 this.filesRadioButton.setSelected(
true);
274 this.dirsRadioButton.setSelected(
true);
277 this.allRadioButton.setSelected(
true);
287 private void populateNameConditionComponents(FilesSet.Rule rule) {
288 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
289 if (nameCondition != null) {
290 this.nameCheck.setSelected(
true);
291 this.nameCheckActionPerformed(null);
292 this.nameTextField.setText(nameCondition.getTextToMatch());
293 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
294 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
295 this.fullNameRadioButton.setSelected(
true);
297 this.extensionRadioButton.setSelected(
true);
308 private void populatePathConditionComponents(FilesSet.Rule rule) {
309 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
310 if (pathCondition != null) {
311 this.pathCheck.setSelected(
true);
312 this.pathCheckActionPerformed(null);
313 this.pathTextField.setText(pathCondition.getTextToMatch());
314 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
324 private void populateDateConditionComponents(FilesSet.Rule rule) {
325 FilesSet.Rule.DateCondition dateCondition = rule.getDateCondition();
326 if (dateCondition != null) {
327 this.dateCheck.setSelected(
true);
328 this.dateCheckActionPerformed(null);
329 this.daysIncludedTextField.setText(Integer.toString(dateCondition.getDaysIncluded()));
340 boolean isValidRuleDefinition() {
342 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected() || this.dateCheck.isSelected())) {
343 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
344 Bundle.FilesSetRulePanel_NoConditionError(),
345 NotifyDescriptor.WARNING_MESSAGE);
346 DialogDisplayer.getDefault().notify(notifyDesc);
350 if (this.nameCheck.isSelected()) {
353 if (this.nameTextField.getText().isEmpty()) {
354 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
355 Bundle.FilesSetRulePanel_NoNameError(),
356 NotifyDescriptor.WARNING_MESSAGE);
357 DialogDisplayer.getDefault().notify(notifyDesc);
360 if (this.nameRegexCheckbox.isSelected()) {
362 Pattern.compile(this.nameTextField.getText());
363 }
catch (PatternSyntaxException ex) {
364 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
365 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
366 NotifyDescriptor.WARNING_MESSAGE);
367 DialogDisplayer.getDefault().notify(notifyDesc);
370 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
371 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
372 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
373 NotifyDescriptor.WARNING_MESSAGE);
374 DialogDisplayer.getDefault().notify(notifyDesc);
381 if (this.pathCheck.isSelected()) {
382 if (this.pathTextField.getText().isEmpty()) {
383 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
384 Bundle.FilesSetRulePanel_NoPathError(),
385 NotifyDescriptor.WARNING_MESSAGE);
386 DialogDisplayer.getDefault().notify(notifyDesc);
389 if (this.pathRegexCheckBox.isSelected()) {
391 Pattern.compile(this.pathTextField.getText());
392 }
catch (PatternSyntaxException ex) {
393 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
394 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
395 NotifyDescriptor.WARNING_MESSAGE);
396 DialogDisplayer.getDefault().notify(notifyDesc);
399 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
400 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
401 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
402 NotifyDescriptor.WARNING_MESSAGE);
403 DialogDisplayer.getDefault().notify(notifyDesc);
407 if (this.mimeCheck.isSelected()) {
408 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
409 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
410 Bundle.FilesSetRulePanel_NoMimeTypeError(),
411 NotifyDescriptor.WARNING_MESSAGE);
412 DialogDisplayer.getDefault().notify(notifyDesc);
416 if (this.fileSizeCheck.isSelected()) {
417 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
418 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
419 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
420 NotifyDescriptor.WARNING_MESSAGE);
421 DialogDisplayer.getDefault().notify(notifyDesc);
426 if (this.dateCheck.isSelected()) {
427 if (this.daysIncludedTextField.getText().isEmpty()) {
428 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
429 Bundle.FilesSetRulePanel_DaysIncludedEmptyError(),
430 NotifyDescriptor.WARNING_MESSAGE);
431 DialogDisplayer.getDefault().notify(notifyDesc);
435 int value = Integer.parseInt(daysIncludedTextField.getText());
437 throw new NumberFormatException(
"Negative numbers are not allowed for the within N days condition");
439 }
catch (NumberFormatException e) {
441 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
442 Bundle.FilesSetRulePanel_DaysIncludedInvalidError(),
443 NotifyDescriptor.WARNING_MESSAGE);
444 DialogDisplayer.getDefault().notify(notifyDesc);
456 String getRuleName() {
457 return this.ruleNameTextField.getText();
469 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
470 FilesSet.Rule.FileNameCondition condition = null;
471 if (!this.nameTextField.getText().isEmpty()) {
472 if (this.nameRegexCheckbox.isSelected()) {
474 Pattern pattern = Pattern.compile(this.nameTextField.getText(), Pattern.CASE_INSENSITIVE);
475 if (this.fullNameRadioButton.isSelected()) {
476 condition =
new FilesSet.Rule.FullNameCondition(pattern);
478 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
480 }
catch (PatternSyntaxException ex) {
481 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
482 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
484 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
485 if (this.fullNameRadioButton.isSelected()) {
486 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
488 List<String> extensions = Arrays.asList(this.nameTextField.getText().split(
","));
489 for (
int i=0; i < extensions.size(); i++) {
491 extensions.set(i, extensions.get(i).trim());
493 condition =
new FilesSet.Rule.ExtensionCondition(extensions);
496 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
497 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
508 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
509 FilesSet.Rule.MimeTypeCondition condition = null;
510 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
511 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
521 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
522 FilesSet.Rule.FileSizeCondition condition = null;
523 if (this.fileSizeCheck.isSelected()) {
524 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
525 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
526 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
527 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
528 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
540 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
541 if (this.filesRadioButton.isSelected()) {
542 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
543 }
else if (this.dirsRadioButton.isSelected()) {
544 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
546 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
559 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
560 FilesSet.Rule.ParentPathCondition condition = null;
561 if (!this.pathTextField.getText().isEmpty()) {
562 if (this.pathRegexCheckBox.isSelected()) {
564 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText(), Pattern.CASE_INSENSITIVE));
565 }
catch (PatternSyntaxException ex) {
566 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
567 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
570 String path = this.pathTextField.getText();
571 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
573 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
574 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
577 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
578 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
580 condition =
new FilesSet.Rule.ParentPathCondition(path);
582 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
583 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
599 FilesSet.Rule.DateCondition getDateCondition() {
600 FilesSet.Rule.DateCondition dateCondition = null;
601 if (!daysIncludedTextField.getText().isEmpty()) {
602 dateCondition =
new FilesSet.Rule.DateCondition(Integer.parseInt(daysIncludedTextField.getText()));
604 return dateCondition;
616 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
617 for (String illegalChar : illegalChars) {
618 if (toBeChecked.contains(illegalChar)) {
629 private void setComponentsForSearchType() {
630 if (!this.filesRadioButton.isSelected()) {
631 this.fullNameRadioButton.setSelected(
true);
632 this.extensionRadioButton.setEnabled(
false);
633 this.mimeTypeComboBox.setEnabled(
false);
634 this.mimeTypeComboBox.setSelectedIndex(0);
635 this.equalitySymbolComboBox.setEnabled(
false);
636 this.fileSizeComboBox.setEnabled(
false);
637 this.fileSizeSpinner.setEnabled(
false);
638 this.fileSizeSpinner.setValue(0);
639 this.fileSizeCheck.setEnabled(
false);
640 this.fileSizeCheck.setSelected(
false);
641 this.mimeCheck.setEnabled(
false);
642 this.mimeCheck.setSelected(
false);
644 if (this.nameCheck.isSelected()) {
645 this.extensionRadioButton.setEnabled(
true);
647 this.fileSizeCheck.setEnabled(
true);
648 this.mimeCheck.setEnabled(
true);
657 @SuppressWarnings(
"unchecked")
659 private
void initComponents() {
661 nameButtonGroup =
new javax.swing.ButtonGroup();
662 typeButtonGroup =
new javax.swing.ButtonGroup();
663 ruleNameLabel =
new javax.swing.JLabel();
664 ruleNameTextField =
new javax.swing.JTextField();
665 jLabel1 =
new javax.swing.JLabel();
666 nameTextField =
new javax.swing.JTextField();
667 fullNameRadioButton =
new javax.swing.JRadioButton();
668 extensionRadioButton =
new javax.swing.JRadioButton();
669 nameRegexCheckbox =
new javax.swing.JCheckBox();
670 pathTextField =
new javax.swing.JTextField();
671 pathRegexCheckBox =
new javax.swing.JCheckBox();
672 pathSeparatorInfoLabel =
new javax.swing.JLabel();
673 jLabel5 =
new javax.swing.JLabel();
674 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
675 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
676 fileSizeComboBox =
new javax.swing.JComboBox<String>();
677 fileSizeSpinner =
new javax.swing.JSpinner();
678 nameCheck =
new javax.swing.JCheckBox();
679 pathCheck =
new javax.swing.JCheckBox();
680 mimeCheck =
new javax.swing.JCheckBox();
681 fileSizeCheck =
new javax.swing.JCheckBox();
682 filesRadioButton =
new javax.swing.JRadioButton();
683 dirsRadioButton =
new javax.swing.JRadioButton();
684 allRadioButton =
new javax.swing.JRadioButton();
685 daysIncludedTextField =
new javax.swing.JTextField();
686 daysIncludedLabel =
new javax.swing.JLabel();
687 dateCheck =
new javax.swing.JCheckBox();
689 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
691 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
693 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
695 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
696 nameTextField.setEnabled(
false);
698 nameButtonGroup.add(fullNameRadioButton);
699 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
700 fullNameRadioButton.setEnabled(
false);
701 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
702 public void actionPerformed(java.awt.event.ActionEvent evt) {
703 fullNameRadioButtonActionPerformed(evt);
707 nameButtonGroup.add(extensionRadioButton);
708 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
709 extensionRadioButton.setEnabled(
false);
710 extensionRadioButton.addActionListener(
new java.awt.event.ActionListener() {
711 public void actionPerformed(java.awt.event.ActionEvent evt) {
712 extensionRadioButtonActionPerformed(evt);
716 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
717 nameRegexCheckbox.setEnabled(
false);
719 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
720 pathTextField.setEnabled(
false);
722 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
723 pathRegexCheckBox.setEnabled(
false);
725 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
726 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
727 pathSeparatorInfoLabel.setEnabled(
false);
729 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.interesting.jLabel5.text"));
731 mimeTypeComboBox.setEditable(
true);
732 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
733 mimeTypeComboBox.setEnabled(
false);
735 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
736 equalitySymbolComboBox.setEnabled(
false);
738 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
739 fileSizeComboBox.setEnabled(
false);
741 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
742 fileSizeSpinner.setEnabled(
false);
744 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
745 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
746 public void actionPerformed(java.awt.event.ActionEvent evt) {
747 nameCheckActionPerformed(evt);
751 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
752 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
753 public void actionPerformed(java.awt.event.ActionEvent evt) {
754 pathCheckActionPerformed(evt);
758 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
759 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
760 public void actionPerformed(java.awt.event.ActionEvent evt) {
761 mimeCheckActionPerformed(evt);
765 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
766 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
767 public void actionPerformed(java.awt.event.ActionEvent evt) {
768 fileSizeCheckActionPerformed(evt);
772 typeButtonGroup.add(filesRadioButton);
773 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
774 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
775 public void actionPerformed(java.awt.event.ActionEvent evt) {
776 filesRadioButtonActionPerformed(evt);
780 typeButtonGroup.add(dirsRadioButton);
781 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
782 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
783 public void actionPerformed(java.awt.event.ActionEvent evt) {
784 dirsRadioButtonActionPerformed(evt);
788 typeButtonGroup.add(allRadioButton);
789 org.openide.awt.Mnemonics.setLocalizedText(allRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.allRadioButton.text"));
790 allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
791 public void actionPerformed(java.awt.event.ActionEvent evt) {
792 allRadioButtonActionPerformed(evt);
796 daysIncludedTextField.setEnabled(
false);
797 daysIncludedTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
798 daysIncludedTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
800 org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.daysIncludedLabel.text"));
802 org.openide.awt.Mnemonics.setLocalizedText(dateCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dateCheck.text"));
803 dateCheck.addActionListener(
new java.awt.event.ActionListener() {
804 public void actionPerformed(java.awt.event.ActionEvent evt) {
805 dateCheckActionPerformed(evt);
809 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
810 this.setLayout(layout);
811 layout.setHorizontalGroup(
812 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
813 .addGroup(layout.createSequentialGroup()
814 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
815 .addGroup(layout.createSequentialGroup()
817 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
818 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
819 .addComponent(ruleNameLabel)
821 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
822 .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
823 .addComponent(pathTextField)
824 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
825 .addComponent(equalitySymbolComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
826 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
827 .addComponent(fileSizeSpinner)
828 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
829 .addComponent(fileSizeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
830 .addGroup(layout.createSequentialGroup()
831 .addComponent(pathRegexCheckBox)
832 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
833 .addComponent(pathSeparatorInfoLabel))
834 .addGroup(layout.createSequentialGroup()
835 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
836 .addComponent(ruleNameTextField)
837 .addGroup(layout.createSequentialGroup()
838 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
839 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
840 .addComponent(daysIncludedLabel)
841 .addGap(0, 0, Short.MAX_VALUE)))
843 .addGroup(layout.createSequentialGroup()
844 .addComponent(fullNameRadioButton)
845 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
846 .addComponent(extensionRadioButton)
847 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
848 .addComponent(nameRegexCheckbox))))
849 .addComponent(jLabel5)
850 .addGroup(layout.createSequentialGroup()
851 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
852 .addComponent(nameCheck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
853 .addComponent(jLabel1))
855 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
856 .addGroup(layout.createSequentialGroup()
857 .addComponent(filesRadioButton)
858 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
859 .addComponent(dirsRadioButton)
860 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
861 .addComponent(allRadioButton))
862 .addComponent(nameTextField)))))
863 .addGroup(layout.createSequentialGroup()
865 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
866 .addComponent(pathCheck)
867 .addComponent(mimeCheck)
868 .addComponent(fileSizeCheck)
869 .addComponent(dateCheck))
870 .addGap(0, 0, Short.MAX_VALUE)))
873 layout.setVerticalGroup(
874 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
875 .addGroup(layout.createSequentialGroup()
876 .addComponent(jLabel5)
878 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
879 .addGroup(layout.createSequentialGroup()
880 .addComponent(jLabel1)
882 .addComponent(nameCheck))
883 .addGroup(layout.createSequentialGroup()
884 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
885 .addComponent(filesRadioButton)
886 .addComponent(dirsRadioButton)
887 .addComponent(allRadioButton))
888 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
889 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
890 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
891 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
892 .addComponent(fullNameRadioButton)
893 .addComponent(extensionRadioButton)
894 .addComponent(nameRegexCheckbox))
895 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
896 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
897 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
898 .addComponent(pathCheck))
899 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
900 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
901 .addComponent(pathRegexCheckBox)
902 .addComponent(pathSeparatorInfoLabel))
903 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
904 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
905 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
906 .addComponent(mimeCheck))
908 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
909 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
910 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
911 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
912 .addComponent(fileSizeCheck))
913 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
914 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
915 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
916 .addComponent(daysIncludedLabel)
917 .addComponent(dateCheck))
918 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
919 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
920 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
921 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
926 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
927 if (!this.nameCheck.isSelected()) {
928 this.nameTextField.setEnabled(
false);
929 this.nameTextField.setText(
"");
930 this.fullNameRadioButton.setEnabled(
false);
931 this.extensionRadioButton.setEnabled(
false);
932 this.nameRegexCheckbox.setEnabled(
false);
934 this.nameTextField.setEnabled(
true);
935 this.fullNameRadioButton.setEnabled(
true);
936 if (this.filesRadioButton.isSelected()) {
937 this.extensionRadioButton.setEnabled(
true);
939 this.nameRegexCheckbox.setEnabled(
true);
944 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
945 if (!this.pathCheck.isSelected()) {
946 this.pathTextField.setEnabled(
false);
947 this.pathTextField.setText(
"");
948 this.pathRegexCheckBox.setEnabled(
false);
949 this.pathSeparatorInfoLabel.setEnabled(
false);
951 this.pathTextField.setEnabled(
true);
952 this.pathRegexCheckBox.setEnabled(
true);
953 this.pathSeparatorInfoLabel.setEnabled(
true);
958 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
960 this.setComponentsForSearchType();
963 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
964 this.setComponentsForSearchType();
967 private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
968 this.setComponentsForSearchType();
971 private void dateCheckActionPerformed(java.awt.event.ActionEvent evt) {
972 if (!this.dateCheck.isSelected()) {
973 this.daysIncludedTextField.setEnabled(
false);
974 this.daysIncludedLabel.setEnabled(
false);
975 this.daysIncludedTextField.setText(
"");
977 this.daysIncludedTextField.setEnabled(
true);
978 this.daysIncludedLabel.setEnabled(
true);
983 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
984 if (!this.fileSizeCheck.isSelected()) {
985 this.fileSizeComboBox.setEnabled(
false);
986 this.fileSizeSpinner.setEnabled(
false);
987 this.fileSizeSpinner.setValue(0);
988 this.equalitySymbolComboBox.setEnabled(
false);
990 this.fileSizeComboBox.setEnabled(
true);
991 this.fileSizeSpinner.setEnabled(
true);
992 this.equalitySymbolComboBox.setEnabled(
true);
997 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
998 if (!this.mimeCheck.isSelected()) {
999 this.mimeTypeComboBox.setEnabled(
false);
1000 this.mimeTypeComboBox.setSelectedIndex(0);
1002 this.mimeTypeComboBox.setEnabled(
true);
1007 private void extensionRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1008 updateNameTextFieldPrompt();
1011 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1012 updateNameTextFieldPrompt();
1016 private javax.swing.JRadioButton allRadioButton;
1017 private javax.swing.JCheckBox dateCheck;
1018 private javax.swing.JLabel daysIncludedLabel;
1019 private javax.swing.JTextField daysIncludedTextField;
1020 private javax.swing.JRadioButton dirsRadioButton;
1021 private javax.swing.JComboBox<String> equalitySymbolComboBox;
1022 private javax.swing.JRadioButton extensionRadioButton;
1023 private javax.swing.JCheckBox fileSizeCheck;
1024 private javax.swing.JComboBox<String> fileSizeComboBox;
1025 private javax.swing.JSpinner fileSizeSpinner;
1026 private javax.swing.JRadioButton filesRadioButton;
1027 private javax.swing.JRadioButton fullNameRadioButton;
1028 private javax.swing.JLabel jLabel1;
1029 private javax.swing.JLabel jLabel5;
1030 private javax.swing.JCheckBox mimeCheck;
1031 private javax.swing.JComboBox<String> mimeTypeComboBox;
1032 private javax.swing.ButtonGroup nameButtonGroup;
1033 private javax.swing.JCheckBox nameCheck;
1034 private javax.swing.JCheckBox nameRegexCheckbox;
1035 private javax.swing.JTextField nameTextField;
1036 private javax.swing.JCheckBox pathCheck;
1037 private javax.swing.JCheckBox pathRegexCheckBox;
1038 private javax.swing.JLabel pathSeparatorInfoLabel;
1039 private javax.swing.JTextField pathTextField;
1040 private javax.swing.JLabel ruleNameLabel;
1041 private javax.swing.JTextField ruleNameTextField;
1042 private javax.swing.ButtonGroup typeButtonGroup;