19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.HashSet;
25 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.regex.Pattern;
29 import java.util.regex.PatternSyntaxException;
30 import javax.swing.JButton;
31 import javax.swing.JComponent;
32 import javax.swing.JOptionPane;
33 import org.openide.DialogDisplayer;
34 import org.openide.NotifyDescriptor;
35 import org.openide.util.NbBundle;
36 import org.openide.util.NbBundle.Messages;
44 final class FilesSetRulePanel
extends javax.swing.JPanel {
47 "FilesSetRulePanel.bytes=Bytes",
48 "FilesSetRulePanel.kiloBytes=Kilobytes",
49 "FilesSetRulePanel.megaBytes=Megabytes",
50 "FilesSetRulePanel.gigaBytes=Gigabytes",
51 "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
52 "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
53 "FilesSetRulePanel.NoNameError=Name cannot be empty",
54 "FilesSetRulePanel.NoPathError=Path cannot be empty",
55 "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
58 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
59 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
60 private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
61 private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
62 private JButton okButton;
63 private JButton cancelButton;
68 FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
70 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
71 mimeTypeComboBox.setVisible(
false);
72 mimeCheck.setVisible(
false);
73 fileSizeComboBox.setVisible(
false);
74 fileSizeCheck.setVisible(
false);
75 equalitySymbolComboBox.setVisible(
false);
76 fileSizeSpinner.setVisible(
false);
77 jLabel1.setVisible(
false);
78 filesRadioButton.setVisible(
false);
79 dirsRadioButton.setVisible(
false);
80 allRadioButton.setVisible(
false);
81 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ingest.jLabel5.text"));
84 populateMimeTypesComboBox();
86 populateComponentsWithDefaultValues();
87 this.setButtons(okButton, cancelButton);
95 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
97 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
98 mimeTypeComboBox.setVisible(
false);
99 mimeCheck.setVisible(
false);
100 fileSizeComboBox.setVisible(
false);
101 fileSizeCheck.setVisible(
false);
102 equalitySymbolComboBox.setVisible(
false);
103 fileSizeSpinner.setVisible(
false);
104 jLabel1.setVisible(
false);
105 filesRadioButton.setVisible(
false);
106 dirsRadioButton.setVisible(
false);
107 allRadioButton.setVisible(
false);
109 populateMimeTypesComboBox();
110 populateMimeConditionComponents(rule);
111 populateSizeConditionComponents(rule);
113 populateMimeTypesComboBox();
114 populateRuleNameComponent(rule);
115 populateTypeConditionComponents(rule);
116 populateNameConditionComponents(rule);
117 populatePathConditionComponents(rule);
118 this.setButtons(okButton, cancelButton);
124 private void populateComponentsWithDefaultValues() {
125 this.filesRadioButton.setSelected(
true);
126 this.fullNameRadioButton.setSelected(
true);
127 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
128 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
129 this.mimeTypeComboBox.setSelectedIndex(0);
132 private void populateMimeTypesComboBox() {
133 Set<String> fileTypesCollated =
new HashSet<>();
134 for (String mediaType : FileTypeDetector.getStandardDetectedTypes()) {
135 fileTypesCollated.add(mediaType);
138 FileTypeDetector fileTypeDetector;
140 fileTypeDetector =
new FileTypeDetector();
141 List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
142 fileTypesCollated.addAll(userDefinedFileTypes);
144 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
145 logger.log(Level.SEVERE,
"Unable to get user defined file types", ex);
148 List<String> toSort =
new ArrayList<>(fileTypesCollated);
149 toSort.sort((String string1, String string2) -> {
150 int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
152 result = string1.compareTo(string2);
157 for (String file : toSort) {
158 mimeTypeComboBox.addItem(file);
168 private void populateRuleNameComponent(FilesSet.Rule rule) {
169 this.ruleNameTextField.setText(rule.getName());
172 private void populateMimeConditionComponents(FilesSet.Rule rule) {
173 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
174 if (mimeTypeCondition != null) {
175 this.mimeCheck.setSelected(
true);
176 this.mimeCheckActionPerformed(null);
177 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
181 private void populateSizeConditionComponents(FilesSet.Rule rule) {
182 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
183 if (fileSizeCondition != null) {
184 this.fileSizeCheck.setSelected(
true);
185 this.fileSizeCheckActionPerformed(null);
186 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
187 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
188 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
196 private void setOkButton() {
197 if (this.okButton != null) {
198 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
199 || this.nameCheck.isSelected() || this.pathCheck.isSelected());
210 private JOptionPane getOptionPane(JComponent parent) {
211 JOptionPane pane = null;
212 if (!(parent instanceof JOptionPane)) {
213 pane = getOptionPane((JComponent) parent.getParent());
215 pane = (JOptionPane) parent;
226 private void setButtons(JButton ok, JButton cancel) {
228 this.cancelButton = cancel;
229 okButton.addActionListener(
new ActionListener() {
231 public void actionPerformed(ActionEvent e) {
232 JOptionPane pane = getOptionPane(okButton);
233 pane.setValue(okButton);
236 cancelButton.addActionListener(
new ActionListener() {
238 public void actionPerformed(ActionEvent e) {
239 JOptionPane pane = getOptionPane(cancelButton);
240 pane.setValue(cancelButton);
252 private void populateTypeConditionComponents(FilesSet.Rule rule) {
253 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
254 switch (typeCondition.getMetaType()) {
256 this.filesRadioButton.setSelected(
true);
259 this.dirsRadioButton.setSelected(
true);
262 this.allRadioButton.setSelected(
true);
272 private void populateNameConditionComponents(FilesSet.Rule rule) {
273 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
274 if (nameCondition != null) {
275 this.nameCheck.setSelected(
true);
276 this.nameCheckActionPerformed(null);
277 this.nameTextField.setText(nameCondition.getTextToMatch());
278 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
279 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
280 this.fullNameRadioButton.setSelected(
true);
282 this.extensionRadioButton.setSelected(
true);
293 private void populatePathConditionComponents(FilesSet.Rule rule) {
294 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
295 if (pathCondition != null) {
296 this.pathCheck.setSelected(
true);
297 this.pathCheckActionPerformed(null);
298 this.pathTextField.setText(pathCondition.getTextToMatch());
299 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
310 boolean isValidRuleDefinition() {
312 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
313 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
314 Bundle.FilesSetRulePanel_NoConditionError(),
315 NotifyDescriptor.WARNING_MESSAGE);
316 DialogDisplayer.getDefault().notify(notifyDesc);
320 if (this.nameCheck.isSelected()) {
323 if (this.nameTextField.getText().isEmpty()) {
324 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
325 Bundle.FilesSetRulePanel_NoNameError(),
326 NotifyDescriptor.WARNING_MESSAGE);
327 DialogDisplayer.getDefault().notify(notifyDesc);
330 if (this.nameRegexCheckbox.isSelected()) {
332 Pattern.compile(this.nameTextField.getText());
333 }
catch (PatternSyntaxException ex) {
334 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
335 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
336 NotifyDescriptor.WARNING_MESSAGE);
337 DialogDisplayer.getDefault().notify(notifyDesc);
340 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
341 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
342 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
343 NotifyDescriptor.WARNING_MESSAGE);
344 DialogDisplayer.getDefault().notify(notifyDesc);
351 if (this.pathCheck.isSelected()) {
352 if (this.pathTextField.getText().isEmpty()) {
353 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
354 Bundle.FilesSetRulePanel_NoPathError(),
355 NotifyDescriptor.WARNING_MESSAGE);
356 DialogDisplayer.getDefault().notify(notifyDesc);
359 if (this.pathRegexCheckBox.isSelected()) {
361 Pattern.compile(this.pathTextField.getText());
362 }
catch (PatternSyntaxException ex) {
363 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
364 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
365 NotifyDescriptor.WARNING_MESSAGE);
366 DialogDisplayer.getDefault().notify(notifyDesc);
369 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
370 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
371 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
372 NotifyDescriptor.WARNING_MESSAGE);
373 DialogDisplayer.getDefault().notify(notifyDesc);
377 if (this.mimeCheck.isSelected()) {
378 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
379 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
380 Bundle.FilesSetRulePanel_NoMimeTypeError(),
381 NotifyDescriptor.WARNING_MESSAGE);
382 DialogDisplayer.getDefault().notify(notifyDesc);
386 if (this.fileSizeCheck.isSelected()) {
387 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
388 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
389 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
390 NotifyDescriptor.WARNING_MESSAGE);
391 DialogDisplayer.getDefault().notify(notifyDesc);
404 String getRuleName() {
405 return this.ruleNameTextField.getText();
417 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
418 FilesSet.Rule.FileNameCondition condition = null;
419 if (!this.nameTextField.getText().isEmpty()) {
420 if (this.nameRegexCheckbox.isSelected()) {
422 Pattern pattern = Pattern.compile(this.nameTextField.getText());
423 if (this.fullNameRadioButton.isSelected()) {
424 condition =
new FilesSet.Rule.FullNameCondition(pattern);
426 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
428 }
catch (PatternSyntaxException ex) {
429 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
430 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
432 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
433 if (this.fullNameRadioButton.isSelected()) {
434 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
436 condition =
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
439 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
440 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
451 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
452 FilesSet.Rule.MimeTypeCondition condition = null;
453 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
454 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
464 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
465 FilesSet.Rule.FileSizeCondition condition = null;
466 if (this.fileSizeCheck.isSelected()) {
467 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
468 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
469 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
470 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
471 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
483 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
484 if (this.filesRadioButton.isSelected()) {
485 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
486 }
else if (this.dirsRadioButton.isSelected()) {
487 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
489 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
502 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
503 FilesSet.Rule.ParentPathCondition condition = null;
504 if (!this.pathTextField.getText().isEmpty()) {
505 if (this.pathRegexCheckBox.isSelected()) {
507 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
508 }
catch (PatternSyntaxException ex) {
509 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
510 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
513 String path = this.pathTextField.getText();
514 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
516 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
517 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
520 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
521 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
523 condition =
new FilesSet.Rule.ParentPathCondition(path);
525 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
526 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
542 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
543 for (String illegalChar : illegalChars) {
544 if (toBeChecked.contains(illegalChar)) {
555 private void setComponentsForSearchType() {
556 if (!this.filesRadioButton.isSelected()) {
557 this.fullNameRadioButton.setSelected(
true);
558 this.extensionRadioButton.setEnabled(
false);
559 this.mimeTypeComboBox.setEnabled(
false);
560 this.mimeTypeComboBox.setSelectedIndex(0);
561 this.equalitySymbolComboBox.setEnabled(
false);
562 this.fileSizeComboBox.setEnabled(
false);
563 this.fileSizeSpinner.setEnabled(
false);
564 this.fileSizeSpinner.setValue(0);
565 this.fileSizeCheck.setEnabled(
false);
566 this.fileSizeCheck.setSelected(
false);
567 this.mimeCheck.setEnabled(
false);
568 this.mimeCheck.setSelected(
false);
570 if (this.nameCheck.isSelected()) {
571 this.extensionRadioButton.setEnabled(
true);
573 this.fileSizeCheck.setEnabled(
true);
574 this.mimeCheck.setEnabled(
true);
583 @SuppressWarnings(
"unchecked")
585 private
void initComponents() {
587 nameButtonGroup =
new javax.swing.ButtonGroup();
588 typeButtonGroup =
new javax.swing.ButtonGroup();
589 ruleNameLabel =
new javax.swing.JLabel();
590 ruleNameTextField =
new javax.swing.JTextField();
591 jLabel1 =
new javax.swing.JLabel();
592 nameTextField =
new javax.swing.JTextField();
593 fullNameRadioButton =
new javax.swing.JRadioButton();
594 extensionRadioButton =
new javax.swing.JRadioButton();
595 nameRegexCheckbox =
new javax.swing.JCheckBox();
596 pathTextField =
new javax.swing.JTextField();
597 pathRegexCheckBox =
new javax.swing.JCheckBox();
598 pathSeparatorInfoLabel =
new javax.swing.JLabel();
599 jLabel5 =
new javax.swing.JLabel();
600 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
601 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
602 fileSizeComboBox =
new javax.swing.JComboBox<String>();
603 fileSizeSpinner =
new javax.swing.JSpinner();
604 nameCheck =
new javax.swing.JCheckBox();
605 pathCheck =
new javax.swing.JCheckBox();
606 mimeCheck =
new javax.swing.JCheckBox();
607 fileSizeCheck =
new javax.swing.JCheckBox();
608 filesRadioButton =
new javax.swing.JRadioButton();
609 dirsRadioButton =
new javax.swing.JRadioButton();
610 allRadioButton =
new javax.swing.JRadioButton();
612 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
614 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
615 ruleNameTextField.addActionListener(
new java.awt.event.ActionListener() {
616 public void actionPerformed(java.awt.event.ActionEvent evt) {
617 ruleNameTextFieldActionPerformed(evt);
621 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
623 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
624 nameTextField.setEnabled(
false);
626 nameButtonGroup.add(fullNameRadioButton);
627 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
628 fullNameRadioButton.setEnabled(
false);
630 nameButtonGroup.add(extensionRadioButton);
631 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
632 extensionRadioButton.setEnabled(
false);
634 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
635 nameRegexCheckbox.setEnabled(
false);
637 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
638 pathTextField.setEnabled(
false);
640 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
641 pathRegexCheckBox.setEnabled(
false);
643 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
644 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
645 pathSeparatorInfoLabel.setEnabled(
false);
647 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.interesting.jLabel5.text"));
649 mimeTypeComboBox.setEditable(
true);
650 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
651 mimeTypeComboBox.setEnabled(
false);
653 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
654 equalitySymbolComboBox.setEnabled(
false);
656 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
657 fileSizeComboBox.setEnabled(
false);
659 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
660 fileSizeSpinner.setEnabled(
false);
662 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
663 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
664 public void actionPerformed(java.awt.event.ActionEvent evt) {
665 nameCheckActionPerformed(evt);
669 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
670 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
671 public void actionPerformed(java.awt.event.ActionEvent evt) {
672 pathCheckActionPerformed(evt);
676 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
677 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
678 public void actionPerformed(java.awt.event.ActionEvent evt) {
679 mimeCheckActionPerformed(evt);
683 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
684 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
685 public void actionPerformed(java.awt.event.ActionEvent evt) {
686 fileSizeCheckActionPerformed(evt);
690 typeButtonGroup.add(filesRadioButton);
691 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
692 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
693 public void actionPerformed(java.awt.event.ActionEvent evt) {
694 filesRadioButtonActionPerformed(evt);
698 typeButtonGroup.add(dirsRadioButton);
699 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
700 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
701 public void actionPerformed(java.awt.event.ActionEvent evt) {
702 dirsRadioButtonActionPerformed(evt);
706 typeButtonGroup.add(allRadioButton);
707 org.openide.awt.Mnemonics.setLocalizedText(allRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.allRadioButton.text"));
708 allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
709 public void actionPerformed(java.awt.event.ActionEvent evt) {
710 allRadioButtonActionPerformed(evt);
714 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
715 this.setLayout(layout);
716 layout.setHorizontalGroup(
717 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
718 .addGroup(layout.createSequentialGroup()
719 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
720 .addGroup(layout.createSequentialGroup()
722 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
723 .addGroup(layout.createSequentialGroup()
724 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
725 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
726 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
727 .addGroup(layout.createSequentialGroup()
728 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
729 .addComponent(jLabel5)
730 .addGroup(layout.createSequentialGroup()
731 .addComponent(jLabel1)
733 .addComponent(filesRadioButton)
734 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
735 .addComponent(dirsRadioButton)
736 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
737 .addComponent(allRadioButton)))
738 .addGap(0, 0, Short.MAX_VALUE))))
739 .addGroup(layout.createSequentialGroup()
741 .addComponent(nameCheck)
742 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
743 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
744 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
746 .addComponent(pathCheck)
748 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
749 .addGroup(layout.createSequentialGroup()
750 .addComponent(pathRegexCheckBox)
751 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
752 .addComponent(pathSeparatorInfoLabel))
753 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
754 .addGap(0, 0, Short.MAX_VALUE)
755 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
756 .addGroup(layout.createSequentialGroup()
757 .addComponent(fullNameRadioButton)
758 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
759 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
760 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
761 .addComponent(nameRegexCheckbox)
762 .addGap(0, 0, Short.MAX_VALUE))))
763 .addGroup(layout.createSequentialGroup()
765 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
766 .addComponent(mimeCheck)
767 .addComponent(fileSizeCheck))
768 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
769 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
770 .addGroup(layout.createSequentialGroup()
771 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
773 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
775 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
776 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
779 layout.setVerticalGroup(
780 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
781 .addGroup(layout.createSequentialGroup()
782 .addComponent(jLabel5)
783 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
784 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
785 .addComponent(jLabel1)
786 .addComponent(filesRadioButton)
787 .addComponent(dirsRadioButton)
788 .addComponent(allRadioButton))
790 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
791 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
792 .addComponent(nameCheck))
793 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
794 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
795 .addComponent(fullNameRadioButton)
796 .addComponent(extensionRadioButton)
797 .addComponent(nameRegexCheckbox))
798 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
799 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
800 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
801 .addComponent(pathCheck))
802 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
803 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
804 .addComponent(pathRegexCheckBox)
805 .addComponent(pathSeparatorInfoLabel))
806 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
807 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
808 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
809 .addComponent(mimeCheck))
811 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
812 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
813 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
814 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
815 .addComponent(fileSizeCheck))
817 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
818 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
819 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
824 private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
828 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
829 if (!this.nameCheck.isSelected()) {
830 this.nameTextField.setEnabled(
false);
831 this.nameTextField.setText(
"");
832 this.fullNameRadioButton.setEnabled(
false);
833 this.extensionRadioButton.setEnabled(
false);
834 this.nameRegexCheckbox.setEnabled(
false);
836 this.nameTextField.setEnabled(
true);
837 this.fullNameRadioButton.setEnabled(
true);
838 if (this.filesRadioButton.isSelected()) {
839 this.extensionRadioButton.setEnabled(
true);
841 this.nameRegexCheckbox.setEnabled(
true);
846 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
847 if (!this.pathCheck.isSelected()) {
848 this.pathTextField.setEnabled(
false);
849 this.pathTextField.setText(
"");
850 this.pathRegexCheckBox.setEnabled(
false);
851 this.pathSeparatorInfoLabel.setEnabled(
false);
853 this.pathTextField.setEnabled(
true);
854 this.pathRegexCheckBox.setEnabled(
true);
855 this.pathSeparatorInfoLabel.setEnabled(
true);
860 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
861 if (!this.mimeCheck.isSelected()) {
862 this.mimeTypeComboBox.setEnabled(
false);
863 this.mimeTypeComboBox.setSelectedIndex(0);
865 this.mimeTypeComboBox.setEnabled(
true);
870 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
871 if (!this.fileSizeCheck.isSelected()) {
872 this.fileSizeComboBox.setEnabled(
false);
873 this.fileSizeSpinner.setEnabled(
false);
874 this.fileSizeSpinner.setValue(0);
875 this.equalitySymbolComboBox.setEnabled(
false);
877 this.fileSizeComboBox.setEnabled(
true);
878 this.fileSizeSpinner.setEnabled(
true);
879 this.equalitySymbolComboBox.setEnabled(
true);
884 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
886 this.setComponentsForSearchType();
889 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
890 this.setComponentsForSearchType();
893 private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
894 this.setComponentsForSearchType();
898 private javax.swing.JRadioButton allRadioButton;
899 private javax.swing.JRadioButton dirsRadioButton;
900 private javax.swing.JComboBox<String> equalitySymbolComboBox;
901 private javax.swing.JRadioButton extensionRadioButton;
902 private javax.swing.JCheckBox fileSizeCheck;
903 private javax.swing.JComboBox<String> fileSizeComboBox;
904 private javax.swing.JSpinner fileSizeSpinner;
905 private javax.swing.JRadioButton filesRadioButton;
906 private javax.swing.JRadioButton fullNameRadioButton;
907 private javax.swing.JLabel jLabel1;
908 private javax.swing.JLabel jLabel5;
909 private javax.swing.JCheckBox mimeCheck;
910 private javax.swing.JComboBox<String> mimeTypeComboBox;
911 private javax.swing.ButtonGroup nameButtonGroup;
912 private javax.swing.JCheckBox nameCheck;
913 private javax.swing.JCheckBox nameRegexCheckbox;
914 private javax.swing.JTextField nameTextField;
915 private javax.swing.JCheckBox pathCheck;
916 private javax.swing.JCheckBox pathRegexCheckBox;
917 private javax.swing.JLabel pathSeparatorInfoLabel;
918 private javax.swing.JTextField pathTextField;
919 private javax.swing.JLabel ruleNameLabel;
920 private javax.swing.JTextField ruleNameTextField;
921 private javax.swing.ButtonGroup typeButtonGroup;