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.SortedSet;
28 import java.util.logging.Level;
29 import java.util.regex.Pattern;
30 import java.util.regex.PatternSyntaxException;
31 import javax.swing.JButton;
32 import javax.swing.JComponent;
33 import javax.swing.JOptionPane;
34 import org.apache.tika.mime.MediaType;
35 import org.apache.tika.mime.MimeTypes;
36 import org.openide.DialogDisplayer;
37 import org.openide.NotifyDescriptor;
38 import org.openide.util.NbBundle;
39 import org.openide.util.NbBundle.Messages;
47 final class FilesSetRulePanel
extends javax.swing.JPanel {
50 "FilesSetRulePanel.bytes=Bytes",
51 "FilesSetRulePanel.kiloBytes=Kilobytes",
52 "FilesSetRulePanel.megaBytes=Megabytes",
53 "FilesSetRulePanel.gigaBytes=Gigabytes",
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.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
61 private static final SortedSet<MediaType> mediaTypes = MimeTypes.getDefaultMimeTypes().getMediaTypeRegistry().getTypes();
62 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
63 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
64 private static final List<String> ILLEGAL_FILE_NAME_CHARS = InterestingItemDefsManager.getIllegalFileNameChars();
65 private static final List<String> ILLEGAL_FILE_PATH_CHARS = InterestingItemDefsManager.getIllegalFilePathChars();
66 private JButton okButton;
67 private JButton cancelButton;
72 FilesSetRulePanel(JButton okButton, JButton cancelButton) {
74 populateMimeTypesComboBox();
75 populateComponentsWithDefaultValues();
76 this.setButtons(okButton, cancelButton);
84 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton) {
86 populateMimeTypesComboBox();
87 populateRuleNameComponent(rule);
88 populateTypeConditionComponents(rule);
89 populateNameConditionComponents(rule);
90 populatePathConditionComponents(rule);
91 populateMimeConditionComponents(rule);
92 populateSizeConditionComponents(rule);
93 this.setButtons(okButton, cancelButton);
99 private void populateComponentsWithDefaultValues() {
100 this.filesRadioButton.setSelected(
true);
101 this.fullNameRadioButton.setSelected(
true);
102 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
103 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
104 this.mimeTypeComboBox.setSelectedIndex(0);
107 private void populateMimeTypesComboBox() {
108 Set<String> fileTypesCollated =
new HashSet<>();
109 for (MediaType mediaType : mediaTypes) {
110 fileTypesCollated.add(mediaType.toString());
113 FileTypeDetector fileTypeDetector;
115 fileTypeDetector =
new FileTypeDetector();
116 List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
117 fileTypesCollated.addAll(userDefinedFileTypes);
119 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
120 logger.log(Level.SEVERE,
"Unable to get user defined file types", ex);
123 List<String> toSort =
new ArrayList<>(fileTypesCollated);
124 toSort.sort((String string1, String string2) -> {
125 int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
127 result = string1.compareTo(string2);
132 for (String file : toSort) {
133 mimeTypeComboBox.addItem(file);
143 private void populateRuleNameComponent(FilesSet.Rule rule) {
144 this.ruleNameTextField.setText(rule.getName());
147 private void populateMimeConditionComponents(FilesSet.Rule rule) {
148 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
149 if (mimeTypeCondition != null) {
150 this.mimeCheck.setSelected(
true);
151 this.mimeCheckActionPerformed(null);
152 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
156 private void populateSizeConditionComponents(FilesSet.Rule rule) {
157 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
158 if (fileSizeCondition != null) {
159 this.fileSizeCheck.setSelected(
true);
160 this.fileSizeCheckActionPerformed(null);
161 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
162 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
163 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
171 private void setOkButton() {
172 if (this.okButton != null) {
173 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
174 || this.nameCheck.isSelected() || this.pathCheck.isSelected());
185 private JOptionPane getOptionPane(JComponent parent) {
186 JOptionPane pane = null;
187 if (!(parent instanceof JOptionPane)) {
188 pane = getOptionPane((JComponent) parent.getParent());
190 pane = (JOptionPane) parent;
201 private void setButtons(JButton ok, JButton cancel) {
203 this.cancelButton = cancel;
204 okButton.addActionListener(
new ActionListener() {
206 public void actionPerformed(ActionEvent e) {
207 JOptionPane pane = getOptionPane(okButton);
208 pane.setValue(okButton);
211 cancelButton.addActionListener(
new ActionListener() {
213 public void actionPerformed(ActionEvent e) {
214 JOptionPane pane = getOptionPane(cancelButton);
215 pane.setValue(cancelButton);
227 private void populateTypeConditionComponents(FilesSet.Rule rule) {
228 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
229 switch (typeCondition.getMetaType()) {
231 this.filesRadioButton.setSelected(
true);
234 this.dirsRadioButton.setSelected(
true);
236 case FILES_AND_DIRECTORIES:
237 this.filesAndDirsRadioButton.setSelected(
true);
247 private void populateNameConditionComponents(FilesSet.Rule rule) {
248 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
249 if (nameCondition != null) {
250 this.nameCheck.setSelected(
true);
251 this.nameCheckActionPerformed(null);
252 this.nameTextField.setText(nameCondition.getTextToMatch());
253 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
254 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
255 this.fullNameRadioButton.setSelected(
true);
257 this.extensionRadioButton.setSelected(
true);
268 private void populatePathConditionComponents(FilesSet.Rule rule) {
269 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
270 if (pathCondition != null) {
271 this.pathCheck.setSelected(
true);
272 this.pathCheckActionPerformed(null);
273 this.pathTextField.setText(pathCondition.getTextToMatch());
274 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
285 boolean isValidRuleDefinition() {
287 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
288 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
289 Bundle.FilesSetRulePanel_NoConditionError(),
290 NotifyDescriptor.WARNING_MESSAGE);
291 DialogDisplayer.getDefault().notify(notifyDesc);
295 if (this.nameCheck.isSelected()) {
298 if (this.nameTextField.getText().isEmpty()) {
299 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
300 Bundle.FilesSetRulePanel_NoNameError(),
301 NotifyDescriptor.WARNING_MESSAGE);
302 DialogDisplayer.getDefault().notify(notifyDesc);
305 if (this.nameRegexCheckbox.isSelected()) {
307 Pattern.compile(this.nameTextField.getText());
308 }
catch (PatternSyntaxException ex) {
309 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
310 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
311 NotifyDescriptor.WARNING_MESSAGE);
312 DialogDisplayer.getDefault().notify(notifyDesc);
315 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
316 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
317 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
318 NotifyDescriptor.WARNING_MESSAGE);
319 DialogDisplayer.getDefault().notify(notifyDesc);
326 if (this.pathCheck.isSelected()) {
327 if (this.pathTextField.getText().isEmpty()) {
328 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
329 Bundle.FilesSetRulePanel_NoPathError(),
330 NotifyDescriptor.WARNING_MESSAGE);
331 DialogDisplayer.getDefault().notify(notifyDesc);
334 if (this.pathRegexCheckBox.isSelected()) {
336 Pattern.compile(this.pathTextField.getText());
337 }
catch (PatternSyntaxException ex) {
338 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
339 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
340 NotifyDescriptor.WARNING_MESSAGE);
341 DialogDisplayer.getDefault().notify(notifyDesc);
344 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
345 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
346 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
347 NotifyDescriptor.WARNING_MESSAGE);
348 DialogDisplayer.getDefault().notify(notifyDesc);
352 if (this.mimeCheck.isSelected()) {
353 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
354 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
355 Bundle.FilesSetRulePanel_NoMimeTypeError(),
356 NotifyDescriptor.WARNING_MESSAGE);
357 DialogDisplayer.getDefault().notify(notifyDesc);
361 if (this.fileSizeCheck.isSelected()) {
362 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
363 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
364 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
365 NotifyDescriptor.WARNING_MESSAGE);
366 DialogDisplayer.getDefault().notify(notifyDesc);
379 String getRuleName() {
380 return this.ruleNameTextField.getText();
392 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
393 FilesSet.Rule.FileNameCondition condition = null;
394 if (!this.nameTextField.getText().isEmpty()) {
395 if (this.nameRegexCheckbox.isSelected()) {
397 Pattern pattern = Pattern.compile(this.nameTextField.getText());
398 if (this.fullNameRadioButton.isSelected()) {
399 condition =
new FilesSet.Rule.FullNameCondition(pattern);
401 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
403 }
catch (PatternSyntaxException ex) {
404 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
405 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
407 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
408 if (this.fullNameRadioButton.isSelected()) {
409 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
411 condition =
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
414 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
415 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
426 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
427 FilesSet.Rule.MimeTypeCondition condition = null;
428 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
429 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
439 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
440 FilesSet.Rule.FileSizeCondition condition = null;
441 if (this.fileSizeCheck.isSelected()) {
442 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
443 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
444 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
445 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
446 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
458 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
459 if (this.filesRadioButton.isSelected()) {
460 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
461 }
else if (this.dirsRadioButton.isSelected()) {
462 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
464 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
477 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
478 FilesSet.Rule.ParentPathCondition condition = null;
479 if (!this.pathTextField.getText().isEmpty()) {
480 if (this.pathRegexCheckBox.isSelected()) {
482 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
483 }
catch (PatternSyntaxException ex) {
484 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
485 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
488 String path = this.pathTextField.getText();
489 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
491 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
492 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
495 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
496 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
498 condition =
new FilesSet.Rule.ParentPathCondition(path);
500 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
501 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
517 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
518 for (String illegalChar : illegalChars) {
519 if (toBeChecked.contains(illegalChar)) {
530 private void setComponentsForSearchType() {
531 if (!this.filesRadioButton.isSelected()) {
532 this.fullNameRadioButton.setSelected(
true);
533 this.extensionRadioButton.setEnabled(
false);
534 this.mimeTypeComboBox.setEnabled(
false);
535 this.mimeTypeComboBox.setSelectedIndex(0);
536 this.equalitySymbolComboBox.setEnabled(
false);
537 this.fileSizeComboBox.setEnabled(
false);
538 this.fileSizeSpinner.setEnabled(
false);
539 this.fileSizeSpinner.setValue(0);
540 this.fileSizeCheck.setEnabled(
false);
541 this.fileSizeCheck.setSelected(
false);
542 this.mimeCheck.setEnabled(
false);
543 this.mimeCheck.setSelected(
false);
546 if (this.nameCheck.isSelected()) {
547 this.extensionRadioButton.setEnabled(
true);
549 this.fileSizeCheck.setEnabled(
true);
550 this.mimeCheck.setEnabled(
true);
559 @SuppressWarnings(
"unchecked")
561 private
void initComponents() {
563 nameButtonGroup =
new javax.swing.ButtonGroup();
564 typeButtonGroup =
new javax.swing.ButtonGroup();
565 ruleNameLabel =
new javax.swing.JLabel();
566 ruleNameTextField =
new javax.swing.JTextField();
567 jLabel1 =
new javax.swing.JLabel();
568 nameTextField =
new javax.swing.JTextField();
569 fullNameRadioButton =
new javax.swing.JRadioButton();
570 extensionRadioButton =
new javax.swing.JRadioButton();
571 nameRegexCheckbox =
new javax.swing.JCheckBox();
572 pathTextField =
new javax.swing.JTextField();
573 pathRegexCheckBox =
new javax.swing.JCheckBox();
574 pathSeparatorInfoLabel =
new javax.swing.JLabel();
575 jLabel5 =
new javax.swing.JLabel();
576 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
577 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
578 fileSizeComboBox =
new javax.swing.JComboBox<String>();
579 fileSizeSpinner =
new javax.swing.JSpinner();
580 nameCheck =
new javax.swing.JCheckBox();
581 pathCheck =
new javax.swing.JCheckBox();
582 mimeCheck =
new javax.swing.JCheckBox();
583 fileSizeCheck =
new javax.swing.JCheckBox();
584 filesRadioButton =
new javax.swing.JRadioButton();
585 dirsRadioButton =
new javax.swing.JRadioButton();
586 filesAndDirsRadioButton =
new javax.swing.JRadioButton();
588 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
590 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
591 ruleNameTextField.addActionListener(
new java.awt.event.ActionListener() {
592 public void actionPerformed(java.awt.event.ActionEvent evt) {
593 ruleNameTextFieldActionPerformed(evt);
597 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
599 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
600 nameTextField.setEnabled(
false);
602 nameButtonGroup.add(fullNameRadioButton);
603 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
604 fullNameRadioButton.setEnabled(
false);
605 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
606 public void actionPerformed(java.awt.event.ActionEvent evt) {
607 fullNameRadioButtonActionPerformed(evt);
611 nameButtonGroup.add(extensionRadioButton);
612 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
613 extensionRadioButton.setEnabled(
false);
615 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
616 nameRegexCheckbox.setEnabled(
false);
618 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
619 pathTextField.setEnabled(
false);
621 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
622 pathRegexCheckBox.setEnabled(
false);
624 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
625 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
626 pathSeparatorInfoLabel.setEnabled(
false);
628 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel5.text"));
630 mimeTypeComboBox.setEditable(
true);
631 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
632 mimeTypeComboBox.setEnabled(
false);
634 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
635 equalitySymbolComboBox.setEnabled(
false);
637 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
638 fileSizeComboBox.setEnabled(
false);
640 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
641 fileSizeSpinner.setEnabled(
false);
643 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
644 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
645 public void actionPerformed(java.awt.event.ActionEvent evt) {
646 nameCheckActionPerformed(evt);
650 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
651 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
652 public void actionPerformed(java.awt.event.ActionEvent evt) {
653 pathCheckActionPerformed(evt);
657 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
658 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
659 public void actionPerformed(java.awt.event.ActionEvent evt) {
660 mimeCheckActionPerformed(evt);
664 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
665 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
666 public void actionPerformed(java.awt.event.ActionEvent evt) {
667 fileSizeCheckActionPerformed(evt);
671 typeButtonGroup.add(filesRadioButton);
672 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
673 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
674 public void actionPerformed(java.awt.event.ActionEvent evt) {
675 filesRadioButtonActionPerformed(evt);
679 typeButtonGroup.add(dirsRadioButton);
680 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
681 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
682 public void actionPerformed(java.awt.event.ActionEvent evt) {
683 dirsRadioButtonActionPerformed(evt);
687 typeButtonGroup.add(filesAndDirsRadioButton);
688 org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesAndDirsRadioButton.text"));
689 filesAndDirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
690 public void actionPerformed(java.awt.event.ActionEvent evt) {
691 filesAndDirsRadioButtonActionPerformed(evt);
695 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
696 this.setLayout(layout);
697 layout.setHorizontalGroup(
698 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
699 .addGroup(layout.createSequentialGroup()
700 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
701 .addGroup(layout.createSequentialGroup()
703 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
704 .addGroup(layout.createSequentialGroup()
705 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
706 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
707 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
708 .addGroup(layout.createSequentialGroup()
709 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
710 .addComponent(jLabel5)
711 .addGroup(layout.createSequentialGroup()
712 .addComponent(jLabel1)
714 .addComponent(filesRadioButton)
715 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
716 .addComponent(dirsRadioButton)
717 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
718 .addComponent(filesAndDirsRadioButton)))
719 .addGap(0, 0, Short.MAX_VALUE))))
720 .addGroup(layout.createSequentialGroup()
722 .addComponent(nameCheck)
723 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
724 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
725 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
727 .addComponent(pathCheck)
729 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
730 .addGroup(layout.createSequentialGroup()
731 .addComponent(pathRegexCheckBox)
732 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
733 .addComponent(pathSeparatorInfoLabel))
734 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
735 .addGap(0, 0, Short.MAX_VALUE)
736 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
737 .addGroup(layout.createSequentialGroup()
738 .addComponent(fullNameRadioButton)
739 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
740 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
741 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
742 .addComponent(nameRegexCheckbox)
743 .addGap(0, 0, Short.MAX_VALUE))))
744 .addGroup(layout.createSequentialGroup()
746 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
747 .addComponent(mimeCheck)
748 .addComponent(fileSizeCheck))
749 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
750 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
751 .addGroup(layout.createSequentialGroup()
752 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
754 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
756 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
757 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
760 layout.setVerticalGroup(
761 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
762 .addGroup(layout.createSequentialGroup()
763 .addComponent(jLabel5)
764 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
765 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
766 .addComponent(jLabel1)
767 .addComponent(filesRadioButton)
768 .addComponent(dirsRadioButton)
769 .addComponent(filesAndDirsRadioButton))
771 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
772 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
773 .addComponent(nameCheck))
774 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
775 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
776 .addComponent(fullNameRadioButton)
777 .addComponent(extensionRadioButton)
778 .addComponent(nameRegexCheckbox))
779 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
780 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
781 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
782 .addComponent(pathCheck))
783 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
784 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
785 .addComponent(pathRegexCheckBox)
786 .addComponent(pathSeparatorInfoLabel))
787 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
788 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
789 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
790 .addComponent(mimeCheck))
792 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
793 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
794 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
795 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
796 .addComponent(fileSizeCheck))
798 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
799 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
800 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
805 private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
809 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
810 if (!this.nameCheck.isSelected()) {
811 this.nameTextField.setEnabled(
false);
812 this.nameTextField.setText(
"");
813 this.fullNameRadioButton.setEnabled(
false);
814 this.extensionRadioButton.setEnabled(
false);
815 this.nameRegexCheckbox.setEnabled(
false);
817 this.nameTextField.setEnabled(
true);
818 this.fullNameRadioButton.setEnabled(
true);
819 if (this.filesRadioButton.isSelected()) {
820 this.extensionRadioButton.setEnabled(
true);
822 this.nameRegexCheckbox.setEnabled(
true);
827 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
828 if (!this.pathCheck.isSelected()) {
829 this.pathTextField.setEnabled(
false);
830 this.pathTextField.setText(
"");
831 this.pathRegexCheckBox.setEnabled(
false);
832 this.pathSeparatorInfoLabel.setEnabled(
false);
834 this.pathTextField.setEnabled(
true);
835 this.pathRegexCheckBox.setEnabled(
true);
836 this.pathSeparatorInfoLabel.setEnabled(
true);
841 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
842 if (!this.mimeCheck.isSelected()) {
843 this.mimeTypeComboBox.setEnabled(
false);
844 this.mimeTypeComboBox.setSelectedIndex(0);
846 this.mimeTypeComboBox.setEnabled(
true);
851 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
852 if (!this.fileSizeCheck.isSelected()) {
853 this.fileSizeComboBox.setEnabled(
false);
854 this.fileSizeSpinner.setEnabled(
false);
855 this.fileSizeSpinner.setValue(0);
856 this.equalitySymbolComboBox.setEnabled(
false);
858 this.fileSizeComboBox.setEnabled(
true);
859 this.fileSizeSpinner.setEnabled(
true);
860 this.equalitySymbolComboBox.setEnabled(
true);
865 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
867 this.setComponentsForSearchType();
870 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
871 this.setComponentsForSearchType();
874 private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
875 this.setComponentsForSearchType();
878 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
883 private javax.swing.JRadioButton dirsRadioButton;
884 private javax.swing.JComboBox<String> equalitySymbolComboBox;
885 private javax.swing.JRadioButton extensionRadioButton;
886 private javax.swing.JCheckBox fileSizeCheck;
887 private javax.swing.JComboBox<String> fileSizeComboBox;
888 private javax.swing.JSpinner fileSizeSpinner;
889 private javax.swing.JRadioButton filesAndDirsRadioButton;
890 private javax.swing.JRadioButton filesRadioButton;
891 private javax.swing.JRadioButton fullNameRadioButton;
892 private javax.swing.JLabel jLabel1;
893 private javax.swing.JLabel jLabel5;
894 private javax.swing.JCheckBox mimeCheck;
895 private javax.swing.JComboBox<String> mimeTypeComboBox;
896 private javax.swing.ButtonGroup nameButtonGroup;
897 private javax.swing.JCheckBox nameCheck;
898 private javax.swing.JCheckBox nameRegexCheckbox;
899 private javax.swing.JTextField nameTextField;
900 private javax.swing.JCheckBox pathCheck;
901 private javax.swing.JCheckBox pathRegexCheckBox;
902 private javax.swing.JLabel pathSeparatorInfoLabel;
903 private javax.swing.JTextField pathTextField;
904 private javax.swing.JLabel ruleNameLabel;
905 private javax.swing.JTextField ruleNameTextField;
906 private javax.swing.ButtonGroup typeButtonGroup;