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 fileSizeComboBox.setVisible(
false);
83 fileSizeCheck.setVisible(
false);
84 equalitySymbolComboBox.setVisible(
false);
85 fileSizeSpinner.setVisible(
false);
86 jLabel1.setVisible(
false);
87 filesRadioButton.setVisible(
false);
88 dirsRadioButton.setVisible(
false);
89 allRadioButton.setVisible(
false);
90 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ingest.jLabel5.text"));
93 populateMimeTypesComboBox();
95 this.dateCheckActionPerformed(null);
96 populateComponentsWithDefaultValues();
97 this.setButtons(okButton, cancelButton);
99 updateNameTextFieldPrompt();
107 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
109 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
110 mimeTypeComboBox.setVisible(
false);
111 mimeCheck.setVisible(
false);
112 fileSizeComboBox.setVisible(
false);
113 fileSizeCheck.setVisible(
false);
114 equalitySymbolComboBox.setVisible(
false);
115 fileSizeSpinner.setVisible(
false);
116 jLabel1.setVisible(
false);
117 filesRadioButton.setVisible(
false);
118 dirsRadioButton.setVisible(
false);
119 allRadioButton.setVisible(
false);
121 populateMimeTypesComboBox();
122 populateMimeConditionComponents(rule);
123 populateSizeConditionComponents(rule);
126 populateMimeTypesComboBox();
127 populateRuleNameComponent(rule);
128 populateTypeConditionComponents(rule);
129 populateNameConditionComponents(rule);
130 populatePathConditionComponents(rule);
131 populateDateConditionComponents(rule);
132 this.setButtons(okButton, cancelButton);
134 updateNameTextFieldPrompt();
135 setComponentsForSearchType();
142 private void updateNameTextFieldPrompt() {
147 if (fullNameRadioButton.isSelected()) {
148 text = Bundle.FilesSetRulePanel_nameTextField_fullNameExample();
150 text = Bundle.FilesSetRulePanel_nameTextField_extensionExample();
152 nameTextFieldPrompt =
new TextPrompt(text, nameTextField);
157 nameTextFieldPrompt.setForeground(Color.LIGHT_GRAY);
158 nameTextFieldPrompt.changeAlpha(0.9f);
167 private void populateComponentsWithDefaultValues() {
168 this.filesRadioButton.setSelected(
true);
169 this.fullNameRadioButton.setSelected(
true);
170 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
171 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
172 this.mimeTypeComboBox.setSelectedIndex(0);
175 private void populateMimeTypesComboBox() {
177 SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
178 detectableMimeTypes.forEach((type) -> {
179 mimeTypeComboBox.addItem(type);
181 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
182 logger.log(Level.SEVERE,
"Unable to get detectable file types", ex);
192 private void populateRuleNameComponent(FilesSet.Rule rule) {
193 this.ruleNameTextField.setText(rule.getName());
196 private void populateMimeConditionComponents(FilesSet.Rule rule) {
197 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
198 if (mimeTypeCondition != null) {
199 this.mimeCheck.setSelected(
true);
200 this.mimeCheckActionPerformed(null);
201 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
205 private void populateSizeConditionComponents(FilesSet.Rule rule) {
206 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
207 if (fileSizeCondition != null) {
208 this.fileSizeCheck.setSelected(
true);
209 this.fileSizeCheckActionPerformed(null);
210 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
211 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
212 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
220 private void setOkButton() {
221 if (this.okButton != null) {
222 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
223 || this.nameCheck.isSelected() || this.pathCheck.isSelected() || this.dateCheck.isSelected());
234 private JOptionPane getOptionPane(JComponent parent) {
236 if (!(parent instanceof JOptionPane)) {
237 pane = getOptionPane((JComponent) parent.getParent());
239 pane = (JOptionPane) parent;
250 private void setButtons(JButton ok, JButton cancel) {
252 this.cancelButton = cancel;
253 okButton.addActionListener((ActionEvent e) -> {
254 JOptionPane pane = getOptionPane(okButton);
255 pane.setValue(okButton);
257 cancelButton.addActionListener((ActionEvent e) -> {
258 JOptionPane pane = getOptionPane(cancelButton);
259 pane.setValue(cancelButton);
270 private void populateTypeConditionComponents(FilesSet.Rule rule) {
271 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
272 switch (typeCondition.getMetaType()) {
274 this.filesRadioButton.setSelected(
true);
277 this.dirsRadioButton.setSelected(
true);
280 this.allRadioButton.setSelected(
true);
290 private void populateNameConditionComponents(FilesSet.Rule rule) {
291 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
292 if (nameCondition != null) {
293 this.nameCheck.setSelected(
true);
294 this.nameCheckActionPerformed(null);
295 this.nameTextField.setText(nameCondition.getTextToMatch());
296 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
297 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
298 this.fullNameRadioButton.setSelected(
true);
300 this.extensionRadioButton.setSelected(
true);
311 private void populatePathConditionComponents(FilesSet.Rule rule) {
312 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
313 if (pathCondition != null) {
314 this.pathCheck.setSelected(
true);
315 this.pathCheckActionPerformed(null);
316 this.pathTextField.setText(pathCondition.getTextToMatch());
317 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
327 private void populateDateConditionComponents(FilesSet.Rule rule) {
328 FilesSet.Rule.DateCondition dateCondition = rule.getDateCondition();
329 if (dateCondition != null) {
330 this.dateCheck.setSelected(
true);
331 this.dateCheckActionPerformed(null);
332 this.daysIncludedTextField.setText(Integer.toString(dateCondition.getDaysIncluded()));
343 boolean isValidRuleDefinition() {
345 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected() || this.dateCheck.isSelected())) {
346 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
347 Bundle.FilesSetRulePanel_NoConditionError(),
348 NotifyDescriptor.WARNING_MESSAGE);
349 DialogDisplayer.getDefault().notify(notifyDesc);
353 if (this.nameCheck.isSelected()) {
356 if (this.nameTextField.getText().isEmpty()) {
357 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
358 Bundle.FilesSetRulePanel_NoNameError(),
359 NotifyDescriptor.WARNING_MESSAGE);
360 DialogDisplayer.getDefault().notify(notifyDesc);
363 if (this.nameRegexCheckbox.isSelected()) {
367 if (this.extensionRadioButton.isSelected() && this.nameTextField.getText().contains(
",")) {
368 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
369 Bundle.FilesSetRulePanel_CommaInRegexWarning(
this.nameTextField.getText()),
370 NotifyDescriptor.WARNING_MESSAGE);
371 DialogDisplayer.getDefault().notify(notifyDesc);
375 Pattern.compile(this.nameTextField.getText());
376 }
catch (PatternSyntaxException ex) {
377 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
378 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
379 NotifyDescriptor.WARNING_MESSAGE);
380 DialogDisplayer.getDefault().notify(notifyDesc);
383 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
384 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
385 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
386 NotifyDescriptor.WARNING_MESSAGE);
387 DialogDisplayer.getDefault().notify(notifyDesc);
394 if (this.pathCheck.isSelected()) {
395 if (this.pathTextField.getText().isEmpty()) {
396 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
397 Bundle.FilesSetRulePanel_NoPathError(),
398 NotifyDescriptor.WARNING_MESSAGE);
399 DialogDisplayer.getDefault().notify(notifyDesc);
402 if (this.pathRegexCheckBox.isSelected()) {
404 Pattern.compile(this.pathTextField.getText());
405 }
catch (PatternSyntaxException ex) {
406 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
407 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
408 NotifyDescriptor.WARNING_MESSAGE);
409 DialogDisplayer.getDefault().notify(notifyDesc);
412 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
413 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
414 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
415 NotifyDescriptor.WARNING_MESSAGE);
416 DialogDisplayer.getDefault().notify(notifyDesc);
420 if (this.mimeCheck.isSelected()) {
421 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
422 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
423 Bundle.FilesSetRulePanel_NoMimeTypeError(),
424 NotifyDescriptor.WARNING_MESSAGE);
425 DialogDisplayer.getDefault().notify(notifyDesc);
429 if (this.fileSizeCheck.isSelected()) {
430 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
431 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
432 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
433 NotifyDescriptor.WARNING_MESSAGE);
434 DialogDisplayer.getDefault().notify(notifyDesc);
439 if (this.dateCheck.isSelected()) {
440 if (this.daysIncludedTextField.getText().isEmpty()) {
441 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
442 Bundle.FilesSetRulePanel_DaysIncludedEmptyError(),
443 NotifyDescriptor.WARNING_MESSAGE);
444 DialogDisplayer.getDefault().notify(notifyDesc);
448 int value = Integer.parseInt(daysIncludedTextField.getText());
450 throw new NumberFormatException(
"Negative numbers are not allowed for the within N days condition");
452 }
catch (NumberFormatException e) {
454 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
455 Bundle.FilesSetRulePanel_DaysIncludedInvalidError(),
456 NotifyDescriptor.WARNING_MESSAGE);
457 DialogDisplayer.getDefault().notify(notifyDesc);
469 String getRuleName() {
470 return this.ruleNameTextField.getText();
482 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
483 FilesSet.Rule.FileNameCondition condition = null;
484 if (!this.nameTextField.getText().isEmpty()) {
485 if (this.nameRegexCheckbox.isSelected()) {
487 Pattern pattern = Pattern.compile(this.nameTextField.getText(), Pattern.CASE_INSENSITIVE);
488 if (this.fullNameRadioButton.isSelected()) {
489 condition =
new FilesSet.Rule.FullNameCondition(pattern);
491 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
493 }
catch (PatternSyntaxException ex) {
494 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
495 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
497 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
498 if (this.fullNameRadioButton.isSelected()) {
499 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
501 List<String> extensions = Arrays.asList(this.nameTextField.getText().split(
","));
502 for (
int i=0; i < extensions.size(); i++) {
504 extensions.set(i, extensions.get(i).trim());
506 condition =
new FilesSet.Rule.ExtensionCondition(extensions);
509 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
510 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
521 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
522 FilesSet.Rule.MimeTypeCondition condition = null;
523 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
524 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
534 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
535 FilesSet.Rule.FileSizeCondition condition = null;
536 if (this.fileSizeCheck.isSelected()) {
537 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
538 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
539 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
540 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
541 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
553 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
554 if (this.filesRadioButton.isSelected()) {
555 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
556 }
else if (this.dirsRadioButton.isSelected()) {
557 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
559 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
572 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
573 FilesSet.Rule.ParentPathCondition condition = null;
574 if (!this.pathTextField.getText().isEmpty()) {
575 if (this.pathRegexCheckBox.isSelected()) {
577 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText(), Pattern.CASE_INSENSITIVE));
578 }
catch (PatternSyntaxException ex) {
579 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
580 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
583 String path = this.pathTextField.getText();
584 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
586 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
587 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
590 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
591 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
593 condition =
new FilesSet.Rule.ParentPathCondition(path);
595 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
596 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
612 FilesSet.Rule.DateCondition getDateCondition() {
613 FilesSet.Rule.DateCondition dateCondition = null;
614 if (!daysIncludedTextField.getText().isEmpty()) {
615 dateCondition =
new FilesSet.Rule.DateCondition(Integer.parseInt(daysIncludedTextField.getText()));
617 return dateCondition;
629 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
630 for (String illegalChar : illegalChars) {
631 if (toBeChecked.contains(illegalChar)) {
642 private void setComponentsForSearchType() {
643 if (!this.filesRadioButton.isSelected()) {
644 this.fullNameRadioButton.setSelected(
true);
645 this.extensionRadioButton.setEnabled(
false);
646 this.mimeTypeComboBox.setEnabled(
false);
647 this.mimeTypeComboBox.setSelectedIndex(0);
648 this.equalitySymbolComboBox.setEnabled(
false);
649 this.fileSizeComboBox.setEnabled(
false);
650 this.fileSizeSpinner.setEnabled(
false);
651 this.fileSizeSpinner.setValue(0);
652 this.fileSizeCheck.setEnabled(
false);
653 this.fileSizeCheck.setSelected(
false);
654 this.mimeCheck.setEnabled(
false);
655 this.mimeCheck.setSelected(
false);
657 if (this.nameCheck.isSelected()) {
658 this.extensionRadioButton.setEnabled(
true);
660 this.fileSizeCheck.setEnabled(
true);
661 this.mimeCheck.setEnabled(
true);
670 @SuppressWarnings(
"unchecked")
672 private
void initComponents() {
674 nameButtonGroup =
new javax.swing.ButtonGroup();
675 typeButtonGroup =
new javax.swing.ButtonGroup();
676 ruleNameLabel =
new javax.swing.JLabel();
677 ruleNameTextField =
new javax.swing.JTextField();
678 jLabel1 =
new javax.swing.JLabel();
679 nameTextField =
new javax.swing.JTextField();
680 fullNameRadioButton =
new javax.swing.JRadioButton();
681 extensionRadioButton =
new javax.swing.JRadioButton();
682 nameRegexCheckbox =
new javax.swing.JCheckBox();
683 pathTextField =
new javax.swing.JTextField();
684 pathRegexCheckBox =
new javax.swing.JCheckBox();
685 pathSeparatorInfoLabel =
new javax.swing.JLabel();
686 jLabel5 =
new javax.swing.JLabel();
687 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
688 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
689 fileSizeComboBox =
new javax.swing.JComboBox<String>();
690 fileSizeSpinner =
new javax.swing.JSpinner();
691 nameCheck =
new javax.swing.JCheckBox();
692 pathCheck =
new javax.swing.JCheckBox();
693 mimeCheck =
new javax.swing.JCheckBox();
694 fileSizeCheck =
new javax.swing.JCheckBox();
695 filesRadioButton =
new javax.swing.JRadioButton();
696 dirsRadioButton =
new javax.swing.JRadioButton();
697 allRadioButton =
new javax.swing.JRadioButton();
698 daysIncludedTextField =
new javax.swing.JTextField();
699 daysIncludedLabel =
new javax.swing.JLabel();
700 dateCheck =
new javax.swing.JCheckBox();
702 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
704 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
706 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
708 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
709 nameTextField.setEnabled(
false);
711 nameButtonGroup.add(fullNameRadioButton);
712 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
713 fullNameRadioButton.setEnabled(
false);
714 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
715 public void actionPerformed(java.awt.event.ActionEvent evt) {
716 fullNameRadioButtonActionPerformed(evt);
720 nameButtonGroup.add(extensionRadioButton);
721 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
722 extensionRadioButton.setEnabled(
false);
723 extensionRadioButton.addActionListener(
new java.awt.event.ActionListener() {
724 public void actionPerformed(java.awt.event.ActionEvent evt) {
725 extensionRadioButtonActionPerformed(evt);
729 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
730 nameRegexCheckbox.setEnabled(
false);
732 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
733 pathTextField.setEnabled(
false);
735 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
736 pathRegexCheckBox.setEnabled(
false);
738 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
739 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
740 pathSeparatorInfoLabel.setEnabled(
false);
742 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.interesting.jLabel5.text"));
744 mimeTypeComboBox.setEditable(
true);
745 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
746 mimeTypeComboBox.setEnabled(
false);
748 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
749 equalitySymbolComboBox.setEnabled(
false);
751 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
752 fileSizeComboBox.setEnabled(
false);
754 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
755 fileSizeSpinner.setEnabled(
false);
757 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
758 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
759 public void actionPerformed(java.awt.event.ActionEvent evt) {
760 nameCheckActionPerformed(evt);
764 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
765 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
766 public void actionPerformed(java.awt.event.ActionEvent evt) {
767 pathCheckActionPerformed(evt);
771 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
772 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
773 public void actionPerformed(java.awt.event.ActionEvent evt) {
774 mimeCheckActionPerformed(evt);
778 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
779 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
780 public void actionPerformed(java.awt.event.ActionEvent evt) {
781 fileSizeCheckActionPerformed(evt);
785 typeButtonGroup.add(filesRadioButton);
786 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
787 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
788 public void actionPerformed(java.awt.event.ActionEvent evt) {
789 filesRadioButtonActionPerformed(evt);
793 typeButtonGroup.add(dirsRadioButton);
794 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
795 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
796 public void actionPerformed(java.awt.event.ActionEvent evt) {
797 dirsRadioButtonActionPerformed(evt);
801 typeButtonGroup.add(allRadioButton);
802 org.openide.awt.Mnemonics.setLocalizedText(allRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.allRadioButton.text"));
803 allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
804 public void actionPerformed(java.awt.event.ActionEvent evt) {
805 allRadioButtonActionPerformed(evt);
809 daysIncludedTextField.setEnabled(
false);
810 daysIncludedTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
811 daysIncludedTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
813 org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.daysIncludedLabel.text"));
815 org.openide.awt.Mnemonics.setLocalizedText(dateCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dateCheck.text"));
816 dateCheck.addActionListener(
new java.awt.event.ActionListener() {
817 public void actionPerformed(java.awt.event.ActionEvent evt) {
818 dateCheckActionPerformed(evt);
822 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
823 this.setLayout(layout);
824 layout.setHorizontalGroup(
825 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
826 .addGroup(layout.createSequentialGroup()
827 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
828 .addGroup(layout.createSequentialGroup()
830 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
831 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
832 .addComponent(ruleNameLabel)
834 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
835 .addComponent(mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
836 .addComponent(pathTextField)
837 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
838 .addComponent(equalitySymbolComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
839 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
840 .addComponent(fileSizeSpinner)
841 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
842 .addComponent(fileSizeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
843 .addGroup(layout.createSequentialGroup()
844 .addComponent(pathRegexCheckBox)
845 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
846 .addComponent(pathSeparatorInfoLabel))
847 .addGroup(layout.createSequentialGroup()
848 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
849 .addComponent(ruleNameTextField)
850 .addGroup(layout.createSequentialGroup()
851 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
852 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
853 .addComponent(daysIncludedLabel)
854 .addGap(0, 0, Short.MAX_VALUE)))
856 .addGroup(layout.createSequentialGroup()
857 .addComponent(fullNameRadioButton)
858 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
859 .addComponent(extensionRadioButton)
860 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
861 .addComponent(nameRegexCheckbox))))
862 .addComponent(jLabel5)
863 .addGroup(layout.createSequentialGroup()
864 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
865 .addComponent(nameCheck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
866 .addComponent(jLabel1))
868 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
869 .addGroup(layout.createSequentialGroup()
870 .addComponent(filesRadioButton)
871 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
872 .addComponent(dirsRadioButton)
873 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
874 .addComponent(allRadioButton))
875 .addComponent(nameTextField)))))
876 .addGroup(layout.createSequentialGroup()
878 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
879 .addComponent(pathCheck)
880 .addComponent(mimeCheck)
881 .addComponent(fileSizeCheck)
882 .addComponent(dateCheck))
883 .addGap(0, 0, Short.MAX_VALUE)))
886 layout.setVerticalGroup(
887 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
888 .addGroup(layout.createSequentialGroup()
889 .addComponent(jLabel5)
891 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
892 .addGroup(layout.createSequentialGroup()
893 .addComponent(jLabel1)
895 .addComponent(nameCheck))
896 .addGroup(layout.createSequentialGroup()
897 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
898 .addComponent(filesRadioButton)
899 .addComponent(dirsRadioButton)
900 .addComponent(allRadioButton))
901 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
902 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
903 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
904 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
905 .addComponent(fullNameRadioButton)
906 .addComponent(extensionRadioButton)
907 .addComponent(nameRegexCheckbox))
908 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
909 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
910 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
911 .addComponent(pathCheck))
912 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
913 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
914 .addComponent(pathRegexCheckBox)
915 .addComponent(pathSeparatorInfoLabel))
916 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
917 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
918 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
919 .addComponent(mimeCheck))
921 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
922 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
923 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
924 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
925 .addComponent(fileSizeCheck))
926 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
927 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
928 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
929 .addComponent(daysIncludedLabel)
930 .addComponent(dateCheck))
931 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
932 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
933 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
934 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
939 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
940 if (!this.nameCheck.isSelected()) {
941 this.nameTextField.setEnabled(
false);
942 this.nameTextField.setText(
"");
943 this.fullNameRadioButton.setEnabled(
false);
944 this.extensionRadioButton.setEnabled(
false);
945 this.nameRegexCheckbox.setEnabled(
false);
947 this.nameTextField.setEnabled(
true);
948 this.fullNameRadioButton.setEnabled(
true);
949 if (this.filesRadioButton.isSelected()) {
950 this.extensionRadioButton.setEnabled(
true);
952 this.nameRegexCheckbox.setEnabled(
true);
957 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
958 if (!this.pathCheck.isSelected()) {
959 this.pathTextField.setEnabled(
false);
960 this.pathTextField.setText(
"");
961 this.pathRegexCheckBox.setEnabled(
false);
962 this.pathSeparatorInfoLabel.setEnabled(
false);
964 this.pathTextField.setEnabled(
true);
965 this.pathRegexCheckBox.setEnabled(
true);
966 this.pathSeparatorInfoLabel.setEnabled(
true);
971 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
973 this.setComponentsForSearchType();
976 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
977 this.setComponentsForSearchType();
980 private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
981 this.setComponentsForSearchType();
984 private void dateCheckActionPerformed(java.awt.event.ActionEvent evt) {
985 if (!this.dateCheck.isSelected()) {
986 this.daysIncludedTextField.setEnabled(
false);
987 this.daysIncludedLabel.setEnabled(
false);
988 this.daysIncludedTextField.setText(
"");
990 this.daysIncludedTextField.setEnabled(
true);
991 this.daysIncludedLabel.setEnabled(
true);
996 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
997 if (!this.fileSizeCheck.isSelected()) {
998 this.fileSizeComboBox.setEnabled(
false);
999 this.fileSizeSpinner.setEnabled(
false);
1000 this.fileSizeSpinner.setValue(0);
1001 this.equalitySymbolComboBox.setEnabled(
false);
1003 this.fileSizeComboBox.setEnabled(
true);
1004 this.fileSizeSpinner.setEnabled(
true);
1005 this.equalitySymbolComboBox.setEnabled(
true);
1010 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
1011 if (!this.mimeCheck.isSelected()) {
1012 this.mimeTypeComboBox.setEnabled(
false);
1013 this.mimeTypeComboBox.setSelectedIndex(0);
1015 this.mimeTypeComboBox.setEnabled(
true);
1020 private void extensionRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1021 updateNameTextFieldPrompt();
1024 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
1025 updateNameTextFieldPrompt();
1029 private javax.swing.JRadioButton allRadioButton;
1030 private javax.swing.JCheckBox dateCheck;
1031 private javax.swing.JLabel daysIncludedLabel;
1032 private javax.swing.JTextField daysIncludedTextField;
1033 private javax.swing.JRadioButton dirsRadioButton;
1034 private javax.swing.JComboBox<String> equalitySymbolComboBox;
1035 private javax.swing.JRadioButton extensionRadioButton;
1036 private javax.swing.JCheckBox fileSizeCheck;
1037 private javax.swing.JComboBox<String> fileSizeComboBox;
1038 private javax.swing.JSpinner fileSizeSpinner;
1039 private javax.swing.JRadioButton filesRadioButton;
1040 private javax.swing.JRadioButton fullNameRadioButton;
1041 private javax.swing.JLabel jLabel1;
1042 private javax.swing.JLabel jLabel5;
1043 private javax.swing.JCheckBox mimeCheck;
1044 private javax.swing.JComboBox<String> mimeTypeComboBox;
1045 private javax.swing.ButtonGroup nameButtonGroup;
1046 private javax.swing.JCheckBox nameCheck;
1047 private javax.swing.JCheckBox nameRegexCheckbox;
1048 private javax.swing.JTextField nameTextField;
1049 private javax.swing.JCheckBox pathCheck;
1050 private javax.swing.JCheckBox pathRegexCheckBox;
1051 private javax.swing.JLabel pathSeparatorInfoLabel;
1052 private javax.swing.JTextField pathTextField;
1053 private javax.swing.JLabel ruleNameLabel;
1054 private javax.swing.JTextField ruleNameTextField;
1055 private javax.swing.ButtonGroup typeButtonGroup;